Skip to content

Commit a90f06e

Browse files
committed
minor #1377 Upgrade ESLint to ^9, migrate some plugins and configuration (Kocal)
This PR was squashed before being merged into the main branch. Discussion ---------- Upgrade ESLint to ^9, migrate some plugins and configuration | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes <!-- please update CHANGELOG.md file --> | Deprecations? | no <!-- please update CHANGELOG.md file --> | Issues | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead --> | License | MIT <!-- Replace this notice by a description of your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Features and deprecations must be submitted against the latest branch. - For new features, provide some code snippets to help understand usage. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility. --> Commits ------- 8ad53f3 eslint --fix 37dacd6 Upgrade ESLint to ^9, migrate some plugins and configuration
2 parents f9c64ba + 8ad53f3 commit a90f06e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2168
-1374
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+
];

lib/package-helper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function isPackageInstalled(packageConfig) {
6666
try {
6767
require.resolve(packageConfig.name);
6868
return true;
69-
} catch (e) {
69+
} catch {
7070
return false;
7171
}
7272
}
@@ -79,7 +79,7 @@ function isPackageInstalled(packageConfig) {
7979
function getPackageVersion(packageName) {
8080
try {
8181
return require(`${packageName}/package.json`).version;
82-
} catch (e) {
82+
} catch {
8383
return null;
8484
}
8585
}

lib/utils/package-up.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function findUpSync(name, { cwd = process.cwd() } = {}) {
5252
if (stats && stats.isFile()) {
5353
return filePath;
5454
}
55-
} catch (e) {}
55+
} catch {}
5656

5757
directory = path.dirname(directory);
5858
}

0 commit comments

Comments
 (0)