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
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
2
|
|
|
3
|
-
exports[`'
|
|
3
|
+
exports[`'legacy' > Plain JS (bad) 1`] = `
|
|
4
|
+
[
|
|
5
|
+
{
|
|
6
|
+
"column": 7,
|
|
7
|
+
"endColumn": 10,
|
|
8
|
+
"endLine": 4,
|
|
9
|
+
"line": 4,
|
|
10
|
+
"messageId": "unusedVar",
|
|
11
|
+
"nodeType": "Identifier",
|
|
12
|
+
"ruleId": "no-unused-vars",
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"column": 26,
|
|
16
|
+
"endColumn": 31,
|
|
17
|
+
"endLine": 13,
|
|
18
|
+
"line": 13,
|
|
19
|
+
"messageId": "notInScope",
|
|
20
|
+
"nodeType": "JSXOpeningElement",
|
|
21
|
+
"ruleId": "react/react-in-jsx-scope",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"column": 26,
|
|
25
|
+
"endColumn": 46,
|
|
26
|
+
"endLine": 13,
|
|
27
|
+
"line": 13,
|
|
28
|
+
"messageId": "noJSXWithExtension",
|
|
29
|
+
"nodeType": "JSXElement",
|
|
30
|
+
"ruleId": "react/jsx-filename-extension",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"column": 20,
|
|
34
|
+
"endColumn": 24,
|
|
35
|
+
"endLine": 16,
|
|
36
|
+
"line": 16,
|
|
37
|
+
"messageId": "undef",
|
|
38
|
+
"nodeType": "Identifier",
|
|
39
|
+
"ruleId": "no-undef",
|
|
40
|
+
},
|
|
41
|
+
]
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
exports[`'legacy' > Plain JS (good) 1`] = `[]`;
|
|
45
|
+
|
|
46
|
+
exports[`'legacy' > Plain TS (bad) 1`] = `
|
|
4
47
|
[
|
|
5
48
|
{
|
|
6
49
|
"column": 7,
|
|
@@ -21,44 +64,35 @@ exports[`'recommended' > Plain TS (bad) 1`] = `
|
|
|
21
64
|
"ruleId": "@typescript-eslint/no-unused-vars",
|
|
22
65
|
},
|
|
23
66
|
{
|
|
24
|
-
"column":
|
|
25
|
-
"endColumn":
|
|
67
|
+
"column": 7,
|
|
68
|
+
"endColumn": 10,
|
|
26
69
|
"endLine": 8,
|
|
27
70
|
"line": 8,
|
|
28
71
|
"messageId": "unusedVar",
|
|
29
72
|
"nodeType": null,
|
|
30
73
|
"ruleId": "@typescript-eslint/no-unused-vars",
|
|
31
74
|
},
|
|
32
|
-
{
|
|
33
|
-
"column": 14,
|
|
34
|
-
"endColumn": 26,
|
|
35
|
-
"endLine": 17,
|
|
36
|
-
"line": 17,
|
|
37
|
-
"messageId": "anyAssignment",
|
|
38
|
-
"nodeType": "VariableDeclarator",
|
|
39
|
-
"ruleId": "@typescript-eslint/no-unsafe-assignment",
|
|
40
|
-
},
|
|
41
75
|
{
|
|
42
76
|
"column": 20,
|
|
43
77
|
"endColumn": 24,
|
|
44
|
-
"endLine":
|
|
45
|
-
"line":
|
|
46
|
-
"messageId": "
|
|
78
|
+
"endLine": 16,
|
|
79
|
+
"line": 16,
|
|
80
|
+
"messageId": "undef",
|
|
47
81
|
"nodeType": "Identifier",
|
|
48
|
-
"ruleId": "
|
|
82
|
+
"ruleId": "no-undef",
|
|
49
83
|
},
|
|
50
84
|
]
|
|
51
85
|
`;
|
|
52
86
|
|
|
53
|
-
exports[`'
|
|
87
|
+
exports[`'legacy' > Plain TS (good) 1`] = `[]`;
|
|
54
88
|
|
|
55
|
-
exports[`'
|
|
89
|
+
exports[`'legacy' > React JSX (bad) 1`] = `
|
|
56
90
|
[
|
|
57
91
|
{
|
|
58
|
-
"column":
|
|
59
|
-
"endColumn":
|
|
60
|
-
"endLine":
|
|
61
|
-
"line":
|
|
92
|
+
"column": 7,
|
|
93
|
+
"endColumn": 10,
|
|
94
|
+
"endLine": 5,
|
|
95
|
+
"line": 5,
|
|
62
96
|
"messageId": "unusedVar",
|
|
63
97
|
"nodeType": "Identifier",
|
|
64
98
|
"ruleId": "no-unused-vars",
|
|
@@ -66,8 +100,8 @@ exports[`'recommended' > React JSX (bad) 1`] = `
|
|
|
66
100
|
{
|
|
67
101
|
"column": 20,
|
|
68
102
|
"endColumn": 24,
|
|
69
|
-
"endLine":
|
|
70
|
-
"line":
|
|
103
|
+
"endLine": 15,
|
|
104
|
+
"line": 15,
|
|
71
105
|
"messageId": "undef",
|
|
72
106
|
"nodeType": "Identifier",
|
|
73
107
|
"ruleId": "no-undef",
|
|
@@ -75,9 +109,9 @@ exports[`'recommended' > React JSX (bad) 1`] = `
|
|
|
75
109
|
]
|
|
76
110
|
`;
|
|
77
111
|
|
|
78
|
-
exports[`'
|
|
112
|
+
exports[`'legacy' > React JSX (good) 1`] = `[]`;
|
|
79
113
|
|
|
80
|
-
exports[`'recommended' >
|
|
114
|
+
exports[`'recommended' > Plain JS (bad) 1`] = `
|
|
81
115
|
[
|
|
82
116
|
{
|
|
83
117
|
"column": 10,
|
|
@@ -109,4 +143,81 @@ exports[`'recommended' > plain JS (bad) 1`] = `
|
|
|
109
143
|
]
|
|
110
144
|
`;
|
|
111
145
|
|
|
112
|
-
exports[`'recommended' >
|
|
146
|
+
exports[`'recommended' > Plain JS (good) 1`] = `[]`;
|
|
147
|
+
|
|
148
|
+
exports[`'recommended' > Plain TS (bad) 1`] = `
|
|
149
|
+
[
|
|
150
|
+
{
|
|
151
|
+
"column": 7,
|
|
152
|
+
"endColumn": 25,
|
|
153
|
+
"endLine": 5,
|
|
154
|
+
"line": 5,
|
|
155
|
+
"messageId": "noInferrableType",
|
|
156
|
+
"nodeType": "VariableDeclarator",
|
|
157
|
+
"ruleId": "@typescript-eslint/no-inferrable-types",
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"column": 7,
|
|
161
|
+
"endColumn": 12,
|
|
162
|
+
"endLine": 5,
|
|
163
|
+
"line": 5,
|
|
164
|
+
"messageId": "unusedVar",
|
|
165
|
+
"nodeType": null,
|
|
166
|
+
"ruleId": "@typescript-eslint/no-unused-vars",
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"column": 10,
|
|
170
|
+
"endColumn": 13,
|
|
171
|
+
"endLine": 8,
|
|
172
|
+
"line": 8,
|
|
173
|
+
"messageId": "unusedVar",
|
|
174
|
+
"nodeType": null,
|
|
175
|
+
"ruleId": "@typescript-eslint/no-unused-vars",
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"column": 14,
|
|
179
|
+
"endColumn": 26,
|
|
180
|
+
"endLine": 17,
|
|
181
|
+
"line": 17,
|
|
182
|
+
"messageId": "anyAssignment",
|
|
183
|
+
"nodeType": "VariableDeclarator",
|
|
184
|
+
"ruleId": "@typescript-eslint/no-unsafe-assignment",
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"column": 20,
|
|
188
|
+
"endColumn": 24,
|
|
189
|
+
"endLine": 17,
|
|
190
|
+
"line": 17,
|
|
191
|
+
"messageId": "unsafeCall",
|
|
192
|
+
"nodeType": "Identifier",
|
|
193
|
+
"ruleId": "@typescript-eslint/no-unsafe-call",
|
|
194
|
+
},
|
|
195
|
+
]
|
|
196
|
+
`;
|
|
197
|
+
|
|
198
|
+
exports[`'recommended' > Plain TS (good) 1`] = `[]`;
|
|
199
|
+
|
|
200
|
+
exports[`'recommended' > React JSX (bad) 1`] = `
|
|
201
|
+
[
|
|
202
|
+
{
|
|
203
|
+
"column": 10,
|
|
204
|
+
"endColumn": 13,
|
|
205
|
+
"endLine": 4,
|
|
206
|
+
"line": 4,
|
|
207
|
+
"messageId": "unusedVar",
|
|
208
|
+
"nodeType": "Identifier",
|
|
209
|
+
"ruleId": "no-unused-vars",
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"column": 20,
|
|
213
|
+
"endColumn": 24,
|
|
214
|
+
"endLine": 14,
|
|
215
|
+
"line": 14,
|
|
216
|
+
"messageId": "undef",
|
|
217
|
+
"nodeType": "Identifier",
|
|
218
|
+
"ruleId": "no-undef",
|
|
219
|
+
},
|
|
220
|
+
]
|
|
221
|
+
`;
|
|
222
|
+
|
|
223
|
+
exports[`'recommended' > React JSX (good) 1`] = `[]`;
|
package/test/eslint.test.mjs
CHANGED
|
@@ -3,6 +3,10 @@ import path from 'path'
|
|
|
3
3
|
import util from 'util'
|
|
4
4
|
import { beforeAll, describe, expect, test } from 'vitest'
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @import { Linter } from 'eslint'
|
|
8
|
+
*/
|
|
9
|
+
|
|
6
10
|
/**
|
|
7
11
|
* @typedef {object} EslintTestInfo
|
|
8
12
|
* @property {string} name - the title/message for this test
|
|
@@ -17,7 +21,7 @@ import { beforeAll, describe, expect, test } from 'vitest'
|
|
|
17
21
|
const testInfo = {
|
|
18
22
|
recommended: [
|
|
19
23
|
{
|
|
20
|
-
name: '
|
|
24
|
+
name: 'Plain JS (good)',
|
|
21
25
|
filePath: 'plain.good.mjs',
|
|
22
26
|
warningCount: 0,
|
|
23
27
|
errorCount: 0,
|
|
@@ -29,7 +33,7 @@ const testInfo = {
|
|
|
29
33
|
errorCount: 0,
|
|
30
34
|
},
|
|
31
35
|
{
|
|
32
|
-
name: '
|
|
36
|
+
name: 'Plain JS (bad)',
|
|
33
37
|
filePath: 'plain.bad.mjs',
|
|
34
38
|
warningCount: 0,
|
|
35
39
|
errorCount: 3,
|
|
@@ -53,12 +57,50 @@ const testInfo = {
|
|
|
53
57
|
errorCount: 5,
|
|
54
58
|
},
|
|
55
59
|
],
|
|
60
|
+
legacy: [
|
|
61
|
+
{
|
|
62
|
+
name: 'Plain JS (good)',
|
|
63
|
+
filePath: 'plain.good.mjs',
|
|
64
|
+
warningCount: 0,
|
|
65
|
+
errorCount: 0,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'React JSX (good)',
|
|
69
|
+
filePath: 'react.good.jsx',
|
|
70
|
+
warningCount: 0,
|
|
71
|
+
errorCount: 0,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: 'Plain JS (bad)',
|
|
75
|
+
filePath: 'plain.bad.mjs',
|
|
76
|
+
warningCount: 0,
|
|
77
|
+
errorCount: 4,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: 'React JSX (bad)',
|
|
81
|
+
filePath: 'react.bad.jsx',
|
|
82
|
+
warningCount: 0,
|
|
83
|
+
errorCount: 2,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: 'Plain TS (good)',
|
|
87
|
+
filePath: 'plain.good.ts',
|
|
88
|
+
warningCount: 0,
|
|
89
|
+
errorCount: 0,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: 'Plain TS (bad)',
|
|
93
|
+
filePath: 'plain.bad.ts',
|
|
94
|
+
warningCount: 0,
|
|
95
|
+
errorCount: 4,
|
|
96
|
+
},
|
|
97
|
+
],
|
|
56
98
|
}
|
|
57
99
|
|
|
58
100
|
/**
|
|
59
101
|
* Create a snapshot of a lint message.
|
|
60
102
|
* Excludes properties that may change without affecting correctness, such as human-readable text.
|
|
61
|
-
* @param {
|
|
103
|
+
* @param {Linter.LintMessage} result - the lint message to filter
|
|
62
104
|
* @returns {object} a filtered snapshot of the lint message
|
|
63
105
|
*/
|
|
64
106
|
const messageSnapshot = result =>
|
|
@@ -94,7 +136,7 @@ describe.concurrent.for(Object.entries(testInfo))('$0', ([subdir, testList]) =>
|
|
|
94
136
|
results = await eslint.lintFiles(testList.map(info => path.resolve(import.meta.dirname, subdir, info.filePath)))
|
|
95
137
|
})
|
|
96
138
|
|
|
97
|
-
test('
|
|
139
|
+
test('Results container', () => {
|
|
98
140
|
expect(results).toBeDefined()
|
|
99
141
|
expect(results.length).toBe(testList.length)
|
|
100
142
|
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {eslintConfigScratch} from '../../lib/index.mjs';
|
|
2
|
+
|
|
3
|
+
const config = eslintConfigScratch.defineConfig(
|
|
4
|
+
{
|
|
5
|
+
files: ['**/*.{mjs,cjs,js,jsx,ts,tsx}'],
|
|
6
|
+
extends: [
|
|
7
|
+
eslintConfigScratch.legacy.base,
|
|
8
|
+
eslintConfigScratch.legacy.react
|
|
9
|
+
]
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
files: ['**/*.{ts,tsx}'],
|
|
13
|
+
extends: [
|
|
14
|
+
eslintConfigScratch.legacy.typescript
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export default config;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {ESLint} from 'eslint';
|
|
2
|
+
|
|
3
|
+
// foo isn't used
|
|
4
|
+
const foo = () => {
|
|
5
|
+
const eslint = new ESLint({
|
|
6
|
+
overrideConfigFile: true
|
|
7
|
+
});
|
|
8
|
+
return eslint;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// React isn't allowed in plain JS
|
|
12
|
+
// React must be in scope when using JSX
|
|
13
|
+
export const myElement = <div>{'hello'}</div>;
|
|
14
|
+
|
|
15
|
+
// foo2 isn't defined
|
|
16
|
+
export const bar = foo2();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {ESLint} from 'eslint';
|
|
2
|
+
|
|
3
|
+
// @typescript-eslint/no-inferrable-types
|
|
4
|
+
// @typescript-eslint/no-unused-vars
|
|
5
|
+
const forty: number = 40;
|
|
6
|
+
|
|
7
|
+
// @typescript-eslint/no-unused-vars
|
|
8
|
+
const foo = (): ESLint => {
|
|
9
|
+
const eslint = new ESLint({
|
|
10
|
+
overrideConfigFile: true
|
|
11
|
+
});
|
|
12
|
+
return eslint;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// no-undef ('foo2' is not defined)
|
|
16
|
+
export const bar = foo2();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {ESLint} from 'eslint';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
// @typescript-eslint/no-unused-vars
|
|
5
|
+
const foo = () => {
|
|
6
|
+
const eslint = new ESLint({
|
|
7
|
+
overrideConfigFile: true
|
|
8
|
+
});
|
|
9
|
+
return eslint;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const myElement = <div>{'hello'}</div>;
|
|
13
|
+
|
|
14
|
+
// foo2 isn't defined
|
|
15
|
+
export const bar = foo2();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { eslintConfigScratch } from '../../lib/index.mjs'
|
|
2
2
|
|
|
3
|
-
const config = eslintConfigScratch.
|
|
3
|
+
const config = eslintConfigScratch.defineConfig(eslintConfigScratch.recommended, {
|
|
4
4
|
files: ['**/*.ts', '**/*.tsx'],
|
|
5
5
|
languageOptions: {
|
|
6
6
|
parserOptions: {
|