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 CHANGED
@@ -1 +1,4 @@
1
1
  /CHANGELOG.md
2
+ /test/legacy/*
3
+ /test/recommended/*
4
+ /test/__snapshots__/*
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.config(eslintConfigScratch.recommended, {
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.config` is a re-export of the `config` function from `typescript-eslint`, and helps
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.config` is a re-export of the `config` function from `typescript-eslint`. Full documentation
66
- is available here: <https://typescript-eslint.io/packages/typescript-eslint#config>.
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.config(
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.config(
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.config(
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 = tseslint.config([
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 = tseslint.config([
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 `tseslint.config` expects.
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 = tseslint.config([
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 = tseslint.config([
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 = tseslint.config(typeFreeRules, eslintConfigPrettier)
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 = tseslint.config(typeCheckedRules, eslintConfigPrettier)
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 = tseslint.config(
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 { config } from 'typescript-eslint'
371
+ export { defineConfig } from 'eslint/config'
360
372
 
361
373
  // Our exported configurations
362
374
  export { recommended, recommendedTypeChecked, recommendedTypeFree, miscFileRules, legacy }
@@ -1,51 +1,49 @@
1
- /** @type {import('eslint').Linter.Config[]} */
2
- export default [
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
- rules: {
11
- 'arrow-body-style': [2, 'as-needed'],
12
- 'arrow-parens': [2, 'as-needed'],
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
- 'arrow-spacing': [
15
- 2,
16
- {
17
- before: true,
18
- after: true,
19
- },
20
- ],
12
+ 'arrow-spacing': [
13
+ 2,
14
+ {
15
+ before: true,
16
+ after: true,
17
+ },
18
+ ],
21
19
 
22
- 'no-prototype-builtins': [2],
23
- 'no-confusing-arrow': [2],
24
- 'no-duplicate-imports': [2],
25
- 'no-return-await': [2],
26
- 'no-template-curly-in-string': [2],
27
- 'no-useless-computed-key': [2],
28
- 'no-useless-constructor': [2],
29
- 'no-useless-rename': [2],
30
- 'no-var': [2],
31
- 'prefer-arrow-callback': [2],
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
- 'prefer-const': [
34
- 2,
35
- {
36
- destructuring: 'all',
37
- },
38
- ],
31
+ 'prefer-const': [
32
+ 2,
33
+ {
34
+ destructuring: 'all',
35
+ },
36
+ ],
39
37
 
40
- 'prefer-promise-reject-errors': [2],
41
- 'prefer-rest-params': [2],
42
- 'prefer-spread': [2],
43
- 'prefer-template': [2],
44
- 'require-atomic-updates': [2],
45
- 'require-await': [2],
46
- 'rest-spread-spacing': [2, 'never'],
47
- 'symbol-description': [2],
48
- 'template-curly-spacing': [2, 'never'],
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
+ })