mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-24 19:08:53 +00:00
[ticket/17517] Refactor eslint config, remove unused rules
PHPBB-17517
This commit is contained in:
parent
35a1af5a11
commit
2daabd34be
4 changed files with 64 additions and 3262 deletions
|
@ -1,87 +1,68 @@
|
|||
// eslint.config.mjs
|
||||
const { browser: browserGlobals, node: nodeGlobals, jquery: jqueryGlobals } = (await import('globals')).default;
|
||||
|
||||
// Use Promise.all for parallel imports to improve loading performance
|
||||
const [
|
||||
{ default: globalsAll },
|
||||
{ default: unicorn },
|
||||
{ default: importPlugin },
|
||||
{ default: nodePlugin },
|
||||
{ default: promisePlugin },
|
||||
] = await Promise.all([
|
||||
import('globals'),
|
||||
import('eslint-plugin-unicorn'),
|
||||
import('eslint-plugin-import'),
|
||||
import('eslint-plugin-n'),
|
||||
import('eslint-plugin-promise'),
|
||||
]);
|
||||
// File patterns to ignore
|
||||
const IGNORED_FILES = [
|
||||
'phpBB/assets/javascript/cropper.js',
|
||||
'phpBB/assets/javascript/hermite.js',
|
||||
'phpBB/assets/javascript/jquery-cropper.js',
|
||||
'phpBB/ext/**/*.js',
|
||||
'phpBB/**/*.min.js',
|
||||
'phpBB/vendor/**/*.js',
|
||||
'phpBB/vendor-ext/**/*.js',
|
||||
'phpBB/phpbb/**/*.js',
|
||||
'phpBB/tests/**/*.js',
|
||||
];
|
||||
|
||||
// ESLint rule configurations
|
||||
const FORMATTING_RULES = {
|
||||
'quotes': ['error', 'single'],
|
||||
'comma-dangle': ['error', 'always-multiline'],
|
||||
'block-spacing': 'error',
|
||||
'array-bracket-spacing': ['error', 'always'],
|
||||
'object-curly-spacing': ['error', 'always'],
|
||||
'space-before-function-paren': ['error', 'never'],
|
||||
'space-in-parens': 'off',
|
||||
};
|
||||
|
||||
const CODE_QUALITY_RULES = {
|
||||
'semi': ['error', 'always'],
|
||||
'eqeqeq': ['error', 'always'],
|
||||
'curly': ['error', 'multi-line'],
|
||||
'no-var': 'error',
|
||||
'prefer-const': 'error',
|
||||
'no-console': 'off',
|
||||
'no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
|
||||
};
|
||||
|
||||
const DISABLED_STYLE_RULES = {
|
||||
'multiline-comment-style': 'off',
|
||||
'computed-property-spacing': 'off',
|
||||
'capitalized-comments': 'off',
|
||||
'no-lonely-if': 'off',
|
||||
};
|
||||
|
||||
const mainConfig = {
|
||||
files: ['**/*.js', '**/*.js.twig'],
|
||||
linterOptions: {
|
||||
reportUnusedDisableDirectives: false,
|
||||
},
|
||||
languageOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
globals: {
|
||||
...browserGlobals,
|
||||
...nodeGlobals,
|
||||
...jqueryGlobals,
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
...FORMATTING_RULES,
|
||||
...CODE_QUALITY_RULES,
|
||||
...DISABLED_STYLE_RULES,
|
||||
},
|
||||
};
|
||||
|
||||
export default [
|
||||
// 🔒 Global ignore block — applies BEFORE any parsing
|
||||
{
|
||||
ignores: [
|
||||
'phpBB/assets/javascript/cropper.js',
|
||||
'phpBB/assets/javascript/hermite.js',
|
||||
'phpBB/assets/javascript/jquery-cropper.js',
|
||||
'phpBB/ext/**/*.js',
|
||||
'phpBB/**/*.min.js',
|
||||
'phpBB/vendor/**/*.js',
|
||||
'phpBB/vendor-ext/**/*.js',
|
||||
'phpBB/phpbb/**/*.js',
|
||||
'phpBB/tests/**/*.js',
|
||||
],
|
||||
},
|
||||
|
||||
// 🌐 Main config for your source files
|
||||
{
|
||||
files: ['**/*.js', '**/*.js.twig'],
|
||||
linterOptions: {
|
||||
reportUnusedDisableDirectives: false,
|
||||
},
|
||||
languageOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
globals: {
|
||||
...globalsAll.browser,
|
||||
...globalsAll.node,
|
||||
...globalsAll.jquery,
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
unicorn,
|
||||
import: importPlugin,
|
||||
n: nodePlugin,
|
||||
promise: promisePlugin,
|
||||
},
|
||||
rules: {
|
||||
// Your personal customizations
|
||||
'quotes': ['error', 'single'],
|
||||
'comma-dangle': ['error', 'always-multiline'],
|
||||
'block-spacing': 'error',
|
||||
'array-bracket-spacing': ['error', 'always'],
|
||||
'multiline-comment-style': 'off',
|
||||
'computed-property-spacing': 'off',
|
||||
'space-before-function-paren': ['error', 'never'],
|
||||
'space-in-parens': 'off',
|
||||
'capitalized-comments': 'off',
|
||||
'object-curly-spacing': ['error', 'always'],
|
||||
'no-lonely-if': 'off',
|
||||
'unicorn/prefer-module': 'off',
|
||||
|
||||
// XO-inspired defaults
|
||||
'semi': ['error', 'always'],
|
||||
'eqeqeq': ['error', 'always'],
|
||||
'curly': ['error', 'multi-line'],
|
||||
'no-var': 'error',
|
||||
'prefer-const': 'error',
|
||||
'no-console': 'off',
|
||||
'no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
|
||||
'unicorn/filename-case': ['off', { case: 'kebabCase' }],
|
||||
'unicorn/no-null': 'off',
|
||||
'unicorn/prefer-ternary': 'off',
|
||||
'unicorn/no-array-for-each': 'off',
|
||||
'import/order': ['error', { 'newlines-between': 'always' }],
|
||||
'n/no-missing-import': 'error',
|
||||
'promise/always-return': 'off',
|
||||
},
|
||||
},
|
||||
{ ignores: IGNORED_FILES },
|
||||
mainConfig,
|
||||
];
|
||||
|
|
|
@ -7,7 +7,6 @@ const postcss = require('gulp-postcss');
|
|||
const autoprefixer = require('autoprefixer');
|
||||
const cssnano = require('cssnano');
|
||||
const sorting = require('postcss-sorting');
|
||||
|
||||
const sortOrder = require('./.postcss-sorting.json');
|
||||
|
||||
// Config
|
||||
|
|
3174
package-lock.json
generated
3174
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -43,10 +43,6 @@
|
|||
"autoprefixer": "^10.4.4",
|
||||
"cssnano": "^5.1.7",
|
||||
"eslint": "^9.28.0",
|
||||
"eslint-plugin-import": "^2.31.0",
|
||||
"eslint-plugin-n": "^17.18.0",
|
||||
"eslint-plugin-promise": "^7.2.1",
|
||||
"eslint-plugin-unicorn": "^59.0.1",
|
||||
"globals": "^16.2.0",
|
||||
"gulp": "^5.0.0",
|
||||
"gulp-concat": "^2.6.1",
|
||||
|
|
Loading…
Add table
Reference in a new issue