@typescript-eslint/typescript-estree 8.51.1-alpha.5 → 8.51.1-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/check-syntax-errors.js +193 -3
- package/dist/convert.js +3 -151
- package/dist/create-program/createProjectProgramError.js +2 -2
- package/dist/create-program/validateDefaultProjectForFilesGlob.d.ts +1 -1
- package/dist/create-program/validateDefaultProjectForFilesGlob.js +1 -1
- package/dist/parseSettings/candidateTSConfigRootDirs.js +1 -1
- package/package.json +5 -5
|
@@ -42,14 +42,204 @@ function checkSyntaxError(tsNode) {
|
|
|
42
42
|
(0, check_modifiers_1.checkModifiers)(tsNode);
|
|
43
43
|
const node = tsNode;
|
|
44
44
|
switch (node.kind) {
|
|
45
|
+
case SyntaxKind.SwitchStatement:
|
|
46
|
+
if (node.caseBlock.clauses.filter(switchCase => switchCase.kind === SyntaxKind.DefaultClause).length > 1) {
|
|
47
|
+
throw (0, node_utils_1.createError)(node, "A 'default' clause cannot appear more than once in a 'switch' statement.");
|
|
48
|
+
}
|
|
49
|
+
break;
|
|
50
|
+
case SyntaxKind.ThrowStatement:
|
|
51
|
+
if (node.expression.end === node.expression.pos) {
|
|
52
|
+
throw (0, node_utils_1.createError)(node, 'A throw statement must throw an expression.');
|
|
53
|
+
}
|
|
54
|
+
break;
|
|
55
|
+
case SyntaxKind.CatchClause:
|
|
56
|
+
if (node.variableDeclaration?.initializer) {
|
|
57
|
+
throw (0, node_utils_1.createError)(node.variableDeclaration.initializer, 'Catch clause variable cannot have an initializer.');
|
|
58
|
+
}
|
|
59
|
+
break;
|
|
60
|
+
case SyntaxKind.FunctionDeclaration: {
|
|
61
|
+
const isDeclare = (0, node_utils_1.hasModifier)(SyntaxKind.DeclareKeyword, node);
|
|
62
|
+
const isAsync = (0, node_utils_1.hasModifier)(SyntaxKind.AsyncKeyword, node);
|
|
63
|
+
const isGenerator = !!node.asteriskToken;
|
|
64
|
+
if (isDeclare) {
|
|
65
|
+
if (node.body) {
|
|
66
|
+
throw (0, node_utils_1.createError)(node, 'An implementation cannot be declared in ambient contexts.');
|
|
67
|
+
}
|
|
68
|
+
else if (isAsync) {
|
|
69
|
+
throw (0, node_utils_1.createError)(node, "'async' modifier cannot be used in an ambient context.");
|
|
70
|
+
}
|
|
71
|
+
else if (isGenerator) {
|
|
72
|
+
throw (0, node_utils_1.createError)(node, 'Generators are not allowed in an ambient context.');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else if (!node.body && isGenerator) {
|
|
76
|
+
throw (0, node_utils_1.createError)(node, 'A function signature cannot be declared as a generator.');
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
case SyntaxKind.VariableDeclaration: {
|
|
81
|
+
const hasExclamationToken = !!node.exclamationToken;
|
|
82
|
+
if (hasExclamationToken) {
|
|
83
|
+
if (node.initializer) {
|
|
84
|
+
throw (0, node_utils_1.createError)(node, 'Declarations with initializers cannot also have definite assignment assertions.');
|
|
85
|
+
}
|
|
86
|
+
else if (node.name.kind !== SyntaxKind.Identifier || !node.type) {
|
|
87
|
+
throw (0, node_utils_1.createError)(node, 'Declarations with definite assignment assertions must also have type annotations.');
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (node.parent.kind === SyntaxKind.VariableDeclarationList) {
|
|
91
|
+
const variableDeclarationList = node.parent;
|
|
92
|
+
const kind = (0, node_utils_1.getDeclarationKind)(variableDeclarationList);
|
|
93
|
+
if ((variableDeclarationList.parent.kind === SyntaxKind.ForInStatement ||
|
|
94
|
+
variableDeclarationList.parent.kind === SyntaxKind.ForStatement) &&
|
|
95
|
+
(kind === 'using' || kind === 'await using')) {
|
|
96
|
+
if (!node.initializer) {
|
|
97
|
+
throw (0, node_utils_1.createError)(node, `'${kind}' declarations may not be initialized in for statement.`);
|
|
98
|
+
}
|
|
99
|
+
if (node.name.kind !== SyntaxKind.Identifier) {
|
|
100
|
+
throw (0, node_utils_1.createError)(node.name, `'${kind}' declarations may not have binding patterns.`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (variableDeclarationList.parent.kind === SyntaxKind.VariableStatement) {
|
|
104
|
+
const variableStatement = variableDeclarationList.parent;
|
|
105
|
+
if (kind === 'using' || kind === 'await using') {
|
|
106
|
+
if (!node.initializer) {
|
|
107
|
+
throw (0, node_utils_1.createError)(node, `'${kind}' declarations must be initialized.`);
|
|
108
|
+
}
|
|
109
|
+
if (node.name.kind !== SyntaxKind.Identifier) {
|
|
110
|
+
throw (0, node_utils_1.createError)(node.name, `'${kind}' declarations may not have binding patterns.`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const hasDeclareKeyword = (0, node_utils_1.hasModifier)(SyntaxKind.DeclareKeyword, variableStatement);
|
|
114
|
+
// Definite assignment only allowed for non-declare let and var
|
|
115
|
+
if ((hasDeclareKeyword ||
|
|
116
|
+
['await using', 'const', 'using'].includes(kind)) &&
|
|
117
|
+
hasExclamationToken) {
|
|
118
|
+
throw (0, node_utils_1.createError)(node, `A definite assignment assertion '!' is not permitted in this context.`);
|
|
119
|
+
}
|
|
120
|
+
if (hasDeclareKeyword &&
|
|
121
|
+
node.initializer &&
|
|
122
|
+
(['let', 'var'].includes(kind) || node.type)) {
|
|
123
|
+
throw (0, node_utils_1.createError)(node, `Initializers are not permitted in ambient contexts.`);
|
|
124
|
+
}
|
|
125
|
+
// Theoretically, only certain initializers are allowed for declare const,
|
|
126
|
+
// (TS1254: A 'const' initializer in an ambient context must be a string
|
|
127
|
+
// or numeric literal or literal enum reference.) but we just allow
|
|
128
|
+
// all expressions
|
|
129
|
+
// Note! No-declare does not mean the variable is not ambient, because
|
|
130
|
+
// it can be further nested in other declare contexts. Therefore we cannot
|
|
131
|
+
// check for const initializers.
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
case SyntaxKind.VariableStatement: {
|
|
137
|
+
const declarations = node.declarationList.declarations;
|
|
138
|
+
if (!declarations.length) {
|
|
139
|
+
throw (0, node_utils_1.createError)(node, 'A variable declaration list must have at least one variable declarator.');
|
|
140
|
+
}
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
case SyntaxKind.PropertyAssignment: {
|
|
144
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
145
|
+
const { exclamationToken, questionToken } = node;
|
|
146
|
+
if (questionToken) {
|
|
147
|
+
throw (0, node_utils_1.createError)(questionToken, 'A property assignment cannot have a question token.');
|
|
148
|
+
}
|
|
149
|
+
if (exclamationToken) {
|
|
150
|
+
throw (0, node_utils_1.createError)(exclamationToken, 'A property assignment cannot have an exclamation token.');
|
|
151
|
+
}
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
case SyntaxKind.ShorthandPropertyAssignment: {
|
|
155
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
156
|
+
const { exclamationToken, modifiers, questionToken } = node;
|
|
157
|
+
if (modifiers) {
|
|
158
|
+
throw (0, node_utils_1.createError)(modifiers[0], 'A shorthand property assignment cannot have modifiers.');
|
|
159
|
+
}
|
|
160
|
+
if (questionToken) {
|
|
161
|
+
throw (0, node_utils_1.createError)(questionToken, 'A shorthand property assignment cannot have a question token.');
|
|
162
|
+
}
|
|
163
|
+
if (exclamationToken) {
|
|
164
|
+
throw (0, node_utils_1.createError)(exclamationToken, 'A shorthand property assignment cannot have an exclamation token.');
|
|
165
|
+
}
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
case SyntaxKind.PropertyDeclaration: {
|
|
169
|
+
const isAbstract = (0, node_utils_1.hasModifier)(SyntaxKind.AbstractKeyword, node);
|
|
170
|
+
if (isAbstract && node.initializer) {
|
|
171
|
+
throw (0, node_utils_1.createError)(node.initializer, `Abstract property cannot have an initializer.`);
|
|
172
|
+
}
|
|
173
|
+
if (node.name.kind === SyntaxKind.StringLiteral &&
|
|
174
|
+
node.name.text === 'constructor') {
|
|
175
|
+
throw (0, node_utils_1.createError)(node.name, "Classes may not have a field named 'constructor'.");
|
|
176
|
+
}
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
case SyntaxKind.TaggedTemplateExpression:
|
|
180
|
+
if (node.tag.flags & ts.NodeFlags.OptionalChain) {
|
|
181
|
+
throw (0, node_utils_1.createError)(node, 'Tagged template expressions are not permitted in an optional chain.');
|
|
182
|
+
}
|
|
183
|
+
break;
|
|
184
|
+
case SyntaxKind.ClassDeclaration:
|
|
185
|
+
if (!node.name &&
|
|
186
|
+
(!(0, node_utils_1.hasModifier)(ts.SyntaxKind.ExportKeyword, node) ||
|
|
187
|
+
!(0, node_utils_1.hasModifier)(ts.SyntaxKind.DefaultKeyword, node))) {
|
|
188
|
+
throw (0, node_utils_1.createError)(node, "A class declaration without the 'default' modifier must have a name.");
|
|
189
|
+
}
|
|
190
|
+
break;
|
|
191
|
+
case SyntaxKind.BinaryExpression:
|
|
192
|
+
if (node.operatorToken.kind !== SyntaxKind.InKeyword &&
|
|
193
|
+
node.left.kind === SyntaxKind.PrivateIdentifier) {
|
|
194
|
+
throw (0, node_utils_1.createError)(node.left, "Private identifiers cannot appear on the right-hand-side of an 'in' expression.");
|
|
195
|
+
}
|
|
196
|
+
else if (node.right.kind === SyntaxKind.PrivateIdentifier) {
|
|
197
|
+
throw (0, node_utils_1.createError)(node.right, "Private identifiers are only allowed on the left-hand-side of an 'in' expression.");
|
|
198
|
+
}
|
|
199
|
+
break;
|
|
200
|
+
case SyntaxKind.MappedType:
|
|
201
|
+
if (node.members && node.members.length > 0) {
|
|
202
|
+
throw (0, node_utils_1.createError)(node.members[0], 'A mapped type may not declare properties or methods.');
|
|
203
|
+
}
|
|
204
|
+
break;
|
|
205
|
+
case SyntaxKind.PropertySignature: {
|
|
206
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
207
|
+
const { initializer } = node;
|
|
208
|
+
if (initializer) {
|
|
209
|
+
throw (0, node_utils_1.createError)(initializer, 'A property signature cannot have an initializer.');
|
|
210
|
+
}
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
case SyntaxKind.FunctionType: {
|
|
214
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
215
|
+
const { modifiers } = node;
|
|
216
|
+
if (modifiers) {
|
|
217
|
+
throw (0, node_utils_1.createError)(modifiers[0], 'A function type cannot have modifiers.');
|
|
218
|
+
}
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
case SyntaxKind.EnumMember: {
|
|
222
|
+
const computed = node.name.kind === ts.SyntaxKind.ComputedPropertyName;
|
|
223
|
+
if (computed) {
|
|
224
|
+
throw (0, node_utils_1.createError)(node.name, 'Computed property names are not allowed in enums.');
|
|
225
|
+
}
|
|
226
|
+
if (node.name.kind === SyntaxKind.NumericLiteral ||
|
|
227
|
+
node.name.kind === SyntaxKind.BigIntLiteral) {
|
|
228
|
+
throw (0, node_utils_1.createError)(node.name, 'An enum member cannot have a numeric name.');
|
|
229
|
+
}
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
case SyntaxKind.ExternalModuleReference:
|
|
233
|
+
if (node.expression.kind !== SyntaxKind.StringLiteral) {
|
|
234
|
+
throw (0, node_utils_1.createError)(node.expression, 'String literal expected.');
|
|
235
|
+
}
|
|
236
|
+
break;
|
|
45
237
|
case SyntaxKind.ForInStatement:
|
|
46
238
|
case SyntaxKind.ForOfStatement: {
|
|
47
239
|
checkForStatementDeclaration(node);
|
|
48
240
|
break;
|
|
49
241
|
}
|
|
50
|
-
default
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
242
|
+
// No default
|
|
53
243
|
}
|
|
54
244
|
}
|
|
55
245
|
function checkForStatementDeclaration(node) {
|
package/dist/convert.js
CHANGED
|
@@ -103,7 +103,7 @@ class Converter {
|
|
|
103
103
|
? () => node[valueKey]
|
|
104
104
|
: () => {
|
|
105
105
|
if (!warned) {
|
|
106
|
-
process.emitWarning(`The '${aliasKey}' property is deprecated on ${node.type} nodes. Use '${valueKey}' instead. See https://
|
|
106
|
+
process.emitWarning(`The '${aliasKey}' property is deprecated on ${node.type} nodes. Use '${valueKey}' instead. See https://tseslint.com/key-property-deprecated.`, 'DeprecationWarning');
|
|
107
107
|
warned = true;
|
|
108
108
|
}
|
|
109
109
|
return node[valueKey];
|
|
@@ -130,8 +130,7 @@ class Converter {
|
|
|
130
130
|
if (preferredKey) {
|
|
131
131
|
message += ` Use ${preferredKey} instead.`;
|
|
132
132
|
}
|
|
133
|
-
message +=
|
|
134
|
-
' See https://typescript-eslint.io/troubleshooting/faqs/general#the-key-property-is-deprecated-on-type-nodes-use-key-instead-warnings.';
|
|
133
|
+
message += ' See https://tseslint.com/key-property-deprecated.';
|
|
135
134
|
process.emitWarning(message, 'DeprecationWarning');
|
|
136
135
|
warned = true;
|
|
137
136
|
}
|
|
@@ -558,9 +557,6 @@ class Converter {
|
|
|
558
557
|
test: this.convertChild(node.expression),
|
|
559
558
|
});
|
|
560
559
|
case SyntaxKind.SwitchStatement:
|
|
561
|
-
if (node.caseBlock.clauses.filter(switchCase => switchCase.kind === SyntaxKind.DefaultClause).length > 1) {
|
|
562
|
-
this.#throwError(node, "A 'default' clause cannot appear more than once in a 'switch' statement.");
|
|
563
|
-
}
|
|
564
560
|
return this.createNode(node, {
|
|
565
561
|
type: ts_estree_1.AST_NODE_TYPES.SwitchStatement,
|
|
566
562
|
cases: this.convertChildren(node.caseBlock.clauses),
|
|
@@ -578,9 +574,6 @@ class Converter {
|
|
|
578
574
|
});
|
|
579
575
|
// Exceptions
|
|
580
576
|
case SyntaxKind.ThrowStatement:
|
|
581
|
-
if (node.expression.end === node.expression.pos) {
|
|
582
|
-
this.#throwError(node, 'A throw statement must throw an expression.');
|
|
583
|
-
}
|
|
584
577
|
return this.createNode(node, {
|
|
585
578
|
type: ts_estree_1.AST_NODE_TYPES.ThrowStatement,
|
|
586
579
|
argument: this.convertChild(node.expression),
|
|
@@ -593,9 +586,6 @@ class Converter {
|
|
|
593
586
|
handler: this.convertChild(node.catchClause),
|
|
594
587
|
});
|
|
595
588
|
case SyntaxKind.CatchClause:
|
|
596
|
-
if (node.variableDeclaration?.initializer) {
|
|
597
|
-
this.#throwError(node.variableDeclaration.initializer, 'Catch clause variable cannot have an initializer.');
|
|
598
|
-
}
|
|
599
589
|
return this.createNode(node, {
|
|
600
590
|
type: ts_estree_1.AST_NODE_TYPES.CatchClause,
|
|
601
591
|
body: this.convertChild(node.block),
|
|
@@ -649,20 +639,6 @@ class Converter {
|
|
|
649
639
|
const isDeclare = (0, node_utils_1.hasModifier)(SyntaxKind.DeclareKeyword, node);
|
|
650
640
|
const isAsync = (0, node_utils_1.hasModifier)(SyntaxKind.AsyncKeyword, node);
|
|
651
641
|
const isGenerator = !!node.asteriskToken;
|
|
652
|
-
if (isDeclare) {
|
|
653
|
-
if (node.body) {
|
|
654
|
-
this.#throwError(node, 'An implementation cannot be declared in ambient contexts.');
|
|
655
|
-
}
|
|
656
|
-
else if (isAsync) {
|
|
657
|
-
this.#throwError(node, "'async' modifier cannot be used in an ambient context.");
|
|
658
|
-
}
|
|
659
|
-
else if (isGenerator) {
|
|
660
|
-
this.#throwError(node, 'Generators are not allowed in an ambient context.');
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
else if (!node.body && isGenerator) {
|
|
664
|
-
this.#throwError(node, 'A function signature cannot be declared as a generator.');
|
|
665
|
-
}
|
|
666
642
|
const result = this.createNode(node, {
|
|
667
643
|
// declare implies no body due to the invariant above
|
|
668
644
|
type: !node.body
|
|
@@ -683,60 +659,6 @@ class Converter {
|
|
|
683
659
|
}
|
|
684
660
|
case SyntaxKind.VariableDeclaration: {
|
|
685
661
|
const hasExclamationToken = !!node.exclamationToken;
|
|
686
|
-
if (hasExclamationToken) {
|
|
687
|
-
if (node.initializer) {
|
|
688
|
-
this.#throwError(node, 'Declarations with initializers cannot also have definite assignment assertions.');
|
|
689
|
-
}
|
|
690
|
-
else if (node.name.kind !== SyntaxKind.Identifier || !node.type) {
|
|
691
|
-
this.#throwError(node, 'Declarations with definite assignment assertions must also have type annotations.');
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
if (node.parent.kind === SyntaxKind.VariableDeclarationList) {
|
|
695
|
-
const variableDeclarationList = node.parent;
|
|
696
|
-
const kind = (0, node_utils_1.getDeclarationKind)(variableDeclarationList);
|
|
697
|
-
if ((variableDeclarationList.parent.kind ===
|
|
698
|
-
SyntaxKind.ForInStatement ||
|
|
699
|
-
variableDeclarationList.parent.kind ===
|
|
700
|
-
SyntaxKind.ForStatement) &&
|
|
701
|
-
(kind === 'using' || kind === 'await using')) {
|
|
702
|
-
if (!node.initializer) {
|
|
703
|
-
this.#throwError(node, `'${kind}' declarations may not be initialized in for statement.`);
|
|
704
|
-
}
|
|
705
|
-
if (node.name.kind !== SyntaxKind.Identifier) {
|
|
706
|
-
this.#throwError(node.name, `'${kind}' declarations may not have binding patterns.`);
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
if (variableDeclarationList.parent.kind === SyntaxKind.VariableStatement) {
|
|
710
|
-
const variableStatement = variableDeclarationList.parent;
|
|
711
|
-
if (kind === 'using' || kind === 'await using') {
|
|
712
|
-
if (!node.initializer) {
|
|
713
|
-
this.#throwError(node, `'${kind}' declarations must be initialized.`);
|
|
714
|
-
}
|
|
715
|
-
if (node.name.kind !== SyntaxKind.Identifier) {
|
|
716
|
-
this.#throwError(node.name, `'${kind}' declarations may not have binding patterns.`);
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
const hasDeclareKeyword = (0, node_utils_1.hasModifier)(SyntaxKind.DeclareKeyword, variableStatement);
|
|
720
|
-
// Definite assignment only allowed for non-declare let and var
|
|
721
|
-
if ((hasDeclareKeyword ||
|
|
722
|
-
['await using', 'const', 'using'].includes(kind)) &&
|
|
723
|
-
hasExclamationToken) {
|
|
724
|
-
this.#throwError(node, `A definite assignment assertion '!' is not permitted in this context.`);
|
|
725
|
-
}
|
|
726
|
-
if (hasDeclareKeyword &&
|
|
727
|
-
node.initializer &&
|
|
728
|
-
(['let', 'var'].includes(kind) || node.type)) {
|
|
729
|
-
this.#throwError(node, `Initializers are not permitted in ambient contexts.`);
|
|
730
|
-
}
|
|
731
|
-
// Theoretically, only certain initializers are allowed for declare const,
|
|
732
|
-
// (TS1254: A 'const' initializer in an ambient context must be a string
|
|
733
|
-
// or numeric literal or literal enum reference.) but we just allow
|
|
734
|
-
// all expressions
|
|
735
|
-
// Note! No-declare does not mean the variable is not ambient, because
|
|
736
|
-
// it can be further nested in other declare contexts. Therefore we cannot
|
|
737
|
-
// check for const initializers.
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
662
|
const init = this.convertChild(node.initializer);
|
|
741
663
|
const id = this.convertBindingNameWithTypeAnnotation(node.name, node.type, node);
|
|
742
664
|
return this.createNode(node, {
|
|
@@ -748,9 +670,6 @@ class Converter {
|
|
|
748
670
|
}
|
|
749
671
|
case SyntaxKind.VariableStatement: {
|
|
750
672
|
const declarations = node.declarationList.declarations;
|
|
751
|
-
if (!declarations.length) {
|
|
752
|
-
this.#throwError(node, 'A variable declaration list must have at least one variable declarator.');
|
|
753
|
-
}
|
|
754
673
|
const result = this.createNode(node, {
|
|
755
674
|
type: ts_estree_1.AST_NODE_TYPES.VariableDeclaration,
|
|
756
675
|
declarations: this.convertChildren(declarations),
|
|
@@ -829,14 +748,6 @@ class Converter {
|
|
|
829
748
|
});
|
|
830
749
|
}
|
|
831
750
|
case SyntaxKind.PropertyAssignment: {
|
|
832
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
833
|
-
const { exclamationToken, questionToken } = node;
|
|
834
|
-
if (questionToken) {
|
|
835
|
-
this.#throwError(questionToken, 'A property assignment cannot have a question token.');
|
|
836
|
-
}
|
|
837
|
-
if (exclamationToken) {
|
|
838
|
-
this.#throwError(exclamationToken, 'A property assignment cannot have an exclamation token.');
|
|
839
|
-
}
|
|
840
751
|
return this.createNode(node, {
|
|
841
752
|
type: ts_estree_1.AST_NODE_TYPES.Property,
|
|
842
753
|
computed: (0, node_utils_1.isComputedProperty)(node.name),
|
|
@@ -849,17 +760,6 @@ class Converter {
|
|
|
849
760
|
});
|
|
850
761
|
}
|
|
851
762
|
case SyntaxKind.ShorthandPropertyAssignment: {
|
|
852
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
853
|
-
const { exclamationToken, modifiers, questionToken } = node;
|
|
854
|
-
if (modifiers) {
|
|
855
|
-
this.#throwError(modifiers[0], 'A shorthand property assignment cannot have modifiers.');
|
|
856
|
-
}
|
|
857
|
-
if (questionToken) {
|
|
858
|
-
this.#throwError(questionToken, 'A shorthand property assignment cannot have a question token.');
|
|
859
|
-
}
|
|
860
|
-
if (exclamationToken) {
|
|
861
|
-
this.#throwError(exclamationToken, 'A shorthand property assignment cannot have an exclamation token.');
|
|
862
|
-
}
|
|
863
763
|
if (node.objectAssignmentInitializer) {
|
|
864
764
|
return this.createNode(node, {
|
|
865
765
|
type: ts_estree_1.AST_NODE_TYPES.Property,
|
|
@@ -894,13 +794,6 @@ class Converter {
|
|
|
894
794
|
return this.convertChild(node.expression);
|
|
895
795
|
case SyntaxKind.PropertyDeclaration: {
|
|
896
796
|
const isAbstract = (0, node_utils_1.hasModifier)(SyntaxKind.AbstractKeyword, node);
|
|
897
|
-
if (isAbstract && node.initializer) {
|
|
898
|
-
this.#throwError(node.initializer, `Abstract property cannot have an initializer.`);
|
|
899
|
-
}
|
|
900
|
-
if (node.name.kind === SyntaxKind.StringLiteral &&
|
|
901
|
-
node.name.text === 'constructor') {
|
|
902
|
-
this.#throwError(node.name, "Classes may not have a field named 'constructor'.");
|
|
903
|
-
}
|
|
904
797
|
const isAccessor = (0, node_utils_1.hasModifier)(SyntaxKind.AccessorKeyword, node);
|
|
905
798
|
const type = (() => {
|
|
906
799
|
if (isAccessor) {
|
|
@@ -1233,9 +1126,6 @@ class Converter {
|
|
|
1233
1126
|
return result;
|
|
1234
1127
|
}
|
|
1235
1128
|
case SyntaxKind.TaggedTemplateExpression: {
|
|
1236
|
-
if (node.tag.flags & ts.NodeFlags.OptionalChain) {
|
|
1237
|
-
this.#throwError(node, 'Tagged template expressions are not permitted in an optional chain.');
|
|
1238
|
-
}
|
|
1239
1129
|
return this.createNode(node, {
|
|
1240
1130
|
type: ts_estree_1.AST_NODE_TYPES.TaggedTemplateExpression,
|
|
1241
1131
|
quasi: this.convertChild(node.template),
|
|
@@ -1336,12 +1226,6 @@ class Converter {
|
|
|
1336
1226
|
}
|
|
1337
1227
|
// Classes
|
|
1338
1228
|
case SyntaxKind.ClassDeclaration:
|
|
1339
|
-
if (!node.name &&
|
|
1340
|
-
(!(0, node_utils_1.hasModifier)(ts.SyntaxKind.ExportKeyword, node) ||
|
|
1341
|
-
!(0, node_utils_1.hasModifier)(ts.SyntaxKind.DefaultKeyword, node))) {
|
|
1342
|
-
this.#throwError(node, "A class declaration without the 'default' modifier must have a name.");
|
|
1343
|
-
}
|
|
1344
|
-
/* intentional fallthrough */
|
|
1345
1229
|
case SyntaxKind.ClassExpression: {
|
|
1346
1230
|
const heritageClauses = node.heritageClauses ?? [];
|
|
1347
1231
|
const classNodeType = node.kind === SyntaxKind.ClassDeclaration
|
|
@@ -1559,13 +1443,6 @@ class Converter {
|
|
|
1559
1443
|
});
|
|
1560
1444
|
// Binary Operations
|
|
1561
1445
|
case SyntaxKind.BinaryExpression: {
|
|
1562
|
-
if (node.operatorToken.kind !== SyntaxKind.InKeyword &&
|
|
1563
|
-
node.left.kind === SyntaxKind.PrivateIdentifier) {
|
|
1564
|
-
this.#throwError(node.left, "Private identifiers cannot appear on the right-hand-side of an 'in' expression.");
|
|
1565
|
-
}
|
|
1566
|
-
else if (node.right.kind === SyntaxKind.PrivateIdentifier) {
|
|
1567
|
-
this.#throwError(node.right, "Private identifiers are only allowed on the left-hand-side of an 'in' expression.");
|
|
1568
|
-
}
|
|
1569
1446
|
// TypeScript uses BinaryExpression for sequences as well
|
|
1570
1447
|
if ((0, node_utils_1.isComma)(node.operatorToken)) {
|
|
1571
1448
|
const result = this.createNode(node, {
|
|
@@ -1963,9 +1840,6 @@ class Converter {
|
|
|
1963
1840
|
this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node),
|
|
1964
1841
|
});
|
|
1965
1842
|
case SyntaxKind.MappedType: {
|
|
1966
|
-
if (node.members && node.members.length > 0) {
|
|
1967
|
-
this.#throwError(node.members[0], 'A mapped type may not declare properties or methods.');
|
|
1968
|
-
}
|
|
1969
1843
|
return this.createNode(node, this.#withDeprecatedGetter({
|
|
1970
1844
|
type: ts_estree_1.AST_NODE_TYPES.TSMappedType,
|
|
1971
1845
|
constraint: this.convertChild(node.typeParameter.constraint),
|
|
@@ -1999,11 +1873,6 @@ class Converter {
|
|
|
1999
1873
|
return this.convertMethodSignature(node);
|
|
2000
1874
|
}
|
|
2001
1875
|
case SyntaxKind.PropertySignature: {
|
|
2002
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
2003
|
-
const { initializer } = node;
|
|
2004
|
-
if (initializer) {
|
|
2005
|
-
this.#throwError(initializer, 'A property signature cannot have an initializer.');
|
|
2006
|
-
}
|
|
2007
1876
|
return this.createNode(node, {
|
|
2008
1877
|
type: ts_estree_1.AST_NODE_TYPES.TSPropertySignature,
|
|
2009
1878
|
accessibility: (0, node_utils_1.getTSNodeAccessibility)(node),
|
|
@@ -2035,14 +1904,7 @@ class Converter {
|
|
|
2035
1904
|
this.convertTSTypeParametersToTypeParametersDeclaration(node.typeParameters),
|
|
2036
1905
|
});
|
|
2037
1906
|
}
|
|
2038
|
-
case SyntaxKind.FunctionType:
|
|
2039
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
2040
|
-
const { modifiers } = node;
|
|
2041
|
-
if (modifiers) {
|
|
2042
|
-
this.#throwError(modifiers[0], 'A function type cannot have modifiers.');
|
|
2043
|
-
}
|
|
2044
|
-
}
|
|
2045
|
-
// intentional fallthrough
|
|
1907
|
+
case SyntaxKind.FunctionType:
|
|
2046
1908
|
case SyntaxKind.ConstructSignature:
|
|
2047
1909
|
case SyntaxKind.CallSignature: {
|
|
2048
1910
|
const type = node.kind === SyntaxKind.ConstructSignature
|
|
@@ -2223,13 +2085,6 @@ class Converter {
|
|
|
2223
2085
|
}
|
|
2224
2086
|
case SyntaxKind.EnumMember: {
|
|
2225
2087
|
const computed = node.name.kind === ts.SyntaxKind.ComputedPropertyName;
|
|
2226
|
-
if (computed) {
|
|
2227
|
-
this.#throwError(node.name, 'Computed property names are not allowed in enums.');
|
|
2228
|
-
}
|
|
2229
|
-
if (node.name.kind === SyntaxKind.NumericLiteral ||
|
|
2230
|
-
node.name.kind === SyntaxKind.BigIntLiteral) {
|
|
2231
|
-
this.#throwError(node.name, 'An enum member cannot have a numeric name.');
|
|
2232
|
-
}
|
|
2233
2088
|
return this.createNode(node, this.#withDeprecatedGetter({
|
|
2234
2089
|
type: ts_estree_1.AST_NODE_TYPES.TSEnumMember,
|
|
2235
2090
|
id: this.convertChild(node.name),
|
|
@@ -2383,9 +2238,6 @@ class Converter {
|
|
|
2383
2238
|
}));
|
|
2384
2239
|
}
|
|
2385
2240
|
case SyntaxKind.ExternalModuleReference: {
|
|
2386
|
-
if (node.expression.kind !== SyntaxKind.StringLiteral) {
|
|
2387
|
-
this.#throwError(node.expression, 'String literal expected.');
|
|
2388
|
-
}
|
|
2389
2241
|
return this.createNode(node, {
|
|
2390
2242
|
type: ts_estree_1.AST_NODE_TYPES.TSExternalModuleReference,
|
|
2391
2243
|
expression: this.convertChild(node.expression),
|
|
@@ -29,7 +29,7 @@ function getErrorDetails(describedFilePath, parseSettings, programsForProjects)
|
|
|
29
29
|
`Either:`,
|
|
30
30
|
`- Switch to \`parserOptions.projectService\``,
|
|
31
31
|
`- Use an ESLint-specific TSConfig`,
|
|
32
|
-
`See the typescript-eslint docs for more info: https://
|
|
32
|
+
`See the typescript-eslint docs for more info: https://tseslint.com/are-project-references-supported`,
|
|
33
33
|
];
|
|
34
34
|
}
|
|
35
35
|
const { extraFileExtensions } = parseSettings;
|
|
@@ -69,6 +69,6 @@ function getErrorDetails(describedFilePath, parseSettings, programsForProjects)
|
|
|
69
69
|
`- Change ESLint's list of included files to not include this file`,
|
|
70
70
|
`- Change ${describedSpecifiers} to include this file`,
|
|
71
71
|
`- Create a new TSConfig that includes this file and include it in your parserOptions.project`,
|
|
72
|
-
`See the typescript-eslint docs for more info: https://
|
|
72
|
+
`See the typescript-eslint docs for more info: https://tseslint.com/none-of-those-tsconfigs-include-this-file`,
|
|
73
73
|
];
|
|
74
74
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const DEFAULT_PROJECT_FILES_ERROR_EXPLANATION = "\n\nHaving many files run with the default project is known to cause performance issues and slow down linting.\n\nSee https://
|
|
1
|
+
export declare const DEFAULT_PROJECT_FILES_ERROR_EXPLANATION = "\n\nHaving many files run with the default project is known to cause performance issues and slow down linting.\n\nSee https://tseslint.com/allowdefaultproject-glob-too-wide\n";
|
|
2
2
|
export declare function validateDefaultProjectForFilesGlob(allowDefaultProject: string[] | undefined): void;
|
|
@@ -6,7 +6,7 @@ exports.DEFAULT_PROJECT_FILES_ERROR_EXPLANATION = `
|
|
|
6
6
|
|
|
7
7
|
Having many files run with the default project is known to cause performance issues and slow down linting.
|
|
8
8
|
|
|
9
|
-
See https://
|
|
9
|
+
See https://tseslint.com/allowdefaultproject-glob-too-wide
|
|
10
10
|
`;
|
|
11
11
|
function validateDefaultProjectForFilesGlob(allowDefaultProject) {
|
|
12
12
|
if (!allowDefaultProject?.length) {
|
|
@@ -22,7 +22,7 @@ function getInferredTSConfigRootDir() {
|
|
|
22
22
|
'No tsconfigRootDir was set, and multiple candidate TSConfigRootDirs are present:',
|
|
23
23
|
...entries.map(candidate => ` - ${candidate}`),
|
|
24
24
|
"You'll need to explicitly set tsconfigRootDir in your parser options.",
|
|
25
|
-
'See: https://
|
|
25
|
+
'See: https://tseslint.com/parser-tsconfigrootdir',
|
|
26
26
|
].join('\n'));
|
|
27
27
|
}
|
|
28
28
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/typescript-estree",
|
|
3
|
-
"version": "8.51.1-alpha.
|
|
3
|
+
"version": "8.51.1-alpha.7",
|
|
4
4
|
"description": "A parser that converts TypeScript source code into an ESTree compatible form",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"typecheck": "yarn run -BT nx typecheck"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@typescript-eslint/project-service": "8.51.1-alpha.
|
|
56
|
-
"@typescript-eslint/tsconfig-utils": "8.51.1-alpha.
|
|
57
|
-
"@typescript-eslint/types": "8.51.1-alpha.
|
|
58
|
-
"@typescript-eslint/visitor-keys": "8.51.1-alpha.
|
|
55
|
+
"@typescript-eslint/project-service": "8.51.1-alpha.7",
|
|
56
|
+
"@typescript-eslint/tsconfig-utils": "8.51.1-alpha.7",
|
|
57
|
+
"@typescript-eslint/types": "8.51.1-alpha.7",
|
|
58
|
+
"@typescript-eslint/visitor-keys": "8.51.1-alpha.7",
|
|
59
59
|
"debug": "^4.4.3",
|
|
60
60
|
"minimatch": "^9.0.5",
|
|
61
61
|
"semver": "^7.7.3",
|