Skip to content

Commit 57701de

Browse files
Bump ESLint to version 10 (#42205)
1 parent 7f53421 commit 57701de

8 files changed

Lines changed: 1396 additions & 1814 deletions

File tree

.babelrc.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ export default {
99
}
1010
]
1111
]
12-
};
12+
}

.eslintignore

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

eslint.config.js

Lines changed: 330 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,330 @@
1+
import xoBrowser from 'eslint-config-xo/browser'
2+
import unicorn from 'eslint-plugin-unicorn'
3+
import importXPlugin from 'eslint-plugin-import-x'
4+
import html from 'eslint-plugin-html'
5+
import markdown from 'eslint-plugin-markdown'
6+
import globals from 'globals'
7+
8+
const importRules = {
9+
'import/extensions': [
10+
'error',
11+
'ignorePackages',
12+
{
13+
js: 'always'
14+
}
15+
],
16+
'import/first': 'error',
17+
'import/newline-after-import': 'error',
18+
'import/no-absolute-path': 'error',
19+
'import/no-amd': 'error',
20+
'import/no-cycle': [
21+
'error',
22+
{
23+
ignoreExternal: true
24+
}
25+
],
26+
'import/no-duplicates': 'error',
27+
'import/no-extraneous-dependencies': 'error',
28+
'import/no-mutable-exports': 'error',
29+
'import/no-named-as-default': 'error',
30+
'import/no-named-as-default-member': 'error',
31+
'import/no-named-default': 'error',
32+
'import/no-self-import': 'error',
33+
'import/no-unassigned-import': [
34+
'error'
35+
],
36+
'import/no-useless-path-segments': 'error',
37+
'import/order': 'error'
38+
}
39+
40+
const localRules = {
41+
'arrow-body-style': 'off',
42+
'capitalized-comments': 'off',
43+
'@stylistic/comma-dangle': [
44+
'error',
45+
'never'
46+
],
47+
...importRules,
48+
'@stylistic/indent': [
49+
'error',
50+
2,
51+
{
52+
MemberExpression: 'off',
53+
SwitchCase: 1
54+
}
55+
],
56+
'logical-assignment-operators': 'off',
57+
'max-params': [
58+
'warn',
59+
5
60+
],
61+
'@stylistic/multiline-ternary': [
62+
'error',
63+
'always-multiline'
64+
],
65+
'new-cap': [
66+
'error',
67+
{
68+
properties: false
69+
}
70+
],
71+
'no-console': 'error',
72+
'no-negated-condition': 'off',
73+
'@stylistic/object-curly-spacing': [
74+
'error',
75+
'always'
76+
],
77+
'@stylistic/operator-linebreak': [
78+
'error',
79+
'after'
80+
],
81+
'prefer-object-has-own': 'off',
82+
'prefer-template': 'error',
83+
'@stylistic/semi': [
84+
'error',
85+
'never'
86+
],
87+
strict: 'error',
88+
'unicorn/explicit-length-check': 'off',
89+
'unicorn/filename-case': 'off',
90+
'unicorn/no-anonymous-default-export': 'off',
91+
'unicorn/no-array-callback-reference': 'off',
92+
'unicorn/no-array-method-this-argument': 'off',
93+
'unicorn/no-null': 'off',
94+
'unicorn/no-typeof-undefined': 'off',
95+
'unicorn/no-unused-properties': 'error',
96+
'unicorn/numeric-separators-style': 'off',
97+
'unicorn/prefer-array-flat': 'off',
98+
'unicorn/prefer-at': 'off',
99+
'unicorn/prefer-dom-node-dataset': 'off',
100+
'unicorn/prefer-global-this': 'off',
101+
'unicorn/prefer-module': 'off',
102+
'unicorn/prefer-query-selector': 'off',
103+
'unicorn/prefer-spread': 'off',
104+
'unicorn/prefer-string-raw': 'off',
105+
'unicorn/prefer-string-replace-all': 'off',
106+
'unicorn/prefer-structured-clone': 'off',
107+
'unicorn/prevent-abbreviations': 'off',
108+
// Rules new/changed in ESLint 10 / updated plugins — disable to preserve old behaviour
109+
'require-unicode-regexp': 'off',
110+
'@stylistic/indent-binary-ops': 'off',
111+
'@stylistic/curly-newline': 'off',
112+
'@stylistic/function-paren-newline': 'off',
113+
'unicorn/no-array-sort': 'off',
114+
'unicorn/prefer-classlist-toggle': 'off'
115+
}
116+
117+
// Base config: xo/browser + unicorn + import-x for all JS/HTML/MD files
118+
const [xoBrowserConfig] = xoBrowser
119+
const unicornConfig = unicorn.configs['flat/recommended']
120+
121+
export default [
122+
// Global ignores (replaces .eslintignore)
123+
{
124+
ignores: [
125+
'**/*.min.js',
126+
'**/dist/**',
127+
'**/vendor/**',
128+
'_site/**',
129+
'site/public/**',
130+
'js/coverage/**',
131+
'site/static/sw.js',
132+
'site/static/docs/**/assets/sw.js',
133+
'site/layouts/partials/**',
134+
// TypeScript, declaration and Astro files are not linted
135+
'**/*.ts',
136+
'**/*.d.ts',
137+
'**/*.astro',
138+
// Meteor metadata file (uses unsupported eslint-env comment)
139+
'package.js'
140+
]
141+
},
142+
143+
// Base config for all JS files
144+
{
145+
...xoBrowserConfig,
146+
plugins: {
147+
...xoBrowserConfig.plugins,
148+
unicorn,
149+
import: importXPlugin
150+
},
151+
rules: {
152+
...xoBrowserConfig.rules,
153+
...unicornConfig.rules,
154+
...localRules
155+
}
156+
},
157+
158+
// build/** — node environment, no browser
159+
{
160+
files: ['build/**'],
161+
languageOptions: {
162+
globals: {
163+
...globals.node
164+
},
165+
sourceType: 'module'
166+
},
167+
rules: {
168+
'no-console': 'off',
169+
'unicorn/prefer-top-level-await': 'off'
170+
}
171+
},
172+
173+
// js/** — ESM source
174+
{
175+
files: ['js/**'],
176+
languageOptions: {
177+
sourceType: 'module'
178+
}
179+
},
180+
181+
// CJS files — Node.js environment, script mode
182+
{
183+
files: ['**/*.cjs'],
184+
languageOptions: {
185+
globals: {
186+
...globals.node,
187+
...globals.commonjs
188+
},
189+
sourceType: 'script'
190+
},
191+
rules: {
192+
strict: 'off',
193+
'unicorn/prefer-module': 'off'
194+
}
195+
},
196+
197+
// js/tests/*.js + integration rollup configs — browser ESM
198+
{
199+
files: [
200+
'js/tests/integration/bundle*.js',
201+
'js/tests/integration/rollup*.js'
202+
],
203+
languageOptions: {
204+
globals: {
205+
...globals.browser
206+
},
207+
sourceType: 'module'
208+
}
209+
},
210+
211+
// js/tests/unit/** — jasmine
212+
{
213+
files: ['js/tests/unit/**'],
214+
languageOptions: {
215+
globals: {
216+
...globals.jasmine
217+
}
218+
},
219+
rules: {
220+
'no-console': 'off',
221+
'unicorn/consistent-function-scoping': 'off',
222+
'unicorn/no-useless-undefined': 'off',
223+
'unicorn/prefer-add-event-listener': 'off'
224+
}
225+
},
226+
227+
// js/tests/visual/** — HTML files with inline scripts
228+
{
229+
files: ['js/tests/visual/**'],
230+
plugins: {
231+
html
232+
},
233+
settings: {
234+
'html/html-extensions': ['.html']
235+
},
236+
rules: {
237+
'no-console': 'off',
238+
'no-new': 'off',
239+
'unicorn/no-array-for-each': 'off'
240+
}
241+
},
242+
243+
// scss/tests/** — node, script mode
244+
{
245+
files: ['scss/tests/**'],
246+
languageOptions: {
247+
globals: {
248+
...globals.node
249+
},
250+
sourceType: 'script'
251+
}
252+
},
253+
254+
// site/** — browser, script mode, older ecmaVersion
255+
{
256+
files: ['site/**'],
257+
languageOptions: {
258+
globals: {
259+
...globals.browser
260+
},
261+
sourceType: 'script',
262+
parserOptions: {
263+
ecmaVersion: 2019
264+
}
265+
},
266+
rules: {
267+
'no-new': 'off',
268+
'unicorn/no-array-for-each': 'off',
269+
strict: 'off'
270+
}
271+
},
272+
273+
// site specific module files
274+
{
275+
files: [
276+
'site/src/assets/application.js',
277+
'site/src/assets/partials/*.js',
278+
'site/src/assets/search.js',
279+
'site/src/assets/snippets.js',
280+
'site/src/assets/stackblitz.js',
281+
'site/src/plugins/*.js'
282+
],
283+
languageOptions: {
284+
sourceType: 'module',
285+
parserOptions: {
286+
ecmaVersion: 2020
287+
}
288+
},
289+
// These files may have eslint-disable directives for the old import plugin
290+
linterOptions: {
291+
reportUnusedDisableDirectives: 'off'
292+
}
293+
},
294+
295+
// site/static/**/*.js — older scripts with 'use strict', not modules
296+
{
297+
files: ['site/static/**/*.js'],
298+
rules: {
299+
strict: 'off'
300+
}
301+
},
302+
303+
// site cheatsheet/sidebars — module, no-unresolved off
304+
{
305+
files: [
306+
'site/src/assets/examples/cheatsheet/cheatsheet.js',
307+
'site/src/assets/examples/sidebars/sidebars.js'
308+
],
309+
languageOptions: {
310+
sourceType: 'module',
311+
parserOptions: {
312+
ecmaVersion: 2020
313+
}
314+
},
315+
rules: {
316+
'import/no-unresolved': 'off'
317+
}
318+
},
319+
320+
// Markdown files — use processor
321+
...markdown.configs.recommended,
322+
323+
// Markdown code blocks
324+
{
325+
files: ['**/*.md/*.js', '**/*.md/*.mjs'],
326+
rules: {
327+
'unicorn/prefer-node-protocol': 'off'
328+
}
329+
}
330+
]

0 commit comments

Comments
 (0)