@flint.fyi/ts 0.23.1 → 0.23.3

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 (3) hide show
  1. package/dist/index.d.mts +301 -1202
  2. package/dist/index.mjs +193 -238
  3. package/package.json +11 -10
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { RuleCreator, createPlugin } from "@flint.fyi/core";
2
2
  import { declarationIncludesGlobal, forEachChild, getModifyingReferences, getScopeManager, getStaticNumberValue, getStaticStringValue, getStaticValue, getTSNodeRange, hasSameTokens, isBuiltinArrayMethod, isFunction, isGlobalDeclaration, isGlobalDeclarationOfName, isGlobalVariable, isInlineArrayCreation, typescriptLanguage, unwrapParentParenthesizedExpressions, unwrapParenthesizedNode } from "@flint.fyi/typescript-language";
3
- import ts$1, { NodeFlags, SignatureKind, SymbolFlags, SyntaxKind, TypeFlags, getLeadingCommentRanges, getTrailingCommentRanges, isArrayLiteralExpression, isBigIntLiteral, isElementAccessExpression, isExpressionWithTypeArguments, isFunctionLike, isIdentifier, isInterfaceDeclaration, isLiteralExpression, isNewExpression, isNumericLiteral, isParenthesizedExpression, isPrefixUnaryExpression, isPropertyAccessExpression, isShorthandPropertyAssignment, isSpreadElement, isStringLiteral, isTypeNode, isTypeParameterDeclaration, isVariableDeclaration } from "typescript";
3
+ import ts$1, { NodeFlags, SignatureKind, SymbolFlags, SyntaxKind, TypeFlags, getLeadingCommentRanges, getTrailingCommentRanges, isLiteralExpression, isTypeNode } from "typescript";
4
4
  import * as tsutils from "ts-api-utils";
5
5
  import { isNodeFlagSet, isNullKeyword } from "ts-api-utils";
6
6
  import { nullThrows, pathKey } from "@flint.fyi/utils";
@@ -8,7 +8,7 @@ import z, { z as z$1 } from "zod/v4";
8
8
  import { RegExpParser, RegExpValidator, parseRegExpLiteral, visitRegExpAST } from "@eslint-community/regexpp";
9
9
  import { Chars, isPotentiallyEmpty, isZeroLength, toUnicodeSet } from "regexp-ast-analysis";
10
10
  import { analyse } from "scslre";
11
- import path from "node:path";
11
+ import { resolve } from "pathe";
12
12
  //#region src/rules/ruleCreator.ts
13
13
  const ruleCreator = new RuleCreator({
14
14
  docs: (ruleId) => `https://flint.fyi/rules/ts/${ruleId.toLowerCase()}`,
@@ -184,8 +184,8 @@ var accessorThisRecursion_default = ruleCreator.createRule(typescriptLanguage, {
184
184
  const isGetter = accessor.kind === SyntaxKind.GetAccessor;
185
185
  function checkNode(node) {
186
186
  if (tsutils.isFunctionScopeBoundary(node)) return;
187
- if (ts$1.isPropertyAccessExpression(node)) checkPropertyAccessExpression(node);
188
- ts$1.forEachChild(node, checkNode);
187
+ if (node.kind === SyntaxKind.PropertyAccessExpression) checkPropertyAccessExpression(node);
188
+ forEachChild(node, checkNode);
189
189
  }
190
190
  function checkPropertyAccessExpression(node) {
191
191
  if (node.name.text !== propertyName || node.expression.kind !== SyntaxKind.ThisKeyword) return;
@@ -196,7 +196,7 @@ var accessorThisRecursion_default = ruleCreator.createRule(typescriptLanguage, {
196
196
  end: node.getEnd()
197
197
  }
198
198
  });
199
- else if (ts$1.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === SyntaxKind.EqualsToken) context.report({
199
+ else if (node.parent.kind === SyntaxKind.BinaryExpression && node.parent.left === node && node.parent.operatorToken.kind === SyntaxKind.EqualsToken) context.report({
200
200
  message: "noSetterRecursion",
201
201
  range: {
202
202
  begin: node.getStart(sourceFile),
@@ -204,7 +204,7 @@ var accessorThisRecursion_default = ruleCreator.createRule(typescriptLanguage, {
204
204
  }
205
205
  });
206
206
  }
207
- ts$1.forEachChild(accessor.body, checkNode);
207
+ forEachChild(accessor.body, checkNode);
208
208
  }
209
209
  return { visitors: {
210
210
  GetAccessor: checkAccessor,
@@ -461,7 +461,7 @@ var anyArguments_default = ruleCreator.createRule(typescriptLanguage, {
461
461
  const lastParam = parameters.at(-1);
462
462
  if (!lastParam) return;
463
463
  const lastParamDeclaration = lastParam.declarations?.[0];
464
- if (lastParamDeclaration && ts$1.isParameter(lastParamDeclaration) && lastParamDeclaration.dotDotDotToken) {
464
+ if (lastParamDeclaration?.kind === SyntaxKind.Parameter && lastParamDeclaration.dotDotDotToken) {
465
465
  if (index < parameters.length - 1) {
466
466
  const param = parameters[index];
467
467
  if (!param) return;
@@ -581,7 +581,7 @@ var anyAssignments_default = ruleCreator.createRule(typescriptLanguage, {
581
581
  let didReport = false;
582
582
  for (let i = 0; i < pattern.elements.length; i++) {
583
583
  const element = pattern.elements[i];
584
- if (!element || ts$1.isOmittedExpression(element)) continue;
584
+ if (!element || element.kind === SyntaxKind.OmittedExpression) continue;
585
585
  if (element.dotDotDotToken) continue;
586
586
  const elementType = tupleElements[i];
587
587
  if (!elementType) continue;
@@ -596,8 +596,8 @@ var anyAssignments_default = ruleCreator.createRule(typescriptLanguage, {
596
596
  }
597
597
  });
598
598
  didReport = true;
599
- } else if (ts$1.isArrayBindingPattern(name)) didReport = checkArrayDestructureWorker(name, elementType, sourceFile, typeChecker) || didReport;
600
- else if (ts$1.isObjectBindingPattern(name)) didReport = checkObjectDestructureWorker(name, elementType, sourceFile, typeChecker) || didReport;
599
+ } else if (name.kind === SyntaxKind.ArrayBindingPattern) didReport = checkArrayDestructureWorker(name, elementType, sourceFile, typeChecker) || didReport;
600
+ else if (name.kind === SyntaxKind.ObjectBindingPattern) didReport = checkObjectDestructureWorker(name, elementType, sourceFile, typeChecker) || didReport;
601
601
  }
602
602
  return didReport;
603
603
  }
@@ -607,10 +607,10 @@ var anyAssignments_default = ruleCreator.createRule(typescriptLanguage, {
607
607
  if (element.dotDotDotToken) continue;
608
608
  let key;
609
609
  const propertyName = element.propertyName ?? element.name;
610
- if (ts$1.isIdentifier(propertyName) || ts$1.isStringLiteral(propertyName) || ts$1.isNumericLiteral(propertyName)) key = propertyName.text;
611
- else if (ts$1.isComputedPropertyName(propertyName)) {
610
+ if (propertyName.kind === SyntaxKind.Identifier || propertyName.kind === SyntaxKind.StringLiteral || propertyName.kind === SyntaxKind.NumericLiteral) key = propertyName.text;
611
+ else if (propertyName.kind === SyntaxKind.ComputedPropertyName) {
612
612
  const expression = propertyName.expression;
613
- if (ts$1.isStringLiteral(expression) || ts$1.isNoSubstitutionTemplateLiteral(expression)) key = expression.text;
613
+ if (expression.kind === SyntaxKind.StringLiteral || expression.kind === SyntaxKind.NoSubstitutionTemplateLiteral) key = expression.text;
614
614
  }
615
615
  if (key === void 0) continue;
616
616
  const propertySymbol = senderType.getProperty(key);
@@ -627,8 +627,8 @@ var anyAssignments_default = ruleCreator.createRule(typescriptLanguage, {
627
627
  }
628
628
  });
629
629
  didReport = true;
630
- } else if (ts$1.isArrayBindingPattern(name)) didReport = checkArrayDestructureWorker(name, propertyType, sourceFile, typeChecker) || didReport;
631
- else if (ts$1.isObjectBindingPattern(name)) didReport = checkObjectDestructureWorker(name, propertyType, sourceFile, typeChecker) || didReport;
630
+ } else if (name.kind === SyntaxKind.ArrayBindingPattern) didReport = checkArrayDestructureWorker(name, propertyType, sourceFile, typeChecker) || didReport;
631
+ else if (name.kind === SyntaxKind.ObjectBindingPattern) didReport = checkObjectDestructureWorker(name, propertyType, sourceFile, typeChecker) || didReport;
632
632
  }
633
633
  return didReport;
634
634
  }
@@ -1044,8 +1044,8 @@ var anyReturns_default = ruleCreator.createRule(typescriptLanguage, {
1044
1044
  //#endregion
1045
1045
  //#region src/rules/arguments.ts
1046
1046
  function isNonArrowFunctionBoundary(node) {
1047
- if (ts$1.isArrowFunction(node)) return "quit";
1048
- return ts$1.isFunctionDeclaration(node) || ts$1.isFunctionExpression(node) || ts$1.isMethodDeclaration(node) || ts$1.isGetAccessorDeclaration(node) || ts$1.isSetAccessorDeclaration(node) || ts$1.isConstructorDeclaration(node);
1047
+ if (node.kind === SyntaxKind.ArrowFunction) return "quit";
1048
+ return node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.FunctionExpression || node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.GetAccessor || node.kind === SyntaxKind.SetAccessor || node.kind === SyntaxKind.Constructor;
1049
1049
  }
1050
1050
  var arguments_default = ruleCreator.createRule(typescriptLanguage, {
1051
1051
  about: {
@@ -1065,7 +1065,7 @@ var arguments_default = ruleCreator.createRule(typescriptLanguage, {
1065
1065
  if ((parent.kind === SyntaxKind.PropertyAccessExpression || parent.kind === SyntaxKind.PropertyAssignment || parent.kind === SyntaxKind.ShorthandPropertyAssignment || parent.kind === SyntaxKind.Parameter || parent.kind === SyntaxKind.VariableDeclaration || parent.kind === SyntaxKind.PropertyDeclaration || parent.kind === SyntaxKind.BindingElement || parent.kind === SyntaxKind.PropertySignature) && parent.name === node) return;
1066
1066
  if (!ts$1.findAncestor(node, isNonArrowFunctionBoundary)) return;
1067
1067
  const symbol = typeChecker.getSymbolAtLocation(node);
1068
- if (!symbol || symbol.getDeclarations()?.some((declaration) => ts$1.isParameter(declaration) || ts$1.isVariableDeclaration(declaration) || ts$1.isPropertyDeclaration(declaration) || ts$1.isBindingElement(declaration))) return;
1068
+ if (!symbol || symbol.getDeclarations()?.some((declaration) => declaration.kind === SyntaxKind.Parameter || declaration.kind === SyntaxKind.VariableDeclaration || declaration.kind === SyntaxKind.PropertyDeclaration || declaration.kind === SyntaxKind.BindingElement)) return;
1069
1069
  context.report({
1070
1070
  message: "preferRestParameters",
1071
1071
  range: getTSNodeRange(node, sourceFile)
@@ -1686,9 +1686,7 @@ function isDirectEqualityCheck(node, operators, parameterName) {
1686
1686
  case SyntaxKind.ArrowFunction:
1687
1687
  body = node.body.kind === SyntaxKind.Block ? getDirectReturnExpression(node.body) : node.body;
1688
1688
  break;
1689
- case SyntaxKind.FunctionExpression:
1690
- body = getDirectReturnExpression(node.body);
1691
- break;
1689
+ case SyntaxKind.FunctionExpression: body = getDirectReturnExpression(node.body);
1692
1690
  }
1693
1691
  if (body?.kind !== SyntaxKind.BinaryExpression) return false;
1694
1692
  const { left, operatorToken, right } = body;
@@ -2273,10 +2271,7 @@ var arrayTypes_default = ruleCreator.createRule(typescriptLanguage, {
2273
2271
  if (node.parent.kind === SyntaxKind.TypeOperator && node.parent.operator === SyntaxKind.ReadonlyKeyword) return;
2274
2272
  switch (options.style) {
2275
2273
  case "array": return;
2276
- case "array-simple":
2277
- if (isSimpleType(node.elementType)) return;
2278
- break;
2279
- case "generic": break;
2274
+ case "array-simple": if (isSimpleType(node.elementType)) return;
2280
2275
  }
2281
2276
  context.report({
2282
2277
  message: "preferGenericSyntax",
@@ -2288,10 +2283,7 @@ var arrayTypes_default = ruleCreator.createRule(typescriptLanguage, {
2288
2283
  const arrayType = node.type;
2289
2284
  switch (options.style) {
2290
2285
  case "array": return;
2291
- case "array-simple":
2292
- if (isSimpleType(arrayType.elementType)) return;
2293
- break;
2294
- case "generic": break;
2286
+ case "array-simple": if (isSimpleType(arrayType.elementType)) return;
2295
2287
  }
2296
2288
  context.report({
2297
2289
  message: "preferReadonlyGenericSyntax",
@@ -3024,17 +3016,20 @@ var catchCallbackTypes_default = ruleCreator.createRule(typescriptLanguage, {
3024
3016
  if (symbol?.getName() !== "Promise") return false;
3025
3017
  const declarations = symbol.getDeclarations();
3026
3018
  if (!declarations) return false;
3027
- return declarations.some((declaration) => isInterfaceDeclaration(declaration) && declaration.name.text === "Promise" && declarationIncludesGlobal(declaration, program));
3019
+ return declarations.some((declaration) => {
3020
+ const node = declaration;
3021
+ return node.kind === SyntaxKind.InterfaceDeclaration && node.name.text === "Promise" && declarationIncludesGlobal(declaration, program);
3022
+ });
3028
3023
  }
3029
3024
  function isCatchOrThenCallback(node, typeChecker, program) {
3030
- if (!isPropertyAccessExpression(node.expression)) return;
3025
+ if (node.expression.kind !== SyntaxKind.PropertyAccessExpression) return;
3031
3026
  const methodName = node.expression.name.text;
3032
3027
  if (methodName !== "catch" && methodName !== "then") return;
3033
3028
  if (!isGlobalPromiseType(getConstrainedTypeAtLocation(node.expression.expression, typeChecker), program)) return;
3034
3029
  return methodName === "catch" ? "catch" : "then";
3035
3030
  }
3036
3031
  function checkCallbackParameter(callback, sourceFile, typeChecker) {
3037
- if (!isFunctionLike(callback) || !callback.parameters.length) return;
3032
+ if (callback.kind !== SyntaxKind.ArrowFunction && callback.kind !== SyntaxKind.FunctionExpression || !callback.parameters.length) return;
3038
3033
  const firstParameter = callback.parameters[0];
3039
3034
  if (firstParameter.type) {
3040
3035
  const paramType = typeChecker.getTypeFromTypeNode(firstParameter.type);
@@ -3053,9 +3048,7 @@ var catchCallbackTypes_default = ruleCreator.createRule(typescriptLanguage, {
3053
3048
  case "catch":
3054
3049
  if (node.arguments.length >= 1) checkCallbackParameter(node.arguments[0], sourceFile, typeChecker);
3055
3050
  break;
3056
- case "then":
3057
- if (node.arguments.length >= 2) checkCallbackParameter(node.arguments[1], sourceFile, typeChecker);
3058
- break;
3051
+ case "then": if (node.arguments.length >= 2) checkCallbackParameter(node.arguments[1], sourceFile, typeChecker);
3059
3052
  }
3060
3053
  } } };
3061
3054
  }
@@ -3339,17 +3332,15 @@ function classImplementsSomething(classNode) {
3339
3332
  function containsThis$1(node) {
3340
3333
  switch (node.kind) {
3341
3334
  case SyntaxKind.ClassDeclaration:
3342
- case SyntaxKind.ClassExpression: {
3343
- const classNode = node;
3344
- for (const member of classNode.members) if (ts$1.isPropertyDeclaration(member) && ts$1.isComputedPropertyName(member.name) && containsThis$1(member.name.expression)) return true;
3335
+ case SyntaxKind.ClassExpression:
3336
+ for (const member of node.members) if (member.kind === SyntaxKind.PropertyDeclaration && member.name.kind === SyntaxKind.ComputedPropertyName && containsThis$1(member.name.expression)) return true;
3345
3337
  return false;
3346
- }
3347
3338
  case SyntaxKind.ClassStaticBlockDeclaration:
3348
3339
  case SyntaxKind.FunctionDeclaration:
3349
3340
  case SyntaxKind.FunctionExpression: return false;
3350
3341
  case SyntaxKind.SuperKeyword:
3351
3342
  case SyntaxKind.ThisKeyword: return true;
3352
- default: return ts$1.forEachChild(node, containsThis$1) ?? false;
3343
+ default: return forEachChild(node, containsThis$1) ?? false;
3353
3344
  }
3354
3345
  }
3355
3346
  function getMemberDisplayName(member, sourceFile) {
@@ -3437,9 +3428,7 @@ var classMethodsThis_default = ruleCreator.createRule(typescriptLanguage, {
3437
3428
  case SyntaxKind.PropertyDeclaration:
3438
3429
  checkPropertyInitializerFunction(member, node, sourceFile, options);
3439
3430
  break;
3440
- case SyntaxKind.SetAccessor:
3441
- checkAccessor(member, node, sourceFile, options, "setter");
3442
- break;
3431
+ case SyntaxKind.SetAccessor: checkAccessor(member, node, sourceFile, options, "setter");
3443
3432
  }
3444
3433
  }
3445
3434
  return { visitors: {
@@ -3670,7 +3659,7 @@ var constructorGenericCalls_default = ruleCreator.createRule(typescriptLanguage,
3670
3659
  }
3671
3660
  return;
3672
3661
  }
3673
- if (!ts$1.isTypeReferenceNode(typeAnnotation) || typeAnnotation.typeName.kind !== SyntaxKind.Identifier || typeAnnotation.typeName.text !== constructorName || isBuiltInTypedArray(typeAnnotation.typeName.text) || !!typeAnnotation.typeArguments !== !initializer.typeArguments) return;
3662
+ if (typeAnnotation.kind !== SyntaxKind.TypeReference || typeAnnotation.typeName.kind !== SyntaxKind.Identifier || typeAnnotation.typeName.text !== constructorName || isBuiltInTypedArray(typeAnnotation.typeName.text) || !!typeAnnotation.typeArguments !== !initializer.typeArguments) return;
3674
3663
  if (style === "constructor" && typeAnnotation.typeArguments && !initializer.typeArguments) {
3675
3664
  const typeArgsText = getTypeArgumentsText(typeAnnotation, typeAnnotation.typeArguments, sourceFile);
3676
3665
  const typeArgsRange = getTypeArgumentsRange(typeAnnotation, typeAnnotation.typeArguments, sourceFile);
@@ -3894,12 +3883,10 @@ var dateNowTimestamps_default = ruleCreator.createRule(typescriptLanguage, {
3894
3883
  range: getTSNodeRange(node.parent, sourceFile)
3895
3884
  });
3896
3885
  break;
3897
- case SyntaxKind.PrefixUnaryExpression:
3898
- if (node.parent.operator === SyntaxKind.MinusToken || node.parent.operator === SyntaxKind.PlusToken) context.report({
3899
- message: "preferDateNow",
3900
- range: getTSNodeRange(node, sourceFile)
3901
- });
3902
- break;
3886
+ case SyntaxKind.PrefixUnaryExpression: if (node.parent.operator === SyntaxKind.MinusToken || node.parent.operator === SyntaxKind.PlusToken) context.report({
3887
+ message: "preferDateNow",
3888
+ range: getTSNodeRange(node, sourceFile)
3889
+ });
3903
3890
  }
3904
3891
  }
3905
3892
  } };
@@ -4220,8 +4207,8 @@ function isInsideHeritageClause(node) {
4220
4207
  if (node.kind === SyntaxKind.HeritageClause) return true;
4221
4208
  let current = node.parent;
4222
4209
  while (current) {
4223
- if (ts$1.isHeritageClause(current)) return true;
4224
- if (ts$1.isSourceFile(current) || ts$1.isClassDeclaration(current)) break;
4210
+ if (current.kind === SyntaxKind.HeritageClause) return true;
4211
+ if (current.kind === SyntaxKind.SourceFile || current.kind === SyntaxKind.ClassDeclaration) break;
4225
4212
  current = current.parent;
4226
4213
  }
4227
4214
  return false;
@@ -4230,8 +4217,8 @@ function isInsideImport(node) {
4230
4217
  if (node.kind === SyntaxKind.ImportDeclaration) return true;
4231
4218
  let current = node.parent;
4232
4219
  while (current) {
4233
- if (ts$1.isImportDeclaration(current)) return true;
4234
- if (ts$1.isSourceFile(current) || ts$1.isFunctionDeclaration(current) || ts$1.isFunctionExpression(current) || ts$1.isArrowFunction(current) || ts$1.isClassDeclaration(current) || ts$1.isClassExpression(current) || ts$1.isBlock(current)) return false;
4220
+ if (current.kind === SyntaxKind.ImportDeclaration) return true;
4221
+ if (current.kind === SyntaxKind.SourceFile || current.kind === SyntaxKind.FunctionDeclaration || current.kind === SyntaxKind.FunctionExpression || current.kind === SyntaxKind.ArrowFunction || current.kind === SyntaxKind.ClassDeclaration || current.kind === SyntaxKind.ClassExpression || current.kind === SyntaxKind.Block) return false;
4235
4222
  current = current.parent;
4236
4223
  }
4237
4224
  return false;
@@ -4291,7 +4278,7 @@ var destructuringConsistency_default = ruleCreator.createRule(typescriptLanguage
4291
4278
  const propertyName = node.name.text;
4292
4279
  if (!destructured.destructuredProperties.has(propertyName)) return;
4293
4280
  const variableName = destructured.destructuredProperties.get(propertyName);
4294
- if (ts$1.isCallExpression(node.parent) && node.parent.expression === node || isLeftHandSide$1(node)) return;
4281
+ if (node.parent.kind === SyntaxKind.CallExpression && node.parent.expression === node || isLeftHandSide$1(node)) return;
4295
4282
  const range = getTSNodeRange(node, sourceFile);
4296
4283
  const expression = node.getText(sourceFile);
4297
4284
  const [variable, suggestions] = variableName ? [variableName, [{
@@ -4313,19 +4300,16 @@ var destructuringConsistency_default = ruleCreator.createRule(typescriptLanguage
4313
4300
  destructuredObjects.length = 0;
4314
4301
  },
4315
4302
  VariableDeclaration: (node, { sourceFile }) => {
4316
- if (!node.initializer || !ts$1.isObjectBindingPattern(node.name)) return;
4303
+ if (!node.initializer || node.name.kind !== SyntaxKind.ObjectBindingPattern) return;
4317
4304
  const initKey = getInitializerKey(node.initializer);
4318
4305
  if (!initKey) return;
4319
4306
  const properties = /* @__PURE__ */ new Map();
4320
- for (const element of node.name.elements) {
4321
- if (!ts$1.isBindingElement(element)) continue;
4322
- if (element.propertyName) {
4323
- if (ts$1.isIdentifier(element.propertyName)) {
4324
- if (ts$1.isObjectBindingPattern(element.name) || ts$1.isArrayBindingPattern(element.name)) properties.set(element.propertyName.text, null);
4325
- else if (ts$1.isIdentifier(element.name)) properties.set(element.propertyName.text, element.name.text);
4326
- }
4327
- } else if (ts$1.isIdentifier(element.name)) properties.set(element.name.text, element.name.text);
4328
- }
4307
+ for (const element of node.name.elements) if (element.propertyName) {
4308
+ if (element.propertyName.kind === SyntaxKind.Identifier) {
4309
+ if (element.name.kind === SyntaxKind.ObjectBindingPattern || element.name.kind === SyntaxKind.ArrayBindingPattern) properties.set(element.propertyName.text, null);
4310
+ else properties.set(element.propertyName.text, element.name.text);
4311
+ }
4312
+ } else if (element.name.kind === SyntaxKind.Identifier) properties.set(element.name.text, element.name.text);
4329
4313
  if (properties.size) destructuredObjects.push({
4330
4314
  declarationEnd: node.getEnd(),
4331
4315
  destructuredProperties: properties,
@@ -4378,7 +4362,7 @@ var duplicateArguments_default = ruleCreator.createRule(typescriptLanguage, {
4378
4362
  //#endregion
4379
4363
  //#region src/rules/dynamicDeletes.ts
4380
4364
  function isAcceptableIndexExpression(property) {
4381
- return isStringLiteral(property) || isNumericLiteral(property) || isPrefixUnaryExpression(property) && property.operator === SyntaxKind.MinusToken && isNumericLiteral(property.operand);
4365
+ return property.kind === SyntaxKind.StringLiteral || property.kind === SyntaxKind.NumericLiteral || property.kind === SyntaxKind.PrefixUnaryExpression && property.operator === SyntaxKind.MinusToken && property.operand.kind === SyntaxKind.NumericLiteral;
4382
4366
  }
4383
4367
  var dynamicDeletes_default = ruleCreator.createRule(typescriptLanguage, {
4384
4368
  about: {
@@ -4394,7 +4378,7 @@ var dynamicDeletes_default = ruleCreator.createRule(typescriptLanguage, {
4394
4378
  setup(context) {
4395
4379
  return { visitors: { DeleteExpression: (node, { sourceFile }) => {
4396
4380
  const argument = node.expression;
4397
- if (!isElementAccessExpression(argument) || isAcceptableIndexExpression(argument.argumentExpression)) return;
4381
+ if (argument.kind !== SyntaxKind.ElementAccessExpression || isAcceptableIndexExpression(argument.argumentExpression)) return;
4398
4382
  const property = argument.argumentExpression;
4399
4383
  context.report({
4400
4384
  message: "dynamicDelete",
@@ -5244,7 +5228,7 @@ function isErrorSubclass(node, typeChecker, program) {
5244
5228
  if (clause.token !== SyntaxKind.ExtendsKeyword) continue;
5245
5229
  for (const type of clause.types) {
5246
5230
  const typeName = type.expression;
5247
- if (isIdentifier(typeName) && builtinErrorNames.has(typeName.text) && isGlobalDeclaration(typeName, typeChecker, program)) return true;
5231
+ if (typeName.kind === SyntaxKind.Identifier && builtinErrorNames.has(typeName.text) && isGlobalDeclaration(typeName, typeChecker, program)) return true;
5248
5232
  }
5249
5233
  }
5250
5234
  return false;
@@ -5389,15 +5373,13 @@ var errorSubclassProperties_default = ruleCreator.createRule(typescriptLanguage,
5389
5373
  //#endregion
5390
5374
  //#region src/rules/errorUnnecessaryCaptureStackTraces.ts
5391
5375
  function isCaptureStackTraceCall(node) {
5392
- if (!ts$1.isCallExpression(node) && !ts$1.isOptionalChain(node)) return false;
5393
- const callExpression = ts$1.isCallExpression(node) ? node : void 0;
5394
- if (!callExpression) return ts$1.isCallExpression(node) && isCaptureStackTraceCall(node);
5395
- return ts$1.isPropertyAccessExpression(callExpression.expression) && ts$1.isIdentifier(callExpression.expression.expression) && callExpression.expression.expression.text === "Error" && ts$1.isIdentifier(callExpression.expression.name) && callExpression.expression.name.text === "captureStackTrace";
5376
+ if (node.kind !== SyntaxKind.CallExpression) return false;
5377
+ return node.expression.kind === SyntaxKind.PropertyAccessExpression && node.expression.expression.kind === SyntaxKind.Identifier && node.expression.expression.text === "Error" && node.expression.name.text === "captureStackTrace";
5396
5378
  }
5397
5379
  function isValidSecondArgument(node, className) {
5398
- if (ts$1.isIdentifier(node)) return node.text === className;
5399
- if (ts$1.isPropertyAccessExpression(node) && node.expression.kind === SyntaxKind.ThisKeyword && ts$1.isIdentifier(node.name) && node.name.text === "constructor") return true;
5400
- if (ts$1.isMetaProperty(node) && node.keywordToken === SyntaxKind.NewKeyword && ts$1.isIdentifier(node.name) && node.name.text === "target") return true;
5380
+ if (node.kind === SyntaxKind.Identifier) return node.text === className;
5381
+ if (node.kind === SyntaxKind.PropertyAccessExpression && node.expression.kind === SyntaxKind.ThisKeyword && node.name.kind === SyntaxKind.Identifier && node.name.text === "constructor") return true;
5382
+ if (node.kind === SyntaxKind.MetaProperty && node.keywordToken === SyntaxKind.NewKeyword && node.name.text === "target") return true;
5401
5383
  return false;
5402
5384
  }
5403
5385
  var errorUnnecessaryCaptureStackTraces_default = ruleCreator.createRule(typescriptLanguage, {
@@ -5415,9 +5397,9 @@ var errorUnnecessaryCaptureStackTraces_default = ruleCreator.createRule(typescri
5415
5397
  return { visitors: { ClassDeclaration: (node, { program, sourceFile, typeChecker }) => {
5416
5398
  if (!isErrorSubclass(node, typeChecker, program)) return;
5417
5399
  for (const member of node.members) {
5418
- if (!ts$1.isConstructorDeclaration(member) || !member.body) continue;
5400
+ if (member.kind !== SyntaxKind.Constructor || !member.body) continue;
5419
5401
  for (const statement of member.body.statements) {
5420
- if (statement.kind !== SyntaxKind.ExpressionStatement || !(statement.expression.kind === SyntaxKind.CallExpression || ts$1.isCallChain(statement.expression)) || !isCaptureStackTraceCall(statement.expression)) continue;
5402
+ if (statement.kind !== SyntaxKind.ExpressionStatement || statement.expression.kind !== SyntaxKind.CallExpression || !isCaptureStackTraceCall(statement.expression)) continue;
5421
5403
  const args = statement.expression.arguments;
5422
5404
  if (args.length < 1) continue;
5423
5405
  if (args[0].kind !== SyntaxKind.ThisKeyword) continue;
@@ -5679,8 +5661,8 @@ function getImportInfo(node, sourceFile) {
5679
5661
  const clause = node.importClause;
5680
5662
  if (clause.name) info.defaultImport = clause.name.text;
5681
5663
  if (clause.namedBindings) {
5682
- if (ts$1.isNamespaceImport(clause.namedBindings)) info.namespaceImport = clause.namedBindings.name.text;
5683
- else if (ts$1.isNamedImports(clause.namedBindings)) for (const element of clause.namedBindings.elements) {
5664
+ if (clause.namedBindings.kind === SyntaxKind.NamespaceImport) info.namespaceImport = clause.namedBindings.name.text;
5665
+ else for (const element of clause.namedBindings.elements) {
5684
5666
  const importedName = element.propertyName ? element.propertyName.text : element.name.text;
5685
5667
  const localName = element.name.text;
5686
5668
  info.namedImports.set(localName, importedName);
@@ -5734,7 +5716,7 @@ var exportFromImports_default = ruleCreator.createRule(typescriptLanguage, {
5734
5716
  }
5735
5717
  }
5736
5718
  for (const exportDeclaration of namedExports) {
5737
- if (!exportDeclaration.exportClause || !ts$1.isNamedExports(exportDeclaration.exportClause)) continue;
5719
+ if (exportDeclaration.exportClause?.kind !== SyntaxKind.NamedExports) continue;
5738
5720
  for (const element of exportDeclaration.exportClause.elements) {
5739
5721
  const localName = element.propertyName ? element.propertyName.text : element.name.text;
5740
5722
  const exportedName = element.name.text;
@@ -5767,7 +5749,7 @@ var exportFromImports_default = ruleCreator.createRule(typescriptLanguage, {
5767
5749
  }
5768
5750
  }
5769
5751
  for (const exportAssignment of exportAssignments) {
5770
- if (!ts$1.isIdentifier(exportAssignment.expression)) continue;
5752
+ if (exportAssignment.expression.kind !== SyntaxKind.Identifier) continue;
5771
5753
  const localName = exportAssignment.expression.text;
5772
5754
  const importInfo = imports.get(localName);
5773
5755
  if (importInfo?.defaultImport !== localName) continue;
@@ -5859,9 +5841,7 @@ var exportUniqueNames_default = ruleCreator.createRule(typescriptLanguage, {
5859
5841
  case SyntaxKind.ExportDeclaration:
5860
5842
  checkExportDeclaration(statement);
5861
5843
  break;
5862
- case SyntaxKind.VariableStatement:
5863
- checkVariableStatement(statement);
5864
- break;
5844
+ case SyntaxKind.VariableStatement: checkVariableStatement(statement);
5865
5845
  }
5866
5846
  } } };
5867
5847
  }
@@ -6001,7 +5981,6 @@ var fetchMethodBodies_default = ruleCreator.createRule(typescriptLanguage, {
6001
5981
  case "method":
6002
5982
  if (property.initializer.kind !== SyntaxKind.StringLiteral) return;
6003
5983
  methodText = property.initializer.text;
6004
- break;
6005
5984
  }
6006
5985
  break;
6007
5986
  case SyntaxKind.SpreadAssignment: return;
@@ -6750,9 +6729,7 @@ function getCalleeName(node) {
6750
6729
  if (node.expression.kind === SyntaxKind.Identifier && globalCandidates.has(node.expression.text) && node.argumentExpression.kind === SyntaxKind.StringLiteral) return node.argumentExpression.text;
6751
6730
  break;
6752
6731
  case SyntaxKind.Identifier: return node.text;
6753
- case SyntaxKind.PropertyAccessExpression:
6754
- if (node.expression.kind === SyntaxKind.Identifier && globalCandidates.has(node.expression.text)) return node.name.text;
6755
- break;
6732
+ case SyntaxKind.PropertyAccessExpression: if (node.expression.kind === SyntaxKind.Identifier && globalCandidates.has(node.expression.text)) return node.name.text;
6756
6733
  }
6757
6734
  }
6758
6735
  function isBind(node) {
@@ -6842,9 +6819,7 @@ var impliedEvals_default = ruleCreator.createRule(typescriptLanguage, {
6842
6819
  checkCalleeFunction(node, services);
6843
6820
  break;
6844
6821
  case void 0: return;
6845
- default:
6846
- checkCalleeEval(node, calleeName, services);
6847
- break;
6822
+ default: checkCalleeEval(node, calleeName, services);
6848
6823
  }
6849
6824
  }
6850
6825
  return { visitors: {
@@ -7168,8 +7143,8 @@ function isLiteralArgument(node, constructorName) {
7168
7143
  switch (constructorName) {
7169
7144
  case "BigInt": return isNumericLiteralForBigInt(node);
7170
7145
  case "Boolean": return isLiteralExpression(node) || isBooleanLiteral(node);
7171
- case "Number": return isStringLiteral(node) && isValidNumericString(node.text);
7172
- case "String": return isNumericLiteral(node) || isBooleanLiteral(node) || isBigIntLiteral(node);
7146
+ case "Number": return node.kind === SyntaxKind.StringLiteral && isValidNumericString(node.text);
7147
+ case "String": return node.kind === SyntaxKind.NumericLiteral || isBooleanLiteral(node) || node.kind === SyntaxKind.BigIntLiteral;
7173
7148
  default: return false;
7174
7149
  }
7175
7150
  }
@@ -7195,7 +7170,7 @@ var literalConstructorWrappers_default = ruleCreator.createRule(typescriptLangua
7195
7170
  } },
7196
7171
  setup(context) {
7197
7172
  return { visitors: { CallExpression: (node, { program, sourceFile, typeChecker }) => {
7198
- if (!isIdentifier(node.expression)) return;
7173
+ if (node.expression.kind !== SyntaxKind.Identifier) return;
7199
7174
  const name = node.expression.text;
7200
7175
  if (!literalConstructors.has(name) || node.arguments.length !== 1 || !isGlobalDeclarationOfName(node.expression, name, typeChecker, program)) return;
7201
7176
  const argument = node.arguments[0];
@@ -8418,21 +8393,21 @@ function hasNoAssignmentBeforeNode(identifier, node, sourceFile, typeChecker) {
8418
8393
  const nodeEnd = node.getEnd();
8419
8394
  for (const declaration of declarations) {
8420
8395
  if (declaration.getEnd() >= nodeEnd) continue;
8421
- if (ts$1.isVariableDeclaration(declaration)) {
8396
+ if (declaration.kind === SyntaxKind.VariableDeclaration) {
8422
8397
  if (declaration.exclamationToken || declaration.initializer) return false;
8423
- } else if (ts$1.isParameter(declaration) && declaration.initializer) return false;
8398
+ } else if (declaration.kind === SyntaxKind.Parameter && declaration.initializer) return false;
8424
8399
  }
8425
8400
  const valueDeclaration = symbol.valueDeclaration;
8426
8401
  if (!valueDeclaration) return true;
8427
8402
  function findModifyingReference(current) {
8428
- if (ts$1.isIdentifier(current)) {
8403
+ if (current.kind === SyntaxKind.Identifier) {
8429
8404
  if (typeChecker.getSymbolAtLocation(current)?.valueDeclaration === valueDeclaration) {
8430
8405
  const parent = current.parent;
8431
- if (ts$1.isBinaryExpression(parent) && tsutils.isAssignmentKind(parent.operatorToken.kind) && parent.left === current && parent.getEnd() < nodeEnd) return true;
8432
- if ((ts$1.isPostfixUnaryExpression(parent) || ts$1.isPrefixUnaryExpression(parent)) && parent.operand === current && parent.getEnd() < nodeEnd) return true;
8406
+ if (parent.kind === SyntaxKind.BinaryExpression && tsutils.isAssignmentKind(parent.operatorToken.kind) && parent.left === current && parent.getEnd() < nodeEnd) return true;
8407
+ if ((parent.kind === SyntaxKind.PostfixUnaryExpression || parent.kind === SyntaxKind.PrefixUnaryExpression) && parent.operand === current && parent.getEnd() < nodeEnd) return true;
8433
8408
  }
8434
8409
  }
8435
- return ts$1.forEachChild(current, findModifyingReference) ?? false;
8410
+ return forEachChild(current, findModifyingReference) ?? false;
8436
8411
  }
8437
8412
  return !findModifyingReference(sourceFile);
8438
8413
  }
@@ -8604,13 +8579,11 @@ var nonNullAssertionPlacement_default = ruleCreator.createRule(typescriptLanguag
8604
8579
  suggestions
8605
8580
  });
8606
8581
  break;
8607
- default:
8608
- context.report({
8609
- message: "confusingEqual",
8610
- range,
8611
- suggestions
8612
- });
8613
- break;
8582
+ default: context.report({
8583
+ message: "confusingEqual",
8584
+ range,
8585
+ suggestions
8586
+ });
8614
8587
  }
8615
8588
  } } };
8616
8589
  }
@@ -9181,16 +9154,16 @@ var numberMethodRanges_default = ruleCreator.createRule(typescriptLanguage, {
9181
9154
  //#region src/rules/numberStaticMethods.ts
9182
9155
  const globalReplacements = /* @__PURE__ */ new Map([["isFinite", "Number.isFinite"], ["isNaN", "Number.isNaN"]]);
9183
9156
  function isDeclarationName(node) {
9184
- return ts$1.isFunctionDeclaration(node.parent) && node.parent.name === node || ts$1.isVariableDeclaration(node.parent) && node.parent.name === node || ts$1.isParameter(node.parent) && node.parent.name === node;
9157
+ return node.parent.kind === SyntaxKind.FunctionDeclaration && node.parent.name === node || node.parent.kind === SyntaxKind.VariableDeclaration && node.parent.name === node || node.parent.kind === SyntaxKind.Parameter && node.parent.name === node;
9185
9158
  }
9186
9159
  function isLeftHandSide(node) {
9187
9160
  return node.parent.kind === SyntaxKind.BinaryExpression && node.parent.left === node && node.parent.operatorToken.kind >= SyntaxKind.FirstAssignment && node.parent.operatorToken.kind <= SyntaxKind.LastAssignment;
9188
9161
  }
9189
9162
  function isPropertyAccessOfNode(node) {
9190
- return ts$1.isPropertyAccessExpression(node.parent) && node.parent.name === node;
9163
+ return node.parent.kind === SyntaxKind.PropertyAccessExpression && node.parent.name === node;
9191
9164
  }
9192
9165
  function isPropertyShorthandOfNode(node) {
9193
- return ts$1.isShorthandPropertyAssignment(node.parent) && node.parent.name === node;
9166
+ return node.parent.kind === SyntaxKind.ShorthandPropertyAssignment && node.parent.name === node;
9194
9167
  }
9195
9168
  var numberStaticMethods_default = ruleCreator.createRule(typescriptLanguage, {
9196
9169
  about: {
@@ -9254,12 +9227,10 @@ var numericErasingOperations_default = ruleCreator.createRule(typescriptLanguage
9254
9227
  range: getTSNodeRange(node, sourceFile)
9255
9228
  });
9256
9229
  break;
9257
- case SyntaxKind.SlashToken:
9258
- if (isZeroLiteral(node.left) && !isZeroLiteral(node.right)) context.report({
9259
- message: "erasingOperation",
9260
- range: getTSNodeRange(node, sourceFile)
9261
- });
9262
- break;
9230
+ case SyntaxKind.SlashToken: if (isZeroLiteral(node.left) && !isZeroLiteral(node.right)) context.report({
9231
+ message: "erasingOperation",
9232
+ range: getTSNodeRange(node, sourceFile)
9233
+ });
9263
9234
  }
9264
9235
  } } };
9265
9236
  }
@@ -10185,7 +10156,7 @@ function getMethodDisplayName(method) {
10185
10156
  function getNameFromPropertyName(name) {
10186
10157
  switch (name.kind) {
10187
10158
  case SyntaxKind.ComputedPropertyName:
10188
- if (ts$1.isStringLiteral(name.expression)) return {
10159
+ if (name.expression.kind === SyntaxKind.StringLiteral) return {
10189
10160
  name: name.expression.text,
10190
10161
  type: "quoted"
10191
10162
  };
@@ -10576,7 +10547,7 @@ function isDescendantOf(node, potentialAncestor) {
10576
10547
  }
10577
10548
  function isNodeInsideReturnType(node) {
10578
10549
  let current = node.parent;
10579
- while (current) {
10550
+ while (current.kind !== SyntaxKind.SourceFile) {
10580
10551
  if (current.kind === SyntaxKind.FunctionDeclaration || current.kind === SyntaxKind.FunctionExpression || current.kind === SyntaxKind.ArrowFunction || current.kind === SyntaxKind.MethodDeclaration || current.kind === SyntaxKind.MethodSignature || current.kind === SyntaxKind.FunctionType || current.kind === SyntaxKind.CallSignature || current.kind === SyntaxKind.ConstructSignature || current.kind === SyntaxKind.ConstructorType) return !!current.type && isDescendantOf(node, current.type);
10581
10552
  current = current.parent;
10582
10553
  }
@@ -11202,9 +11173,7 @@ function elementsToCharacterClass(elements) {
11202
11173
  case "CharacterClassRange":
11203
11174
  case "CharacterSet":
11204
11175
  case "ClassStringDisjunction":
11205
- case "ExpressionCharacterClass":
11206
- parts.push(element.raw);
11207
- break;
11176
+ case "ExpressionCharacterClass": parts.push(element.raw);
11208
11177
  }
11209
11178
  if (!parts.length) return "[]";
11210
11179
  if (parts[0]?.[0] === "^") parts[0] = `\\${parts[0]}`;
@@ -11428,7 +11397,9 @@ function processCharacterClass(node) {
11428
11397
  } else continue;
11429
11398
  const group = groups.find((gp) => {
11430
11399
  if (!(gp.min.value - 1 <= data.max.value && data.min.value <= gp.max.value + 1)) return false;
11431
- return inRange(ALPHANUMERIC_RANGES, Math.min(gp.min.value, data.min.value), Math.max(gp.max.value, data.max.value));
11400
+ const min = Math.min(gp.min.value, data.min.value);
11401
+ const max = Math.max(gp.max.value, data.max.value);
11402
+ return inRange(ALPHANUMERIC_RANGES, min, max);
11432
11403
  });
11433
11404
  if (group) {
11434
11405
  if (data.min.value < group.min.value) group.min = data.min;
@@ -12103,17 +12074,19 @@ function findIssues$2(pattern, flags) {
12103
12074
  const groups = [];
12104
12075
  for (const element of ccNode.elements) {
12105
12076
  let data;
12106
- if (element.type === "Character") if (checkInAllowedRange(element.value)) data = {
12107
- max: element,
12108
- min: element
12109
- };
12110
- else continue;
12111
- else if (element.type === "CharacterClassRange") if (checkInAllowedRange(element.min.value, element.min.value, element.max.value)) data = {
12112
- max: element.max,
12113
- min: element.min
12114
- };
12115
- else continue;
12116
- else continue;
12077
+ if (element.type === "Character") {
12078
+ if (checkInAllowedRange(element.value)) data = {
12079
+ max: element,
12080
+ min: element
12081
+ };
12082
+ else continue;
12083
+ } else if (element.type === "CharacterClassRange") {
12084
+ if (checkInAllowedRange(element.min.value, element.min.value, element.max.value)) data = {
12085
+ max: element.max,
12086
+ min: element.min
12087
+ };
12088
+ else continue;
12089
+ } else continue;
12117
12090
  const group = groups.find((gp) => {
12118
12091
  if (!(gp.min.value - 1 <= data.max.value && data.min.value <= gp.max.value + 1)) return false;
12119
12092
  const min = Math.min(gp.min.value, data.min.value);
@@ -12456,9 +12429,10 @@ function findEmptyAlternativesInGroup(pattern, groupStart, groupEnd, results) {
12456
12429
  "?!",
12457
12430
  "?:",
12458
12431
  "?="
12459
- ].includes(pattern.slice(groupStart, groupStart + 2)) || ["?<!", "?<="].includes(pattern.slice(groupStart, groupStart + 3))) if (pattern.slice(groupStart, groupStart + 3).startsWith("?<")) contentStart = groupStart + 3;
12460
- else contentStart = groupStart + 2;
12461
- else if (pattern[groupStart] === "?" && pattern[groupStart + 1] === "<") {
12432
+ ].includes(pattern.slice(groupStart, groupStart + 2)) || ["?<!", "?<="].includes(pattern.slice(groupStart, groupStart + 3))) {
12433
+ if (pattern.slice(groupStart, groupStart + 3).startsWith("?<")) contentStart = groupStart + 3;
12434
+ else contentStart = groupStart + 2;
12435
+ } else if (pattern[groupStart] === "?" && pattern[groupStart + 1] === "<") {
12462
12436
  const closeAngle = pattern.indexOf(">", groupStart + 2);
12463
12437
  if (closeAngle !== -1 && closeAngle < groupEnd) contentStart = closeAngle + 1;
12464
12438
  }
@@ -12475,9 +12449,7 @@ function findEmptyAlternativesInGroup(pattern, groupStart, groupEnd, results) {
12475
12449
  case "\\":
12476
12450
  i++;
12477
12451
  break;
12478
- case "|":
12479
- pipePositions.push(i);
12480
- break;
12452
+ case "|": pipePositions.push(i);
12481
12453
  }
12482
12454
  if (!pipePositions.length) return;
12483
12455
  const alternativeBoundaries = [];
@@ -12768,14 +12740,11 @@ function* extractLazyEndQuantifiers(alternatives) {
12768
12740
  case "Group":
12769
12741
  yield* extractLazyEndQuantifiers(last.alternatives);
12770
12742
  break;
12771
- case "Quantifier":
12772
- if (!last.greedy && last.min !== last.max) yield last;
12773
- else if (last.max === 1) {
12774
- const element = last.element;
12775
- if (element.type === "Group" || element.type === "CapturingGroup") yield* extractLazyEndQuantifiers(element.alternatives);
12776
- }
12777
- break;
12778
- default: break;
12743
+ case "Quantifier": if (!last.greedy && last.min !== last.max) yield last;
12744
+ else if (last.max === 1) {
12745
+ const element = last.element;
12746
+ if (element.type === "Group" || element.type === "CapturingGroup") yield* extractLazyEndQuantifiers(element.alternatives);
12747
+ }
12779
12748
  }
12780
12749
  }
12781
12750
  }
@@ -13233,9 +13202,10 @@ function simplifyCharacterClass(pattern, charClass) {
13233
13202
  const elements = charClass.elements;
13234
13203
  const keptCharacters = /* @__PURE__ */ new Set();
13235
13204
  const rangesToKeep = [];
13236
- for (const element of elements) if (element.type === "Character") if (isLetter$1(element.value)) keptCharacters.add(toLowerCase(element.value));
13237
- else keptCharacters.add(element.value);
13238
- else if (element.type === "CharacterClassRange") {
13205
+ for (const element of elements) if (element.type === "Character") {
13206
+ if (isLetter$1(element.value)) keptCharacters.add(toLowerCase(element.value));
13207
+ else keptCharacters.add(element.value);
13208
+ } else if (element.type === "CharacterClassRange") {
13239
13209
  const min = element.min.value;
13240
13210
  const max = element.max.value;
13241
13211
  const minIsUpper = min >= 65 && min <= 90;
@@ -13504,9 +13474,7 @@ function checkPattern(pattern, flags) {
13504
13474
  checkHexadecimalEscape(charNode);
13505
13475
  break;
13506
13476
  case "unicode":
13507
- case "unicodeCodePoint":
13508
- checkUnicodeEscape(charNode);
13509
- break;
13477
+ case "unicodeCodePoint": checkUnicodeEscape(charNode);
13510
13478
  }
13511
13479
  }
13512
13480
  });
@@ -13602,9 +13570,7 @@ function escapeForRegexLiteral(pattern) {
13602
13570
  result += char;
13603
13571
  escaped = true;
13604
13572
  break;
13605
- default:
13606
- result += char;
13607
- break;
13573
+ default: result += char;
13608
13574
  }
13609
13575
  }
13610
13576
  return result;
@@ -13816,9 +13782,7 @@ function* extractInvalidQuantifiers(alternatives, kind) {
13816
13782
  case "Group":
13817
13783
  yield* extractInvalidQuantifiers(last.alternatives, kind);
13818
13784
  break;
13819
- case "Quantifier":
13820
- if (last.min !== last.max && !hasCapturingGroupDescendant(last.element)) yield last;
13821
- break;
13785
+ case "Quantifier": if (last.min !== last.max && !hasCapturingGroupDescendant(last.element)) yield last;
13822
13786
  }
13823
13787
  }
13824
13788
  }
@@ -13933,17 +13897,14 @@ function isMatchAnyCharacterClass(node, flags) {
13933
13897
  type: "CharacterSet"
13934
13898
  });
13935
13899
  break;
13936
- case "word":
13937
- if (element.negate) negativeElements.push({
13938
- kind: "word",
13939
- type: "CharacterSet"
13940
- });
13941
- else positiveElements.push({
13942
- kind: "word",
13943
- type: "CharacterSet"
13944
- });
13945
- break;
13946
- default: break;
13900
+ case "word": if (element.negate) negativeElements.push({
13901
+ kind: "word",
13902
+ type: "CharacterSet"
13903
+ });
13904
+ else positiveElements.push({
13905
+ kind: "word",
13906
+ type: "CharacterSet"
13907
+ });
13947
13908
  }
13948
13909
  else if (element.type === "CharacterClassRange" && element.min.value === 0 && (element.max.value === 65535 || element.max.value === 1114111 || flags.unicode && element.max.value >= 1114111)) return true;
13949
13910
  for (const positive of positiveElements) if (negativeElements.find((negative) => negative.kind === positive.kind)) return true;
@@ -14376,12 +14337,15 @@ function* findZeroWidthJoins(characters) {
14376
14337
  for (const [index, char] of characters.entries()) {
14377
14338
  const previous = characters[index - 1];
14378
14339
  const next = characters[index + 1];
14379
- if (previous && next && char.value === 8205 && previous.value !== 8205 && next.value !== 8205) if (sequence) if (sequence.at(-1) === previous) sequence.push(char, next);
14380
- else {
14381
- yield sequence;
14382
- sequence = characters.slice(index - 1, index + 2);
14340
+ if (previous && next && char.value === 8205 && previous.value !== 8205 && next.value !== 8205) {
14341
+ if (sequence) {
14342
+ if (sequence.at(-1) === previous) sequence.push(char, next);
14343
+ else {
14344
+ yield sequence;
14345
+ sequence = characters.slice(index - 1, index + 2);
14346
+ }
14347
+ } else sequence = characters.slice(index - 1, index + 2);
14383
14348
  }
14384
- else sequence = characters.slice(index - 1, index + 2);
14385
14349
  }
14386
14350
  if (sequence) yield sequence;
14387
14351
  }
@@ -14429,7 +14393,6 @@ function* iterateCharacterSequence(nodes) {
14429
14393
  sequence.push(node.min);
14430
14394
  yield sequence;
14431
14395
  sequence = [node.max];
14432
- break;
14433
14396
  }
14434
14397
  if (sequence.length) yield sequence;
14435
14398
  }
@@ -15262,10 +15225,10 @@ function extractCallExpression(expression) {
15262
15225
  function findAssignmentsToSymbol(symbol, sourceFile, typeChecker) {
15263
15226
  const assignments = [];
15264
15227
  function visit(node) {
15265
- if (ts$1.isBinaryExpression(node) && node.operatorToken.kind === SyntaxKind.EqualsToken && ts$1.isIdentifier(node.left)) {
15228
+ if (node.kind === SyntaxKind.BinaryExpression && node.operatorToken.kind === SyntaxKind.EqualsToken && node.left.kind === SyntaxKind.Identifier) {
15266
15229
  if (typeChecker.getSymbolAtLocation(node.left) === symbol) assignments.push(node);
15267
15230
  }
15268
- ts$1.forEachChild(node, visit);
15231
+ forEachChild(node, visit);
15269
15232
  }
15270
15233
  visit(sourceFile);
15271
15234
  return assignments;
@@ -15345,7 +15308,7 @@ function getRegexInfoFromExpression(node, typeChecker, sourceFile) {
15345
15308
  if (symbol) {
15346
15309
  const declarations = symbol.getDeclarations();
15347
15310
  if (declarations) {
15348
- for (const declaration of declarations) if (ts$1.isVariableDeclaration(declaration) && declaration.initializer) return getRegexInfoFromExpression(declaration.initializer, typeChecker, sourceFile);
15311
+ for (const declaration of declarations) if (declaration.kind === SyntaxKind.VariableDeclaration && declaration.initializer) return getRegexInfoFromExpression(declaration.initializer, typeChecker, sourceFile);
15349
15312
  }
15350
15313
  }
15351
15314
  }
@@ -15353,7 +15316,7 @@ function getRegexInfoFromExpression(node, typeChecker, sourceFile) {
15353
15316
  function getRegexInfoFromSymbol(symbol, typeChecker, sourceFile) {
15354
15317
  const declarations = symbol.getDeclarations();
15355
15318
  if (declarations) for (const declaration of declarations) {
15356
- if (ts$1.isVariableDeclaration(declaration) && declaration.initializer) {
15319
+ if (declaration.kind === SyntaxKind.VariableDeclaration && declaration.initializer) {
15357
15320
  const callExpression = extractCallExpression(declaration.initializer);
15358
15321
  if (callExpression) {
15359
15322
  const regexInfo = getRegexFromCall(callExpression, typeChecker, sourceFile);
@@ -15363,7 +15326,7 @@ function getRegexInfoFromSymbol(symbol, typeChecker, sourceFile) {
15363
15326
  }
15364
15327
  }
15365
15328
  }
15366
- if (ts$1.isParameter(declaration)) continue;
15329
+ if (declaration.kind === SyntaxKind.Parameter) continue;
15367
15330
  }
15368
15331
  const assignments = findAssignmentsToSymbol(symbol, sourceFile, typeChecker);
15369
15332
  for (const assignment of assignments) {
@@ -15844,9 +15807,7 @@ function findReachableQuantifiers(pattern) {
15844
15807
  case "Group":
15845
15808
  for (const innerAlternative of element.alternatives) walkAlternative(innerAlternative);
15846
15809
  break;
15847
- case "Quantifier":
15848
- if (element.max === Infinity && element.min === 0) quantifiers.push(element);
15849
- break;
15810
+ case "Quantifier": if (element.max === Infinity && element.min === 0) quantifiers.push(element);
15850
15811
  }
15851
15812
  if (!canMatchEmpty(element)) return;
15852
15813
  }
@@ -15865,19 +15826,15 @@ function generateAttackString(quantifier) {
15865
15826
  if (first.type === "Character") character = String.fromCharCode(first.value);
15866
15827
  break;
15867
15828
  }
15868
- case "CharacterSet":
15869
- switch (quantifier.element.kind) {
15870
- case "any":
15871
- character = "x";
15872
- break;
15873
- case "digit":
15874
- character = "0";
15875
- break;
15876
- case "space":
15877
- character = " ";
15878
- break;
15879
- }
15880
- break;
15829
+ case "CharacterSet": switch (quantifier.element.kind) {
15830
+ case "any":
15831
+ character = "x";
15832
+ break;
15833
+ case "digit":
15834
+ character = "0";
15835
+ break;
15836
+ case "space": character = " ";
15837
+ }
15881
15838
  }
15882
15839
  return (character ?? "a").repeat(20);
15883
15840
  }
@@ -17846,9 +17803,7 @@ function isOptionalAssertion(quantifierElement, assertion) {
17846
17803
  }
17847
17804
  }
17848
17805
  break;
17849
- case "Quantifier":
17850
- if (parent !== quantifierElement && parent.max > 1 && canConsumeCharacters(parent.element)) return false;
17851
- break;
17806
+ case "Quantifier": if (parent !== quantifierElement && parent.max > 1 && canConsumeCharacters(parent.element)) return false;
17852
17807
  }
17853
17808
  current = parent;
17854
17809
  }
@@ -18906,14 +18861,14 @@ function getSpecifierNames(specifier) {
18906
18861
  function isFromFile(sourceFile, specifiedPath, program) {
18907
18862
  if (specifiedPath === void 0) return !sourceFile.fileName.includes("/node_modules/") && !program.isSourceFileDefaultLibrary(sourceFile);
18908
18863
  const caseSensitive = ts$1.sys.useCaseSensitiveFileNames;
18909
- return pathKey(sourceFile.fileName, caseSensitive) === pathKey(path.resolve(program.getCurrentDirectory(), specifiedPath), caseSensitive);
18864
+ return pathKey(sourceFile.fileName, caseSensitive) === pathKey(resolve(program.getCurrentDirectory(), specifiedPath), caseSensitive);
18910
18865
  }
18911
18866
  //#endregion
18912
18867
  //#region src/type-utils/isDeclaredInModuleBlock.ts
18913
18868
  function isDeclaredInModuleBlock(declaration, packageName) {
18914
18869
  let current = declaration;
18915
- while (!ts$1.isSourceFile(current)) {
18916
- if (ts$1.isModuleDeclaration(current) && !(current.flags & ts$1.NodeFlags.Namespace) && ts$1.isStringLiteral(current.name) && current.name.text === packageName) return true;
18870
+ while (current.kind !== SyntaxKind.SourceFile) {
18871
+ if (current.kind === SyntaxKind.ModuleDeclaration && !(current.flags & NodeFlags.Namespace) && current.name.kind === SyntaxKind.StringLiteral && current.name.text === packageName) return true;
18917
18872
  current = current.parent;
18918
18873
  }
18919
18874
  return false;
@@ -19309,20 +19264,20 @@ var sequences_default = ruleCreator.createRule(typescriptLanguage, {
19309
19264
  //#endregion
19310
19265
  //#region src/rules/setSizeLengthChecks.ts
19311
19266
  function isNewSetExpression(expression, typeChecker, program) {
19312
- return isNewExpression(expression) && isIdentifier(expression.expression) && expression.expression.text === "Set" && isGlobalDeclarationOfName(expression.expression, "Set", typeChecker, program);
19267
+ return expression.kind === SyntaxKind.NewExpression && expression.expression.kind === SyntaxKind.Identifier && expression.expression.text === "Set" && isGlobalDeclarationOfName(expression.expression, "Set", typeChecker, program);
19313
19268
  }
19314
19269
  function isSetExpression(expression, typeChecker, program) {
19315
19270
  const unwrapped = unwrapParentheses$1(expression);
19316
19271
  if (isNewSetExpression(unwrapped, typeChecker, program)) return true;
19317
- if (!isIdentifier(unwrapped)) return false;
19272
+ if (unwrapped.kind !== SyntaxKind.Identifier) return false;
19318
19273
  const symbol = typeChecker.getSymbolAtLocation(unwrapped);
19319
- if (!symbol?.valueDeclaration || !isVariableDeclaration(symbol.valueDeclaration)) return false;
19274
+ if (symbol?.valueDeclaration?.kind !== SyntaxKind.VariableDeclaration) return false;
19320
19275
  const declaration = symbol.valueDeclaration;
19321
19276
  if (declaration.parent.kind !== SyntaxKind.VariableDeclarationList || !(declaration.parent.flags & NodeFlags.Const) || !declaration.initializer) return false;
19322
19277
  return isNewSetExpression(unwrapParentheses$1(declaration.initializer), typeChecker, program);
19323
19278
  }
19324
19279
  function unwrapParentheses$1(expression) {
19325
- while (isParenthesizedExpression(expression)) expression = expression.expression;
19280
+ while (expression.kind === SyntaxKind.ParenthesizedExpression) expression = expression.expression;
19326
19281
  return expression;
19327
19282
  }
19328
19283
  var setSizeLengthChecks_default = ruleCreator.createRule(typescriptLanguage, {
@@ -19338,9 +19293,9 @@ var setSizeLengthChecks_default = ruleCreator.createRule(typescriptLanguage, {
19338
19293
  } },
19339
19294
  setup(context) {
19340
19295
  return { visitors: { PropertyAccessExpression: (node, { program, sourceFile, typeChecker }) => {
19341
- if (node.questionDotToken || node.name.text !== "length" || !isArrayLiteralExpression(node.expression) || node.expression.elements.length !== 1) return;
19296
+ if (node.questionDotToken || node.name.text !== "length" || node.expression.kind !== SyntaxKind.ArrayLiteralExpression || node.expression.elements.length !== 1) return;
19342
19297
  const element = node.expression.elements[0];
19343
- if (!isSpreadElement(element) || !isSetExpression(element.expression, typeChecker, program)) return;
19298
+ if (element.kind !== SyntaxKind.SpreadElement || !isSetExpression(element.expression, typeChecker, program)) return;
19344
19299
  context.report({
19345
19300
  message: "preferSize",
19346
19301
  range: getTSNodeRange(node, sourceFile)
@@ -19654,7 +19609,7 @@ var sparseArrays_default = ruleCreator.createRule(typescriptLanguage, {
19654
19609
  //#endregion
19655
19610
  //#region src/rules/staticMemberOnlyClasses.ts
19656
19611
  function hasDecorators(node) {
19657
- return node.modifiers?.some(ts$1.isDecorator) ?? false;
19612
+ return node.modifiers?.some((modifier) => modifier.kind === SyntaxKind.Decorator) ?? false;
19658
19613
  }
19659
19614
  function hasExtendsClause(node) {
19660
19615
  return node.heritageClauses?.some((clause) => clause.token === SyntaxKind.ExtendsKeyword) ?? false;
@@ -20162,8 +20117,8 @@ function hasExportModifier(node) {
20162
20117
  }
20163
20118
  function isInsideFunction(node) {
20164
20119
  let current = node.parent;
20165
- while (current) {
20166
- if (ts$1.isFunctionDeclaration(current) || ts$1.isFunctionExpression(current) || ts$1.isArrowFunction(current) || ts$1.isMethodDeclaration(current) || ts$1.isConstructorDeclaration(current) || ts$1.isGetAccessorDeclaration(current) || ts$1.isSetAccessorDeclaration(current)) return true;
20120
+ while (current.kind !== SyntaxKind.SourceFile) {
20121
+ if (current.kind === SyntaxKind.FunctionDeclaration || current.kind === SyntaxKind.FunctionExpression || current.kind === SyntaxKind.ArrowFunction || current.kind === SyntaxKind.MethodDeclaration || current.kind === SyntaxKind.Constructor || current.kind === SyntaxKind.GetAccessor || current.kind === SyntaxKind.SetAccessor) return true;
20167
20122
  current = current.parent;
20168
20123
  }
20169
20124
  return false;
@@ -20385,15 +20340,13 @@ var tsComments_default = ruleCreator.createRule(typescriptLanguage, {
20385
20340
  case true:
20386
20341
  reportCommentDirective(comment, directive, { directive }, "directiveComment", "preferExpectError");
20387
20342
  return;
20388
- default:
20389
- if (typeof config === "object" && config.descriptionFormat) {
20390
- const format = descriptionFormats.get(directive);
20391
- if (format && !format.test(description)) reportCommentDirective(comment, directive, {
20392
- directive,
20393
- format: format.source
20394
- }, "descriptionNotMatchPattern");
20395
- }
20396
- break;
20343
+ default: if (typeof config === "object" && config.descriptionFormat) {
20344
+ const format = descriptionFormats.get(directive);
20345
+ if (format && !format.test(description)) reportCommentDirective(comment, directive, {
20346
+ directive,
20347
+ format: format.source
20348
+ }, "descriptionNotMatchPattern");
20349
+ }
20397
20350
  }
20398
20351
  }
20399
20352
  } } };
@@ -20475,14 +20428,16 @@ function getImportSpecifiers(node) {
20475
20428
  const specifiers = [];
20476
20429
  if (importClause.name) specifiers.push(importClause.name);
20477
20430
  const namedBindings = importClause.namedBindings;
20478
- if (namedBindings) if (namedBindings.kind === SyntaxKind.NamespaceImport) specifiers.push(namedBindings);
20479
- else specifiers.push(...namedBindings.elements);
20431
+ if (namedBindings) {
20432
+ if (namedBindings.kind === SyntaxKind.NamespaceImport) specifiers.push(namedBindings);
20433
+ else specifiers.push(...namedBindings.elements);
20434
+ }
20480
20435
  return specifiers;
20481
20436
  }
20482
20437
  function getReferencedSymbol(typeChecker, node) {
20483
20438
  let symbol;
20484
20439
  const parent = node.parent;
20485
- if (isShorthandPropertyAssignment(parent)) symbol = typeChecker.getShorthandAssignmentValueSymbol(parent);
20440
+ if (parent.kind === SyntaxKind.ShorthandPropertyAssignment) symbol = typeChecker.getShorthandAssignmentValueSymbol(parent);
20486
20441
  else symbol = typeChecker.getSymbolAtLocation(node);
20487
20442
  return symbol?.flags && (symbol.flags & SymbolFlags.Alias) !== 0 ? typeChecker.getAliasedSymbol(symbol) : symbol;
20488
20443
  }
@@ -20534,7 +20489,7 @@ function getTypeKeywordRange(node, sourceFile) {
20534
20489
  }
20535
20490
  function isInImportDeclaration(node) {
20536
20491
  let current = node;
20537
- while (current) {
20492
+ while (current.kind !== SyntaxKind.SourceFile) {
20538
20493
  if (current.kind === SyntaxKind.ImportDeclaration) return true;
20539
20494
  current = current.parent;
20540
20495
  }
@@ -20549,8 +20504,8 @@ function isOnlyTypeReference(node) {
20549
20504
  let parent = node.parent;
20550
20505
  while (parent) {
20551
20506
  if (parent.kind === SyntaxKind.HeritageClause) return parent.token === SyntaxKind.ImplementsKeyword;
20552
- if (parent.kind === SyntaxKind.TypeAliasDeclaration || parent.kind === SyntaxKind.InterfaceDeclaration || isTypeParameterDeclaration(parent)) return true;
20553
- if (isTypeNode(parent) && !isExpressionWithTypeArguments(parent)) return true;
20507
+ if (parent.kind === SyntaxKind.TypeAliasDeclaration || parent.kind === SyntaxKind.InterfaceDeclaration || parent.kind === SyntaxKind.TypeParameter) return true;
20508
+ if (isTypeNode(parent) && parent.kind !== SyntaxKind.ExpressionWithTypeArguments) return true;
20554
20509
  current = parent;
20555
20510
  parent = current.parent;
20556
20511
  }
@@ -20917,23 +20872,23 @@ var unicodeBOMs_default = ruleCreator.createRule(typescriptLanguage, {
20917
20872
  //#region src/rules/unnecessaryBinds.ts
20918
20873
  function containsThis(node) {
20919
20874
  if (node.kind === SyntaxKind.ThisKeyword) return true;
20920
- if (ts$1.isFunctionExpression(node) || ts$1.isFunctionDeclaration(node) || ts$1.isArrowFunction(node)) return false;
20875
+ if (node.kind === SyntaxKind.FunctionExpression || node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.ArrowFunction) return false;
20921
20876
  let found = false;
20922
- node.forEachChild((child) => {
20877
+ forEachChild(node, (child) => {
20923
20878
  if (containsThis(child)) found = true;
20924
20879
  });
20925
20880
  return found;
20926
20881
  }
20927
20882
  function isStaticValue(node) {
20928
- if (ts$1.isParenthesizedExpression(node)) return isStaticValue(node.expression);
20929
- if (ts$1.isPrefixUnaryExpression(node)) return isStaticValue(node.operand);
20930
- if (ts$1.isIdentifier(node)) return true;
20931
- if (ts$1.isPropertyAccessExpression(node)) return isStaticValue(node.expression);
20932
- if (ts$1.isElementAccessExpression(node)) return isStaticValue(node.expression) && isStaticValue(node.argumentExpression);
20933
- return node.kind === SyntaxKind.ThisKeyword || node.kind === SyntaxKind.SuperKeyword || node.kind === SyntaxKind.TrueKeyword || node.kind === SyntaxKind.FalseKeyword || node.kind === SyntaxKind.NullKeyword || ts$1.isBigIntLiteral(node) || ts$1.isNumericLiteral(node) || ts$1.isStringLiteral(node) || ts$1.isNoSubstitutionTemplateLiteral(node) || node.kind === SyntaxKind.RegularExpressionLiteral;
20883
+ if (node.kind === SyntaxKind.ParenthesizedExpression) return isStaticValue(node.expression);
20884
+ if (node.kind === SyntaxKind.PrefixUnaryExpression) return isStaticValue(node.operand);
20885
+ if (node.kind === SyntaxKind.Identifier) return true;
20886
+ if (node.kind === SyntaxKind.PropertyAccessExpression) return isStaticValue(node.expression);
20887
+ if (node.kind === SyntaxKind.ElementAccessExpression) return isStaticValue(node.expression) && isStaticValue(node.argumentExpression);
20888
+ return node.kind === SyntaxKind.ThisKeyword || node.kind === SyntaxKind.SuperKeyword || node.kind === SyntaxKind.TrueKeyword || node.kind === SyntaxKind.FalseKeyword || node.kind === SyntaxKind.NullKeyword || node.kind === SyntaxKind.BigIntLiteral || node.kind === SyntaxKind.NumericLiteral || node.kind === SyntaxKind.StringLiteral || node.kind === SyntaxKind.NoSubstitutionTemplateLiteral || node.kind === SyntaxKind.RegularExpressionLiteral;
20934
20889
  }
20935
20890
  function unwrapParentheses(node) {
20936
- while (ts$1.isParenthesizedExpression(node)) node = node.expression;
20891
+ while (node.kind === SyntaxKind.ParenthesizedExpression) node = node.expression;
20937
20892
  return node;
20938
20893
  }
20939
20894
  var unnecessaryBinds_default = ruleCreator.createRule(typescriptLanguage, {
@@ -20963,7 +20918,7 @@ var unnecessaryBinds_default = ruleCreator.createRule(typescriptLanguage, {
20963
20918
  range: getTSNodeRange(node, sourceFile),
20964
20919
  text: node.expression.expression.getText(sourceFile)
20965
20920
  } : void 0;
20966
- if (ts$1.isArrowFunction(boundFunction)) {
20921
+ if (boundFunction.kind === SyntaxKind.ArrowFunction) {
20967
20922
  context.report({
20968
20923
  fix,
20969
20924
  message: "arrowBind",
@@ -20974,7 +20929,7 @@ var unnecessaryBinds_default = ruleCreator.createRule(typescriptLanguage, {
20974
20929
  });
20975
20930
  return;
20976
20931
  }
20977
- if (ts$1.isFunctionExpression(boundFunction) && !containsThis(boundFunction.body)) context.report({
20932
+ if (boundFunction.kind === SyntaxKind.FunctionExpression && !containsThis(boundFunction.body)) context.report({
20978
20933
  fix,
20979
20934
  message: "unnecessaryBinds",
20980
20935
  range: {