[ticket/17517] Refactor eslint config, remove unused rules

PHPBB-17517
This commit is contained in:
Matt Friedman 2025-05-31 13:26:44 -07:00
parent 35a1af5a11
commit 2daabd34be
No known key found for this signature in database
4 changed files with 64 additions and 3262 deletions

View file

@ -1,24 +1,7 @@
// eslint.config.mjs const { browser: browserGlobals, node: nodeGlobals, jquery: jqueryGlobals } = (await import('globals')).default;
// Use Promise.all for parallel imports to improve loading performance // File patterns to ignore
const [ const IGNORED_FILES = [
{ 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'),
]);
export default [
// 🔒 Global ignore block — applies BEFORE any parsing
{
ignores: [
'phpBB/assets/javascript/cropper.js', 'phpBB/assets/javascript/cropper.js',
'phpBB/assets/javascript/hermite.js', 'phpBB/assets/javascript/hermite.js',
'phpBB/assets/javascript/jquery-cropper.js', 'phpBB/assets/javascript/jquery-cropper.js',
@ -28,11 +11,37 @@ export default [
'phpBB/vendor-ext/**/*.js', 'phpBB/vendor-ext/**/*.js',
'phpBB/phpbb/**/*.js', 'phpBB/phpbb/**/*.js',
'phpBB/tests/**/*.js', 'phpBB/tests/**/*.js',
], ];
},
// 🌐 Main config for your source files // 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'], files: ['**/*.js', '**/*.js.twig'],
linterOptions: { linterOptions: {
reportUnusedDisableDirectives: false, reportUnusedDisableDirectives: false,
@ -41,47 +50,19 @@ export default [
ecmaVersion: 'latest', ecmaVersion: 'latest',
sourceType: 'module', sourceType: 'module',
globals: { globals: {
...globalsAll.browser, ...browserGlobals,
...globalsAll.node, ...nodeGlobals,
...globalsAll.jquery, ...jqueryGlobals,
}, },
}, },
plugins: {
unicorn,
import: importPlugin,
n: nodePlugin,
promise: promisePlugin,
},
rules: { rules: {
// Your personal customizations ...FORMATTING_RULES,
'quotes': ['error', 'single'], ...CODE_QUALITY_RULES,
'comma-dangle': ['error', 'always-multiline'], ...DISABLED_STYLE_RULES,
'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 export default [
'semi': ['error', 'always'], { ignores: IGNORED_FILES },
'eqeqeq': ['error', 'always'], mainConfig,
'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',
},
},
]; ];

View file

@ -7,7 +7,6 @@ const postcss = require('gulp-postcss');
const autoprefixer = require('autoprefixer'); const autoprefixer = require('autoprefixer');
const cssnano = require('cssnano'); const cssnano = require('cssnano');
const sorting = require('postcss-sorting'); const sorting = require('postcss-sorting');
const sortOrder = require('./.postcss-sorting.json'); const sortOrder = require('./.postcss-sorting.json');
// Config // Config

3174
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -43,10 +43,6 @@
"autoprefixer": "^10.4.4", "autoprefixer": "^10.4.4",
"cssnano": "^5.1.7", "cssnano": "^5.1.7",
"eslint": "^9.28.0", "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", "globals": "^16.2.0",
"gulp": "^5.0.0", "gulp": "^5.0.0",
"gulp-concat": "^2.6.1", "gulp-concat": "^2.6.1",