@elizaos/config 1.7.1-alpha.9 → 1.7.1

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/index.js +1209 -414
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -182668,6 +182668,7 @@ var require_node_utils = __commonJS((exports) => {
182668
182668
  exports.isValidAssignmentTarget = isValidAssignmentTarget;
182669
182669
  exports.getNamespaceModifiers = getNamespaceModifiers;
182670
182670
  exports.declarationNameToString = declarationNameToString;
182671
+ exports.isEntityNameExpression = isEntityNameExpression;
182671
182672
  var ts = __importStar(require_typescript());
182672
182673
  var getModifiers_1 = require_getModifiers();
182673
182674
  var xhtml_entities_1 = require_xhtml_entities();
@@ -183099,10 +183100,16 @@ var require_node_utils = __commonJS((exports) => {
183099
183100
  }
183100
183101
  return modifiers;
183101
183102
  }
183102
- function declarationNameToString(name, ast) {
183103
- const text = ast.text.slice(name.pos, name.end).trimStart();
183103
+ function declarationNameToString(node) {
183104
+ const text = node.getSourceFile().text.slice(node.pos, node.end).trimStart();
183104
183105
  return text || "(Missing)";
183105
183106
  }
183107
+ function isPropertyAccessEntityNameExpression(node) {
183108
+ return ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.name) && isEntityNameExpression(node.expression);
183109
+ }
183110
+ function isEntityNameExpression(node) {
183111
+ return node.kind === SyntaxKind.Identifier || isPropertyAccessEntityNameExpression(node);
183112
+ }
183106
183113
  });
183107
183114
 
183108
183115
  // ../../node_modules/@typescript-eslint/typescript-estree/dist/check-modifiers.js
@@ -183299,6 +183306,397 @@ var require_check_modifiers = __commonJS((exports) => {
183299
183306
  }
183300
183307
  });
183301
183308
 
183309
+ // ../../node_modules/@typescript-eslint/typescript-estree/dist/check-syntax-errors.js
183310
+ var require_check_syntax_errors = __commonJS((exports) => {
183311
+ var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
183312
+ if (k2 === undefined)
183313
+ k2 = k;
183314
+ var desc = Object.getOwnPropertyDescriptor(m, k);
183315
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
183316
+ desc = { enumerable: true, get: function() {
183317
+ return m[k];
183318
+ } };
183319
+ }
183320
+ Object.defineProperty(o, k2, desc);
183321
+ } : function(o, m, k, k2) {
183322
+ if (k2 === undefined)
183323
+ k2 = k;
183324
+ o[k2] = m[k];
183325
+ });
183326
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
183327
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
183328
+ } : function(o, v) {
183329
+ o["default"] = v;
183330
+ });
183331
+ var __importStar = exports && exports.__importStar || function() {
183332
+ var ownKeys = function(o) {
183333
+ ownKeys = Object.getOwnPropertyNames || function(o2) {
183334
+ var ar = [];
183335
+ for (var k in o2)
183336
+ if (Object.prototype.hasOwnProperty.call(o2, k))
183337
+ ar[ar.length] = k;
183338
+ return ar;
183339
+ };
183340
+ return ownKeys(o);
183341
+ };
183342
+ return function(mod) {
183343
+ if (mod && mod.__esModule)
183344
+ return mod;
183345
+ var result = {};
183346
+ if (mod != null) {
183347
+ for (var k = ownKeys(mod), i = 0;i < k.length; i++)
183348
+ if (k[i] !== "default")
183349
+ __createBinding(result, mod, k[i]);
183350
+ }
183351
+ __setModuleDefault(result, mod);
183352
+ return result;
183353
+ };
183354
+ }();
183355
+ Object.defineProperty(exports, "__esModule", { value: true });
183356
+ exports.checkSyntaxError = checkSyntaxError;
183357
+ var ts = __importStar(require_typescript());
183358
+ var check_modifiers_1 = require_check_modifiers();
183359
+ var node_utils_1 = require_node_utils();
183360
+ var SyntaxKind = ts.SyntaxKind;
183361
+ function checkSyntaxError(tsNode, parent, allowPattern) {
183362
+ (0, check_modifiers_1.checkModifiers)(tsNode);
183363
+ const node = tsNode;
183364
+ switch (node.kind) {
183365
+ case SyntaxKind.SwitchStatement:
183366
+ if (node.caseBlock.clauses.filter((switchCase) => switchCase.kind === SyntaxKind.DefaultClause).length > 1) {
183367
+ throw (0, node_utils_1.createError)(node, "A 'default' clause cannot appear more than once in a 'switch' statement.");
183368
+ }
183369
+ break;
183370
+ case SyntaxKind.ThrowStatement:
183371
+ if (node.expression.end === node.expression.pos) {
183372
+ throw (0, node_utils_1.createError)(node, "A throw statement must throw an expression.");
183373
+ }
183374
+ break;
183375
+ case SyntaxKind.CatchClause:
183376
+ if (node.variableDeclaration?.initializer) {
183377
+ throw (0, node_utils_1.createError)(node.variableDeclaration.initializer, "Catch clause variable cannot have an initializer.");
183378
+ }
183379
+ break;
183380
+ case SyntaxKind.FunctionDeclaration: {
183381
+ const isDeclare = (0, node_utils_1.hasModifier)(SyntaxKind.DeclareKeyword, node);
183382
+ const isAsync = (0, node_utils_1.hasModifier)(SyntaxKind.AsyncKeyword, node);
183383
+ const isGenerator = !!node.asteriskToken;
183384
+ if (isDeclare) {
183385
+ if (node.body) {
183386
+ throw (0, node_utils_1.createError)(node, "An implementation cannot be declared in ambient contexts.");
183387
+ } else if (isAsync) {
183388
+ throw (0, node_utils_1.createError)(node, "'async' modifier cannot be used in an ambient context.");
183389
+ } else if (isGenerator) {
183390
+ throw (0, node_utils_1.createError)(node, "Generators are not allowed in an ambient context.");
183391
+ }
183392
+ } else if (!node.body && isGenerator) {
183393
+ throw (0, node_utils_1.createError)(node, "A function signature cannot be declared as a generator.");
183394
+ }
183395
+ break;
183396
+ }
183397
+ case SyntaxKind.VariableDeclaration: {
183398
+ const hasExclamationToken = !!node.exclamationToken;
183399
+ if (hasExclamationToken) {
183400
+ if (node.initializer) {
183401
+ throw (0, node_utils_1.createError)(node, "Declarations with initializers cannot also have definite assignment assertions.");
183402
+ } else if (node.name.kind !== SyntaxKind.Identifier || !node.type) {
183403
+ throw (0, node_utils_1.createError)(node, "Declarations with definite assignment assertions must also have type annotations.");
183404
+ }
183405
+ }
183406
+ if (node.parent.kind === SyntaxKind.VariableDeclarationList) {
183407
+ const variableDeclarationList = node.parent;
183408
+ const kind = (0, node_utils_1.getDeclarationKind)(variableDeclarationList);
183409
+ if (kind === "using" || kind === "await using") {
183410
+ if (variableDeclarationList.parent.kind === SyntaxKind.ForInStatement) {
183411
+ throw (0, node_utils_1.createError)(variableDeclarationList, `The left-hand side of a 'for...in' statement cannot be a '${kind}' declaration.`);
183412
+ }
183413
+ if (variableDeclarationList.parent.kind === SyntaxKind.ForStatement || variableDeclarationList.parent.kind === SyntaxKind.VariableStatement) {
183414
+ if (!node.initializer) {
183415
+ throw (0, node_utils_1.createError)(node, `'${kind}' declarations must be initialized.`);
183416
+ }
183417
+ if (node.name.kind !== SyntaxKind.Identifier) {
183418
+ throw (0, node_utils_1.createError)(node.name, `'${kind}' declarations may not have binding patterns.`);
183419
+ }
183420
+ }
183421
+ }
183422
+ if (variableDeclarationList.parent.kind === SyntaxKind.VariableStatement) {
183423
+ const variableStatement = variableDeclarationList.parent;
183424
+ const hasDeclareKeyword = (0, node_utils_1.hasModifier)(SyntaxKind.DeclareKeyword, variableStatement);
183425
+ if ((hasDeclareKeyword || ["await using", "const", "using"].includes(kind)) && hasExclamationToken) {
183426
+ throw (0, node_utils_1.createError)(node, `A definite assignment assertion '!' is not permitted in this context.`);
183427
+ }
183428
+ if (hasDeclareKeyword && node.initializer && (["let", "var"].includes(kind) || node.type)) {
183429
+ throw (0, node_utils_1.createError)(node, `Initializers are not permitted in ambient contexts.`);
183430
+ }
183431
+ }
183432
+ }
183433
+ break;
183434
+ }
183435
+ case SyntaxKind.VariableStatement: {
183436
+ const declarations = node.declarationList.declarations;
183437
+ if (!declarations.length) {
183438
+ throw (0, node_utils_1.createError)(node, "A variable declaration list must have at least one variable declarator.");
183439
+ }
183440
+ break;
183441
+ }
183442
+ case SyntaxKind.PropertyAssignment: {
183443
+ const { exclamationToken, questionToken } = node;
183444
+ if (questionToken) {
183445
+ throw (0, node_utils_1.createError)(questionToken, "A property assignment cannot have a question token.");
183446
+ }
183447
+ if (exclamationToken) {
183448
+ throw (0, node_utils_1.createError)(exclamationToken, "A property assignment cannot have an exclamation token.");
183449
+ }
183450
+ break;
183451
+ }
183452
+ case SyntaxKind.ShorthandPropertyAssignment: {
183453
+ const { exclamationToken, modifiers, questionToken } = node;
183454
+ if (modifiers) {
183455
+ throw (0, node_utils_1.createError)(modifiers[0], "A shorthand property assignment cannot have modifiers.");
183456
+ }
183457
+ if (questionToken) {
183458
+ throw (0, node_utils_1.createError)(questionToken, "A shorthand property assignment cannot have a question token.");
183459
+ }
183460
+ if (exclamationToken) {
183461
+ throw (0, node_utils_1.createError)(exclamationToken, "A shorthand property assignment cannot have an exclamation token.");
183462
+ }
183463
+ break;
183464
+ }
183465
+ case SyntaxKind.PropertyDeclaration: {
183466
+ const isAbstract = (0, node_utils_1.hasModifier)(SyntaxKind.AbstractKeyword, node);
183467
+ if (isAbstract && node.initializer) {
183468
+ throw (0, node_utils_1.createError)(node.initializer, `Abstract property cannot have an initializer.`);
183469
+ }
183470
+ if (node.name.kind === SyntaxKind.StringLiteral && node.name.text === "constructor") {
183471
+ throw (0, node_utils_1.createError)(node.name, "Classes may not have a field named 'constructor'.");
183472
+ }
183473
+ break;
183474
+ }
183475
+ case SyntaxKind.TaggedTemplateExpression:
183476
+ if (node.tag.flags & ts.NodeFlags.OptionalChain) {
183477
+ throw (0, node_utils_1.createError)(node, "Tagged template expressions are not permitted in an optional chain.");
183478
+ }
183479
+ break;
183480
+ case SyntaxKind.BinaryExpression:
183481
+ if (node.operatorToken.kind !== SyntaxKind.InKeyword && node.left.kind === SyntaxKind.PrivateIdentifier) {
183482
+ throw (0, node_utils_1.createError)(node.left, "Private identifiers cannot appear on the right-hand-side of an 'in' expression.");
183483
+ } else if (node.right.kind === SyntaxKind.PrivateIdentifier) {
183484
+ throw (0, node_utils_1.createError)(node.right, "Private identifiers are only allowed on the left-hand-side of an 'in' expression.");
183485
+ }
183486
+ break;
183487
+ case SyntaxKind.MappedType:
183488
+ if (node.members && node.members.length > 0) {
183489
+ throw (0, node_utils_1.createError)(node.members[0], "A mapped type may not declare properties or methods.");
183490
+ }
183491
+ break;
183492
+ case SyntaxKind.PropertySignature: {
183493
+ const { initializer } = node;
183494
+ if (initializer) {
183495
+ throw (0, node_utils_1.createError)(initializer, "A property signature cannot have an initializer.");
183496
+ }
183497
+ break;
183498
+ }
183499
+ case SyntaxKind.FunctionType: {
183500
+ const { modifiers } = node;
183501
+ if (modifiers) {
183502
+ throw (0, node_utils_1.createError)(modifiers[0], "A function type cannot have modifiers.");
183503
+ }
183504
+ break;
183505
+ }
183506
+ case SyntaxKind.EnumMember: {
183507
+ const computed = node.name.kind === ts.SyntaxKind.ComputedPropertyName;
183508
+ if (computed) {
183509
+ throw (0, node_utils_1.createError)(node.name, "Computed property names are not allowed in enums.");
183510
+ }
183511
+ if (node.name.kind === SyntaxKind.NumericLiteral || node.name.kind === SyntaxKind.BigIntLiteral) {
183512
+ throw (0, node_utils_1.createError)(node.name, "An enum member cannot have a numeric name.");
183513
+ }
183514
+ break;
183515
+ }
183516
+ case SyntaxKind.ExternalModuleReference:
183517
+ if (node.expression.kind !== SyntaxKind.StringLiteral) {
183518
+ throw (0, node_utils_1.createError)(node.expression, "String literal expected.");
183519
+ }
183520
+ break;
183521
+ case SyntaxKind.PrefixUnaryExpression:
183522
+ case SyntaxKind.PostfixUnaryExpression: {
183523
+ const operator = (0, node_utils_1.getTextForTokenKind)(node.operator);
183524
+ if ((operator === "++" || operator === "--") && !(0, node_utils_1.isValidAssignmentTarget)(node.operand)) {
183525
+ throw (0, node_utils_1.createError)(node.operand, "Invalid left-hand side expression in unary operation");
183526
+ }
183527
+ break;
183528
+ }
183529
+ case SyntaxKind.ImportDeclaration: {
183530
+ const { importClause } = node;
183531
+ if (importClause?.isTypeOnly && importClause.name && importClause.namedBindings) {
183532
+ throw (0, node_utils_1.createError)(importClause, "A type-only import can specify a default import or named bindings, but not both.");
183533
+ }
183534
+ assertModuleSpecifier(node, false);
183535
+ break;
183536
+ }
183537
+ case SyntaxKind.ExportDeclaration:
183538
+ assertModuleSpecifier(node, node.exportClause?.kind === SyntaxKind.NamedExports);
183539
+ break;
183540
+ case SyntaxKind.ExportSpecifier: {
183541
+ const local = node.propertyName ?? node.name;
183542
+ if (local.kind === SyntaxKind.StringLiteral && parent.kind === SyntaxKind.ExportDeclaration && parent.moduleSpecifier?.kind !== SyntaxKind.StringLiteral) {
183543
+ throw (0, node_utils_1.createError)(local, "A string literal cannot be used as a local exported binding without `from`.");
183544
+ }
183545
+ break;
183546
+ }
183547
+ case SyntaxKind.CallExpression:
183548
+ if (node.expression.kind === SyntaxKind.ImportKeyword && node.arguments.length !== 1 && node.arguments.length !== 2) {
183549
+ throw (0, node_utils_1.createError)(node.arguments.length > 1 ? node.arguments[2] : node, "Dynamic import requires exactly one or two arguments.");
183550
+ }
183551
+ break;
183552
+ case SyntaxKind.ClassDeclaration:
183553
+ if (!node.name && (!(0, node_utils_1.hasModifier)(ts.SyntaxKind.ExportKeyword, node) || !(0, node_utils_1.hasModifier)(ts.SyntaxKind.DefaultKeyword, node))) {
183554
+ throw (0, node_utils_1.createError)(node, "A class declaration without the 'default' modifier must have a name.");
183555
+ }
183556
+ case SyntaxKind.ClassExpression: {
183557
+ const heritageClauses = node.heritageClauses ?? [];
183558
+ let seenExtendsClause = false;
183559
+ let seenImplementsClause = false;
183560
+ for (const heritageClause of heritageClauses) {
183561
+ const { token, types } = heritageClause;
183562
+ if (types.length === 0) {
183563
+ throw (0, node_utils_1.createError)(heritageClause, `'${ts.tokenToString(token)}' list cannot be empty.`);
183564
+ }
183565
+ if (token === SyntaxKind.ExtendsKeyword) {
183566
+ if (seenExtendsClause) {
183567
+ throw (0, node_utils_1.createError)(heritageClause, "'extends' clause already seen.");
183568
+ }
183569
+ if (seenImplementsClause) {
183570
+ throw (0, node_utils_1.createError)(heritageClause, "'extends' clause must precede 'implements' clause.");
183571
+ }
183572
+ if (types.length > 1) {
183573
+ throw (0, node_utils_1.createError)(types[1], "Classes can only extend a single class.");
183574
+ }
183575
+ seenExtendsClause = true;
183576
+ } else {
183577
+ if (seenImplementsClause) {
183578
+ throw (0, node_utils_1.createError)(heritageClause, "'implements' clause already seen.");
183579
+ }
183580
+ for (const heritageType of heritageClause.types) {
183581
+ if (!(0, node_utils_1.isEntityNameExpression)(heritageType.expression) || ts.isOptionalChain(heritageType.expression)) {
183582
+ throw (0, node_utils_1.createError)(heritageType, "A class can only implement an identifier/qualified-name with optional type arguments.");
183583
+ }
183584
+ }
183585
+ seenImplementsClause = true;
183586
+ }
183587
+ }
183588
+ break;
183589
+ }
183590
+ case SyntaxKind.InterfaceDeclaration: {
183591
+ const interfaceHeritageClauses = node.heritageClauses ?? [];
183592
+ let seenExtendsClause = false;
183593
+ for (const heritageClause of interfaceHeritageClauses) {
183594
+ const { token, types } = heritageClause;
183595
+ if (token === SyntaxKind.ImplementsKeyword) {
183596
+ throw (0, node_utils_1.createError)(heritageClause, "Interface declaration cannot have 'implements' clause.");
183597
+ }
183598
+ if (token !== SyntaxKind.ExtendsKeyword) {
183599
+ throw (0, node_utils_1.createError)(heritageClause, "Unexpected token.");
183600
+ }
183601
+ if (types.length === 0) {
183602
+ throw (0, node_utils_1.createError)(heritageClause, `'${ts.tokenToString(token)}' list cannot be empty.`);
183603
+ }
183604
+ if (seenExtendsClause) {
183605
+ throw (0, node_utils_1.createError)(heritageClause, "'extends' clause already seen.");
183606
+ }
183607
+ seenExtendsClause = true;
183608
+ for (const heritageType of heritageClause.types) {
183609
+ if (!(0, node_utils_1.isEntityNameExpression)(heritageType.expression) || ts.isOptionalChain(heritageType.expression)) {
183610
+ throw (0, node_utils_1.createError)(heritageType, "Interface declaration can only extend an identifier/qualified name with optional type arguments.");
183611
+ }
183612
+ }
183613
+ }
183614
+ break;
183615
+ }
183616
+ case SyntaxKind.GetAccessor:
183617
+ case SyntaxKind.SetAccessor:
183618
+ if (node.parent.kind === SyntaxKind.InterfaceDeclaration || node.parent.kind === SyntaxKind.TypeLiteral) {
183619
+ return;
183620
+ }
183621
+ case SyntaxKind.MethodDeclaration: {
183622
+ const isAbstract = (0, node_utils_1.hasModifier)(SyntaxKind.AbstractKeyword, node);
183623
+ if (isAbstract && node.body) {
183624
+ throw (0, node_utils_1.createError)(node.name, node.kind === SyntaxKind.GetAccessor || node.kind === SyntaxKind.SetAccessor ? "An abstract accessor cannot have an implementation." : `Method '${(0, node_utils_1.declarationNameToString)(node.name)}' cannot have an implementation because it is marked abstract.`);
183625
+ }
183626
+ break;
183627
+ }
183628
+ case SyntaxKind.ObjectLiteralExpression: {
183629
+ if (!allowPattern) {
183630
+ for (const property of node.properties) {
183631
+ if ((property.kind === SyntaxKind.GetAccessor || property.kind === SyntaxKind.SetAccessor || property.kind === SyntaxKind.MethodDeclaration) && !property.body) {
183632
+ throw (0, node_utils_1.createError)(property.end - 1, "'{' expected.", node.getSourceFile());
183633
+ }
183634
+ }
183635
+ }
183636
+ break;
183637
+ }
183638
+ case SyntaxKind.ImportEqualsDeclaration:
183639
+ if (node.isTypeOnly && node.moduleReference.kind !== SyntaxKind.ExternalModuleReference) {
183640
+ throw (0, node_utils_1.createError)(node, "An import alias cannot use 'import type'");
183641
+ }
183642
+ break;
183643
+ case SyntaxKind.ModuleDeclaration: {
183644
+ if (node.flags & ts.NodeFlags.GlobalAugmentation) {
183645
+ const { body } = node;
183646
+ if (body == null || body.kind === SyntaxKind.ModuleDeclaration) {
183647
+ throw (0, node_utils_1.createError)(node.body ?? node, "Expected a valid module body");
183648
+ }
183649
+ const { name } = node;
183650
+ if (name.kind !== ts.SyntaxKind.Identifier) {
183651
+ throw (0, node_utils_1.createError)(name, "global module augmentation must have an Identifier id");
183652
+ }
183653
+ return;
183654
+ }
183655
+ if (ts.isStringLiteral(node.name)) {
183656
+ return;
183657
+ }
183658
+ if (node.body == null) {
183659
+ throw (0, node_utils_1.createError)(node, "Expected a module body");
183660
+ }
183661
+ if (node.name.kind !== ts.SyntaxKind.Identifier) {
183662
+ throw (0, node_utils_1.createError)(node.name, "`namespace`s must have an Identifier id");
183663
+ }
183664
+ break;
183665
+ }
183666
+ case SyntaxKind.ForInStatement:
183667
+ case SyntaxKind.ForOfStatement: {
183668
+ checkForStatementDeclaration(node);
183669
+ break;
183670
+ }
183671
+ }
183672
+ }
183673
+ function checkForStatementDeclaration(node) {
183674
+ const { initializer, kind } = node;
183675
+ const loop = kind === SyntaxKind.ForInStatement ? "for...in" : "for...of";
183676
+ if (ts.isVariableDeclarationList(initializer)) {
183677
+ if (initializer.declarations.length !== 1) {
183678
+ throw (0, node_utils_1.createError)(initializer, `Only a single variable declaration is allowed in a '${loop}' statement.`);
183679
+ }
183680
+ const declaration = initializer.declarations[0];
183681
+ if (declaration.initializer) {
183682
+ throw (0, node_utils_1.createError)(declaration, `The variable declaration of a '${loop}' statement cannot have an initializer.`);
183683
+ } else if (declaration.type) {
183684
+ throw (0, node_utils_1.createError)(declaration, `The variable declaration of a '${loop}' statement cannot have a type annotation.`);
183685
+ }
183686
+ } else if (!(0, node_utils_1.isValidAssignmentTarget)(initializer) && initializer.kind !== SyntaxKind.ObjectLiteralExpression && initializer.kind !== SyntaxKind.ArrayLiteralExpression) {
183687
+ throw (0, node_utils_1.createError)(initializer, `The left-hand side of a '${loop}' statement must be a variable or a property access.`);
183688
+ }
183689
+ }
183690
+ function assertModuleSpecifier(node, allowNull) {
183691
+ if (!allowNull && node.moduleSpecifier == null) {
183692
+ throw (0, node_utils_1.createError)(node, "Module specifier must be a string literal.");
183693
+ }
183694
+ if (node.moduleSpecifier && node.moduleSpecifier.kind !== SyntaxKind.StringLiteral) {
183695
+ throw (0, node_utils_1.createError)(node.moduleSpecifier, "Module specifier must be a string literal.");
183696
+ }
183697
+ }
183698
+ });
183699
+
183302
183700
  // ../../node_modules/@typescript-eslint/typescript-estree/dist/convert.js
183303
183701
  var require_convert = __commonJS((exports) => {
183304
183702
  var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
@@ -183349,7 +183747,7 @@ var require_convert = __commonJS((exports) => {
183349
183747
  exports.Converter = undefined;
183350
183748
  exports.convertError = convertError;
183351
183749
  var ts = __importStar(require_typescript());
183352
- var check_modifiers_1 = require_check_modifiers();
183750
+ var check_syntax_errors_1 = require_check_syntax_errors();
183353
183751
  var getModifiers_1 = require_getModifiers();
183354
183752
  var node_utils_1 = require_node_utils();
183355
183753
  var ts_estree_1 = require_ts_estree2();
@@ -183357,12 +183755,6 @@ var require_convert = __commonJS((exports) => {
183357
183755
  function convertError(error) {
183358
183756
  return (0, node_utils_1.createError)(error.start, "message" in error && error.message || error.messageText, error.file);
183359
183757
  }
183360
- function isPropertyAccessEntityNameExpression(node) {
183361
- return ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.name) && isEntityNameExpression(node.expression);
183362
- }
183363
- function isEntityNameExpression(node) {
183364
- return node.kind === SyntaxKind.Identifier || isPropertyAccessEntityNameExpression(node);
183365
- }
183366
183758
 
183367
183759
  class Converter {
183368
183760
  allowPattern = false;
@@ -183374,30 +183766,11 @@ var require_convert = __commonJS((exports) => {
183374
183766
  this.ast = ast;
183375
183767
  this.options = { ...options };
183376
183768
  }
183377
- #checkForStatementDeclaration(initializer, kind) {
183378
- const loop = kind === ts.SyntaxKind.ForInStatement ? "for...in" : "for...of";
183379
- if (ts.isVariableDeclarationList(initializer)) {
183380
- if (initializer.declarations.length !== 1) {
183381
- this.#throwError(initializer, `Only a single variable declaration is allowed in a '${loop}' statement.`);
183382
- }
183383
- const declaration = initializer.declarations[0];
183384
- if (declaration.initializer) {
183385
- this.#throwError(declaration, `The variable declaration of a '${loop}' statement cannot have an initializer.`);
183386
- } else if (declaration.type) {
183387
- this.#throwError(declaration, `The variable declaration of a '${loop}' statement cannot have a type annotation.`);
183388
- }
183389
- if (kind === ts.SyntaxKind.ForInStatement && initializer.flags & ts.NodeFlags.Using) {
183390
- this.#throwError(initializer, "The left-hand side of a 'for...in' statement cannot be a 'using' declaration.");
183391
- }
183392
- } else if (!(0, node_utils_1.isValidAssignmentTarget)(initializer) && initializer.kind !== ts.SyntaxKind.ObjectLiteralExpression && initializer.kind !== ts.SyntaxKind.ArrayLiteralExpression) {
183393
- this.#throwError(initializer, `The left-hand side of a '${loop}' statement must be a variable or a property access.`);
183394
- }
183395
- }
183396
- #checkModifiers(node) {
183769
+ #checkSyntaxError(node, parent) {
183397
183770
  if (this.options.allowInvalidAST) {
183398
183771
  return;
183399
183772
  }
183400
- (0, check_modifiers_1.checkModifiers)(node);
183773
+ (0, check_syntax_errors_1.checkSyntaxError)(node, parent, this.allowPattern);
183401
183774
  }
183402
183775
  #throwError(node, message) {
183403
183776
  if (this.options.allowInvalidAST) {
@@ -183411,7 +183784,7 @@ var require_convert = __commonJS((exports) => {
183411
183784
  configurable: true,
183412
183785
  get: this.options.suppressDeprecatedPropertyWarnings ? () => node[valueKey] : () => {
183413
183786
  if (!warned) {
183414
- process.emitWarning(`The '${aliasKey}' property is deprecated on ${node.type} nodes. Use '${valueKey}' instead. See https://typescript-eslint.io/troubleshooting/faqs/general#the-key-property-is-deprecated-on-type-nodes-use-key-instead-warnings.`, "DeprecationWarning");
183787
+ process.emitWarning(`The '${aliasKey}' property is deprecated on ${node.type} nodes. Use '${valueKey}' instead. See https://tseslint.com/key-property-deprecated.`, "DeprecationWarning");
183415
183788
  warned = true;
183416
183789
  }
183417
183790
  return node[valueKey];
@@ -183436,7 +183809,7 @@ var require_convert = __commonJS((exports) => {
183436
183809
  if (preferredKey) {
183437
183810
  message += ` Use ${preferredKey} instead.`;
183438
183811
  }
183439
- message += " See https://typescript-eslint.io/troubleshooting/faqs/general#the-key-property-is-deprecated-on-type-nodes-use-key-instead-warnings.";
183812
+ message += " See https://tseslint.com/key-property-deprecated.";
183440
183813
  process.emitWarning(message, "DeprecationWarning");
183441
183814
  warned = true;
183442
183815
  }
@@ -183452,14 +183825,6 @@ var require_convert = __commonJS((exports) => {
183452
183825
  });
183453
183826
  return node;
183454
183827
  }
183455
- assertModuleSpecifier(node, allowNull) {
183456
- if (!allowNull && node.moduleSpecifier == null) {
183457
- this.#throwError(node, "Module specifier must be a string literal.");
183458
- }
183459
- if (node.moduleSpecifier && node.moduleSpecifier?.kind !== SyntaxKind.StringLiteral) {
183460
- this.#throwError(node.moduleSpecifier, "Module specifier must be a string literal.");
183461
- }
183462
- }
183463
183828
  convertBindingNameWithTypeAnnotation(name, tsType, parent) {
183464
183829
  const id = this.convertPattern(name);
183465
183830
  if (tsType) {
@@ -183533,7 +183898,11 @@ var require_convert = __commonJS((exports) => {
183533
183898
  typeAnnotation: this.convertChild(child)
183534
183899
  };
183535
183900
  }
183536
- convertTypeArgumentsToTypeParameterInstantiation(typeArguments, node) {
183901
+ convertTypeArguments(node) {
183902
+ const { typeArguments } = node;
183903
+ if (!typeArguments) {
183904
+ return;
183905
+ }
183537
183906
  const greaterThanToken = (0, node_utils_1.findNextToken)(typeArguments, this.ast, this.ast);
183538
183907
  const range = [typeArguments.pos - 1, greaterThanToken.end];
183539
183908
  if (typeArguments.length === 0) {
@@ -183545,7 +183914,11 @@ var require_convert = __commonJS((exports) => {
183545
183914
  params: this.convertChildren(typeArguments)
183546
183915
  });
183547
183916
  }
183548
- convertTSTypeParametersToTypeParametersDeclaration(typeParameters) {
183917
+ convertTypeParameters(node) {
183918
+ const { typeParameters } = node;
183919
+ if (!typeParameters) {
183920
+ return;
183921
+ }
183549
183922
  const greaterThanToken = (0, node_utils_1.findNextToken)(typeParameters, this.ast, this.ast);
183550
183923
  const range = [
183551
183924
  typeParameters.pos - 1,
@@ -183575,12 +183948,13 @@ var require_convert = __commonJS((exports) => {
183575
183948
  if (!node) {
183576
183949
  return null;
183577
183950
  }
183578
- this.#checkModifiers(node);
183579
183951
  const pattern = this.allowPattern;
183580
183952
  if (allowPattern != null) {
183581
183953
  this.allowPattern = allowPattern;
183582
183954
  }
183583
- const result = this.convertNode(node, parent ?? node.parent);
183955
+ const parentNode = parent ?? node.parent;
183956
+ this.#checkSyntaxError(node, parentNode);
183957
+ const result = this.convertNode(node, parentNode);
183584
183958
  this.registerTSNodeInNodeMap(node, result);
183585
183959
  this.allowPattern = pattern;
183586
183960
  return result;
@@ -183678,7 +184052,7 @@ var require_convert = __commonJS((exports) => {
183678
184052
  readonly: (0, node_utils_1.hasModifier)(SyntaxKind.ReadonlyKeyword, node),
183679
184053
  returnType: node.type && this.convertTypeAnnotation(node.type, node),
183680
184054
  static: (0, node_utils_1.hasModifier)(SyntaxKind.StaticKeyword, node),
183681
- typeParameters: node.typeParameters && this.convertTSTypeParametersToTypeParametersDeclaration(node.typeParameters)
184055
+ typeParameters: this.convertTypeParameters(node)
183682
184056
  });
183683
184057
  }
183684
184058
  fixParentLocation(result, childRange) {
@@ -183764,9 +184138,6 @@ var require_convert = __commonJS((exports) => {
183764
184138
  test: this.convertChild(node.expression)
183765
184139
  });
183766
184140
  case SyntaxKind.SwitchStatement:
183767
- if (node.caseBlock.clauses.filter((switchCase) => switchCase.kind === SyntaxKind.DefaultClause).length > 1) {
183768
- this.#throwError(node, "A 'default' clause cannot appear more than once in a 'switch' statement.");
183769
- }
183770
184141
  return this.createNode(node, {
183771
184142
  type: ts_estree_1.AST_NODE_TYPES.SwitchStatement,
183772
184143
  cases: this.convertChildren(node.caseBlock.clauses),
@@ -183780,9 +184151,6 @@ var require_convert = __commonJS((exports) => {
183780
184151
  test: node.kind === SyntaxKind.CaseClause ? this.convertChild(node.expression) : null
183781
184152
  });
183782
184153
  case SyntaxKind.ThrowStatement:
183783
- if (node.expression.end === node.expression.pos) {
183784
- this.#throwError(node, "A throw statement must throw an expression.");
183785
- }
183786
184154
  return this.createNode(node, {
183787
184155
  type: ts_estree_1.AST_NODE_TYPES.ThrowStatement,
183788
184156
  argument: this.convertChild(node.expression)
@@ -183795,9 +184163,6 @@ var require_convert = __commonJS((exports) => {
183795
184163
  handler: this.convertChild(node.catchClause)
183796
184164
  });
183797
184165
  case SyntaxKind.CatchClause:
183798
- if (node.variableDeclaration?.initializer) {
183799
- this.#throwError(node.variableDeclaration.initializer, "Catch clause variable cannot have an initializer.");
183800
- }
183801
184166
  return this.createNode(node, {
183802
184167
  type: ts_estree_1.AST_NODE_TYPES.CatchClause,
183803
184168
  body: this.convertChild(node.block),
@@ -183824,7 +184189,6 @@ var require_convert = __commonJS((exports) => {
183824
184189
  update: this.convertChild(node.incrementor)
183825
184190
  });
183826
184191
  case SyntaxKind.ForInStatement:
183827
- this.#checkForStatementDeclaration(node.initializer, node.kind);
183828
184192
  return this.createNode(node, {
183829
184193
  type: ts_estree_1.AST_NODE_TYPES.ForInStatement,
183830
184194
  body: this.convertChild(node.statement),
@@ -183832,7 +184196,6 @@ var require_convert = __commonJS((exports) => {
183832
184196
  right: this.convertChild(node.expression)
183833
184197
  });
183834
184198
  case SyntaxKind.ForOfStatement: {
183835
- this.#checkForStatementDeclaration(node.initializer, node.kind);
183836
184199
  return this.createNode(node, {
183837
184200
  type: ts_estree_1.AST_NODE_TYPES.ForOfStatement,
183838
184201
  await: node.awaitModifier?.kind === SyntaxKind.AwaitKeyword,
@@ -183845,17 +184208,6 @@ var require_convert = __commonJS((exports) => {
183845
184208
  const isDeclare = (0, node_utils_1.hasModifier)(SyntaxKind.DeclareKeyword, node);
183846
184209
  const isAsync = (0, node_utils_1.hasModifier)(SyntaxKind.AsyncKeyword, node);
183847
184210
  const isGenerator = !!node.asteriskToken;
183848
- if (isDeclare) {
183849
- if (node.body) {
183850
- this.#throwError(node, "An implementation cannot be declared in ambient contexts.");
183851
- } else if (isAsync) {
183852
- this.#throwError(node, "'async' modifier cannot be used in an ambient context.");
183853
- } else if (isGenerator) {
183854
- this.#throwError(node, "Generators are not allowed in an ambient context.");
183855
- }
183856
- } else if (!node.body && isGenerator) {
183857
- this.#throwError(node, "A function signature cannot be declared as a generator.");
183858
- }
183859
184211
  const result = this.createNode(node, {
183860
184212
  type: !node.body ? ts_estree_1.AST_NODE_TYPES.TSDeclareFunction : ts_estree_1.AST_NODE_TYPES.FunctionDeclaration,
183861
184213
  async: isAsync,
@@ -183866,49 +184218,12 @@ var require_convert = __commonJS((exports) => {
183866
184218
  id: this.convertChild(node.name),
183867
184219
  params: this.convertParameters(node.parameters),
183868
184220
  returnType: node.type && this.convertTypeAnnotation(node.type, node),
183869
- typeParameters: node.typeParameters && this.convertTSTypeParametersToTypeParametersDeclaration(node.typeParameters)
184221
+ typeParameters: this.convertTypeParameters(node)
183870
184222
  });
183871
184223
  return this.fixExports(node, result);
183872
184224
  }
183873
184225
  case SyntaxKind.VariableDeclaration: {
183874
184226
  const hasExclamationToken = !!node.exclamationToken;
183875
- if (hasExclamationToken) {
183876
- if (node.initializer) {
183877
- this.#throwError(node, "Declarations with initializers cannot also have definite assignment assertions.");
183878
- } else if (node.name.kind !== SyntaxKind.Identifier || !node.type) {
183879
- this.#throwError(node, "Declarations with definite assignment assertions must also have type annotations.");
183880
- }
183881
- }
183882
- if (node.parent.kind === SyntaxKind.VariableDeclarationList) {
183883
- const variableDeclarationList = node.parent;
183884
- const kind = (0, node_utils_1.getDeclarationKind)(variableDeclarationList);
183885
- if ((variableDeclarationList.parent.kind === SyntaxKind.ForInStatement || variableDeclarationList.parent.kind === SyntaxKind.ForStatement) && (kind === "using" || kind === "await using")) {
183886
- if (!node.initializer) {
183887
- this.#throwError(node, `'${kind}' declarations may not be initialized in for statement.`);
183888
- }
183889
- if (node.name.kind !== SyntaxKind.Identifier) {
183890
- this.#throwError(node.name, `'${kind}' declarations may not have binding patterns.`);
183891
- }
183892
- }
183893
- if (variableDeclarationList.parent.kind === SyntaxKind.VariableStatement) {
183894
- const variableStatement = variableDeclarationList.parent;
183895
- if (kind === "using" || kind === "await using") {
183896
- if (!node.initializer) {
183897
- this.#throwError(node, `'${kind}' declarations must be initialized.`);
183898
- }
183899
- if (node.name.kind !== SyntaxKind.Identifier) {
183900
- this.#throwError(node.name, `'${kind}' declarations may not have binding patterns.`);
183901
- }
183902
- }
183903
- const hasDeclareKeyword = (0, node_utils_1.hasModifier)(SyntaxKind.DeclareKeyword, variableStatement);
183904
- if ((hasDeclareKeyword || ["await using", "const", "using"].includes(kind)) && hasExclamationToken) {
183905
- this.#throwError(node, `A definite assignment assertion '!' is not permitted in this context.`);
183906
- }
183907
- if (hasDeclareKeyword && node.initializer && (["let", "var"].includes(kind) || node.type)) {
183908
- this.#throwError(node, `Initializers are not permitted in ambient contexts.`);
183909
- }
183910
- }
183911
- }
183912
184227
  const init = this.convertChild(node.initializer);
183913
184228
  const id = this.convertBindingNameWithTypeAnnotation(node.name, node.type, node);
183914
184229
  return this.createNode(node, {
@@ -183920,9 +184235,6 @@ var require_convert = __commonJS((exports) => {
183920
184235
  }
183921
184236
  case SyntaxKind.VariableStatement: {
183922
184237
  const declarations = node.declarationList.declarations;
183923
- if (!declarations.length) {
183924
- this.#throwError(node, "A variable declaration list must have at least one variable declarator.");
183925
- }
183926
184238
  const result = this.createNode(node, {
183927
184239
  type: ts_estree_1.AST_NODE_TYPES.VariableDeclaration,
183928
184240
  declarations: this.convertChildren(declarations),
@@ -183974,26 +184286,12 @@ var require_convert = __commonJS((exports) => {
183974
184286
  typeAnnotation: undefined
183975
184287
  });
183976
184288
  }
183977
- const properties = [];
183978
- for (const property of node.properties) {
183979
- if ((property.kind === SyntaxKind.GetAccessor || property.kind === SyntaxKind.SetAccessor || property.kind === SyntaxKind.MethodDeclaration) && !property.body) {
183980
- this.#throwError(property.end - 1, "'{' expected.");
183981
- }
183982
- properties.push(this.convertChild(property));
183983
- }
183984
184289
  return this.createNode(node, {
183985
184290
  type: ts_estree_1.AST_NODE_TYPES.ObjectExpression,
183986
- properties
184291
+ properties: this.convertChildren(node.properties)
183987
184292
  });
183988
184293
  }
183989
184294
  case SyntaxKind.PropertyAssignment: {
183990
- const { exclamationToken, questionToken } = node;
183991
- if (questionToken) {
183992
- this.#throwError(questionToken, "A property assignment cannot have a question token.");
183993
- }
183994
- if (exclamationToken) {
183995
- this.#throwError(exclamationToken, "A property assignment cannot have an exclamation token.");
183996
- }
183997
184295
  return this.createNode(node, {
183998
184296
  type: ts_estree_1.AST_NODE_TYPES.Property,
183999
184297
  computed: (0, node_utils_1.isComputedProperty)(node.name),
@@ -184006,16 +184304,6 @@ var require_convert = __commonJS((exports) => {
184006
184304
  });
184007
184305
  }
184008
184306
  case SyntaxKind.ShorthandPropertyAssignment: {
184009
- const { exclamationToken, modifiers, questionToken } = node;
184010
- if (modifiers) {
184011
- this.#throwError(modifiers[0], "A shorthand property assignment cannot have modifiers.");
184012
- }
184013
- if (questionToken) {
184014
- this.#throwError(questionToken, "A shorthand property assignment cannot have a question token.");
184015
- }
184016
- if (exclamationToken) {
184017
- this.#throwError(exclamationToken, "A shorthand property assignment cannot have an exclamation token.");
184018
- }
184019
184307
  if (node.objectAssignmentInitializer) {
184020
184308
  return this.createNode(node, {
184021
184309
  type: ts_estree_1.AST_NODE_TYPES.Property,
@@ -184050,12 +184338,6 @@ var require_convert = __commonJS((exports) => {
184050
184338
  return this.convertChild(node.expression);
184051
184339
  case SyntaxKind.PropertyDeclaration: {
184052
184340
  const isAbstract = (0, node_utils_1.hasModifier)(SyntaxKind.AbstractKeyword, node);
184053
- if (isAbstract && node.initializer) {
184054
- this.#throwError(node.initializer, `Abstract property cannot have an initializer.`);
184055
- }
184056
- if (node.name.kind === SyntaxKind.StringLiteral && node.name.text === "constructor") {
184057
- this.#throwError(node.name, "Classes may not have a field named 'constructor'.");
184058
- }
184059
184341
  const isAccessor = (0, node_utils_1.hasModifier)(SyntaxKind.AccessorKeyword, node);
184060
184342
  const type = (() => {
184061
184343
  if (isAccessor) {
@@ -184093,10 +184375,6 @@ var require_convert = __commonJS((exports) => {
184093
184375
  }
184094
184376
  }
184095
184377
  case SyntaxKind.MethodDeclaration: {
184096
- const isAbstract = (0, node_utils_1.hasModifier)(SyntaxKind.AbstractKeyword, node);
184097
- if (isAbstract && node.body) {
184098
- this.#throwError(node.name, node.kind === SyntaxKind.GetAccessor || node.kind === SyntaxKind.SetAccessor ? "An abstract accessor cannot have an implementation." : `Method '${(0, node_utils_1.declarationNameToString)(node.name, this.ast)}' cannot have an implementation because it is marked abstract.`);
184099
- }
184100
184378
  const method = this.createNode(node, {
184101
184379
  type: !node.body ? ts_estree_1.AST_NODE_TYPES.TSEmptyBodyFunctionExpression : ts_estree_1.AST_NODE_TYPES.FunctionExpression,
184102
184380
  range: [node.parameters.pos - 1, node.end],
@@ -184108,7 +184386,7 @@ var require_convert = __commonJS((exports) => {
184108
184386
  id: null,
184109
184387
  params: [],
184110
184388
  returnType: node.type && this.convertTypeAnnotation(node.type, node),
184111
- typeParameters: node.typeParameters && this.convertTSTypeParametersToTypeParametersDeclaration(node.typeParameters)
184389
+ typeParameters: this.convertTypeParameters(node)
184112
184390
  });
184113
184391
  if (method.typeParameters) {
184114
184392
  this.fixParentLocation(method, method.typeParameters.range);
@@ -184127,6 +184405,7 @@ var require_convert = __commonJS((exports) => {
184127
184405
  value: method
184128
184406
  });
184129
184407
  } else {
184408
+ const isAbstract = (0, node_utils_1.hasModifier)(SyntaxKind.AbstractKeyword, node);
184130
184409
  method.params = this.convertParameters(node.parameters);
184131
184410
  const methodDefinitionType = isAbstract ? ts_estree_1.AST_NODE_TYPES.TSAbstractMethodDefinition : ts_estree_1.AST_NODE_TYPES.MethodDefinition;
184132
184411
  result = this.createNode(node, {
@@ -184165,7 +184444,7 @@ var require_convert = __commonJS((exports) => {
184165
184444
  id: null,
184166
184445
  params: this.convertParameters(node.parameters),
184167
184446
  returnType: node.type && this.convertTypeAnnotation(node.type, node),
184168
- typeParameters: node.typeParameters && this.convertTSTypeParametersToTypeParametersDeclaration(node.typeParameters)
184447
+ typeParameters: this.convertTypeParameters(node)
184169
184448
  });
184170
184449
  if (constructor.typeParameters) {
184171
184450
  this.fixParentLocation(constructor, constructor.typeParameters.range);
@@ -184210,7 +184489,7 @@ var require_convert = __commonJS((exports) => {
184210
184489
  id: this.convertChild(node.name),
184211
184490
  params: this.convertParameters(node.parameters),
184212
184491
  returnType: node.type && this.convertTypeAnnotation(node.type, node),
184213
- typeParameters: node.typeParameters && this.convertTSTypeParametersToTypeParametersDeclaration(node.typeParameters)
184492
+ typeParameters: this.convertTypeParameters(node)
184214
184493
  });
184215
184494
  }
184216
184495
  case SyntaxKind.SuperKeyword:
@@ -184305,7 +184584,7 @@ var require_convert = __commonJS((exports) => {
184305
184584
  id: null,
184306
184585
  params: this.convertParameters(node.parameters),
184307
184586
  returnType: node.type && this.convertTypeAnnotation(node.type, node),
184308
- typeParameters: node.typeParameters && this.convertTSTypeParametersToTypeParametersDeclaration(node.typeParameters)
184587
+ typeParameters: this.convertTypeParameters(node)
184309
184588
  });
184310
184589
  }
184311
184590
  case SyntaxKind.YieldExpression:
@@ -184347,14 +184626,11 @@ var require_convert = __commonJS((exports) => {
184347
184626
  return result;
184348
184627
  }
184349
184628
  case SyntaxKind.TaggedTemplateExpression: {
184350
- if (node.tag.flags & ts.NodeFlags.OptionalChain) {
184351
- this.#throwError(node, "Tagged template expressions are not permitted in an optional chain.");
184352
- }
184353
184629
  return this.createNode(node, {
184354
184630
  type: ts_estree_1.AST_NODE_TYPES.TaggedTemplateExpression,
184355
184631
  quasi: this.convertChild(node.template),
184356
184632
  tag: this.convertChild(node.tag),
184357
- typeArguments: node.typeArguments && this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node)
184633
+ typeArguments: this.convertTypeArguments(node)
184358
184634
  });
184359
184635
  }
184360
184636
  case SyntaxKind.TemplateHead:
@@ -184444,37 +184720,10 @@ var require_convert = __commonJS((exports) => {
184444
184720
  return result;
184445
184721
  }
184446
184722
  case SyntaxKind.ClassDeclaration:
184447
- if (!node.name && (!(0, node_utils_1.hasModifier)(ts.SyntaxKind.ExportKeyword, node) || !(0, node_utils_1.hasModifier)(ts.SyntaxKind.DefaultKeyword, node))) {
184448
- this.#throwError(node, "A class declaration without the 'default' modifier must have a name.");
184449
- }
184450
184723
  case SyntaxKind.ClassExpression: {
184451
- const heritageClauses = node.heritageClauses ?? [];
184452
184724
  const classNodeType = node.kind === SyntaxKind.ClassDeclaration ? ts_estree_1.AST_NODE_TYPES.ClassDeclaration : ts_estree_1.AST_NODE_TYPES.ClassExpression;
184453
- let extendsClause;
184454
- let implementsClause;
184455
- for (const heritageClause of heritageClauses) {
184456
- const { token, types } = heritageClause;
184457
- if (types.length === 0) {
184458
- this.#throwError(heritageClause, `'${ts.tokenToString(token)}' list cannot be empty.`);
184459
- }
184460
- if (token === SyntaxKind.ExtendsKeyword) {
184461
- if (extendsClause) {
184462
- this.#throwError(heritageClause, "'extends' clause already seen.");
184463
- }
184464
- if (implementsClause) {
184465
- this.#throwError(heritageClause, "'extends' clause must precede 'implements' clause.");
184466
- }
184467
- if (types.length > 1) {
184468
- this.#throwError(types[1], "Classes can only extend a single class.");
184469
- }
184470
- extendsClause ??= heritageClause;
184471
- } else if (token === SyntaxKind.ImplementsKeyword) {
184472
- if (implementsClause) {
184473
- this.#throwError(heritageClause, "'implements' clause already seen.");
184474
- }
184475
- implementsClause ??= heritageClause;
184476
- }
184477
- }
184725
+ const extendsClause = node.heritageClauses?.find((heritageClause) => heritageClause.token === SyntaxKind.ExtendsKeyword);
184726
+ const implementsClause = node.heritageClauses?.find((heritageClause) => heritageClause.token === SyntaxKind.ImplementsKeyword);
184478
184727
  const result = this.createNode(node, {
184479
184728
  type: classNodeType,
184480
184729
  abstract: (0, node_utils_1.hasModifier)(SyntaxKind.AbstractKeyword, node),
@@ -184489,10 +184738,10 @@ var require_convert = __commonJS((exports) => {
184489
184738
  implements: this.convertChildren(implementsClause?.types ?? []),
184490
184739
  superClass: extendsClause?.types[0] ? this.convertChild(extendsClause.types[0].expression) : null,
184491
184740
  superTypeArguments: undefined,
184492
- typeParameters: node.typeParameters && this.convertTSTypeParametersToTypeParametersDeclaration(node.typeParameters)
184741
+ typeParameters: this.convertTypeParameters(node)
184493
184742
  });
184494
184743
  if (extendsClause?.types[0]?.typeArguments) {
184495
- result.superTypeArguments = this.convertTypeArgumentsToTypeParameterInstantiation(extendsClause.types[0].typeArguments, extendsClause.types[0]);
184744
+ result.superTypeArguments = this.convertTypeArguments(extendsClause.types[0]);
184496
184745
  }
184497
184746
  return this.fixExports(node, result);
184498
184747
  }
@@ -184502,7 +184751,6 @@ var require_convert = __commonJS((exports) => {
184502
184751
  body: this.convertBodyExpressions(node.statements, node)
184503
184752
  });
184504
184753
  case SyntaxKind.ImportDeclaration: {
184505
- this.assertModuleSpecifier(node, false);
184506
184754
  const result = this.createNode(node, this.#withDeprecatedAliasGetter({
184507
184755
  type: ts_estree_1.AST_NODE_TYPES.ImportDeclaration,
184508
184756
  attributes: this.convertImportAttributes(node),
@@ -184552,7 +184800,6 @@ var require_convert = __commonJS((exports) => {
184552
184800
  }
184553
184801
  case SyntaxKind.ExportDeclaration: {
184554
184802
  if (node.exportClause?.kind === SyntaxKind.NamedExports) {
184555
- this.assertModuleSpecifier(node, true);
184556
184803
  return this.createNode(node, this.#withDeprecatedAliasGetter({
184557
184804
  type: ts_estree_1.AST_NODE_TYPES.ExportNamedDeclaration,
184558
184805
  attributes: this.convertImportAttributes(node),
@@ -184562,7 +184809,6 @@ var require_convert = __commonJS((exports) => {
184562
184809
  specifiers: this.convertChildren(node.exportClause.elements, node)
184563
184810
  }, "assertions", "attributes", true));
184564
184811
  }
184565
- this.assertModuleSpecifier(node, false);
184566
184812
  return this.createNode(node, this.#withDeprecatedAliasGetter({
184567
184813
  type: ts_estree_1.AST_NODE_TYPES.ExportAllDeclaration,
184568
184814
  attributes: this.convertImportAttributes(node),
@@ -184573,9 +184819,6 @@ var require_convert = __commonJS((exports) => {
184573
184819
  }
184574
184820
  case SyntaxKind.ExportSpecifier: {
184575
184821
  const local = node.propertyName ?? node.name;
184576
- if (local.kind === SyntaxKind.StringLiteral && parent.kind === SyntaxKind.ExportDeclaration && parent.moduleSpecifier?.kind !== SyntaxKind.StringLiteral) {
184577
- this.#throwError(local, "A string literal cannot be used as a local exported binding without `from`.");
184578
- }
184579
184822
  return this.createNode(node, {
184580
184823
  type: ts_estree_1.AST_NODE_TYPES.ExportSpecifier,
184581
184824
  exported: this.convertChild(node.name),
@@ -184599,9 +184842,6 @@ var require_convert = __commonJS((exports) => {
184599
184842
  case SyntaxKind.PostfixUnaryExpression: {
184600
184843
  const operator = (0, node_utils_1.getTextForTokenKind)(node.operator);
184601
184844
  if (operator === "++" || operator === "--") {
184602
- if (!(0, node_utils_1.isValidAssignmentTarget)(node.operand)) {
184603
- this.#throwError(node.operand, "Invalid left-hand side expression in unary operation");
184604
- }
184605
184845
  return this.createNode(node, {
184606
184846
  type: ts_estree_1.AST_NODE_TYPES.UpdateExpression,
184607
184847
  argument: this.convertChild(node.operand),
@@ -184644,11 +184884,6 @@ var require_convert = __commonJS((exports) => {
184644
184884
  typeAnnotation: this.convertChild(node.type)
184645
184885
  });
184646
184886
  case SyntaxKind.BinaryExpression: {
184647
- if (node.operatorToken.kind !== SyntaxKind.InKeyword && node.left.kind === SyntaxKind.PrivateIdentifier) {
184648
- this.#throwError(node.left, "Private identifiers cannot appear on the right-hand-side of an 'in' expression.");
184649
- } else if (node.right.kind === SyntaxKind.PrivateIdentifier) {
184650
- this.#throwError(node.right, "Private identifiers are only allowed on the left-hand-side of an 'in' expression.");
184651
- }
184652
184887
  if ((0, node_utils_1.isComma)(node.operatorToken)) {
184653
184888
  const result = this.createNode(node, {
184654
184889
  type: ts_estree_1.AST_NODE_TYPES.SequenceExpression,
@@ -184708,9 +184943,6 @@ var require_convert = __commonJS((exports) => {
184708
184943
  }
184709
184944
  case SyntaxKind.CallExpression: {
184710
184945
  if (node.expression.kind === SyntaxKind.ImportKeyword) {
184711
- if (node.arguments.length !== 1 && node.arguments.length !== 2) {
184712
- this.#throwError(node.arguments[2] ?? node, "Dynamic import requires exactly one or two arguments.");
184713
- }
184714
184946
  return this.createNode(node, this.#withDeprecatedAliasGetter({
184715
184947
  type: ts_estree_1.AST_NODE_TYPES.ImportExpression,
184716
184948
  options: node.arguments[1] ? this.convertChild(node.arguments[1]) : null,
@@ -184719,7 +184951,7 @@ var require_convert = __commonJS((exports) => {
184719
184951
  }
184720
184952
  const callee = this.convertChild(node.expression);
184721
184953
  const args = this.convertChildren(node.arguments);
184722
- const typeArguments = node.typeArguments && this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node);
184954
+ const typeArguments = this.convertTypeArguments(node);
184723
184955
  const result = this.createNode(node, {
184724
184956
  type: ts_estree_1.AST_NODE_TYPES.CallExpression,
184725
184957
  arguments: args,
@@ -184730,7 +184962,7 @@ var require_convert = __commonJS((exports) => {
184730
184962
  return this.convertChainExpression(result, node);
184731
184963
  }
184732
184964
  case SyntaxKind.NewExpression: {
184733
- const typeArguments = node.typeArguments && this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node);
184965
+ const typeArguments = this.convertTypeArguments(node);
184734
184966
  return this.createNode(node, {
184735
184967
  type: ts_estree_1.AST_NODE_TYPES.NewExpression,
184736
184968
  arguments: this.convertChildren(node.arguments ?? []),
@@ -184860,7 +185092,7 @@ var require_convert = __commonJS((exports) => {
184860
185092
  attributes: this.convertChildren(node.attributes.properties),
184861
185093
  name: this.convertJSXTagName(node.tagName, node),
184862
185094
  selfClosing: true,
184863
- typeArguments: node.typeArguments ? this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node) : undefined
185095
+ typeArguments: this.convertTypeArguments(node)
184864
185096
  })
184865
185097
  });
184866
185098
  }
@@ -184870,7 +185102,7 @@ var require_convert = __commonJS((exports) => {
184870
185102
  attributes: this.convertChildren(node.attributes.properties),
184871
185103
  name: this.convertJSXTagName(node.tagName, node),
184872
185104
  selfClosing: false,
184873
- typeArguments: node.typeArguments && this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node)
185105
+ typeArguments: this.convertTypeArguments(node)
184874
185106
  });
184875
185107
  }
184876
185108
  case SyntaxKind.JsxClosingElement:
@@ -184935,7 +185167,7 @@ var require_convert = __commonJS((exports) => {
184935
185167
  case SyntaxKind.TypeReference:
184936
185168
  return this.createNode(node, {
184937
185169
  type: ts_estree_1.AST_NODE_TYPES.TSTypeReference,
184938
- typeArguments: node.typeArguments && this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node),
185170
+ typeArguments: this.convertTypeArguments(node),
184939
185171
  typeName: this.convertChild(node.typeName)
184940
185172
  });
184941
185173
  case SyntaxKind.TypeParameter: {
@@ -185008,12 +185240,9 @@ var require_convert = __commonJS((exports) => {
185008
185240
  return this.createNode(node, {
185009
185241
  type: ts_estree_1.AST_NODE_TYPES.TSTypeQuery,
185010
185242
  exprName: this.convertChild(node.exprName),
185011
- typeArguments: node.typeArguments && this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node)
185243
+ typeArguments: this.convertTypeArguments(node)
185012
185244
  });
185013
185245
  case SyntaxKind.MappedType: {
185014
- if (node.members && node.members.length > 0) {
185015
- this.#throwError(node.members[0], "A mapped type may not declare properties or methods.");
185016
- }
185017
185246
  return this.createNode(node, this.#withDeprecatedGetter({
185018
185247
  type: ts_estree_1.AST_NODE_TYPES.TSMappedType,
185019
185248
  constraint: this.convertChild(node.typeParameter.constraint),
@@ -185032,7 +185261,7 @@ var require_convert = __commonJS((exports) => {
185032
185261
  declare: (0, node_utils_1.hasModifier)(SyntaxKind.DeclareKeyword, node),
185033
185262
  id: this.convertChild(node.name),
185034
185263
  typeAnnotation: this.convertChild(node.type),
185035
- typeParameters: node.typeParameters && this.convertTSTypeParametersToTypeParametersDeclaration(node.typeParameters)
185264
+ typeParameters: this.convertTypeParameters(node)
185036
185265
  });
185037
185266
  return this.fixExports(node, result);
185038
185267
  }
@@ -185040,10 +185269,6 @@ var require_convert = __commonJS((exports) => {
185040
185269
  return this.convertMethodSignature(node);
185041
185270
  }
185042
185271
  case SyntaxKind.PropertySignature: {
185043
- const { initializer } = node;
185044
- if (initializer) {
185045
- this.#throwError(initializer, "A property signature cannot have an initializer.");
185046
- }
185047
185272
  return this.createNode(node, {
185048
185273
  type: ts_estree_1.AST_NODE_TYPES.TSPropertySignature,
185049
185274
  accessibility: (0, node_utils_1.getTSNodeAccessibility)(node),
@@ -185071,15 +185296,10 @@ var require_convert = __commonJS((exports) => {
185071
185296
  abstract: (0, node_utils_1.hasModifier)(SyntaxKind.AbstractKeyword, node),
185072
185297
  params: this.convertParameters(node.parameters),
185073
185298
  returnType: node.type && this.convertTypeAnnotation(node.type, node),
185074
- typeParameters: node.typeParameters && this.convertTSTypeParametersToTypeParametersDeclaration(node.typeParameters)
185299
+ typeParameters: this.convertTypeParameters(node)
185075
185300
  });
185076
185301
  }
185077
- case SyntaxKind.FunctionType: {
185078
- const { modifiers } = node;
185079
- if (modifiers) {
185080
- this.#throwError(modifiers[0], "A function type cannot have modifiers.");
185081
- }
185082
- }
185302
+ case SyntaxKind.FunctionType:
185083
185303
  case SyntaxKind.ConstructSignature:
185084
185304
  case SyntaxKind.CallSignature: {
185085
185305
  const type = node.kind === SyntaxKind.ConstructSignature ? ts_estree_1.AST_NODE_TYPES.TSConstructSignatureDeclaration : node.kind === SyntaxKind.CallSignature ? ts_estree_1.AST_NODE_TYPES.TSCallSignatureDeclaration : ts_estree_1.AST_NODE_TYPES.TSFunctionType;
@@ -185087,7 +185307,7 @@ var require_convert = __commonJS((exports) => {
185087
185307
  type,
185088
185308
  params: this.convertParameters(node.parameters),
185089
185309
  returnType: node.type && this.convertTypeAnnotation(node.type, node),
185090
- typeParameters: node.typeParameters && this.convertTSTypeParametersToTypeParametersDeclaration(node.typeParameters)
185310
+ typeParameters: this.convertTypeParameters(node)
185091
185311
  });
185092
185312
  }
185093
185313
  case SyntaxKind.ExpressionWithTypeArguments: {
@@ -185096,28 +185316,11 @@ var require_convert = __commonJS((exports) => {
185096
185316
  return this.createNode(node, {
185097
185317
  type,
185098
185318
  expression: this.convertChild(node.expression),
185099
- typeArguments: node.typeArguments && this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node)
185319
+ typeArguments: this.convertTypeArguments(node)
185100
185320
  });
185101
185321
  }
185102
185322
  case SyntaxKind.InterfaceDeclaration: {
185103
- const interfaceHeritageClauses = node.heritageClauses ?? [];
185104
- const interfaceExtends = [];
185105
- let seenExtendsClause = false;
185106
- for (const heritageClause of interfaceHeritageClauses) {
185107
- if (heritageClause.token !== SyntaxKind.ExtendsKeyword) {
185108
- this.#throwError(heritageClause, heritageClause.token === SyntaxKind.ImplementsKeyword ? "Interface declaration cannot have 'implements' clause." : "Unexpected token.");
185109
- }
185110
- if (seenExtendsClause) {
185111
- this.#throwError(heritageClause, "'extends' clause already seen.");
185112
- }
185113
- seenExtendsClause = true;
185114
- for (const heritageType of heritageClause.types) {
185115
- if (!isEntityNameExpression(heritageType.expression) || ts.isOptionalChain(heritageType.expression)) {
185116
- this.#throwError(heritageType, "Interface declaration can only extend an identifier/qualified name with optional type arguments.");
185117
- }
185118
- interfaceExtends.push(this.convertChild(heritageType, node));
185119
- }
185120
- }
185323
+ const interfaceExtends = node.heritageClauses?.flatMap((heritageClause) => heritageClause.token === SyntaxKind.ExtendsKeyword ? heritageClause.types.map((heritageType) => this.convertChild(heritageType, node)) : []) ?? [];
185121
185324
  const result = this.createNode(node, {
185122
185325
  type: ts_estree_1.AST_NODE_TYPES.TSInterfaceDeclaration,
185123
185326
  body: this.createNode(node, {
@@ -185128,7 +185331,7 @@ var require_convert = __commonJS((exports) => {
185128
185331
  declare: (0, node_utils_1.hasModifier)(SyntaxKind.DeclareKeyword, node),
185129
185332
  extends: interfaceExtends,
185130
185333
  id: this.convertChild(node.name),
185131
- typeParameters: node.typeParameters && this.convertTSTypeParametersToTypeParametersDeclaration(node.typeParameters)
185334
+ typeParameters: this.convertTypeParameters(node)
185132
185335
  });
185133
185336
  return this.fixExports(node, result);
185134
185337
  }
@@ -185207,7 +185410,7 @@ var require_convert = __commonJS((exports) => {
185207
185410
  options,
185208
185411
  qualifier: this.convertChild(node.qualifier),
185209
185412
  source,
185210
- typeArguments: node.typeArguments ? this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node) : null
185413
+ typeArguments: this.convertTypeArguments(node) ?? null
185211
185414
  }, "argument", "source", argument));
185212
185415
  if (node.isTypeOf) {
185213
185416
  return this.createNode(node, {
@@ -185235,12 +185438,6 @@ var require_convert = __commonJS((exports) => {
185235
185438
  }
185236
185439
  case SyntaxKind.EnumMember: {
185237
185440
  const computed = node.name.kind === ts.SyntaxKind.ComputedPropertyName;
185238
- if (computed) {
185239
- this.#throwError(node.name, "Computed property names are not allowed in enums.");
185240
- }
185241
- if (node.name.kind === SyntaxKind.NumericLiteral || node.name.kind === SyntaxKind.BigIntLiteral) {
185242
- this.#throwError(node.name, "An enum member cannot have a numeric name.");
185243
- }
185244
185441
  return this.createNode(node, this.#withDeprecatedGetter({
185245
185442
  type: ts_estree_1.AST_NODE_TYPES.TSEnumMember,
185246
185443
  id: this.convertChild(node.name),
@@ -185253,19 +185450,11 @@ var require_convert = __commonJS((exports) => {
185253
185450
  type: ts_estree_1.AST_NODE_TYPES.TSModuleDeclaration,
185254
185451
  ...(() => {
185255
185452
  if (node.flags & ts.NodeFlags.GlobalAugmentation) {
185256
- const id = this.convertChild(node.name);
185257
- const body = this.convertChild(node.body);
185258
- if (body == null || body.type === ts_estree_1.AST_NODE_TYPES.TSModuleDeclaration) {
185259
- this.#throwError(node.body ?? node, "Expected a valid module body");
185260
- }
185261
- if (id.type !== ts_estree_1.AST_NODE_TYPES.Identifier) {
185262
- this.#throwError(node.name, "global module augmentation must have an Identifier id");
185263
- }
185264
185453
  return {
185265
- body,
185454
+ body: this.convertChild(node.body),
185266
185455
  declare: false,
185267
185456
  global: false,
185268
- id,
185457
+ id: this.convertChild(node.name),
185269
185458
  kind: "global"
185270
185459
  };
185271
185460
  }
@@ -185279,12 +185468,6 @@ var require_convert = __commonJS((exports) => {
185279
185468
  id: this.convertChild(node.name)
185280
185469
  };
185281
185470
  }
185282
- if (node.body == null) {
185283
- this.#throwError(node, "Expected a module body");
185284
- }
185285
- if (node.name.kind !== ts.SyntaxKind.Identifier) {
185286
- this.#throwError(node.name, "`namespace`s must have an Identifier id");
185287
- }
185288
185471
  let name = this.createNode(node.name, {
185289
185472
  type: ts_estree_1.AST_NODE_TYPES.Identifier,
185290
185473
  range: [node.name.getStart(this.ast), node.name.getEnd()],
@@ -185382,9 +185565,6 @@ var require_convert = __commonJS((exports) => {
185382
185565
  }));
185383
185566
  }
185384
185567
  case SyntaxKind.ExternalModuleReference: {
185385
- if (node.expression.kind !== SyntaxKind.StringLiteral) {
185386
- this.#throwError(node.expression, "String literal expected.");
185387
- }
185388
185568
  return this.createNode(node, {
185389
185569
  type: ts_estree_1.AST_NODE_TYPES.TSExternalModuleReference,
185390
185570
  expression: this.convertChild(node.expression)
@@ -185501,10 +185681,10 @@ var require_convert = __commonJS((exports) => {
185501
185681
  result.typeAnnotation = node.type && "kind" in node.type && ts.isTypeNode(node.type) ? this.convertTypeAnnotation(node.type, node) : null;
185502
185682
  }
185503
185683
  if ("typeArguments" in node) {
185504
- result.typeArguments = node.typeArguments && "pos" in node.typeArguments ? this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node) : null;
185684
+ result.typeArguments = node.typeArguments && "pos" in node.typeArguments ? this.convertTypeArguments(node) : null;
185505
185685
  }
185506
185686
  if ("typeParameters" in node) {
185507
- result.typeParameters = node.typeParameters && "pos" in node.typeParameters ? this.convertTSTypeParametersToTypeParametersDeclaration(node.typeParameters) : null;
185687
+ result.typeParameters = node.typeParameters && "pos" in node.typeParameters ? this.convertTypeParameters(node) : null;
185508
185688
  }
185509
185689
  const decorators = (0, getModifiers_1.getDecorators)(node);
185510
185690
  if (decorators?.length) {
@@ -187683,22 +187863,18 @@ var require_convert_comments = __commonJS((exports) => {
187683
187863
  var ts = __importStar(require_typescript());
187684
187864
  var node_utils_1 = require_node_utils();
187685
187865
  var ts_estree_1 = require_ts_estree2();
187686
- function convertComments(ast, code) {
187687
- const comments = [];
187688
- tsutils.forEachComment(ast, (_, comment) => {
187689
- const type = comment.kind === ts.SyntaxKind.SingleLineCommentTrivia ? ts_estree_1.AST_TOKEN_TYPES.Line : ts_estree_1.AST_TOKEN_TYPES.Block;
187690
- const range = [comment.pos, comment.end];
187866
+ function convertComments(ast) {
187867
+ return Array.from(tsutils.iterateComments(ast), ({ end, kind, pos, value }) => {
187868
+ const type = kind === ts.SyntaxKind.SingleLineCommentTrivia ? ts_estree_1.AST_TOKEN_TYPES.Line : ts_estree_1.AST_TOKEN_TYPES.Block;
187869
+ const range = [pos, end];
187691
187870
  const loc = (0, node_utils_1.getLocFor)(range, ast);
187692
- const textStart = range[0] + 2;
187693
- const textEnd = comment.kind === ts.SyntaxKind.SingleLineCommentTrivia ? range[1] : range[1] - 2;
187694
- comments.push({
187871
+ return {
187695
187872
  type,
187696
187873
  loc,
187697
187874
  range,
187698
- value: code.slice(textStart, textEnd)
187699
- });
187700
- }, ast);
187701
- return comments;
187875
+ value
187876
+ };
187877
+ });
187702
187878
  }
187703
187879
  });
187704
187880
 
@@ -187795,7 +187971,7 @@ var require_ast_converter = __commonJS((exports) => {
187795
187971
  estree.tokens = (0, node_utils_1.convertTokens)(ast);
187796
187972
  }
187797
187973
  if (parseSettings.comment) {
187798
- estree.comments = (0, convert_comments_1.convertComments)(ast, parseSettings.codeFullText);
187974
+ estree.comments = (0, convert_comments_1.convertComments)(ast);
187799
187975
  }
187800
187976
  const astMaps = instance.getASTMaps();
187801
187977
  return { astMaps, estree };
@@ -188050,7 +188226,7 @@ ${relativeProjects.map((project) => `- ${project}`).join(`
188050
188226
  `Either:`,
188051
188227
  `- Switch to \`parserOptions.projectService\``,
188052
188228
  `- Use an ESLint-specific TSConfig`,
188053
- `See the typescript-eslint docs for more info: https://typescript-eslint.io/troubleshooting/typed-linting#are-typescript-project-references-supported`
188229
+ `See the typescript-eslint docs for more info: https://tseslint.com/are-project-references-supported`
188054
188230
  ];
188055
188231
  }
188056
188232
  const { extraFileExtensions } = parseSettings;
@@ -188087,7 +188263,7 @@ ${relativeProjects.map((project) => `- ${project}`).join(`
188087
188263
  `- Change ESLint's list of included files to not include this file`,
188088
188264
  `- Change ${describedSpecifiers} to include this file`,
188089
188265
  `- Create a new TSConfig that includes this file and include it in your parserOptions.project`,
188090
- `See the typescript-eslint docs for more info: https://typescript-eslint.io/troubleshooting/typed-linting#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file`
188266
+ `See the typescript-eslint docs for more info: https://tseslint.com/none-of-those-tsconfigs-include-this-file`
188091
188267
  ];
188092
188268
  }
188093
188269
  });
@@ -188362,7 +188538,7 @@ var require_createProjectService = __commonJS((exports) => {
188362
188538
  var createStubFileWatcher = () => ({
188363
188539
  close: doNothing
188364
188540
  });
188365
- function createProjectService({ jsDocParsingMode, options: optionsRaw = {}, tsconfigRootDir } = {}) {
188541
+ function createProjectService({ host, jsDocParsingMode, options: optionsRaw = {}, tsconfigRootDir } = {}) {
188366
188542
  const options = {
188367
188543
  defaultProject: "tsconfig.json",
188368
188544
  ...optionsRaw
@@ -188383,7 +188559,8 @@ var require_createProjectService = __commonJS((exports) => {
188383
188559
  },
188384
188560
  module: undefined
188385
188561
  })
188386
- }
188562
+ },
188563
+ ...host
188387
188564
  };
188388
188565
  const logger = {
188389
188566
  close: doNothing,
@@ -188480,7 +188657,7 @@ var require_validateDefaultProjectForFilesGlob = __commonJS((exports) => {
188480
188657
 
188481
188658
  Having many files run with the default project is known to cause performance issues and slow down linting.
188482
188659
 
188483
- See https://typescript-eslint.io/troubleshooting/typed-linting#allowdefaultproject-glob-too-wide
188660
+ See https://tseslint.com/allowdefaultproject-glob-too-wide
188484
188661
  `;
188485
188662
  function validateDefaultProjectForFilesGlob(allowDefaultProject) {
188486
188663
  if (!allowDefaultProject?.length) {
@@ -188522,7 +188699,7 @@ var require_candidateTSConfigRootDirs = __commonJS((exports) => {
188522
188699
  "No tsconfigRootDir was set, and multiple candidate TSConfigRootDirs are present:",
188523
188700
  ...entries.map((candidate) => ` - ${candidate}`),
188524
188701
  "You'll need to explicitly set tsconfigRootDir in your parser options.",
188525
- "See: https://typescript-eslint.io/packages/parser/#tsconfigrootdir"
188702
+ "See: https://tseslint.com/parser-tsconfigrootdir"
188526
188703
  ].join(`
188527
188704
  `));
188528
188705
  }
@@ -191132,7 +191309,7 @@ var require_resolveProjectList = __commonJS((exports) => {
191132
191309
  var require_package2 = __commonJS((exports, module) => {
191133
191310
  module.exports = {
191134
191311
  name: "@typescript-eslint/typescript-estree",
191135
- version: "8.51.0",
191312
+ version: "8.53.0",
191136
191313
  description: "A parser that converts TypeScript source code into an ESTree compatible form",
191137
191314
  files: [
191138
191315
  "dist",
@@ -191184,23 +191361,23 @@ var require_package2 = __commonJS((exports, module) => {
191184
191361
  typecheck: "yarn run -BT nx typecheck"
191185
191362
  },
191186
191363
  dependencies: {
191187
- "@typescript-eslint/project-service": "8.51.0",
191188
- "@typescript-eslint/tsconfig-utils": "8.51.0",
191189
- "@typescript-eslint/types": "8.51.0",
191190
- "@typescript-eslint/visitor-keys": "8.51.0",
191191
- debug: "^4.3.4",
191192
- minimatch: "^9.0.4",
191193
- semver: "^7.6.0",
191364
+ "@typescript-eslint/project-service": "8.53.0",
191365
+ "@typescript-eslint/tsconfig-utils": "8.53.0",
191366
+ "@typescript-eslint/types": "8.53.0",
191367
+ "@typescript-eslint/visitor-keys": "8.53.0",
191368
+ debug: "^4.4.3",
191369
+ minimatch: "^9.0.5",
191370
+ semver: "^7.7.3",
191194
191371
  tinyglobby: "^0.2.15",
191195
- "ts-api-utils": "^2.2.0"
191372
+ "ts-api-utils": "^2.4.0"
191196
191373
  },
191197
191374
  devDependencies: {
191198
- "@vitest/coverage-v8": "^3.1.3",
191375
+ "@vitest/coverage-v8": "^3.2.4",
191199
191376
  eslint: "*",
191200
191377
  glob: "*",
191201
191378
  rimraf: "*",
191202
191379
  typescript: "*",
191203
- vitest: "^3.1.3"
191380
+ vitest: "^3.2.4"
191204
191381
  },
191205
191382
  peerDependencies: {
191206
191383
  typescript: ">=4.8.4 <6.0.0"
@@ -193588,7 +193765,7 @@ var require_parser2 = __commonJS((exports) => {
193588
193765
  var require_package3 = __commonJS((exports, module) => {
193589
193766
  module.exports = {
193590
193767
  name: "@typescript-eslint/parser",
193591
- version: "8.51.0",
193768
+ version: "8.53.0",
193592
193769
  description: "An ESLint custom parser which leverages TypeScript ESTree",
193593
193770
  files: [
193594
193771
  "dist",
@@ -193639,19 +193816,19 @@ var require_package3 = __commonJS((exports, module) => {
193639
193816
  typescript: ">=4.8.4 <6.0.0"
193640
193817
  },
193641
193818
  dependencies: {
193642
- "@typescript-eslint/scope-manager": "8.51.0",
193643
- "@typescript-eslint/types": "8.51.0",
193644
- "@typescript-eslint/typescript-estree": "8.51.0",
193645
- "@typescript-eslint/visitor-keys": "8.51.0",
193646
- debug: "^4.3.4"
193819
+ "@typescript-eslint/scope-manager": "8.53.0",
193820
+ "@typescript-eslint/types": "8.53.0",
193821
+ "@typescript-eslint/typescript-estree": "8.53.0",
193822
+ "@typescript-eslint/visitor-keys": "8.53.0",
193823
+ debug: "^4.4.3"
193647
193824
  },
193648
193825
  devDependencies: {
193649
- "@vitest/coverage-v8": "^3.1.3",
193826
+ "@vitest/coverage-v8": "^3.2.4",
193650
193827
  eslint: "*",
193651
193828
  glob: "*",
193652
193829
  rimraf: "*",
193653
193830
  typescript: "*",
193654
- vitest: "^3.1.3"
193831
+ vitest: "^3.2.4"
193655
193832
  },
193656
193833
  funding: {
193657
193834
  type: "opencollective",
@@ -193851,6 +194028,7 @@ var require_all = __commonJS((exports, module) => {
193851
194028
  "no-return-await": "off",
193852
194029
  "@typescript-eslint/return-await": "error",
193853
194030
  "@typescript-eslint/strict-boolean-expressions": "error",
194031
+ "@typescript-eslint/strict-void-return": "error",
193854
194032
  "@typescript-eslint/switch-exhaustiveness-check": "error",
193855
194033
  "@typescript-eslint/triple-slash-reference": "error",
193856
194034
  "@typescript-eslint/unbound-method": "error",
@@ -193931,6 +194109,7 @@ var require_disable_type_checked = __commonJS((exports, module) => {
193931
194109
  "@typescript-eslint/restrict-template-expressions": "off",
193932
194110
  "@typescript-eslint/return-await": "off",
193933
194111
  "@typescript-eslint/strict-boolean-expressions": "off",
194112
+ "@typescript-eslint/strict-void-return": "off",
193934
194113
  "@typescript-eslint/switch-exhaustiveness-check": "off",
193935
194114
  "@typescript-eslint/unbound-method": "off",
193936
194115
  "@typescript-eslint/use-unknown-in-catch-callback-variable": "off"
@@ -194602,6 +194781,7 @@ var require_all2 = __commonJS((exports) => {
194602
194781
  "no-return-await": "off",
194603
194782
  "@typescript-eslint/return-await": "error",
194604
194783
  "@typescript-eslint/strict-boolean-expressions": "error",
194784
+ "@typescript-eslint/strict-void-return": "error",
194605
194785
  "@typescript-eslint/switch-exhaustiveness-check": "error",
194606
194786
  "@typescript-eslint/triple-slash-reference": "error",
194607
194787
  "@typescript-eslint/unbound-method": "error",
@@ -194675,6 +194855,7 @@ var require_disable_type_checked2 = __commonJS((exports) => {
194675
194855
  "@typescript-eslint/restrict-template-expressions": "off",
194676
194856
  "@typescript-eslint/return-await": "off",
194677
194857
  "@typescript-eslint/strict-boolean-expressions": "off",
194858
+ "@typescript-eslint/strict-void-return": "off",
194678
194859
  "@typescript-eslint/switch-exhaustiveness-check": "off",
194679
194860
  "@typescript-eslint/unbound-method": "off",
194680
194861
  "@typescript-eslint/use-unknown-in-catch-callback-variable": "off"
@@ -197583,7 +197764,7 @@ var require_getParserServices = __commonJS((exports) => {
197583
197764
  Object.defineProperty(exports, "__esModule", { value: true });
197584
197765
  exports.getParserServices = getParserServices;
197585
197766
  var parserSeemsToBeTSESLint_1 = require_parserSeemsToBeTSESLint();
197586
- var ERROR_MESSAGE_REQUIRES_PARSER_SERVICES = "You have used a rule which requires type information, but don't have parserOptions set to generate type information for this file. See https://typescript-eslint.io/getting-started/typed-linting for enabling linting with type information.";
197767
+ var ERROR_MESSAGE_REQUIRES_PARSER_SERVICES = "You have used a rule which requires type information, but don't have parserOptions set to generate type information for this file. See https://tseslint.com/typed-linting for enabling linting with type information.";
197587
197768
  var ERROR_MESSAGE_UNKNOWN_PARSER = 'Note: detected a parser other than @typescript-eslint/parser. Make sure the parser is configured to forward "parserOptions.project" to @typescript-eslint/parser.';
197588
197769
  function getParserServices(context, allowWithoutFullTypeInformation = false) {
197589
197770
  const parser = context.parserPath || context.languageOptions.parser?.meta?.name;
@@ -288119,6 +288300,36 @@ var require_createRule = __commonJS((exports) => {
288119
288300
  exports.createRule = utils_1.ESLintUtils.RuleCreator((name) => `https://typescript-eslint.io/rules/${name}`);
288120
288301
  });
288121
288302
 
288303
+ // ../../node_modules/@typescript-eslint/eslint-plugin/dist/util/getBaseTypesOfClassMember.js
288304
+ var require_getBaseTypesOfClassMember = __commonJS((exports) => {
288305
+ Object.defineProperty(exports, "__esModule", { value: true });
288306
+ exports.getBaseTypesOfClassMember = getBaseTypesOfClassMember;
288307
+ function* getBaseTypesOfClassMember(services, memberNode) {
288308
+ const memberTsNode = services.esTreeNodeToTSNodeMap.get(memberNode);
288309
+ if (memberTsNode.name == null) {
288310
+ return;
288311
+ }
288312
+ const checker = services.program.getTypeChecker();
288313
+ const memberSymbol = checker.getSymbolAtLocation(memberTsNode.name);
288314
+ if (memberSymbol == null) {
288315
+ return;
288316
+ }
288317
+ const classNode = memberTsNode.parent;
288318
+ for (const clauseNode of classNode.heritageClauses ?? []) {
288319
+ for (const baseTypeNode of clauseNode.types) {
288320
+ const baseType = checker.getTypeAtLocation(baseTypeNode);
288321
+ const baseMemberSymbol = checker.getPropertyOfType(baseType, memberSymbol.name);
288322
+ if (baseMemberSymbol == null) {
288323
+ continue;
288324
+ }
288325
+ const baseMemberType = checker.getTypeOfSymbolAtLocation(baseMemberSymbol, memberTsNode);
288326
+ const heritageToken = clauseNode.token;
288327
+ yield { baseMemberType, baseType, heritageToken };
288328
+ }
288329
+ }
288330
+ }
288331
+ });
288332
+
288122
288333
  // ../../node_modules/@typescript-eslint/eslint-plugin/dist/util/getFixOrSuggest.js
288123
288334
  var require_getFixOrSuggest = __commonJS((exports) => {
288124
288335
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -291049,6 +291260,60 @@ var require_truthinessUtils = __commonJS((exports) => {
291049
291260
  exports.isPossiblyTruthy = isPossiblyTruthy;
291050
291261
  });
291051
291262
 
291263
+ // ../../node_modules/@typescript-eslint/eslint-plugin/dist/util/walkStatements.js
291264
+ var require_walkStatements = __commonJS((exports) => {
291265
+ Object.defineProperty(exports, "__esModule", { value: true });
291266
+ exports.walkStatements = walkStatements;
291267
+ var utils_1 = require_dist10();
291268
+ function* walkStatements(body) {
291269
+ for (const statement of body) {
291270
+ switch (statement.type) {
291271
+ case utils_1.AST_NODE_TYPES.BlockStatement: {
291272
+ yield* walkStatements(statement.body);
291273
+ continue;
291274
+ }
291275
+ case utils_1.AST_NODE_TYPES.SwitchStatement: {
291276
+ for (const switchCase of statement.cases) {
291277
+ yield* walkStatements(switchCase.consequent);
291278
+ }
291279
+ continue;
291280
+ }
291281
+ case utils_1.AST_NODE_TYPES.IfStatement: {
291282
+ yield* walkStatements([statement.consequent]);
291283
+ if (statement.alternate) {
291284
+ yield* walkStatements([statement.alternate]);
291285
+ }
291286
+ continue;
291287
+ }
291288
+ case utils_1.AST_NODE_TYPES.WhileStatement:
291289
+ case utils_1.AST_NODE_TYPES.DoWhileStatement:
291290
+ case utils_1.AST_NODE_TYPES.ForStatement:
291291
+ case utils_1.AST_NODE_TYPES.ForInStatement:
291292
+ case utils_1.AST_NODE_TYPES.ForOfStatement:
291293
+ case utils_1.AST_NODE_TYPES.WithStatement:
291294
+ case utils_1.AST_NODE_TYPES.LabeledStatement: {
291295
+ yield* walkStatements([statement.body]);
291296
+ continue;
291297
+ }
291298
+ case utils_1.AST_NODE_TYPES.TryStatement: {
291299
+ yield* walkStatements([statement.block]);
291300
+ if (statement.handler) {
291301
+ yield* walkStatements([statement.handler.body]);
291302
+ }
291303
+ if (statement.finalizer) {
291304
+ yield* walkStatements([statement.finalizer]);
291305
+ }
291306
+ continue;
291307
+ }
291308
+ default: {
291309
+ yield statement;
291310
+ continue;
291311
+ }
291312
+ }
291313
+ }
291314
+ }
291315
+ });
291316
+
291052
291317
  // ../../node_modules/@typescript-eslint/eslint-plugin/dist/util/index.js
291053
291318
  var require_util3 = __commonJS((exports) => {
291054
291319
  var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
@@ -291078,6 +291343,7 @@ var require_util3 = __commonJS((exports) => {
291078
291343
  __exportStar(require_baseTypeUtils(), exports);
291079
291344
  __exportStar(require_collectUnusedVariables(), exports);
291080
291345
  __exportStar(require_createRule(), exports);
291346
+ __exportStar(require_getBaseTypesOfClassMember(), exports);
291081
291347
  __exportStar(require_getFixOrSuggest(), exports);
291082
291348
  __exportStar(require_getFunctionHeadLoc(), exports);
291083
291349
  __exportStar(require_getOperatorPrecedence(), exports);
@@ -291104,6 +291370,7 @@ var require_util3 = __commonJS((exports) => {
291104
291370
  __exportStar(require_isHigherPrecedenceThanAwait(), exports);
291105
291371
  __exportStar(require_skipChainExpression(), exports);
291106
291372
  __exportStar(require_truthinessUtils(), exports);
291373
+ __exportStar(require_walkStatements(), exports);
291107
291374
  __exportStar(require_dist11(), exports);
291108
291375
  exports.applyDefault = utils_1.ESLintUtils.applyDefault, exports.deepMerge = utils_1.ESLintUtils.deepMerge, exports.getParserServices = utils_1.ESLintUtils.getParserServices, exports.isObjectNotArray = utils_1.ESLintUtils.isObjectNotArray, exports.nullThrows = utils_1.ESLintUtils.nullThrows, exports.NullThrowsReasons = utils_1.ESLintUtils.NullThrowsReasons;
291109
291376
  });
@@ -297564,20 +297831,17 @@ var require_no_base_to_string = __commonJS((exports) => {
297564
297831
  if (checker.isArrayType(type)) {
297565
297832
  return collectArrayCertainty(type, new Set([...visited, type]));
297566
297833
  }
297567
- const toString = checker.getPropertyOfType(type, "toString") ?? checker.getPropertyOfType(type, "toLocaleString");
297568
- if (!toString) {
297569
- if (option.checkUnknown && type.flags === ts.TypeFlags.Unknown) {
297570
- return Usefulness.Sometimes;
297571
- }
297572
- return Usefulness.Always;
297573
- }
297574
- const declarations = toString.getDeclarations();
297575
- if (declarations == null || declarations.length !== 1) {
297576
- return Usefulness.Always;
297834
+ switch (isToStringLikeFromObject(type)) {
297835
+ case undefined:
297836
+ if (option.checkUnknown && type.flags === ts.TypeFlags.Unknown) {
297837
+ return Usefulness.Sometimes;
297838
+ }
297839
+ return Usefulness.Always;
297840
+ case true:
297841
+ return Usefulness.Never;
297842
+ case false:
297843
+ return Usefulness.Always;
297577
297844
  }
297578
- const declaration = declarations[0];
297579
- const isBaseToString = ts.isInterfaceDeclaration(declaration.parent) && declaration.parent.name.text === "Object";
297580
- return isBaseToString ? Usefulness.Never : Usefulness.Always;
297581
297845
  }
297582
297846
  function isBuiltInStringCall(node) {
297583
297847
  if (node.callee.type === utils_1.AST_NODE_TYPES.Identifier && node.callee.name === "String" && node.arguments[0]) {
@@ -297587,6 +297851,30 @@ var require_no_base_to_string = __commonJS((exports) => {
297587
297851
  }
297588
297852
  return false;
297589
297853
  }
297854
+ function isSymbolToPrimitiveMethod(node) {
297855
+ return ts.isMethodSignature(node) && ts.isComputedPropertyName(node.name) && ts.isPropertyAccessExpression(node.name.expression) && ts.isIdentifier(node.name.expression.expression) && node.name.expression.expression.text === "Symbol" && ts.isIdentifier(node.name.expression.name) && node.name.expression.name.text === "toPrimitive" && checker.getSymbolAtLocation(node.name.expression.expression)?.valueDeclaration?.getSourceFile().hasNoDefaultLib;
297856
+ }
297857
+ function isToStringLikeFromObject(type) {
297858
+ if (type.getProperties().some((property) => property.valueDeclaration && isSymbolToPrimitiveMethod(property.valueDeclaration))) {
297859
+ return false;
297860
+ }
297861
+ let foundFallbackOnObject = false;
297862
+ for (const propertyName of ["toLocaleString", "toString", "valueOf"]) {
297863
+ const candidate = checker.getPropertyOfType(type, propertyName);
297864
+ if (!candidate) {
297865
+ continue;
297866
+ }
297867
+ const declarations = candidate.getDeclarations();
297868
+ if (declarations?.length !== 1) {
297869
+ continue;
297870
+ }
297871
+ if (!ts.isInterfaceDeclaration(declarations[0].parent) || declarations[0].parent.name.text !== "Object") {
297872
+ return false;
297873
+ }
297874
+ foundFallbackOnObject = true;
297875
+ }
297876
+ return foundFallbackOnObject ? true : undefined;
297877
+ }
297590
297878
  return {
297591
297879
  'AssignmentExpression[operator = "+="], BinaryExpression[operator = "+"]'(node) {
297592
297880
  const leftType = services.getTypeAtLocation(node.left);
@@ -307761,14 +308049,18 @@ var require_no_unsafe_call = __commonJS((exports) => {
307761
308049
  requiresTypeChecking: true
307762
308050
  },
307763
308051
  messages: {
307764
- unsafeCall: "Unsafe call of a(n) {{type}} typed value.",
308052
+ errorCall: "Unsafe call of a type that could not be resolved.",
308053
+ errorCallThis: "Unsafe call of a `this` type that could not be resolved.",
308054
+ errorNew: "Unsafe construction of a type that could not be resolved.",
308055
+ errorTemplateTag: "Unsafe use of a template tag whose type could not be resolved.",
308056
+ unsafeCall: "Unsafe call of {{type}} typed value.",
307765
308057
  unsafeCallThis: [
307766
- "Unsafe call of a(n) {{type}} typed value. `this` is typed as {{type}}.",
308058
+ "Unsafe call of {{type}} typed value. `this` is typed as {{type}}.",
307767
308059
  "You can try to fix this by turning on the `noImplicitThis` compiler option, or adding a `this` parameter to the function."
307768
308060
  ].join(`
307769
308061
  `),
307770
- unsafeNew: "Unsafe construction of a(n) {{type}} typed value.",
307771
- unsafeTemplateTag: "Unsafe use of a(n) {{type}} typed template tag."
308062
+ unsafeNew: "Unsafe construction of {{type}} typed value.",
308063
+ unsafeTemplateTag: "Unsafe use of {{type}} typed template tag."
307772
308064
  },
307773
308065
  schema: []
307774
308066
  },
@@ -307777,21 +308069,22 @@ var require_no_unsafe_call = __commonJS((exports) => {
307777
308069
  const services = (0, util_1.getParserServices)(context);
307778
308070
  const compilerOptions = services.program.getCompilerOptions();
307779
308071
  const isNoImplicitThis = tsutils.isStrictCompilerOptionEnabled(compilerOptions, "noImplicitThis");
307780
- function checkCall(node, reportingNode, messageId) {
308072
+ function checkCall(node, reportingNode, unsafeMessageId, errorMessageId) {
307781
308073
  const type = (0, util_1.getConstrainedTypeAtLocation)(services, node);
307782
308074
  if ((0, util_1.isTypeAnyType)(type)) {
307783
308075
  if (!isNoImplicitThis) {
307784
308076
  const thisExpression = (0, util_1.getThisExpression)(node);
307785
308077
  if (thisExpression && (0, util_1.isTypeAnyType)((0, util_1.getConstrainedTypeAtLocation)(services, thisExpression))) {
307786
- messageId = "unsafeCallThis";
308078
+ unsafeMessageId = "unsafeCallThis";
308079
+ errorMessageId = "errorCallThis";
307787
308080
  }
307788
308081
  }
307789
308082
  const isErrorType = tsutils.isIntrinsicErrorType(type);
307790
308083
  context.report({
307791
308084
  node: reportingNode,
307792
- messageId,
308085
+ messageId: isErrorType ? errorMessageId : unsafeMessageId,
307793
308086
  data: {
307794
- type: isErrorType ? "`error` type" : "`any`"
308087
+ type: "an `any`"
307795
308088
  }
307796
308089
  });
307797
308090
  return;
@@ -307802,7 +308095,7 @@ var require_no_unsafe_call = __commonJS((exports) => {
307802
308095
  return;
307803
308096
  }
307804
308097
  const callSignatures = type.getCallSignatures();
307805
- if (messageId === "unsafeNew") {
308098
+ if (unsafeMessageId === "unsafeNew") {
307806
308099
  if (callSignatures.some((signature) => !tsutils.isIntrinsicVoidType(signature.getReturnType()))) {
307807
308100
  return;
307808
308101
  }
@@ -307811,9 +308104,9 @@ var require_no_unsafe_call = __commonJS((exports) => {
307811
308104
  }
307812
308105
  context.report({
307813
308106
  node: reportingNode,
307814
- messageId,
308107
+ messageId: unsafeMessageId,
307815
308108
  data: {
307816
- type: "`Function`"
308109
+ type: "a `Function`"
307817
308110
  }
307818
308111
  });
307819
308112
  return;
@@ -307821,13 +308114,13 @@ var require_no_unsafe_call = __commonJS((exports) => {
307821
308114
  }
307822
308115
  return {
307823
308116
  "CallExpression > *.callee"(node) {
307824
- checkCall(node, node, "unsafeCall");
308117
+ checkCall(node, node, "unsafeCall", "errorCall");
307825
308118
  },
307826
308119
  NewExpression(node) {
307827
- checkCall(node.callee, node, "unsafeNew");
308120
+ checkCall(node.callee, node, "unsafeNew", "errorNew");
307828
308121
  },
307829
308122
  "TaggedTemplateExpression > *.tag"(node) {
307830
- checkCall(node, node, "unsafeTemplateTag");
308123
+ checkCall(node, node, "unsafeTemplateTag", "errorTemplateTag");
307831
308124
  }
307832
308125
  };
307833
308126
  }
@@ -308235,10 +308528,6 @@ var require_no_unsafe_member_access = __commonJS((exports) => {
308235
308528
  State2[State2["Safe"] = 2] = "Safe";
308236
308529
  State2[State2["Chained"] = 3] = "Chained";
308237
308530
  })(State || (State = {}));
308238
- function createDataType(type) {
308239
- const isErrorType = tsutils.isIntrinsicErrorType(type);
308240
- return isErrorType ? "`error` typed" : "`any`";
308241
- }
308242
308531
  exports.default = (0, util_1.createRule)({
308243
308532
  name: "no-unsafe-member-access",
308244
308533
  meta: {
@@ -308249,8 +308538,15 @@ var require_no_unsafe_member_access = __commonJS((exports) => {
308249
308538
  requiresTypeChecking: true
308250
308539
  },
308251
308540
  messages: {
308252
- unsafeComputedMemberAccess: "Computed name {{property}} resolves to an {{type}} value.",
308253
- unsafeMemberExpression: "Unsafe member access {{property}} on an {{type}} value.",
308541
+ errorComputedMemberAccess: "The type of computed name {{property}} cannot be resolved.",
308542
+ errorMemberExpression: "Unsafe member access {{property}} on a type that cannot be resolved.",
308543
+ errorThisMemberExpression: [
308544
+ "Unsafe member access {{property}}. The type of `this` cannot be resolved.",
308545
+ "You can try to fix this by turning on the `noImplicitThis` compiler option, or adding a `this` parameter to the function."
308546
+ ].join(`
308547
+ `),
308548
+ unsafeComputedMemberAccess: "Computed name {{property}} resolves to an `any` value.",
308549
+ unsafeMemberExpression: "Unsafe member access {{property}} on an `any` value.",
308254
308550
  unsafeThisMemberExpression: [
308255
308551
  "Unsafe member access {{property}} on an `any` value. `this` is typed as `any`.",
308256
308552
  "You can try to fix this by turning on the `noImplicitThis` compiler option, or adding a `this` parameter to the function."
@@ -308301,18 +308597,23 @@ var require_no_unsafe_member_access = __commonJS((exports) => {
308301
308597
  stateCache.set(node, state);
308302
308598
  if (state === State.Unsafe) {
308303
308599
  const propertyName = context.sourceCode.getText(node.property);
308304
- let messageId = "unsafeMemberExpression";
308600
+ let messageId;
308305
308601
  if (!isNoImplicitThis) {
308306
308602
  const thisExpression = (0, util_1.getThisExpression)(node);
308307
- if (thisExpression && (0, util_1.isTypeAnyType)((0, util_1.getConstrainedTypeAtLocation)(services, thisExpression))) {
308308
- messageId = "unsafeThisMemberExpression";
308603
+ if (thisExpression) {
308604
+ const thisType = (0, util_1.getConstrainedTypeAtLocation)(services, thisExpression);
308605
+ if ((0, util_1.isTypeAnyType)(thisType)) {
308606
+ messageId = tsutils.isIntrinsicErrorType(thisType) ? "errorThisMemberExpression" : "unsafeThisMemberExpression";
308607
+ }
308309
308608
  }
308310
308609
  }
308610
+ if (!messageId) {
308611
+ messageId = tsutils.isIntrinsicErrorType(type) ? "errorMemberExpression" : "unsafeMemberExpression";
308612
+ }
308311
308613
  context.report({
308312
308614
  node: node.property,
308313
308615
  messageId,
308314
308616
  data: {
308315
- type: createDataType(type),
308316
308617
  property: node.computed ? `[${propertyName}]` : `.${propertyName}`
308317
308618
  }
308318
308619
  });
@@ -308333,9 +308634,8 @@ var require_no_unsafe_member_access = __commonJS((exports) => {
308333
308634
  const propertyName = context.sourceCode.getText(node);
308334
308635
  context.report({
308335
308636
  node,
308336
- messageId: "unsafeComputedMemberAccess",
308637
+ messageId: tsutils.isIntrinsicErrorType(type) ? "errorComputedMemberAccess" : "unsafeComputedMemberAccess",
308337
308638
  data: {
308338
- type: createDataType(type),
308339
308639
  property: `[${propertyName}]`
308340
308640
  }
308341
308641
  });
@@ -309335,6 +309635,42 @@ var require_no_unused_vars2 = __commonJS((exports) => {
309335
309635
  var utils_1 = require_dist10();
309336
309636
  var util_1 = require_util3();
309337
309637
  var referenceContainsTypeQuery_1 = require_referenceContainsTypeQuery();
309638
+ var VariableType;
309639
+ (function(VariableType2) {
309640
+ VariableType2[VariableType2["ArrayDestructure"] = 0] = "ArrayDestructure";
309641
+ VariableType2[VariableType2["CatchClause"] = 1] = "CatchClause";
309642
+ VariableType2[VariableType2["ClassName"] = 2] = "ClassName";
309643
+ VariableType2[VariableType2["FunctionName"] = 3] = "FunctionName";
309644
+ VariableType2[VariableType2["ImportBinding"] = 4] = "ImportBinding";
309645
+ VariableType2[VariableType2["ImplicitGlobalVariable"] = 5] = "ImplicitGlobalVariable";
309646
+ VariableType2[VariableType2["Parameter"] = 6] = "Parameter";
309647
+ VariableType2[VariableType2["TSEnumMember"] = 7] = "TSEnumMember";
309648
+ VariableType2[VariableType2["TSEnumName"] = 8] = "TSEnumName";
309649
+ VariableType2[VariableType2["TSModuleName"] = 9] = "TSModuleName";
309650
+ VariableType2[VariableType2["Type"] = 10] = "Type";
309651
+ VariableType2[VariableType2["Variable"] = 11] = "Variable";
309652
+ })(VariableType || (VariableType = {}));
309653
+ var isCommaToken = {
309654
+ predicate: (token) => token.type === utils_1.AST_TOKEN_TYPES.Punctuator && token.value === ",",
309655
+ tokenChar: ","
309656
+ };
309657
+ var isLeftCurlyToken = {
309658
+ predicate: (token) => token.type === utils_1.AST_TOKEN_TYPES.Punctuator && token.value === "{",
309659
+ tokenChar: "{"
309660
+ };
309661
+ var isRightCurlyToken = {
309662
+ predicate: (token) => token.type === utils_1.AST_TOKEN_TYPES.Punctuator && token.value === "}",
309663
+ tokenChar: "}"
309664
+ };
309665
+ function assertToken({ predicate, tokenChar }, token) {
309666
+ if (token == null) {
309667
+ throw new Error(`Expected a valid "${tokenChar}" token, but found no token`);
309668
+ }
309669
+ if (!predicate(token)) {
309670
+ throw new Error(`Expected a valid "${tokenChar}" token, but got "${token.value}" instead`);
309671
+ }
309672
+ return token;
309673
+ }
309338
309674
  exports.default = (0, util_1.createRule)({
309339
309675
  name: "no-unused-vars",
309340
309676
  meta: {
@@ -309344,7 +309680,11 @@ var require_no_unused_vars2 = __commonJS((exports) => {
309344
309680
  extendsBaseRule: true,
309345
309681
  recommended: "recommended"
309346
309682
  },
309683
+ fixable: "code",
309684
+ hasSuggestions: true,
309347
309685
  messages: {
309686
+ removeUnusedImportDeclaration: "Remove unused import declaration.",
309687
+ removeUnusedVar: 'Remove unused variable "{{varName}}".',
309348
309688
  unusedVar: "'{{varName}}' is {{action}} but never used{{additional}}.",
309349
309689
  usedIgnoredVar: "'{{varName}}' is marked as ignored but is used{{additional}}.",
309350
309690
  usedOnlyAsType: "'{{varName}}' is {{action}} but only used as a type{{additional}}."
@@ -309383,6 +309723,17 @@ var require_no_unused_vars2 = __commonJS((exports) => {
309383
309723
  type: "string",
309384
309724
  description: "Regular expressions of destructured array variable names to not check for usage."
309385
309725
  },
309726
+ enableAutofixRemoval: {
309727
+ type: "object",
309728
+ additionalProperties: false,
309729
+ description: "Configurable automatic fixes for different types of unused variables.",
309730
+ properties: {
309731
+ imports: {
309732
+ type: "boolean",
309733
+ description: "Whether to enable automatic removal of unused imports."
309734
+ }
309735
+ }
309736
+ },
309386
309737
  ignoreClassWithStaticInitBlock: {
309387
309738
  type: "boolean",
309388
309739
  description: "Whether to ignore classes with at least one static initialization block."
@@ -309417,10 +309768,94 @@ var require_no_unused_vars2 = __commonJS((exports) => {
309417
309768
  defaultOptions: [{}],
309418
309769
  create(context, [firstOption]) {
309419
309770
  const MODULE_DECL_CACHE = new Map;
309771
+ const reportedUnusedVariables = new Set;
309772
+ function areAllSpecifiersUnused(decl) {
309773
+ return context.sourceCode.getDeclaredVariables(decl).every((variable) => {
309774
+ return reportedUnusedVariables.has(variable);
309775
+ });
309776
+ }
309777
+ const report = (unusedVar, opts) => {
309778
+ reportedUnusedVariables.add(unusedVar);
309779
+ const writeReferences = unusedVar.references.filter((ref) => ref.isWrite() && ref.from.variableScope === unusedVar.scope.variableScope);
309780
+ const id = writeReferences.length ? writeReferences[writeReferences.length - 1].identifier : unusedVar.identifiers[0];
309781
+ const { start } = id.loc;
309782
+ const idLength = id.name.length;
309783
+ const loc = {
309784
+ start,
309785
+ end: {
309786
+ column: start.column + idLength,
309787
+ line: start.line
309788
+ }
309789
+ };
309790
+ const fixer = (() => {
309791
+ const { messageId, fix, useAutofix } = (() => {
309792
+ if (unusedVar.defs.length !== 1) {
309793
+ return {};
309794
+ }
309795
+ const { type, def } = defToVariableType(unusedVar.defs[0]);
309796
+ switch (type) {
309797
+ case VariableType.ArrayDestructure:
309798
+ return {};
309799
+ case VariableType.CatchClause:
309800
+ return {};
309801
+ case VariableType.ClassName:
309802
+ return {};
309803
+ case VariableType.FunctionName:
309804
+ return {};
309805
+ case VariableType.ImportBinding:
309806
+ return {
309807
+ ...getImportFixer(def),
309808
+ useAutofix: options.enableAutofixRemoval.imports
309809
+ };
309810
+ case VariableType.ImplicitGlobalVariable:
309811
+ return {};
309812
+ case VariableType.Parameter:
309813
+ return {};
309814
+ case VariableType.TSEnumMember:
309815
+ return {};
309816
+ case VariableType.TSEnumName:
309817
+ return {};
309818
+ case VariableType.TSModuleName:
309819
+ return {};
309820
+ case VariableType.Type:
309821
+ return {};
309822
+ case VariableType.Variable:
309823
+ return {};
309824
+ }
309825
+ })();
309826
+ if (!fix) {
309827
+ return {};
309828
+ }
309829
+ if (useAutofix) {
309830
+ return { fix };
309831
+ }
309832
+ const data = {
309833
+ varName: unusedVar.name
309834
+ };
309835
+ return {
309836
+ suggest: [
309837
+ {
309838
+ messageId: messageId ?? "removeUnusedVar",
309839
+ data,
309840
+ fix
309841
+ }
309842
+ ]
309843
+ };
309844
+ })();
309845
+ context.report({
309846
+ ...opts,
309847
+ ...fixer,
309848
+ loc,
309849
+ node: id
309850
+ });
309851
+ };
309420
309852
  const options = (() => {
309421
309853
  const options2 = {
309422
309854
  args: "after-used",
309423
309855
  caughtErrors: "all",
309856
+ enableAutofixRemoval: {
309857
+ imports: false
309858
+ },
309424
309859
  ignoreClassWithStaticInitBlock: false,
309425
309860
  ignoreRestSiblings: false,
309426
309861
  ignoreUsingDeclarations: false,
@@ -309449,40 +309884,136 @@ var require_no_unused_vars2 = __commonJS((exports) => {
309449
309884
  if (firstOption.destructuredArrayIgnorePattern) {
309450
309885
  options2.destructuredArrayIgnorePattern = new RegExp(firstOption.destructuredArrayIgnorePattern, "u");
309451
309886
  }
309887
+ if (firstOption.enableAutofixRemoval) {
309888
+ if (firstOption.enableAutofixRemoval.imports != null) {
309889
+ options2.enableAutofixRemoval.imports = firstOption.enableAutofixRemoval.imports;
309890
+ }
309891
+ }
309452
309892
  }
309453
309893
  return options2;
309454
309894
  })();
309895
+ function getImportFixer(def) {
309896
+ switch (def.node.type) {
309897
+ case utils_1.AST_NODE_TYPES.TSImportEqualsDeclaration:
309898
+ return {
309899
+ messageId: "removeUnusedImportDeclaration",
309900
+ fix: (fixer) => fixer.remove(def.node)
309901
+ };
309902
+ case utils_1.AST_NODE_TYPES.ImportDefaultSpecifier: {
309903
+ const importDecl = def.node.parent;
309904
+ if (importDecl.specifiers.length === 1 || areAllSpecifiersUnused(importDecl)) {
309905
+ return {
309906
+ messageId: "removeUnusedImportDeclaration",
309907
+ fix: (fixer) => fixer.remove(importDecl)
309908
+ };
309909
+ }
309910
+ return {
309911
+ messageId: "removeUnusedVar",
309912
+ fix: (fixer) => {
309913
+ const comma = (0, util_1.nullThrows)(context.sourceCode.getTokenAfter(def.node), util_1.NullThrowsReasons.MissingToken(",", "import specifier"));
309914
+ assertToken(isCommaToken, comma);
309915
+ return fixer.removeRange([
309916
+ Math.min(def.node.range[0], comma.range[0]),
309917
+ Math.max(def.node.range[1], comma.range[1])
309918
+ ]);
309919
+ }
309920
+ };
309921
+ }
309922
+ case utils_1.AST_NODE_TYPES.ImportSpecifier: {
309923
+ const importDecl = def.node.parent;
309924
+ if (importDecl.specifiers.length === 1 || areAllSpecifiersUnused(importDecl)) {
309925
+ return {
309926
+ messageId: "removeUnusedImportDeclaration",
309927
+ fix: (fixer) => fixer.remove(importDecl)
309928
+ };
309929
+ }
309930
+ return {
309931
+ messageId: "removeUnusedVar",
309932
+ fix: (fixer) => {
309933
+ const usedNamedSpecifiers = context.sourceCode.getDeclaredVariables(importDecl).map((variable) => {
309934
+ if (reportedUnusedVariables.has(variable)) {
309935
+ return null;
309936
+ }
309937
+ const specifier = variable.defs[0].node;
309938
+ if (specifier.type !== utils_1.AST_NODE_TYPES.ImportSpecifier) {
309939
+ return null;
309940
+ }
309941
+ return specifier;
309942
+ }).filter((v) => v != null);
309943
+ if (usedNamedSpecifiers.length === 0) {
309944
+ const leftCurly = assertToken(isLeftCurlyToken, context.sourceCode.getFirstToken(importDecl, isLeftCurlyToken.predicate));
309945
+ const leftToken = assertToken(isCommaToken, context.sourceCode.getTokenBefore(leftCurly));
309946
+ const rightToken = assertToken(isRightCurlyToken, context.sourceCode.getFirstToken(importDecl, isRightCurlyToken.predicate));
309947
+ return fixer.removeRange([
309948
+ leftToken.range[0],
309949
+ rightToken.range[1]
309950
+ ]);
309951
+ }
309952
+ const maybeComma = context.sourceCode.getTokenBefore(def.node);
309953
+ const comma = maybeComma && isCommaToken.predicate(maybeComma) ? maybeComma : assertToken(isCommaToken, context.sourceCode.getTokenAfter(def.node));
309954
+ return fixer.removeRange([
309955
+ Math.min(def.node.range[0], comma.range[0]),
309956
+ Math.max(def.node.range[1], comma.range[1])
309957
+ ]);
309958
+ }
309959
+ };
309960
+ }
309961
+ case utils_1.AST_NODE_TYPES.ImportNamespaceSpecifier: {
309962
+ const importDecl = def.node.parent;
309963
+ return {
309964
+ messageId: "removeUnusedImportDeclaration",
309965
+ fix: (fixer) => fixer.remove(importDecl)
309966
+ };
309967
+ }
309968
+ }
309969
+ }
309455
309970
  function defToVariableType(def) {
309456
309971
  if (options.destructuredArrayIgnorePattern && def.name.parent.type === utils_1.AST_NODE_TYPES.ArrayPattern) {
309457
- return "array-destructure";
309972
+ return { type: VariableType.ArrayDestructure, def };
309458
309973
  }
309459
309974
  switch (def.type) {
309460
309975
  case scope_manager_1.DefinitionType.CatchClause:
309461
- return "catch-clause";
309976
+ return { type: VariableType.CatchClause, def };
309977
+ case scope_manager_1.DefinitionType.ClassName:
309978
+ return { type: VariableType.ClassName, def };
309979
+ case scope_manager_1.DefinitionType.FunctionName:
309980
+ return { type: VariableType.FunctionName, def };
309981
+ case scope_manager_1.DefinitionType.ImplicitGlobalVariable:
309982
+ return { type: VariableType.ImplicitGlobalVariable, def };
309983
+ case scope_manager_1.DefinitionType.ImportBinding:
309984
+ return { type: VariableType.ImportBinding, def };
309462
309985
  case scope_manager_1.DefinitionType.Parameter:
309463
- return "parameter";
309464
- default:
309465
- return "variable";
309986
+ return { type: VariableType.Parameter, def };
309987
+ case scope_manager_1.DefinitionType.TSEnumName:
309988
+ return { type: VariableType.TSEnumName, def };
309989
+ case scope_manager_1.DefinitionType.TSEnumMember:
309990
+ return { type: VariableType.TSEnumMember, def };
309991
+ case scope_manager_1.DefinitionType.TSModuleName:
309992
+ return { type: VariableType.TSModuleName, def };
309993
+ case scope_manager_1.DefinitionType.Type:
309994
+ return { type: VariableType.Type, def };
309995
+ case scope_manager_1.DefinitionType.Variable:
309996
+ return { type: VariableType.Variable, def };
309466
309997
  }
309467
309998
  }
309468
309999
  function getVariableDescription(variableType) {
309469
310000
  switch (variableType) {
309470
- case "array-destructure":
310001
+ case VariableType.ArrayDestructure:
309471
310002
  return {
309472
310003
  pattern: options.destructuredArrayIgnorePattern?.toString(),
309473
310004
  variableDescription: "elements of array destructuring"
309474
310005
  };
309475
- case "catch-clause":
310006
+ case VariableType.CatchClause:
309476
310007
  return {
309477
310008
  pattern: options.caughtErrorsIgnorePattern?.toString(),
309478
310009
  variableDescription: "caught errors"
309479
310010
  };
309480
- case "parameter":
310011
+ case VariableType.Parameter:
309481
310012
  return {
309482
310013
  pattern: options.argsIgnorePattern?.toString(),
309483
310014
  variableDescription: "args"
309484
310015
  };
309485
- case "variable":
310016
+ default:
309486
310017
  return {
309487
310018
  pattern: options.varsIgnorePattern?.toString(),
309488
310019
  variableDescription: "vars"
@@ -309493,7 +310024,7 @@ var require_no_unused_vars2 = __commonJS((exports) => {
309493
310024
  const def = unusedVar.defs.at(0);
309494
310025
  let additionalMessageData = "";
309495
310026
  if (def) {
309496
- const { pattern, variableDescription } = getVariableDescription(defToVariableType(def));
310027
+ const { pattern, variableDescription } = getVariableDescription(defToVariableType(def).type);
309497
310028
  if (pattern && variableDescription) {
309498
310029
  additionalMessageData = `. Allowed unused ${variableDescription} must match ${pattern}`;
309499
310030
  }
@@ -309508,7 +310039,7 @@ var require_no_unused_vars2 = __commonJS((exports) => {
309508
310039
  const def = unusedVar.defs.at(0);
309509
310040
  let additionalMessageData = "";
309510
310041
  if (def) {
309511
- const { pattern, variableDescription } = getVariableDescription(defToVariableType(def));
310042
+ const { pattern, variableDescription } = getVariableDescription(defToVariableType(def).type);
309512
310043
  if (pattern && variableDescription) {
309513
310044
  additionalMessageData = `. Allowed unused ${variableDescription} must match ${pattern}`;
309514
310045
  }
@@ -309574,10 +310105,9 @@ var require_no_unused_vars2 = __commonJS((exports) => {
309574
310105
  const refUsedInArrayPatterns = variable.references.some((ref) => ref.identifier.parent.type === utils_1.AST_NODE_TYPES.ArrayPattern);
309575
310106
  if ((def.name.parent.type === utils_1.AST_NODE_TYPES.ArrayPattern || refUsedInArrayPatterns) && def.name.type === utils_1.AST_NODE_TYPES.Identifier && options.destructuredArrayIgnorePattern?.test(def.name.name)) {
309576
310107
  if (options.reportUsedIgnorePattern && used) {
309577
- context.report({
309578
- node: def.name,
310108
+ report(variable, {
309579
310109
  messageId: "usedIgnoredVar",
309580
- data: getUsedIgnoredMessageData(variable, "array-destructure")
310110
+ data: getUsedIgnoredMessageData(variable, VariableType.ArrayDestructure)
309581
310111
  });
309582
310112
  }
309583
310113
  continue;
@@ -309594,10 +310124,9 @@ var require_no_unused_vars2 = __commonJS((exports) => {
309594
310124
  }
309595
310125
  if (def.name.type === utils_1.AST_NODE_TYPES.Identifier && options.caughtErrorsIgnorePattern?.test(def.name.name)) {
309596
310126
  if (options.reportUsedIgnorePattern && used) {
309597
- context.report({
309598
- node: def.name,
310127
+ report(variable, {
309599
310128
  messageId: "usedIgnoredVar",
309600
- data: getUsedIgnoredMessageData(variable, "catch-clause")
310129
+ data: getUsedIgnoredMessageData(variable, VariableType.CatchClause)
309601
310130
  });
309602
310131
  }
309603
310132
  continue;
@@ -309608,10 +310137,9 @@ var require_no_unused_vars2 = __commonJS((exports) => {
309608
310137
  }
309609
310138
  if (def.name.type === utils_1.AST_NODE_TYPES.Identifier && options.argsIgnorePattern?.test(def.name.name)) {
309610
310139
  if (options.reportUsedIgnorePattern && used) {
309611
- context.report({
309612
- node: def.name,
310140
+ report(variable, {
309613
310141
  messageId: "usedIgnoredVar",
309614
- data: getUsedIgnoredMessageData(variable, "parameter")
310142
+ data: getUsedIgnoredMessageData(variable, VariableType.Parameter)
309615
310143
  });
309616
310144
  }
309617
310145
  continue;
@@ -309621,10 +310149,9 @@ var require_no_unused_vars2 = __commonJS((exports) => {
309621
310149
  }
309622
310150
  } else if (def.name.type === utils_1.AST_NODE_TYPES.Identifier && options.varsIgnorePattern?.test(def.name.name)) {
309623
310151
  if (options.reportUsedIgnorePattern && used && def.type !== utils_1.TSESLint.Scope.DefinitionType.TSEnumMember) {
309624
- context.report({
309625
- node: def.name,
310152
+ report(variable, {
309626
310153
  messageId: "usedIgnoredVar",
309627
- data: getUsedIgnoredMessageData(variable, "variable")
310154
+ data: getUsedIgnoredMessageData(variable, VariableType.Variable)
309628
310155
  });
309629
310156
  }
309630
310157
  continue;
@@ -309684,24 +310211,12 @@ var require_no_unused_vars2 = __commonJS((exports) => {
309684
310211
  for (const unusedVar of unusedVars) {
309685
310212
  if (unusedVar.defs.length > 0) {
309686
310213
  const usedOnlyAsType = unusedVar.references.some((ref) => (0, referenceContainsTypeQuery_1.referenceContainsTypeQuery)(ref.identifier));
310214
+ const messageId = usedOnlyAsType ? "usedOnlyAsType" : "unusedVar";
309687
310215
  const isImportUsedOnlyAsType = usedOnlyAsType && unusedVar.defs.some((def) => def.type === scope_manager_1.DefinitionType.ImportBinding);
309688
310216
  if (isImportUsedOnlyAsType) {
309689
310217
  continue;
309690
310218
  }
309691
- const writeReferences = unusedVar.references.filter((ref) => ref.isWrite() && ref.from.variableScope === unusedVar.scope.variableScope);
309692
- const id = writeReferences.length ? writeReferences[writeReferences.length - 1].identifier : unusedVar.identifiers[0];
309693
- const messageId = usedOnlyAsType ? "usedOnlyAsType" : "unusedVar";
309694
- const { start } = id.loc;
309695
- const idLength = id.name.length;
309696
- const loc = {
309697
- start,
309698
- end: {
309699
- column: start.column + idLength,
309700
- line: start.line
309701
- }
309702
- };
309703
- context.report({
309704
- loc,
310219
+ report(unusedVar, {
309705
310220
  messageId,
309706
310221
  data: unusedVar.references.some((ref) => ref.isWrite()) ? getAssignedMessageData(unusedVar) : getDefinedMessageData(unusedVar)
309707
310222
  });
@@ -310170,13 +310685,6 @@ var require_no_useless_default_assignment = __commonJS((exports) => {
310170
310685
  }
310171
310686
  return tsutils.unionConstituents(type).some((part) => (0, util_1.isTypeFlagSet)(part, ts.TypeFlags.Undefined));
310172
310687
  }
310173
- function getPropertyType(objectType, propertyName) {
310174
- const symbol = objectType.getProperty(propertyName);
310175
- if (!symbol) {
310176
- return null;
310177
- }
310178
- return checker.getTypeOfSymbol(symbol);
310179
- }
310180
310688
  function getArrayElementType(arrayType, elementIndex) {
310181
310689
  if (checker.isTupleType(arrayType)) {
310182
310690
  const tupleArgs = checker.getTypeArguments(arrayType);
@@ -310214,6 +310722,9 @@ var require_no_useless_default_assignment = __commonJS((exports) => {
310214
310722
  const params = signatures[0].getParameters();
310215
310723
  if (paramIndex < params.length) {
310216
310724
  const paramSymbol = params[paramIndex];
310725
+ if (paramSymbol.valueDeclaration && ts.isParameter(paramSymbol.valueDeclaration) && paramSymbol.valueDeclaration.dotDotDotToken != null) {
310726
+ return;
310727
+ }
310217
310728
  if ((paramSymbol.flags & ts.SymbolFlags.Optional) === 0) {
310218
310729
  const paramType = checker.getTypeOfSymbol(paramSymbol);
310219
310730
  if (!canBeUndefined(paramType)) {
@@ -310262,7 +310773,24 @@ var require_no_useless_default_assignment = __commonJS((exports) => {
310262
310773
  if (!propertyName) {
310263
310774
  return null;
310264
310775
  }
310265
- return getPropertyType(sourceType, propertyName);
310776
+ const symbol = sourceType.getProperty(propertyName);
310777
+ if (!symbol) {
310778
+ return null;
310779
+ }
310780
+ if (symbol.flags & ts.SymbolFlags.Optional && hasConditionalInitializer(objectPattern)) {
310781
+ return null;
310782
+ }
310783
+ return checker.getTypeOfSymbol(symbol);
310784
+ }
310785
+ function hasConditionalInitializer(node) {
310786
+ const parent = node.parent;
310787
+ if (!parent) {
310788
+ return false;
310789
+ }
310790
+ if (parent.type === utils_1.AST_NODE_TYPES.VariableDeclarator && parent.init) {
310791
+ return parent.init.type === utils_1.AST_NODE_TYPES.ConditionalExpression || parent.init.type === utils_1.AST_NODE_TYPES.LogicalExpression;
310792
+ }
310793
+ return hasConditionalInitializer(parent);
310266
310794
  }
310267
310795
  function getSourceTypeForPattern(pattern) {
310268
310796
  const parent = (0, util_1.nullThrows)(pattern.parent, util_1.NullThrowsReasons.MissingParent);
@@ -310284,12 +310812,11 @@ var require_no_useless_default_assignment = __commonJS((exports) => {
310284
310812
  return getTypeOfProperty(parent);
310285
310813
  }
310286
310814
  if (parent.type === utils_1.AST_NODE_TYPES.ArrayPattern) {
310287
- const arrayPattern = parent;
310288
- const arrayType = getSourceTypeForPattern(arrayPattern);
310815
+ const arrayType = getSourceTypeForPattern(parent);
310289
310816
  if (!arrayType) {
310290
310817
  return null;
310291
310818
  }
310292
- const elementIndex = arrayPattern.elements.indexOf(pattern);
310819
+ const elementIndex = parent.elements.indexOf(pattern);
310293
310820
  return getArrayElementType(arrayType, elementIndex);
310294
310821
  }
310295
310822
  return null;
@@ -317564,6 +318091,272 @@ var require_strict_boolean_expressions = __commonJS((exports) => {
317564
318091
  }
317565
318092
  });
317566
318093
 
318094
+ // ../../node_modules/@typescript-eslint/eslint-plugin/dist/rules/strict-void-return.js
318095
+ var require_strict_void_return = __commonJS((exports) => {
318096
+ var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
318097
+ if (k2 === undefined)
318098
+ k2 = k;
318099
+ var desc = Object.getOwnPropertyDescriptor(m, k);
318100
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
318101
+ desc = { enumerable: true, get: function() {
318102
+ return m[k];
318103
+ } };
318104
+ }
318105
+ Object.defineProperty(o, k2, desc);
318106
+ } : function(o, m, k, k2) {
318107
+ if (k2 === undefined)
318108
+ k2 = k;
318109
+ o[k2] = m[k];
318110
+ });
318111
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
318112
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
318113
+ } : function(o, v) {
318114
+ o["default"] = v;
318115
+ });
318116
+ var __importStar = exports && exports.__importStar || function() {
318117
+ var ownKeys = function(o) {
318118
+ ownKeys = Object.getOwnPropertyNames || function(o2) {
318119
+ var ar = [];
318120
+ for (var k in o2)
318121
+ if (Object.prototype.hasOwnProperty.call(o2, k))
318122
+ ar[ar.length] = k;
318123
+ return ar;
318124
+ };
318125
+ return ownKeys(o);
318126
+ };
318127
+ return function(mod) {
318128
+ if (mod && mod.__esModule)
318129
+ return mod;
318130
+ var result = {};
318131
+ if (mod != null) {
318132
+ for (var k = ownKeys(mod), i = 0;i < k.length; i++)
318133
+ if (k[i] !== "default")
318134
+ __createBinding(result, mod, k[i]);
318135
+ }
318136
+ __setModuleDefault(result, mod);
318137
+ return result;
318138
+ };
318139
+ }();
318140
+ Object.defineProperty(exports, "__esModule", { value: true });
318141
+ var utils_1 = require_dist10();
318142
+ var tsutils = __importStar(require_lib4());
318143
+ var ts = __importStar(require_typescript());
318144
+ var util = __importStar(require_util3());
318145
+ exports.default = util.createRule({
318146
+ name: "strict-void-return",
318147
+ meta: {
318148
+ type: "problem",
318149
+ docs: {
318150
+ description: "Disallow passing a value-returning function in a position accepting a void function",
318151
+ requiresTypeChecking: true
318152
+ },
318153
+ messages: {
318154
+ asyncFunc: "Async function used in a context where a void function is expected.",
318155
+ nonVoidFunc: "Value-returning function used in a context where a void function is expected.",
318156
+ nonVoidReturn: "Value returned in a context where a void return is expected."
318157
+ },
318158
+ schema: [
318159
+ {
318160
+ type: "object",
318161
+ additionalProperties: false,
318162
+ properties: {
318163
+ allowReturnAny: {
318164
+ type: "boolean",
318165
+ description: "Whether to allow functions returning `any` to be used in place expecting a `void` function."
318166
+ }
318167
+ }
318168
+ }
318169
+ ]
318170
+ },
318171
+ defaultOptions: [
318172
+ {
318173
+ allowReturnAny: false
318174
+ }
318175
+ ],
318176
+ create(context, [options]) {
318177
+ const sourceCode = context.sourceCode;
318178
+ const parserServices = util.getParserServices(context);
318179
+ const checker = parserServices.program.getTypeChecker();
318180
+ return {
318181
+ ArrayExpression: (node) => {
318182
+ for (const elemNode of node.elements) {
318183
+ if (elemNode != null && elemNode.type !== utils_1.AST_NODE_TYPES.SpreadElement) {
318184
+ checkExpressionNode(elemNode);
318185
+ }
318186
+ }
318187
+ },
318188
+ ArrowFunctionExpression: (node) => {
318189
+ if (node.body.type !== utils_1.AST_NODE_TYPES.BlockStatement) {
318190
+ checkExpressionNode(node.body);
318191
+ }
318192
+ },
318193
+ AssignmentExpression: (node) => {
318194
+ checkExpressionNode(node.right);
318195
+ },
318196
+ "CallExpression, NewExpression": checkFunctionCallNode,
318197
+ JSXAttribute: (node) => {
318198
+ if (node.value?.type === utils_1.AST_NODE_TYPES.JSXExpressionContainer && node.value.expression.type !== utils_1.AST_NODE_TYPES.JSXEmptyExpression) {
318199
+ checkExpressionNode(node.value.expression);
318200
+ }
318201
+ },
318202
+ MethodDefinition: checkClassMethodNode,
318203
+ ObjectExpression: (node) => {
318204
+ for (const propNode of node.properties) {
318205
+ if (propNode.type !== utils_1.AST_NODE_TYPES.SpreadElement) {
318206
+ checkObjectPropertyNode(propNode);
318207
+ }
318208
+ }
318209
+ },
318210
+ PropertyDefinition: checkClassPropertyNode,
318211
+ ReturnStatement: (node) => {
318212
+ if (node.argument != null) {
318213
+ checkExpressionNode(node.argument);
318214
+ }
318215
+ },
318216
+ VariableDeclarator: (node) => {
318217
+ if (node.init != null) {
318218
+ checkExpressionNode(node.init);
318219
+ }
318220
+ }
318221
+ };
318222
+ function isVoidReturningFunctionType(type) {
318223
+ const returnTypes = tsutils.getCallSignaturesOfType(type).flatMap((signature) => tsutils.unionConstituents(signature.getReturnType()));
318224
+ return returnTypes.length > 0 && returnTypes.every((type2) => tsutils.isTypeFlagSet(type2, ts.TypeFlags.Void));
318225
+ }
318226
+ function checkExpressionNode(node) {
318227
+ const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);
318228
+ const expectedType = checker.getContextualType(tsNode);
318229
+ if (expectedType != null && isVoidReturningFunctionType(expectedType)) {
318230
+ reportIfNonVoidFunction(node);
318231
+ return true;
318232
+ }
318233
+ return false;
318234
+ }
318235
+ function checkFunctionCallNode(callNode) {
318236
+ const callTsNode = parserServices.esTreeNodeToTSNodeMap.get(callNode);
318237
+ const funcType = checker.getTypeAtLocation(callTsNode.expression);
318238
+ const funcSignatures = tsutils.unionConstituents(funcType).flatMap((type) => ts.isCallExpression(callTsNode) ? type.getCallSignatures() : type.getConstructSignatures());
318239
+ for (const [argIdx, argNode] of callNode.arguments.entries()) {
318240
+ if (argNode.type === utils_1.AST_NODE_TYPES.SpreadElement) {
318241
+ continue;
318242
+ }
318243
+ if (checkExpressionNode(argNode)) {
318244
+ continue;
318245
+ }
318246
+ const argExpectedReturnTypes = funcSignatures.map((s) => s.parameters[argIdx]).filter(Boolean).map((param) => checker.getTypeOfSymbolAtLocation(param, callTsNode.expression)).flatMap((paramType) => tsutils.unionConstituents(paramType)).flatMap((paramType) => paramType.getCallSignatures()).map((paramSignature) => paramSignature.getReturnType());
318247
+ if (argExpectedReturnTypes.some((type) => tsutils.isTypeFlagSet(type, ts.TypeFlags.Void)) && argExpectedReturnTypes.every((type) => tsutils.isTypeFlagSet(type, ts.TypeFlags.VoidLike | ts.TypeFlags.Undefined | ts.TypeFlags.Null | ts.TypeFlags.Any | ts.TypeFlags.Never))) {
318248
+ reportIfNonVoidFunction(argNode);
318249
+ }
318250
+ }
318251
+ }
318252
+ function checkObjectPropertyNode(propNode) {
318253
+ const valueNode = propNode.value;
318254
+ const propTsNode = parserServices.esTreeNodeToTSNodeMap.get(propNode);
318255
+ if (propTsNode.kind === ts.SyntaxKind.MethodDeclaration) {
318256
+ if (propTsNode.name.kind === ts.SyntaxKind.ComputedPropertyName) {
318257
+ return;
318258
+ }
318259
+ const objTsNode = propTsNode.parent;
318260
+ const objType = checker.getContextualType(objTsNode);
318261
+ if (objType == null) {
318262
+ return;
318263
+ }
318264
+ const propSymbol = checker.getPropertyOfType(objType, propTsNode.name.text);
318265
+ if (propSymbol == null) {
318266
+ return;
318267
+ }
318268
+ const propExpectedType = checker.getTypeOfSymbolAtLocation(propSymbol, propTsNode);
318269
+ if (isVoidReturningFunctionType(propExpectedType)) {
318270
+ reportIfNonVoidFunction(valueNode);
318271
+ }
318272
+ return;
318273
+ }
318274
+ checkExpressionNode(valueNode);
318275
+ }
318276
+ function checkClassPropertyNode(propNode) {
318277
+ if (propNode.value == null) {
318278
+ return;
318279
+ }
318280
+ for (const { baseMemberType } of util.getBaseTypesOfClassMember(parserServices, propNode)) {
318281
+ if (isVoidReturningFunctionType(baseMemberType)) {
318282
+ reportIfNonVoidFunction(propNode.value);
318283
+ return;
318284
+ }
318285
+ }
318286
+ checkExpressionNode(propNode.value);
318287
+ }
318288
+ function checkClassMethodNode(methodNode) {
318289
+ if (methodNode.value.type === utils_1.AST_NODE_TYPES.TSEmptyBodyFunctionExpression) {
318290
+ return;
318291
+ }
318292
+ for (const { baseMemberType } of util.getBaseTypesOfClassMember(parserServices, methodNode)) {
318293
+ if (isVoidReturningFunctionType(baseMemberType)) {
318294
+ reportIfNonVoidFunction(methodNode.value);
318295
+ return;
318296
+ }
318297
+ }
318298
+ }
318299
+ function reportIfNonVoidFunction(funcNode) {
318300
+ const allowedReturnType = ts.TypeFlags.Void | ts.TypeFlags.Never | ts.TypeFlags.Undefined | (options.allowReturnAny ? ts.TypeFlags.Any : 0);
318301
+ const tsNode = parserServices.esTreeNodeToTSNodeMap.get(funcNode);
318302
+ const actualType = checker.getApparentType(checker.getTypeAtLocation(tsNode));
318303
+ if (tsutils.getCallSignaturesOfType(actualType).map((signature) => signature.getReturnType()).flatMap((returnType) => tsutils.unionConstituents(returnType)).every((type) => tsutils.isTypeFlagSet(type, allowedReturnType))) {
318304
+ return;
318305
+ }
318306
+ if (funcNode.type !== utils_1.AST_NODE_TYPES.ArrowFunctionExpression && funcNode.type !== utils_1.AST_NODE_TYPES.FunctionExpression) {
318307
+ return context.report({
318308
+ node: funcNode,
318309
+ messageId: `nonVoidFunc`
318310
+ });
318311
+ }
318312
+ if (funcNode.generator) {
318313
+ return context.report({
318314
+ loc: util.getFunctionHeadLoc(funcNode, sourceCode),
318315
+ messageId: `nonVoidFunc`
318316
+ });
318317
+ }
318318
+ if (funcNode.async) {
318319
+ return context.report({
318320
+ loc: util.getFunctionHeadLoc(funcNode, sourceCode),
318321
+ messageId: `asyncFunc`
318322
+ });
318323
+ }
318324
+ if (funcNode.body.type !== utils_1.AST_NODE_TYPES.BlockStatement) {
318325
+ return context.report({
318326
+ node: funcNode.body,
318327
+ messageId: `nonVoidReturn`
318328
+ });
318329
+ }
318330
+ if (funcNode.returnType != null) {
318331
+ const typeAnnotationNode = funcNode.returnType.typeAnnotation;
318332
+ if (typeAnnotationNode.type !== utils_1.AST_NODE_TYPES.TSVoidKeyword) {
318333
+ return context.report({
318334
+ node: typeAnnotationNode,
318335
+ messageId: `nonVoidFunc`
318336
+ });
318337
+ }
318338
+ }
318339
+ for (const statement of util.walkStatements(funcNode.body.body)) {
318340
+ if (statement.type !== utils_1.AST_NODE_TYPES.ReturnStatement || statement.argument == null) {
318341
+ continue;
318342
+ }
318343
+ const returnType = checker.getTypeAtLocation(parserServices.esTreeNodeToTSNodeMap.get(statement.argument));
318344
+ if (tsutils.isTypeFlagSet(returnType, allowedReturnType)) {
318345
+ continue;
318346
+ }
318347
+ const returnKeyword = util.nullThrows(sourceCode.getFirstToken(statement, {
318348
+ filter: (token) => token.value === "return"
318349
+ }), util.NullThrowsReasons.MissingToken("return keyword", statement.type));
318350
+ context.report({
318351
+ node: returnKeyword,
318352
+ messageId: `nonVoidReturn`
318353
+ });
318354
+ }
318355
+ }
318356
+ }
318357
+ });
318358
+ });
318359
+
317567
318360
  // ../../node_modules/@typescript-eslint/eslint-plugin/dist/rules/switch-exhaustiveness-check.js
317568
318361
  var require_switch_exhaustiveness_check = __commonJS((exports) => {
317569
318362
  var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
@@ -319187,6 +319980,7 @@ var require_rules4 = __commonJS((exports, module) => {
319187
319980
  var return_await_1 = __importDefault(require_return_await());
319188
319981
  var sort_type_constituents_1 = __importDefault(require_sort_type_constituents());
319189
319982
  var strict_boolean_expressions_1 = __importDefault(require_strict_boolean_expressions());
319983
+ var strict_void_return_1 = __importDefault(require_strict_void_return());
319190
319984
  var switch_exhaustiveness_check_1 = __importDefault(require_switch_exhaustiveness_check());
319191
319985
  var triple_slash_reference_1 = __importDefault(require_triple_slash_reference());
319192
319986
  var typedef_1 = __importDefault(require_typedef());
@@ -319321,6 +320115,7 @@ var require_rules4 = __commonJS((exports, module) => {
319321
320115
  "return-await": return_await_1.default,
319322
320116
  "sort-type-constituents": sort_type_constituents_1.default,
319323
320117
  "strict-boolean-expressions": strict_boolean_expressions_1.default,
320118
+ "strict-void-return": strict_void_return_1.default,
319324
320119
  "switch-exhaustiveness-check": switch_exhaustiveness_check_1.default,
319325
320120
  "triple-slash-reference": triple_slash_reference_1.default,
319326
320121
  typedef: typedef_1.default,
@@ -319335,7 +320130,7 @@ var require_rules4 = __commonJS((exports, module) => {
319335
320130
  var require_package7 = __commonJS((exports, module) => {
319336
320131
  module.exports = {
319337
320132
  name: "@typescript-eslint/eslint-plugin",
319338
- version: "8.51.0",
320133
+ version: "8.53.0",
319339
320134
  description: "TypeScript plugin for ESLint",
319340
320135
  files: [
319341
320136
  "dist",
@@ -319393,39 +320188,39 @@ var require_package7 = __commonJS((exports, module) => {
319393
320188
  typecheck: "yarn run -BT nx typecheck"
319394
320189
  },
319395
320190
  dependencies: {
319396
- "@eslint-community/regexpp": "^4.10.0",
319397
- "@typescript-eslint/scope-manager": "8.51.0",
319398
- "@typescript-eslint/type-utils": "8.51.0",
319399
- "@typescript-eslint/utils": "8.51.0",
319400
- "@typescript-eslint/visitor-keys": "8.51.0",
319401
- ignore: "^7.0.0",
320191
+ "@eslint-community/regexpp": "^4.12.2",
320192
+ "@typescript-eslint/scope-manager": "8.53.0",
320193
+ "@typescript-eslint/type-utils": "8.53.0",
320194
+ "@typescript-eslint/utils": "8.53.0",
320195
+ "@typescript-eslint/visitor-keys": "8.53.0",
320196
+ ignore: "^7.0.5",
319402
320197
  "natural-compare": "^1.4.0",
319403
- "ts-api-utils": "^2.2.0"
320198
+ "ts-api-utils": "^2.4.0"
319404
320199
  },
319405
320200
  devDependencies: {
319406
- "@types/mdast": "^4.0.3",
320201
+ "@types/mdast": "^4.0.4",
319407
320202
  "@types/natural-compare": "*",
319408
- "@typescript-eslint/rule-schema-to-typescript-types": "8.51.0",
319409
- "@typescript-eslint/rule-tester": "8.51.0",
319410
- "@vitest/coverage-v8": "^3.1.3",
320203
+ "@typescript-eslint/rule-schema-to-typescript-types": "8.53.0",
320204
+ "@typescript-eslint/rule-tester": "8.53.0",
320205
+ "@vitest/coverage-v8": "^3.2.4",
319411
320206
  ajv: "^6.12.6",
319412
320207
  eslint: "*",
319413
320208
  "json-schema": "*",
319414
- "markdown-table": "^3.0.3",
319415
- marked: "^15.0.0",
319416
- "mdast-util-from-markdown": "^2.0.0",
320209
+ "markdown-table": "^3.0.4",
320210
+ marked: "^15.0.12",
320211
+ "mdast-util-from-markdown": "^2.0.2",
319417
320212
  "mdast-util-mdx": "^3.0.0",
319418
320213
  "micromark-extension-mdxjs": "^3.0.0",
319419
- prettier: "3.7.2",
320214
+ prettier: "3.7.4",
319420
320215
  rimraf: "*",
319421
- "title-case": "^4.0.0",
320216
+ "title-case": "^4.3.2",
319422
320217
  tsx: "*",
319423
320218
  typescript: "*",
319424
320219
  "unist-util-visit": "^5.0.0",
319425
- vitest: "^3.1.3"
320220
+ vitest: "^3.2.4"
319426
320221
  },
319427
320222
  peerDependencies: {
319428
- "@typescript-eslint/parser": "^8.51.0",
320223
+ "@typescript-eslint/parser": "^8.53.0",
319429
320224
  eslint: "^8.57.0 || ^9.0.0",
319430
320225
  typescript: ">=4.8.4 <6.0.0"
319431
320226
  },