@typescript-eslint/typescript-estree 8.47.1-alpha.2 → 8.47.1-alpha.4

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.
Files changed (2) hide show
  1. package/dist/convert.js +23 -25
  2. package/package.json +5 -5
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.#throwUnlessAllowInvalidAST(node, 'Module specifier must be a string literal.');
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.#throwUnlessAllowInvalidAST(node.moduleSpecifier, 'Module specifier must be a string literal.');
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.#throwUnlessAllowInvalidAST(node, 'A throw statement must throw an expression.');
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.#throwUnlessAllowInvalidAST(node, 'A variable declaration list must have at least one variable declarator.');
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.#throwUnlessAllowInvalidAST(property.end - 1, "'{' expected.");
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.#throwUnlessAllowInvalidAST(node, "A class declaration without the 'default' modifier must have a name.");
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.#throwUnlessAllowInvalidAST(heritageClause, `'${ts.tokenToString(token)}' list cannot be empty.`);
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.#throwUnlessAllowInvalidAST(heritageClause, "'extends' clause already seen.");
1399
+ this.#throwError(heritageClause, "'extends' clause already seen.");
1402
1400
  }
1403
1401
  if (implementsClause) {
1404
- this.#throwUnlessAllowInvalidAST(heritageClause, "'extends' clause must precede 'implements' clause.");
1402
+ this.#throwError(heritageClause, "'extends' clause must precede 'implements' clause.");
1405
1403
  }
1406
1404
  if (types.length > 1) {
1407
- this.#throwUnlessAllowInvalidAST(types[1], 'Classes can only extend a single class.');
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.#throwUnlessAllowInvalidAST(heritageClause, "'implements' clause already seen.");
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.#throwUnlessAllowInvalidAST(node.operand, 'Invalid left-hand side expression in unary operation');
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.#throwUnlessAllowInvalidAST(node.arguments[2] ?? node, 'Dynamic import requires exactly one or two arguments.');
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.#throwUnlessAllowInvalidAST(node.members[0], 'A mapped type may not declare properties or methods.');
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,
@@ -2264,11 +2262,11 @@ class Converter {
2264
2262
  case SyntaxKind.EnumMember: {
2265
2263
  const computed = node.name.kind === ts.SyntaxKind.ComputedPropertyName;
2266
2264
  if (computed) {
2267
- this.#throwUnlessAllowInvalidAST(node.name, 'Computed property names are not allowed in enums.');
2265
+ this.#throwError(node.name, 'Computed property names are not allowed in enums.');
2268
2266
  }
2269
2267
  if (node.name.kind === SyntaxKind.NumericLiteral ||
2270
2268
  node.name.kind === SyntaxKind.BigIntLiteral) {
2271
- this.#throwUnlessAllowInvalidAST(node.name, 'An enum member cannot have a numeric name.');
2269
+ this.#throwError(node.name, 'An enum member cannot have a numeric name.');
2272
2270
  }
2273
2271
  return this.createNode(node, this.#withDeprecatedGetter({
2274
2272
  type: ts_estree_1.AST_NODE_TYPES.TSEnumMember,
@@ -2288,10 +2286,10 @@ class Converter {
2288
2286
  const body = this.convertChild(node.body);
2289
2287
  if (body == null ||
2290
2288
  body.type === ts_estree_1.AST_NODE_TYPES.TSModuleDeclaration) {
2291
- this.#throwUnlessAllowInvalidAST(node.body ?? node, 'Expected a valid module body');
2289
+ this.#throwError(node.body ?? node, 'Expected a valid module body');
2292
2290
  }
2293
2291
  if (id.type !== ts_estree_1.AST_NODE_TYPES.Identifier) {
2294
- this.#throwUnlessAllowInvalidAST(node.name, 'global module augmentation must have an Identifier id');
2292
+ this.#throwError(node.name, 'global module augmentation must have an Identifier id');
2295
2293
  }
2296
2294
  return {
2297
2295
  body: body,
@@ -2315,10 +2313,10 @@ class Converter {
2315
2313
  // We "unravel" them here by making our own nested TSQualifiedName,
2316
2314
  // with the innermost node's body as the actual node body.
2317
2315
  if (node.body == null) {
2318
- this.#throwUnlessAllowInvalidAST(node, 'Expected a module body');
2316
+ this.#throwError(node, 'Expected a module body');
2319
2317
  }
2320
2318
  if (node.name.kind !== ts.SyntaxKind.Identifier) {
2321
- this.#throwUnlessAllowInvalidAST(node.name, '`namespace`s must have an Identifier id');
2319
+ this.#throwError(node.name, '`namespace`s must have an Identifier id');
2322
2320
  }
2323
2321
  let name = this.createNode(node.name, {
2324
2322
  type: ts_estree_1.AST_NODE_TYPES.Identifier,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typescript-eslint/typescript-estree",
3
- "version": "8.47.1-alpha.2",
3
+ "version": "8.47.1-alpha.4",
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.47.1-alpha.2",
56
- "@typescript-eslint/tsconfig-utils": "8.47.1-alpha.2",
57
- "@typescript-eslint/types": "8.47.1-alpha.2",
58
- "@typescript-eslint/visitor-keys": "8.47.1-alpha.2",
55
+ "@typescript-eslint/project-service": "8.47.1-alpha.4",
56
+ "@typescript-eslint/tsconfig-utils": "8.47.1-alpha.4",
57
+ "@typescript-eslint/types": "8.47.1-alpha.4",
58
+ "@typescript-eslint/visitor-keys": "8.47.1-alpha.4",
59
59
  "debug": "^4.3.4",
60
60
  "fast-glob": "^3.3.2",
61
61
  "is-glob": "^4.0.3",