typescript-eslint 8.30.2-alpha.5 → 8.30.2-alpha.7
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/dist/config-helper.d.ts.map +1 -1
- package/dist/config-helper.js +55 -23
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-helper.d.ts","sourceRoot":"","sources":["../src/config-helper.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzD,MAAM,MAAM,8BAA8B,GACtC,iBAAiB,GACjB,8BAA8B,EAAE,CAAC;AAErC,MAAM,WAAW,iBAAkB,SAAQ,QAAQ,CAAC,UAAU,CAAC,MAAM;IACnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;IACH,OAAO,CAAC,EAAE,8BAA8B,EAAE,CAAC;CAC5C;AAGD,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,WAAW,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,MAAM,CACpB,GAAG,OAAO,EAAE,8BAA8B,EAAE,GAC3C,WAAW,
|
|
1
|
+
{"version":3,"file":"config-helper.d.ts","sourceRoot":"","sources":["../src/config-helper.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzD,MAAM,MAAM,8BAA8B,GACtC,iBAAiB,GACjB,8BAA8B,EAAE,CAAC;AAErC,MAAM,WAAW,iBAAkB,SAAQ,QAAQ,CAAC,UAAU,CAAC,MAAM;IACnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;IACH,OAAO,CAAC,EAAE,8BAA8B,EAAE,CAAC;CAC5C;AAGD,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,WAAW,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,MAAM,CACpB,GAAG,OAAO,EAAE,8BAA8B,EAAE,GAC3C,WAAW,CAEb"}
|
package/dist/config-helper.js
CHANGED
|
@@ -22,46 +22,78 @@ exports.config = config;
|
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
24
|
function config(...configs) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
return configImpl(...configs);
|
|
26
|
+
}
|
|
27
|
+
// Implementation of the config function without assuming the runtime type of
|
|
28
|
+
// the input.
|
|
29
|
+
function configImpl(...configs) {
|
|
30
|
+
const flattened = configs.flat(Infinity);
|
|
28
31
|
return flattened.flatMap((configWithExtends, configIndex) => {
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
if (configWithExtends == null ||
|
|
33
|
+
typeof configWithExtends !== 'object' ||
|
|
34
|
+
!('extends' in configWithExtends)) {
|
|
35
|
+
// Unless the object is a config object with extends key, just forward it
|
|
36
|
+
// along to eslint.
|
|
37
|
+
return configWithExtends;
|
|
38
|
+
}
|
|
39
|
+
const { extends: extendsArr, ..._config } = configWithExtends;
|
|
40
|
+
const config = _config;
|
|
41
|
+
if (extendsArr == null) {
|
|
42
|
+
// If the extends value is nullish, just forward along the rest of the
|
|
43
|
+
// config object to eslint.
|
|
31
44
|
return config;
|
|
32
45
|
}
|
|
46
|
+
const name = (() => {
|
|
47
|
+
if ('name' in configWithExtends && configWithExtends.name != null) {
|
|
48
|
+
if (typeof configWithExtends.name !== 'string') {
|
|
49
|
+
throw new Error(`tseslint.config(): Config at index ${configIndex} has a 'name' property that is not a string.`);
|
|
50
|
+
}
|
|
51
|
+
return configWithExtends.name;
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
})();
|
|
55
|
+
const nameErrorPhrase = name != null ? `, named "${name}",` : ' (anonymous)';
|
|
56
|
+
if (!Array.isArray(extendsArr)) {
|
|
57
|
+
throw new TypeError(`tseslint.config(): Config at index ${configIndex}${nameErrorPhrase} has an 'extends' property that is not an array.`);
|
|
58
|
+
}
|
|
33
59
|
const extendsArrFlattened = extendsArr.flat(Infinity);
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
60
|
+
const nonObjectExtensions = [];
|
|
61
|
+
for (const [extensionIndex, extension] of extendsArrFlattened.entries()) {
|
|
62
|
+
// special error message to be clear we don't support eslint's stringly typed extends.
|
|
63
|
+
// https://eslint.org/docs/latest/use/configure/configuration-files#extending-configurations
|
|
64
|
+
if (typeof extension === 'string') {
|
|
65
|
+
throw new Error(`tseslint.config(): Config at index ${configIndex}${nameErrorPhrase} has an 'extends' array that contains a string (${JSON.stringify(extension)}) at index ${extensionIndex}.` +
|
|
66
|
+
" This is a feature of eslint's `defineConfig()` helper and is not supported by typescript-eslint." +
|
|
67
|
+
' Please provide a config object instead.');
|
|
68
|
+
}
|
|
69
|
+
if (extension == null || typeof extension !== 'object') {
|
|
70
|
+
nonObjectExtensions.push(extensionIndex);
|
|
38
71
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
? `, named "${configWithExtends.name}",`
|
|
44
|
-
: ' (anonymous)';
|
|
45
|
-
const extensionIndices = undefinedExtensions.join(', ');
|
|
46
|
-
throw new Error(`Your config at index ${configIndex}${configName} contains undefined` +
|
|
72
|
+
}
|
|
73
|
+
if (nonObjectExtensions.length > 0) {
|
|
74
|
+
const extensionIndices = nonObjectExtensions.join(', ');
|
|
75
|
+
throw new Error(`tseslint.config(): Config at index ${configIndex}${nameErrorPhrase} contains non-object` +
|
|
47
76
|
` extensions at the following indices: ${extensionIndices}.`);
|
|
48
77
|
}
|
|
49
78
|
const configArray = [];
|
|
50
|
-
for (const
|
|
51
|
-
const
|
|
79
|
+
for (const _extension of extendsArrFlattened) {
|
|
80
|
+
const extension = _extension;
|
|
81
|
+
const resolvedConfigName = [name, extension.name]
|
|
82
|
+
.filter(Boolean)
|
|
83
|
+
.join('__');
|
|
52
84
|
if (isPossiblyGlobalIgnores(extension)) {
|
|
53
85
|
// If it's a global ignores, then just pass it along
|
|
54
86
|
configArray.push({
|
|
55
87
|
...extension,
|
|
56
|
-
...(
|
|
88
|
+
...(resolvedConfigName !== '' ? { name: resolvedConfigName } : {}),
|
|
57
89
|
});
|
|
58
90
|
}
|
|
59
91
|
else {
|
|
60
92
|
configArray.push({
|
|
61
93
|
...extension,
|
|
62
|
-
...(config.files
|
|
63
|
-
...(config.ignores
|
|
64
|
-
...(
|
|
94
|
+
...(config.files ? { files: config.files } : {}),
|
|
95
|
+
...(config.ignores ? { ignores: config.ignores } : {}),
|
|
96
|
+
...(resolvedConfigName !== '' ? { name: resolvedConfigName } : {}),
|
|
65
97
|
});
|
|
66
98
|
}
|
|
67
99
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typescript-eslint",
|
|
3
|
-
"version": "8.30.2-alpha.
|
|
3
|
+
"version": "8.30.2-alpha.7",
|
|
4
4
|
"description": "Tooling which enables you to use TypeScript with ESLint",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
"check-types": "npx nx typecheck"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@typescript-eslint/eslint-plugin": "8.30.2-alpha.
|
|
55
|
-
"@typescript-eslint/parser": "8.30.2-alpha.
|
|
56
|
-
"@typescript-eslint/utils": "8.30.2-alpha.
|
|
54
|
+
"@typescript-eslint/eslint-plugin": "8.30.2-alpha.7",
|
|
55
|
+
"@typescript-eslint/parser": "8.30.2-alpha.7",
|
|
56
|
+
"@typescript-eslint/utils": "8.30.2-alpha.7"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"eslint": "^8.57.0 || ^9.0.0",
|