@typescript-eslint/typescript-estree 8.47.1-alpha.1 → 8.47.1-alpha.11
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/check-modifiers.js
CHANGED
|
@@ -257,6 +257,14 @@ function checkModifiers(node) {
|
|
|
257
257
|
if (!(func?.kind === SyntaxKind.Constructor && nodeIsPresent(func.body))) {
|
|
258
258
|
throwError(modifier, 'A parameter property is only allowed in a constructor implementation.');
|
|
259
259
|
}
|
|
260
|
+
const param = node;
|
|
261
|
+
if (param.dotDotDotToken) {
|
|
262
|
+
throwError(modifier, 'A parameter property cannot be a rest parameter.');
|
|
263
|
+
}
|
|
264
|
+
if (param.name.kind === SyntaxKind.ArrayBindingPattern ||
|
|
265
|
+
param.name.kind === SyntaxKind.ObjectBindingPattern) {
|
|
266
|
+
throwError(modifier, 'A parameter property may not be declared using a binding pattern.');
|
|
267
|
+
}
|
|
260
268
|
}
|
|
261
269
|
// There are more cases in `checkGrammarObjectLiteralExpression` in TypeScript.
|
|
262
270
|
// We may add more validations for them here in the future.
|
package/dist/convert.js
CHANGED
|
@@ -107,6 +107,9 @@ class Converter {
|
|
|
107
107
|
(0, check_modifiers_1.checkModifiers)(node);
|
|
108
108
|
}
|
|
109
109
|
#throwError(node, message) {
|
|
110
|
+
if (this.options.allowInvalidAST) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
110
113
|
let start;
|
|
111
114
|
let end;
|
|
112
115
|
if (Array.isArray(node)) {
|
|
@@ -121,11 +124,6 @@ class Converter {
|
|
|
121
124
|
}
|
|
122
125
|
throw (0, node_utils_1.createError)(message, this.ast, start, end);
|
|
123
126
|
}
|
|
124
|
-
#throwUnlessAllowInvalidAST(node, message) {
|
|
125
|
-
if (!this.options.allowInvalidAST) {
|
|
126
|
-
this.#throwError(node, message);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
127
|
/**
|
|
130
128
|
* Creates a getter for a property under aliasKey that returns the value under
|
|
131
129
|
* valueKey. If suppressDeprecatedPropertyWarnings is not enabled, the
|
|
@@ -187,11 +185,11 @@ class Converter {
|
|
|
187
185
|
}
|
|
188
186
|
assertModuleSpecifier(node, allowNull) {
|
|
189
187
|
if (!allowNull && node.moduleSpecifier == null) {
|
|
190
|
-
this.#
|
|
188
|
+
this.#throwError(node, 'Module specifier must be a string literal.');
|
|
191
189
|
}
|
|
192
190
|
if (node.moduleSpecifier &&
|
|
193
191
|
node.moduleSpecifier?.kind !== SyntaxKind.StringLiteral) {
|
|
194
|
-
this.#
|
|
192
|
+
this.#throwError(node.moduleSpecifier, 'Module specifier must be a string literal.');
|
|
195
193
|
}
|
|
196
194
|
}
|
|
197
195
|
convertBindingNameWithTypeAnnotation(name, tsType, parent) {
|
|
@@ -617,7 +615,7 @@ class Converter {
|
|
|
617
615
|
// Exceptions
|
|
618
616
|
case SyntaxKind.ThrowStatement:
|
|
619
617
|
if (node.expression.end === node.expression.pos) {
|
|
620
|
-
this.#
|
|
618
|
+
this.#throwError(node, 'A throw statement must throw an expression.');
|
|
621
619
|
}
|
|
622
620
|
return this.createNode(node, {
|
|
623
621
|
type: ts_estree_1.AST_NODE_TYPES.ThrowStatement,
|
|
@@ -750,7 +748,7 @@ class Converter {
|
|
|
750
748
|
kind: (0, node_utils_1.getDeclarationKind)(node.declarationList),
|
|
751
749
|
});
|
|
752
750
|
if (!result.declarations.length) {
|
|
753
|
-
this.#
|
|
751
|
+
this.#throwError(node, 'A variable declaration list must have at least one variable declarator.');
|
|
754
752
|
}
|
|
755
753
|
if (result.kind === 'using' || result.kind === 'await using') {
|
|
756
754
|
node.declarationList.declarations.forEach((declaration, i) => {
|
|
@@ -860,7 +858,7 @@ class Converter {
|
|
|
860
858
|
property.kind === SyntaxKind.SetAccessor ||
|
|
861
859
|
property.kind === SyntaxKind.MethodDeclaration) &&
|
|
862
860
|
!property.body) {
|
|
863
|
-
this.#
|
|
861
|
+
this.#throwError(property.end - 1, "'{' expected.");
|
|
864
862
|
}
|
|
865
863
|
properties.push(this.convertChild(property));
|
|
866
864
|
}
|
|
@@ -1381,7 +1379,7 @@ class Converter {
|
|
|
1381
1379
|
if (!node.name &&
|
|
1382
1380
|
(!(0, node_utils_1.hasModifier)(ts.SyntaxKind.ExportKeyword, node) ||
|
|
1383
1381
|
!(0, node_utils_1.hasModifier)(ts.SyntaxKind.DefaultKeyword, node))) {
|
|
1384
|
-
this.#
|
|
1382
|
+
this.#throwError(node, "A class declaration without the 'default' modifier must have a name.");
|
|
1385
1383
|
}
|
|
1386
1384
|
/* intentional fallthrough */
|
|
1387
1385
|
case SyntaxKind.ClassExpression: {
|
|
@@ -1394,23 +1392,23 @@ class Converter {
|
|
|
1394
1392
|
for (const heritageClause of heritageClauses) {
|
|
1395
1393
|
const { token, types } = heritageClause;
|
|
1396
1394
|
if (types.length === 0) {
|
|
1397
|
-
this.#
|
|
1395
|
+
this.#throwError(heritageClause, `'${ts.tokenToString(token)}' list cannot be empty.`);
|
|
1398
1396
|
}
|
|
1399
1397
|
if (token === SyntaxKind.ExtendsKeyword) {
|
|
1400
1398
|
if (extendsClause) {
|
|
1401
|
-
this.#
|
|
1399
|
+
this.#throwError(heritageClause, "'extends' clause already seen.");
|
|
1402
1400
|
}
|
|
1403
1401
|
if (implementsClause) {
|
|
1404
|
-
this.#
|
|
1402
|
+
this.#throwError(heritageClause, "'extends' clause must precede 'implements' clause.");
|
|
1405
1403
|
}
|
|
1406
1404
|
if (types.length > 1) {
|
|
1407
|
-
this.#
|
|
1405
|
+
this.#throwError(types[1], 'Classes can only extend a single class.');
|
|
1408
1406
|
}
|
|
1409
1407
|
extendsClause ??= heritageClause;
|
|
1410
1408
|
}
|
|
1411
1409
|
else if (token === SyntaxKind.ImplementsKeyword) {
|
|
1412
1410
|
if (implementsClause) {
|
|
1413
|
-
this.#
|
|
1411
|
+
this.#throwError(heritageClause, "'implements' clause already seen.");
|
|
1414
1412
|
}
|
|
1415
1413
|
implementsClause ??= heritageClause;
|
|
1416
1414
|
}
|
|
@@ -1556,7 +1554,7 @@ class Converter {
|
|
|
1556
1554
|
*/
|
|
1557
1555
|
if (operator === '++' || operator === '--') {
|
|
1558
1556
|
if (!(0, node_utils_1.isValidAssignmentTarget)(node.operand)) {
|
|
1559
|
-
this.#
|
|
1557
|
+
this.#throwError(node.operand, 'Invalid left-hand side expression in unary operation');
|
|
1560
1558
|
}
|
|
1561
1559
|
return this.createNode(node, {
|
|
1562
1560
|
type: ts_estree_1.AST_NODE_TYPES.UpdateExpression,
|
|
@@ -1672,7 +1670,7 @@ class Converter {
|
|
|
1672
1670
|
case SyntaxKind.CallExpression: {
|
|
1673
1671
|
if (node.expression.kind === SyntaxKind.ImportKeyword) {
|
|
1674
1672
|
if (node.arguments.length !== 1 && node.arguments.length !== 2) {
|
|
1675
|
-
this.#
|
|
1673
|
+
this.#throwError(node.arguments[2] ?? node, 'Dynamic import requires exactly one or two arguments.');
|
|
1676
1674
|
}
|
|
1677
1675
|
return this.createNode(node, this.#withDeprecatedAliasGetter({
|
|
1678
1676
|
type: ts_estree_1.AST_NODE_TYPES.ImportExpression,
|
|
@@ -2006,7 +2004,7 @@ class Converter {
|
|
|
2006
2004
|
});
|
|
2007
2005
|
case SyntaxKind.MappedType: {
|
|
2008
2006
|
if (node.members && node.members.length > 0) {
|
|
2009
|
-
this.#
|
|
2007
|
+
this.#throwError(node.members[0], 'A mapped type may not declare properties or methods.');
|
|
2010
2008
|
}
|
|
2011
2009
|
return this.createNode(node, this.#withDeprecatedGetter({
|
|
2012
2010
|
type: ts_estree_1.AST_NODE_TYPES.TSMappedType,
|
|
@@ -2227,16 +2225,18 @@ class Converter {
|
|
|
2227
2225
|
],
|
|
2228
2226
|
});
|
|
2229
2227
|
}
|
|
2230
|
-
const
|
|
2228
|
+
const argument = this.convertChild(node.argument);
|
|
2229
|
+
const source = argument.literal;
|
|
2230
|
+
const result = this.createNode(node, this.#withDeprecatedGetter({
|
|
2231
2231
|
type: ts_estree_1.AST_NODE_TYPES.TSImportType,
|
|
2232
2232
|
range,
|
|
2233
|
-
argument: this.convertChild(node.argument),
|
|
2234
2233
|
options,
|
|
2235
2234
|
qualifier: this.convertChild(node.qualifier),
|
|
2235
|
+
source,
|
|
2236
2236
|
typeArguments: node.typeArguments
|
|
2237
2237
|
? this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node)
|
|
2238
2238
|
: null,
|
|
2239
|
-
});
|
|
2239
|
+
}, 'argument', 'source', argument));
|
|
2240
2240
|
if (node.isTypeOf) {
|
|
2241
2241
|
return this.createNode(node, {
|
|
2242
2242
|
type: ts_estree_1.AST_NODE_TYPES.TSTypeQuery,
|
|
@@ -2264,11 +2264,11 @@ class Converter {
|
|
|
2264
2264
|
case SyntaxKind.EnumMember: {
|
|
2265
2265
|
const computed = node.name.kind === ts.SyntaxKind.ComputedPropertyName;
|
|
2266
2266
|
if (computed) {
|
|
2267
|
-
this.#
|
|
2267
|
+
this.#throwError(node.name, 'Computed property names are not allowed in enums.');
|
|
2268
2268
|
}
|
|
2269
2269
|
if (node.name.kind === SyntaxKind.NumericLiteral ||
|
|
2270
2270
|
node.name.kind === SyntaxKind.BigIntLiteral) {
|
|
2271
|
-
this.#
|
|
2271
|
+
this.#throwError(node.name, 'An enum member cannot have a numeric name.');
|
|
2272
2272
|
}
|
|
2273
2273
|
return this.createNode(node, this.#withDeprecatedGetter({
|
|
2274
2274
|
type: ts_estree_1.AST_NODE_TYPES.TSEnumMember,
|
|
@@ -2288,10 +2288,10 @@ class Converter {
|
|
|
2288
2288
|
const body = this.convertChild(node.body);
|
|
2289
2289
|
if (body == null ||
|
|
2290
2290
|
body.type === ts_estree_1.AST_NODE_TYPES.TSModuleDeclaration) {
|
|
2291
|
-
this.#
|
|
2291
|
+
this.#throwError(node.body ?? node, 'Expected a valid module body');
|
|
2292
2292
|
}
|
|
2293
2293
|
if (id.type !== ts_estree_1.AST_NODE_TYPES.Identifier) {
|
|
2294
|
-
this.#
|
|
2294
|
+
this.#throwError(node.name, 'global module augmentation must have an Identifier id');
|
|
2295
2295
|
}
|
|
2296
2296
|
return {
|
|
2297
2297
|
body: body,
|
|
@@ -2315,10 +2315,10 @@ class Converter {
|
|
|
2315
2315
|
// We "unravel" them here by making our own nested TSQualifiedName,
|
|
2316
2316
|
// with the innermost node's body as the actual node body.
|
|
2317
2317
|
if (node.body == null) {
|
|
2318
|
-
this.#
|
|
2318
|
+
this.#throwError(node, 'Expected a module body');
|
|
2319
2319
|
}
|
|
2320
2320
|
if (node.name.kind !== ts.SyntaxKind.Identifier) {
|
|
2321
|
-
this.#
|
|
2321
|
+
this.#throwError(node.name, '`namespace`s must have an Identifier id');
|
|
2322
2322
|
}
|
|
2323
2323
|
let name = this.createNode(node.name, {
|
|
2324
2324
|
type: ts_estree_1.AST_NODE_TYPES.Identifier,
|
|
@@ -21,12 +21,12 @@ function inferSingleRun(options) {
|
|
|
21
21
|
// https://github.com/typescript-eslint/typescript-eslint/issues/9504
|
|
22
22
|
// There's no support (yet?) for extraFileExtensions in single-run hosts.
|
|
23
23
|
// Only watch program hosts and project service can support that.
|
|
24
|
-
if (options?.extraFileExtensions?.length) {
|
|
24
|
+
if (options?.extraFileExtensions?.length && options.project) {
|
|
25
25
|
return false;
|
|
26
26
|
}
|
|
27
27
|
if (
|
|
28
28
|
// single-run implies type-aware linting - no projects means we can't be in single-run mode
|
|
29
|
-
options?.project == null ||
|
|
29
|
+
(options?.project == null && !options?.projectService) ||
|
|
30
30
|
// programs passed via options means the user should be managing the programs, so we shouldn't
|
|
31
31
|
// be creating our own single-run programs accidentally
|
|
32
32
|
options.programs != null) {
|
|
@@ -7,8 +7,7 @@ exports.clearGlobCache = clearGlobCache;
|
|
|
7
7
|
exports.resolveProjectList = resolveProjectList;
|
|
8
8
|
exports.clearGlobResolutionCache = clearGlobResolutionCache;
|
|
9
9
|
const debug_1 = __importDefault(require("debug"));
|
|
10
|
-
const
|
|
11
|
-
const is_glob_1 = __importDefault(require("is-glob"));
|
|
10
|
+
const tinyglobby_1 = require("tinyglobby");
|
|
12
11
|
const shared_1 = require("../create-program/shared");
|
|
13
12
|
const ExpiringCache_1 = require("./ExpiringCache");
|
|
14
13
|
const log = (0, debug_1.default)('typescript-eslint:typescript-estree:parseSettings:resolveProjectList');
|
|
@@ -32,10 +31,7 @@ function resolveProjectList(options) {
|
|
|
32
31
|
if (sanitizedProjects.length === 0) {
|
|
33
32
|
return new Map();
|
|
34
33
|
}
|
|
35
|
-
const projectFolderIgnoreList = (options.projectFolderIgnoreList ?? ['**/node_modules/**'])
|
|
36
|
-
.filter(folder => typeof folder === 'string')
|
|
37
|
-
// prefix with a ! for not match glob
|
|
38
|
-
.map(folder => (folder.startsWith('!') ? folder : `!${folder}`));
|
|
34
|
+
const projectFolderIgnoreList = (options.projectFolderIgnoreList ?? ['**/node_modules/**']).filter(folder => typeof folder === 'string');
|
|
39
35
|
const cacheKey = getHash({
|
|
40
36
|
project: sanitizedProjects,
|
|
41
37
|
projectFolderIgnoreList,
|
|
@@ -58,15 +54,15 @@ function resolveProjectList(options) {
|
|
|
58
54
|
}
|
|
59
55
|
}
|
|
60
56
|
// Transform glob patterns into paths
|
|
61
|
-
const nonGlobProjects = sanitizedProjects.filter(project => !(0,
|
|
62
|
-
const globProjects = sanitizedProjects.filter(project => (0,
|
|
57
|
+
const nonGlobProjects = sanitizedProjects.filter(project => !(0, tinyglobby_1.isDynamicPattern)(project));
|
|
58
|
+
const globProjects = sanitizedProjects.filter(project => (0, tinyglobby_1.isDynamicPattern)(project));
|
|
63
59
|
let globProjectPaths = [];
|
|
64
60
|
if (globProjects.length > 0) {
|
|
65
|
-
//
|
|
66
|
-
// to improve performance. To ensure the order is correct, we need to call fast-glob for each pattern
|
|
61
|
+
// To ensure the order is correct, we need to glob for each pattern
|
|
67
62
|
// separately and then concatenate the results in patterns' order.
|
|
68
|
-
globProjectPaths = globProjects.flatMap(pattern => (0,
|
|
63
|
+
globProjectPaths = globProjects.flatMap(pattern => (0, tinyglobby_1.globSync)(pattern, {
|
|
69
64
|
cwd: options.tsconfigRootDir,
|
|
65
|
+
expandDirectories: false,
|
|
70
66
|
ignore: projectFolderIgnoreList,
|
|
71
67
|
}));
|
|
72
68
|
}
|
package/dist/parser-options.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CacheDurationSeconds, DebugLevel, JSDocParsingMode, ProjectServiceOptions, SourceType } from '@typescript-eslint/types';
|
|
2
2
|
import type * as ts from 'typescript';
|
|
3
|
-
import type { TSESTree, TSESTreeToTSNode,
|
|
3
|
+
import type { TSESTree, TSESTreeToTSNode, TSToken } from './ts-estree';
|
|
4
4
|
interface ParseOptions {
|
|
5
5
|
/**
|
|
6
6
|
* Specify the `sourceType`.
|
|
@@ -192,7 +192,7 @@ export interface ParserServicesBase {
|
|
|
192
192
|
}
|
|
193
193
|
export interface ParserServicesNodeMaps {
|
|
194
194
|
esTreeNodeToTSNodeMap: ParserWeakMapESTreeToTSNode;
|
|
195
|
-
tsNodeToESTreeNodeMap: ParserWeakMap<
|
|
195
|
+
tsNodeToESTreeNodeMap: ParserWeakMap<TSToken, TSESTree.Node>;
|
|
196
196
|
}
|
|
197
197
|
export interface ParserServicesWithTypeInformation extends ParserServicesNodeMaps, ParserServicesBase {
|
|
198
198
|
getSymbolAtLocation: (node: TSESTree.Node) => ts.Symbol | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/typescript-estree",
|
|
3
|
-
"version": "8.47.1-alpha.
|
|
3
|
+
"version": "8.47.1-alpha.11",
|
|
4
4
|
"description": "A parser that converts TypeScript source code into an ESTree compatible form",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -52,19 +52,17 @@
|
|
|
52
52
|
"typecheck": "yarn run -BT nx typecheck"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@typescript-eslint/project-service": "8.47.1-alpha.
|
|
56
|
-
"@typescript-eslint/tsconfig-utils": "8.47.1-alpha.
|
|
57
|
-
"@typescript-eslint/types": "8.47.1-alpha.
|
|
58
|
-
"@typescript-eslint/visitor-keys": "8.47.1-alpha.
|
|
55
|
+
"@typescript-eslint/project-service": "8.47.1-alpha.11",
|
|
56
|
+
"@typescript-eslint/tsconfig-utils": "8.47.1-alpha.11",
|
|
57
|
+
"@typescript-eslint/types": "8.47.1-alpha.11",
|
|
58
|
+
"@typescript-eslint/visitor-keys": "8.47.1-alpha.11",
|
|
59
59
|
"debug": "^4.3.4",
|
|
60
|
-
"fast-glob": "^3.3.2",
|
|
61
|
-
"is-glob": "^4.0.3",
|
|
62
60
|
"minimatch": "^9.0.4",
|
|
63
61
|
"semver": "^7.6.0",
|
|
62
|
+
"tinyglobby": "^0.2.15",
|
|
64
63
|
"ts-api-utils": "^2.1.0"
|
|
65
64
|
},
|
|
66
65
|
"devDependencies": {
|
|
67
|
-
"@types/is-glob": "^4.0.4",
|
|
68
66
|
"@vitest/coverage-v8": "^3.1.3",
|
|
69
67
|
"eslint": "*",
|
|
70
68
|
"glob": "*",
|