eslint-config-scratch 11.0.52 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierignore +3 -0
- package/CHANGELOG.md +35 -0
- package/README.md +8 -7
- package/eslint.config.mjs +1 -1
- package/lib/eslint.mjs +24 -12
- package/lib/legacy/es6.mjs +43 -45
- package/lib/legacy/index.mjs +182 -172
- package/lib/legacy/node.mjs +12 -16
- package/lib/legacy/react.mjs +75 -78
- package/lib/legacy/typescript.mjs +59 -0
- package/package.json +5 -4
- package/test/__snapshots__/eslint.test.mjs.snap +138 -27
- package/test/eslint.test.mjs +46 -4
- package/test/legacy/eslint.config.mjs +19 -0
- package/test/legacy/plain.bad.mjs +16 -0
- package/test/legacy/plain.bad.ts +16 -0
- package/test/legacy/plain.good.mjs +10 -0
- package/test/legacy/plain.good.ts +10 -0
- package/test/legacy/react.bad.jsx +15 -0
- package/test/legacy/react.good.jsx +13 -0
- package/test/legacy/tsconfig.json +6 -0
- package/test/recommended/eslint.config.mjs +1 -1
- package/test/recommended/plain.bad.mjs +1 -1
- package/test/recommended/plain.good.mjs +1 -1
- package/test/recommended/react.bad.jsx +1 -1
- package/test/recommended/react.good.jsx +1 -1
package/.prettierignore
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,41 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See
|
|
4
4
|
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [12.0.0](https://github.com/scratchfoundation/eslint-config-scratch/compare/v11.0.53...v12.0.0) (2025-09-23)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **legacy:** forbid JSX syntax outside of JSX/TSX files ([172074c](https://github.com/scratchfoundation/eslint-config-scratch/commit/172074c289b8e308d7cec90406fd907e93a3f7e1))
|
|
12
|
+
* **legacy:** stop TS support from breaking non-TS projects ([b2c62b2](https://github.com/scratchfoundation/eslint-config-scratch/commit/b2c62b222d5f4a4194379deb4ebc79bcc0ffa01a))
|
|
13
|
+
* **legacy:** use TS rules where possible ([335ccb8](https://github.com/scratchfoundation/eslint-config-scratch/commit/335ccb851acec3184e8e42af722509a4937adc96))
|
|
14
|
+
* replace `config` with `defineConfig` ([3b2c7bd](https://github.com/scratchfoundation/eslint-config-scratch/commit/3b2c7bd69908fb3401732d38fee72b5fc221ada2))
|
|
15
|
+
* use @stylistic/indent to work around ts/eslint bug ([63a0d62](https://github.com/scratchfoundation/eslint-config-scratch/commit/63a0d62e30aceb4088a64a14bb11ddfb0f6a3fd2)), closes [typescript-eslint/typescript-eslint#11455](https://github.com/typescript-eslint/typescript-eslint/issues/11455)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* add minimal TS support to legacy rule sets ([2b4d83e](https://github.com/scratchfoundation/eslint-config-scratch/commit/2b4d83eff525854bd8472ea601f023b2a060c463))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### BREAKING CHANGES
|
|
24
|
+
|
|
25
|
+
* **legacy:** TS rules are no longer active in non-TS files unless
|
|
26
|
+
explicitly added through the user's configuration
|
|
27
|
+
* this rule seems to handle a few cases differently.
|
|
28
|
+
* **legacy:** JSX use outside of JSX/TSX files is now forbidden
|
|
29
|
+
* **legacy:** TS rules are now active even in non-TS files
|
|
30
|
+
* while `defineConfig` is almost the same as `config`,
|
|
31
|
+
there are some cases that differ. See:
|
|
32
|
+
<https://typescript-eslint.io/packages/typescript-eslint/#migrating-to-defineconfig>
|
|
33
|
+
|
|
34
|
+
## [11.0.53](https://github.com/scratchfoundation/eslint-config-scratch/compare/v11.0.52...v11.0.53) (2025-09-22)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Bug Fixes
|
|
38
|
+
|
|
39
|
+
* **deps:** update eslint monorepo to v9.36.0 ([#310](https://github.com/scratchfoundation/eslint-config-scratch/issues/310)) ([79f2997](https://github.com/scratchfoundation/eslint-config-scratch/commit/79f2997689f593735d934e51a40e1d093316f967))
|
|
40
|
+
|
|
6
41
|
## [11.0.52](https://github.com/scratchfoundation/eslint-config-scratch/compare/v11.0.51...v11.0.52) (2025-09-18)
|
|
7
42
|
|
|
8
43
|
|
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ For a TypeScript project, you can add `languageOptions` to enable type checking:
|
|
|
20
20
|
// myProjectRoot/eslint.config.mjs
|
|
21
21
|
import { eslintConfigScratch } from 'eslint-config-scratch'
|
|
22
22
|
|
|
23
|
-
export default eslintConfigScratch.
|
|
23
|
+
export default eslintConfigScratch.defineConfig(eslintConfigScratch.recommended, {
|
|
24
24
|
languageOptions: {
|
|
25
25
|
parserOptions: {
|
|
26
26
|
projectService: true,
|
|
@@ -39,8 +39,8 @@ import { eslintConfigScratch } from 'eslint-config-scratch'
|
|
|
39
39
|
export default eslintConfigScratch.recommended
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
The function `eslintConfigScratch.
|
|
43
|
-
with merging and extending configurations.
|
|
42
|
+
The function `eslintConfigScratch.defineConfig` is a re-export of the `defineConfig` function from `@eslint/config`,
|
|
43
|
+
and helps with merging and extending configurations.
|
|
44
44
|
|
|
45
45
|
Add `prettier.config.mjs` to your project root as well:
|
|
46
46
|
|
|
@@ -62,8 +62,9 @@ Finally, add scripts like these to your `package.json`:
|
|
|
62
62
|
|
|
63
63
|
## Basic Configuration
|
|
64
64
|
|
|
65
|
-
The `eslintConfigScratch.
|
|
66
|
-
is available here:
|
|
65
|
+
The function `eslintConfigScratch.defineConfig` is a re-export of the `defineConfig` function from `@eslint/config`,
|
|
66
|
+
and helps with merging and extending configurations. Full documentation is available here:
|
|
67
|
+
<https://eslint.org/blog/2025/03/flat-config-extends-define-config-global-ignores/#introducing-defineconfig()-for-eslint>.
|
|
67
68
|
|
|
68
69
|
The `config` function can be used to add or override rules, plugins, and other configuration options. For example:
|
|
69
70
|
|
|
@@ -73,7 +74,7 @@ import { eslintConfigScratch } from 'eslint-config-scratch'
|
|
|
73
74
|
import { globalIgnores } from 'eslint/config'
|
|
74
75
|
import globals from 'globals'
|
|
75
76
|
|
|
76
|
-
export default eslintConfigScratch.
|
|
77
|
+
export default eslintConfigScratch.defineConfig(
|
|
77
78
|
eslintConfigScratch.recommended,
|
|
78
79
|
{
|
|
79
80
|
languageOptions: {
|
|
@@ -127,7 +128,7 @@ import { eslintConfigScratch } from 'eslint-config-scratch'
|
|
|
127
128
|
import { globalIgnores } from 'eslint/config'
|
|
128
129
|
import globals from 'globals'
|
|
129
130
|
|
|
130
|
-
export default eslintConfigScratch.
|
|
131
|
+
export default eslintConfigScratch.defineConfig(
|
|
131
132
|
eslintConfigScratch.legacy.base,
|
|
132
133
|
eslintConfigScratch.legacy.es6,
|
|
133
134
|
{
|
package/eslint.config.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { globalIgnores } from 'eslint/config'
|
|
|
2
2
|
import globals from 'globals'
|
|
3
3
|
import { eslintConfigScratch } from './lib/index.mjs'
|
|
4
4
|
|
|
5
|
-
export default eslintConfigScratch.
|
|
5
|
+
export default eslintConfigScratch.defineConfig(
|
|
6
6
|
eslintConfigScratch.recommended,
|
|
7
7
|
{
|
|
8
8
|
languageOptions: {
|
package/lib/eslint.mjs
CHANGED
|
@@ -7,6 +7,7 @@ import jsdoc from 'eslint-plugin-jsdoc'
|
|
|
7
7
|
import jsxA11y from 'eslint-plugin-jsx-a11y'
|
|
8
8
|
import react from 'eslint-plugin-react'
|
|
9
9
|
import reactHooks from 'eslint-plugin-react-hooks'
|
|
10
|
+
import { defineConfig } from 'eslint/config'
|
|
10
11
|
import tseslint from 'typescript-eslint'
|
|
11
12
|
import eslintComments from '@eslint-community/eslint-plugin-eslint-comments/configs'
|
|
12
13
|
import eslint from '@eslint/js'
|
|
@@ -15,12 +16,14 @@ import legacyES6 from './legacy/es6.mjs'
|
|
|
15
16
|
import legacyBase from './legacy/index.mjs'
|
|
16
17
|
import legacyNode from './legacy/node.mjs'
|
|
17
18
|
import legacyReact from './legacy/react.mjs'
|
|
19
|
+
import legacyTS from './legacy/typescript.mjs'
|
|
18
20
|
|
|
19
21
|
const legacy = {
|
|
20
22
|
base: legacyBase,
|
|
21
23
|
es6: legacyES6,
|
|
22
24
|
node: legacyNode,
|
|
23
25
|
react: legacyReact,
|
|
26
|
+
typescript: legacyTS,
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
// WARNING: eslint rules from `typescript-eslint`, even the "untyped" rules, assume that your code will be run through
|
|
@@ -65,7 +68,7 @@ const fileGlobs = {
|
|
|
65
68
|
/**
|
|
66
69
|
* Rules for specific file types outside of the core JS/TS rule sets.
|
|
67
70
|
*/
|
|
68
|
-
const miscFileRules =
|
|
71
|
+
const miscFileRules = defineConfig([
|
|
69
72
|
// eslint-plugin-html
|
|
70
73
|
{
|
|
71
74
|
name: 'scratch/miscFileRules[eslint-plugin-html]',
|
|
@@ -89,7 +92,8 @@ const miscFileRules = tseslint.config([
|
|
|
89
92
|
/**
|
|
90
93
|
* Rules recommended for all script files, whether or not type information is available or checked.
|
|
91
94
|
*/
|
|
92
|
-
const allScriptRules =
|
|
95
|
+
const allScriptRules = defineConfig([
|
|
96
|
+
tseslint.configs.base,
|
|
93
97
|
// eslint-plugin-formatjs
|
|
94
98
|
{
|
|
95
99
|
name: 'scratch/allScriptRules[eslint-plugin-formatjs]',
|
|
@@ -112,9 +116,20 @@ const allScriptRules = tseslint.config([
|
|
|
112
116
|
{
|
|
113
117
|
name: 'scratch/allScriptRules[eslint-plugin-jsx-a11y]',
|
|
114
118
|
files: fileGlobs.react,
|
|
119
|
+
// @ts-expect-error This plugin's recommended rules don't quite match the type `defineConfig` expects.
|
|
115
120
|
extends: [jsxA11y.flatConfigs.recommended],
|
|
116
121
|
},
|
|
117
122
|
// eslint-plugin-react
|
|
123
|
+
{
|
|
124
|
+
files: fileGlobs.allScript,
|
|
125
|
+
plugins: {
|
|
126
|
+
react,
|
|
127
|
+
},
|
|
128
|
+
rules: {
|
|
129
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
|
|
130
|
+
'react/jsx-filename-extension': ['error', { allow: 'as-needed', extensions: ['.jsx', '.tsx'] }],
|
|
131
|
+
},
|
|
132
|
+
},
|
|
118
133
|
{
|
|
119
134
|
name: 'scratch/allScriptRules[eslint-plugin-react]',
|
|
120
135
|
files: fileGlobs.react,
|
|
@@ -140,9 +155,6 @@ const allScriptRules = tseslint.config([
|
|
|
140
155
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-equals-spacing.md
|
|
141
156
|
'react/jsx-equals-spacing': ['error'],
|
|
142
157
|
|
|
143
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
|
|
144
|
-
'react/jsx-filename-extension': ['error', { extensions: ['.jsx', '.tsx'] }],
|
|
145
|
-
|
|
146
158
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-first-prop-new-line.md
|
|
147
159
|
'react/jsx-first-prop-new-line': ['error', 'multiline'],
|
|
148
160
|
|
|
@@ -184,7 +196,7 @@ const allScriptRules = tseslint.config([
|
|
|
184
196
|
{
|
|
185
197
|
name: 'scratch/allScriptRules[eslint-plugin-eslint-comments]',
|
|
186
198
|
extends: [
|
|
187
|
-
// @ts-expect-error This plugin's recommended rules don't quite match the type `
|
|
199
|
+
// @ts-expect-error This plugin's recommended rules don't quite match the type `defineConfig` expects.
|
|
188
200
|
eslintComments.recommended,
|
|
189
201
|
],
|
|
190
202
|
rules: {
|
|
@@ -232,7 +244,7 @@ const allScriptRules = tseslint.config([
|
|
|
232
244
|
/**
|
|
233
245
|
* Additional rules recommended when type information is not available or checked.
|
|
234
246
|
*/
|
|
235
|
-
const typeFreeRules =
|
|
247
|
+
const typeFreeRules = defineConfig([
|
|
236
248
|
{
|
|
237
249
|
name: 'scratch/typeFreeRules[base]',
|
|
238
250
|
extends: [eslint.configs.recommended],
|
|
@@ -261,7 +273,7 @@ const typeFreeRules = tseslint.config([
|
|
|
261
273
|
* These rules require additional configuration.
|
|
262
274
|
* @see https://typescript-eslint.io/getting-started/typed-linting/
|
|
263
275
|
*/
|
|
264
|
-
const typeCheckedRules =
|
|
276
|
+
const typeCheckedRules = defineConfig([
|
|
265
277
|
{
|
|
266
278
|
name: 'scratch/typeCheckedRules[base]',
|
|
267
279
|
extends: [
|
|
@@ -318,7 +330,7 @@ const typeCheckedRules = tseslint.config([
|
|
|
318
330
|
/**
|
|
319
331
|
* Scratch's recommended configuration when type information is not available.
|
|
320
332
|
*/
|
|
321
|
-
const recommendedTypeFree =
|
|
333
|
+
const recommendedTypeFree = defineConfig(typeFreeRules, eslintConfigPrettier)
|
|
322
334
|
|
|
323
335
|
/**
|
|
324
336
|
* Scratch's recommended configuration when type information is available.
|
|
@@ -326,7 +338,7 @@ const recommendedTypeFree = tseslint.config(typeFreeRules, eslintConfigPrettier)
|
|
|
326
338
|
* WARNING: These rules do not specify the `files` property.
|
|
327
339
|
* @see https://typescript-eslint.io/getting-started/typed-linting/
|
|
328
340
|
*/
|
|
329
|
-
const recommendedTypeChecked =
|
|
341
|
+
const recommendedTypeChecked = defineConfig(typeCheckedRules, eslintConfigPrettier)
|
|
330
342
|
|
|
331
343
|
/**
|
|
332
344
|
* Scratch's recommended configuration for general use.
|
|
@@ -334,7 +346,7 @@ const recommendedTypeChecked = tseslint.config(typeCheckedRules, eslintConfigPre
|
|
|
334
346
|
* If your project includes such files, you must include additional configuration.
|
|
335
347
|
* @see https://typescript-eslint.io/getting-started/typed-linting/
|
|
336
348
|
*/
|
|
337
|
-
const recommended =
|
|
349
|
+
const recommended = defineConfig(
|
|
338
350
|
{
|
|
339
351
|
name: 'scratch/recommended',
|
|
340
352
|
},
|
|
@@ -356,7 +368,7 @@ const recommended = tseslint.config(
|
|
|
356
368
|
)
|
|
357
369
|
|
|
358
370
|
// Helper to get type hints while conveniently merging and extending configurations
|
|
359
|
-
export {
|
|
371
|
+
export { defineConfig } from 'eslint/config'
|
|
360
372
|
|
|
361
373
|
// Our exported configurations
|
|
362
374
|
export { recommended, recommendedTypeChecked, recommendedTypeFree, miscFileRules, legacy }
|
package/lib/legacy/es6.mjs
CHANGED
|
@@ -1,51 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
{
|
|
4
|
-
languageOptions: {
|
|
5
|
-
globals: {},
|
|
6
|
-
ecmaVersion: 2018,
|
|
7
|
-
sourceType: 'script',
|
|
8
|
-
},
|
|
1
|
+
import { defineConfig } from 'eslint/config'
|
|
2
|
+
import globals from 'globals'
|
|
9
3
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
languageOptions: {
|
|
6
|
+
globals: globals.browser,
|
|
7
|
+
},
|
|
8
|
+
rules: {
|
|
9
|
+
'arrow-body-style': [2, 'as-needed'],
|
|
10
|
+
'arrow-parens': [2, 'as-needed'],
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
'arrow-spacing': [
|
|
13
|
+
2,
|
|
14
|
+
{
|
|
15
|
+
before: true,
|
|
16
|
+
after: true,
|
|
17
|
+
},
|
|
18
|
+
],
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
'no-prototype-builtins': [2],
|
|
21
|
+
'no-confusing-arrow': [2],
|
|
22
|
+
'no-duplicate-imports': [2],
|
|
23
|
+
'no-return-await': [2],
|
|
24
|
+
'no-template-curly-in-string': [2],
|
|
25
|
+
'no-useless-computed-key': [2],
|
|
26
|
+
'no-useless-constructor': [2],
|
|
27
|
+
'no-useless-rename': [2],
|
|
28
|
+
'no-var': [2],
|
|
29
|
+
'prefer-arrow-callback': [2],
|
|
32
30
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
'prefer-const': [
|
|
32
|
+
2,
|
|
33
|
+
{
|
|
34
|
+
destructuring: 'all',
|
|
35
|
+
},
|
|
36
|
+
],
|
|
39
37
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
38
|
+
'no-console': ['error'],
|
|
39
|
+
'prefer-promise-reject-errors': [2],
|
|
40
|
+
'prefer-rest-params': [2],
|
|
41
|
+
'prefer-spread': [2],
|
|
42
|
+
'prefer-template': [2],
|
|
43
|
+
'require-atomic-updates': [2],
|
|
44
|
+
'require-await': [2],
|
|
45
|
+
'rest-spread-spacing': [2, 'never'],
|
|
46
|
+
'symbol-description': [2],
|
|
47
|
+
'template-curly-spacing': [2, 'never'],
|
|
50
48
|
},
|
|
51
|
-
|
|
49
|
+
})
|