mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-25 19:38: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
|
// File patterns to ignore
|
||||||
const [
|
const IGNORED_FILES = [
|
||||||
{ default: globalsAll },
|
'phpBB/assets/javascript/cropper.js',
|
||||||
{ default: unicorn },
|
'phpBB/assets/javascript/hermite.js',
|
||||||
{ default: importPlugin },
|
'phpBB/assets/javascript/jquery-cropper.js',
|
||||||
{ default: nodePlugin },
|
'phpBB/ext/**/*.js',
|
||||||
{ default: promisePlugin },
|
'phpBB/**/*.min.js',
|
||||||
] = await Promise.all([
|
'phpBB/vendor/**/*.js',
|
||||||
import('globals'),
|
'phpBB/vendor-ext/**/*.js',
|
||||||
import('eslint-plugin-unicorn'),
|
'phpBB/phpbb/**/*.js',
|
||||||
import('eslint-plugin-import'),
|
'phpBB/tests/**/*.js',
|
||||||
import('eslint-plugin-n'),
|
];
|
||||||
import('eslint-plugin-promise'),
|
|
||||||
]);
|
// 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 [
|
export default [
|
||||||
// 🔒 Global ignore block — applies BEFORE any parsing
|
{ ignores: IGNORED_FILES },
|
||||||
{
|
mainConfig,
|
||||||
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',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
|
@ -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
3174
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -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",
|
||||||
|
|
Loading…
Add table
Reference in a new issue