Skip to content

Commit 37dacd6

Browse files
committed
Upgrade ESLint to ^9, migrate some plugins and configuration
1 parent f9c64ba commit 37dacd6

File tree

4 files changed

+1151
-381
lines changed

4 files changed

+1151
-381
lines changed

.eslintrc.js

Lines changed: 0 additions & 95 deletions
This file was deleted.

eslint.config.js

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/*
2+
* This file is part of the Symfony Webpack Encore package.
3+
*
4+
* (c) Fabien Potencier <[email protected]>
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
10+
const globals = require('globals');
11+
const js = require('@eslint/js');
12+
const nodePlugin = require('eslint-plugin-n');
13+
const jsdoc = require('eslint-plugin-jsdoc');
14+
const headers = require('eslint-plugin-headers');
15+
const mocha = require('eslint-plugin-mocha').default;
16+
17+
module.exports = [
18+
js.configs.recommended,
19+
nodePlugin.configs['flat/recommended'],
20+
jsdoc.configs['flat/recommended'],
21+
mocha.configs.recommended,
22+
{
23+
plugins: {
24+
headers,
25+
},
26+
languageOptions: {
27+
ecmaVersion: 2021,
28+
globals: {
29+
...globals.browser,
30+
...globals.node,
31+
},
32+
},
33+
ignores: ['lib/webpack-manifest-plugin']
34+
},
35+
{
36+
'rules': {
37+
'quotes': ['error', 'single'],
38+
'no-undef': 'error',
39+
'no-extra-semi': 'error',
40+
'semi': 'error',
41+
'no-template-curly-in-string': 'error',
42+
'no-caller': 'error',
43+
'eqeqeq': 'error',
44+
'global-require': 'off',
45+
'brace-style': 'error',
46+
'eol-last': 'error',
47+
'indent': ['error', 4, { 'SwitchCase': 1 }],
48+
'no-extra-bind': 'warn',
49+
'no-empty': 'off',
50+
'no-multiple-empty-lines': 'error',
51+
'no-multi-spaces': 'error',
52+
'no-process-exit': 'warn',
53+
'space-in-parens': 'error',
54+
'no-trailing-spaces': 'error',
55+
'no-use-before-define': 'off',
56+
'no-unused-vars': ['error', { 'args': 'none' }],
57+
'key-spacing': 'error',
58+
'space-infix-ops': 'error',
59+
'no-unsafe-negation': 'error',
60+
'no-loop-func': 'warn',
61+
'space-before-function-paren': ['error', 'never'],
62+
'space-before-blocks': 'error',
63+
'object-curly-spacing': ['error', 'always'],
64+
'keyword-spacing': ['error', {
65+
'after': true
66+
}],
67+
'no-console': 'off',
68+
'jsdoc/require-jsdoc': 'off',
69+
'jsdoc/require-param-description': 'off',
70+
'jsdoc/require-property-description': 'off',
71+
'jsdoc/require-returns-description': 'off',
72+
'jsdoc/tag-lines': ['warn', 'never', {
73+
'startLines': 1
74+
}],
75+
'n/no-unsupported-features/node-builtins': ['error'],
76+
'n/no-deprecated-api': 'error',
77+
'n/no-missing-import': 'error',
78+
'n/no-missing-require': [
79+
'error',
80+
{
81+
'allowModules': [
82+
'webpack'
83+
]
84+
}
85+
],
86+
'n/no-unpublished-bin': 'error',
87+
'n/no-unpublished-require': 'error',
88+
'n/process-exit-as-throw': 'error',
89+
'headers/header-format': ['error', {
90+
source: 'string',
91+
content: `This file is part of the Symfony Webpack Encore package.
92+
93+
(c) Fabien Potencier <[email protected]>
94+
95+
For the full copyright and license information, please view the LICENSE
96+
file that was distributed with this source code.`,
97+
blockPrefix: '\n',
98+
}]
99+
},
100+
'settings': {
101+
'jsdoc': {
102+
'mode': 'typescript'
103+
}
104+
},
105+
},
106+
{
107+
'files': ['.eslintrc.js'],
108+
'rules': {
109+
'quotes': ['error', 'double'],
110+
},
111+
},
112+
{
113+
'files': ['test/**/*'],
114+
languageOptions: {
115+
globals: {
116+
// For Puppeteer when calling "page.evaluate()"
117+
document: 'readonly',
118+
},
119+
},
120+
rules: {
121+
'mocha/no-setup-in-describe': 'off',
122+
}
123+
}
124+
];

package.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"test": "yarn run test:main && yarn run test:persistent-cache",
88
"test:main": "mocha --reporter spec test --recursive --ignore test/persistent-cache/*",
99
"test:persistent-cache": "node run-persistent-tests",
10-
"lint": "eslint lib test index.js .eslintrc.js --report-unused-disable-directives --max-warnings=0",
10+
"lint": "eslint lib test index.js eslint.config.js --report-unused-disable-directives --max-warnings=0",
1111
"travis:lint": "yarn run lint"
1212
},
1313
"bin": {
@@ -50,6 +50,7 @@
5050
"@babel/preset-env": "^7.16.0",
5151
"@babel/preset-react": "^7.9.0",
5252
"@babel/preset-typescript": "^7.0.0",
53+
"@eslint/js": "^9.32.0",
5354
"@hotwired/stimulus": "^3.0.0",
5455
"@symfony/mock-module": "file:fixtures/stimulus/mock-module",
5556
"@symfony/stimulus-bridge": "^3.0.0 || ^4.0.0",
@@ -62,14 +63,16 @@
6263
"chai-fs": "^2.0.0",
6364
"chai-subset": "^1.6.0",
6465
"core-js": "^3.0.0",
65-
"eslint": "^8.0.0",
66-
"eslint-plugin-header": "^3.0.0",
67-
"eslint-plugin-import": "^2.26.0",
68-
"eslint-plugin-jsdoc": "^50.2.2",
69-
"eslint-plugin-node": "^11.1.0",
66+
"eslint": "^9.32.0",
67+
"eslint-plugin-headers": "^1.3.3",
68+
"eslint-plugin-import": "^2.32.0",
69+
"eslint-plugin-jsdoc": "^50.8.0",
70+
"eslint-plugin-mocha": "^11.1.0",
71+
"eslint-plugin-n": "^17.21.3",
7072
"file-loader": "^6.0.0",
7173
"fork-ts-checker-webpack-plugin": "^7.0.0 || ^8.0.0 || ^9.0.0",
7274
"fs-extra": "^10.0.0",
75+
"globals": "^16.3.0",
7376
"handlebars": "^4.7.7",
7477
"handlebars-loader": "^1.7.0",
7578
"http-server": "^14.1.0",

0 commit comments

Comments
 (0)