@flint.fyi/ts 0.23.2 → 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.
- package/dist/index.d.mts +301 -1202
- package/dist/index.mjs +100 -104
- package/package.json +9 -8
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,
|
|
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
|
|
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 (
|
|
188
|
-
|
|
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 (
|
|
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
|
-
|
|
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
|
|
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 ||
|
|
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 (
|
|
600
|
-
else if (
|
|
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 (
|
|
611
|
-
else if (
|
|
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 (
|
|
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 (
|
|
631
|
-
else if (
|
|
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 (
|
|
1048
|
-
return
|
|
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) =>
|
|
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)
|
|
@@ -3016,17 +3016,20 @@ var catchCallbackTypes_default = ruleCreator.createRule(typescriptLanguage, {
|
|
|
3016
3016
|
if (symbol?.getName() !== "Promise") return false;
|
|
3017
3017
|
const declarations = symbol.getDeclarations();
|
|
3018
3018
|
if (!declarations) return false;
|
|
3019
|
-
return declarations.some((declaration) =>
|
|
3019
|
+
return declarations.some((declaration) => {
|
|
3020
|
+
const node = declaration;
|
|
3021
|
+
return node.kind === SyntaxKind.InterfaceDeclaration && node.name.text === "Promise" && declarationIncludesGlobal(declaration, program);
|
|
3022
|
+
});
|
|
3020
3023
|
}
|
|
3021
3024
|
function isCatchOrThenCallback(node, typeChecker, program) {
|
|
3022
|
-
if (
|
|
3025
|
+
if (node.expression.kind !== SyntaxKind.PropertyAccessExpression) return;
|
|
3023
3026
|
const methodName = node.expression.name.text;
|
|
3024
3027
|
if (methodName !== "catch" && methodName !== "then") return;
|
|
3025
3028
|
if (!isGlobalPromiseType(getConstrainedTypeAtLocation(node.expression.expression, typeChecker), program)) return;
|
|
3026
3029
|
return methodName === "catch" ? "catch" : "then";
|
|
3027
3030
|
}
|
|
3028
3031
|
function checkCallbackParameter(callback, sourceFile, typeChecker) {
|
|
3029
|
-
if (
|
|
3032
|
+
if (callback.kind !== SyntaxKind.ArrowFunction && callback.kind !== SyntaxKind.FunctionExpression || !callback.parameters.length) return;
|
|
3030
3033
|
const firstParameter = callback.parameters[0];
|
|
3031
3034
|
if (firstParameter.type) {
|
|
3032
3035
|
const paramType = typeChecker.getTypeFromTypeNode(firstParameter.type);
|
|
@@ -3329,17 +3332,15 @@ function classImplementsSomething(classNode) {
|
|
|
3329
3332
|
function containsThis$1(node) {
|
|
3330
3333
|
switch (node.kind) {
|
|
3331
3334
|
case SyntaxKind.ClassDeclaration:
|
|
3332
|
-
case SyntaxKind.ClassExpression:
|
|
3333
|
-
const
|
|
3334
|
-
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;
|
|
3335
3337
|
return false;
|
|
3336
|
-
}
|
|
3337
3338
|
case SyntaxKind.ClassStaticBlockDeclaration:
|
|
3338
3339
|
case SyntaxKind.FunctionDeclaration:
|
|
3339
3340
|
case SyntaxKind.FunctionExpression: return false;
|
|
3340
3341
|
case SyntaxKind.SuperKeyword:
|
|
3341
3342
|
case SyntaxKind.ThisKeyword: return true;
|
|
3342
|
-
default: return
|
|
3343
|
+
default: return forEachChild(node, containsThis$1) ?? false;
|
|
3343
3344
|
}
|
|
3344
3345
|
}
|
|
3345
3346
|
function getMemberDisplayName(member, sourceFile) {
|
|
@@ -3658,7 +3659,7 @@ var constructorGenericCalls_default = ruleCreator.createRule(typescriptLanguage,
|
|
|
3658
3659
|
}
|
|
3659
3660
|
return;
|
|
3660
3661
|
}
|
|
3661
|
-
if (
|
|
3662
|
+
if (typeAnnotation.kind !== SyntaxKind.TypeReference || typeAnnotation.typeName.kind !== SyntaxKind.Identifier || typeAnnotation.typeName.text !== constructorName || isBuiltInTypedArray(typeAnnotation.typeName.text) || !!typeAnnotation.typeArguments !== !initializer.typeArguments) return;
|
|
3662
3663
|
if (style === "constructor" && typeAnnotation.typeArguments && !initializer.typeArguments) {
|
|
3663
3664
|
const typeArgsText = getTypeArgumentsText(typeAnnotation, typeAnnotation.typeArguments, sourceFile);
|
|
3664
3665
|
const typeArgsRange = getTypeArgumentsRange(typeAnnotation, typeAnnotation.typeArguments, sourceFile);
|
|
@@ -4206,8 +4207,8 @@ function isInsideHeritageClause(node) {
|
|
|
4206
4207
|
if (node.kind === SyntaxKind.HeritageClause) return true;
|
|
4207
4208
|
let current = node.parent;
|
|
4208
4209
|
while (current) {
|
|
4209
|
-
if (
|
|
4210
|
-
if (
|
|
4210
|
+
if (current.kind === SyntaxKind.HeritageClause) return true;
|
|
4211
|
+
if (current.kind === SyntaxKind.SourceFile || current.kind === SyntaxKind.ClassDeclaration) break;
|
|
4211
4212
|
current = current.parent;
|
|
4212
4213
|
}
|
|
4213
4214
|
return false;
|
|
@@ -4216,8 +4217,8 @@ function isInsideImport(node) {
|
|
|
4216
4217
|
if (node.kind === SyntaxKind.ImportDeclaration) return true;
|
|
4217
4218
|
let current = node.parent;
|
|
4218
4219
|
while (current) {
|
|
4219
|
-
if (
|
|
4220
|
-
if (
|
|
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;
|
|
4221
4222
|
current = current.parent;
|
|
4222
4223
|
}
|
|
4223
4224
|
return false;
|
|
@@ -4277,7 +4278,7 @@ var destructuringConsistency_default = ruleCreator.createRule(typescriptLanguage
|
|
|
4277
4278
|
const propertyName = node.name.text;
|
|
4278
4279
|
if (!destructured.destructuredProperties.has(propertyName)) return;
|
|
4279
4280
|
const variableName = destructured.destructuredProperties.get(propertyName);
|
|
4280
|
-
if (
|
|
4281
|
+
if (node.parent.kind === SyntaxKind.CallExpression && node.parent.expression === node || isLeftHandSide$1(node)) return;
|
|
4281
4282
|
const range = getTSNodeRange(node, sourceFile);
|
|
4282
4283
|
const expression = node.getText(sourceFile);
|
|
4283
4284
|
const [variable, suggestions] = variableName ? [variableName, [{
|
|
@@ -4299,19 +4300,16 @@ var destructuringConsistency_default = ruleCreator.createRule(typescriptLanguage
|
|
|
4299
4300
|
destructuredObjects.length = 0;
|
|
4300
4301
|
},
|
|
4301
4302
|
VariableDeclaration: (node, { sourceFile }) => {
|
|
4302
|
-
if (!node.initializer ||
|
|
4303
|
+
if (!node.initializer || node.name.kind !== SyntaxKind.ObjectBindingPattern) return;
|
|
4303
4304
|
const initKey = getInitializerKey(node.initializer);
|
|
4304
4305
|
if (!initKey) return;
|
|
4305
4306
|
const properties = /* @__PURE__ */ new Map();
|
|
4306
|
-
for (const element of node.name.elements) {
|
|
4307
|
-
if (
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
}
|
|
4313
|
-
} else if (ts$1.isIdentifier(element.name)) properties.set(element.name.text, element.name.text);
|
|
4314
|
-
}
|
|
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);
|
|
4315
4313
|
if (properties.size) destructuredObjects.push({
|
|
4316
4314
|
declarationEnd: node.getEnd(),
|
|
4317
4315
|
destructuredProperties: properties,
|
|
@@ -4364,7 +4362,7 @@ var duplicateArguments_default = ruleCreator.createRule(typescriptLanguage, {
|
|
|
4364
4362
|
//#endregion
|
|
4365
4363
|
//#region src/rules/dynamicDeletes.ts
|
|
4366
4364
|
function isAcceptableIndexExpression(property) {
|
|
4367
|
-
return
|
|
4365
|
+
return property.kind === SyntaxKind.StringLiteral || property.kind === SyntaxKind.NumericLiteral || property.kind === SyntaxKind.PrefixUnaryExpression && property.operator === SyntaxKind.MinusToken && property.operand.kind === SyntaxKind.NumericLiteral;
|
|
4368
4366
|
}
|
|
4369
4367
|
var dynamicDeletes_default = ruleCreator.createRule(typescriptLanguage, {
|
|
4370
4368
|
about: {
|
|
@@ -4380,7 +4378,7 @@ var dynamicDeletes_default = ruleCreator.createRule(typescriptLanguage, {
|
|
|
4380
4378
|
setup(context) {
|
|
4381
4379
|
return { visitors: { DeleteExpression: (node, { sourceFile }) => {
|
|
4382
4380
|
const argument = node.expression;
|
|
4383
|
-
if (
|
|
4381
|
+
if (argument.kind !== SyntaxKind.ElementAccessExpression || isAcceptableIndexExpression(argument.argumentExpression)) return;
|
|
4384
4382
|
const property = argument.argumentExpression;
|
|
4385
4383
|
context.report({
|
|
4386
4384
|
message: "dynamicDelete",
|
|
@@ -5230,7 +5228,7 @@ function isErrorSubclass(node, typeChecker, program) {
|
|
|
5230
5228
|
if (clause.token !== SyntaxKind.ExtendsKeyword) continue;
|
|
5231
5229
|
for (const type of clause.types) {
|
|
5232
5230
|
const typeName = type.expression;
|
|
5233
|
-
if (
|
|
5231
|
+
if (typeName.kind === SyntaxKind.Identifier && builtinErrorNames.has(typeName.text) && isGlobalDeclaration(typeName, typeChecker, program)) return true;
|
|
5234
5232
|
}
|
|
5235
5233
|
}
|
|
5236
5234
|
return false;
|
|
@@ -5375,15 +5373,13 @@ var errorSubclassProperties_default = ruleCreator.createRule(typescriptLanguage,
|
|
|
5375
5373
|
//#endregion
|
|
5376
5374
|
//#region src/rules/errorUnnecessaryCaptureStackTraces.ts
|
|
5377
5375
|
function isCaptureStackTraceCall(node) {
|
|
5378
|
-
if (
|
|
5379
|
-
|
|
5380
|
-
if (!callExpression) return ts$1.isCallExpression(node) && isCaptureStackTraceCall(node);
|
|
5381
|
-
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";
|
|
5382
5378
|
}
|
|
5383
5379
|
function isValidSecondArgument(node, className) {
|
|
5384
|
-
if (
|
|
5385
|
-
if (
|
|
5386
|
-
if (
|
|
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;
|
|
5387
5383
|
return false;
|
|
5388
5384
|
}
|
|
5389
5385
|
var errorUnnecessaryCaptureStackTraces_default = ruleCreator.createRule(typescriptLanguage, {
|
|
@@ -5401,9 +5397,9 @@ var errorUnnecessaryCaptureStackTraces_default = ruleCreator.createRule(typescri
|
|
|
5401
5397
|
return { visitors: { ClassDeclaration: (node, { program, sourceFile, typeChecker }) => {
|
|
5402
5398
|
if (!isErrorSubclass(node, typeChecker, program)) return;
|
|
5403
5399
|
for (const member of node.members) {
|
|
5404
|
-
if (
|
|
5400
|
+
if (member.kind !== SyntaxKind.Constructor || !member.body) continue;
|
|
5405
5401
|
for (const statement of member.body.statements) {
|
|
5406
|
-
if (statement.kind !== SyntaxKind.ExpressionStatement ||
|
|
5402
|
+
if (statement.kind !== SyntaxKind.ExpressionStatement || statement.expression.kind !== SyntaxKind.CallExpression || !isCaptureStackTraceCall(statement.expression)) continue;
|
|
5407
5403
|
const args = statement.expression.arguments;
|
|
5408
5404
|
if (args.length < 1) continue;
|
|
5409
5405
|
if (args[0].kind !== SyntaxKind.ThisKeyword) continue;
|
|
@@ -5665,8 +5661,8 @@ function getImportInfo(node, sourceFile) {
|
|
|
5665
5661
|
const clause = node.importClause;
|
|
5666
5662
|
if (clause.name) info.defaultImport = clause.name.text;
|
|
5667
5663
|
if (clause.namedBindings) {
|
|
5668
|
-
if (
|
|
5669
|
-
else
|
|
5664
|
+
if (clause.namedBindings.kind === SyntaxKind.NamespaceImport) info.namespaceImport = clause.namedBindings.name.text;
|
|
5665
|
+
else for (const element of clause.namedBindings.elements) {
|
|
5670
5666
|
const importedName = element.propertyName ? element.propertyName.text : element.name.text;
|
|
5671
5667
|
const localName = element.name.text;
|
|
5672
5668
|
info.namedImports.set(localName, importedName);
|
|
@@ -5720,7 +5716,7 @@ var exportFromImports_default = ruleCreator.createRule(typescriptLanguage, {
|
|
|
5720
5716
|
}
|
|
5721
5717
|
}
|
|
5722
5718
|
for (const exportDeclaration of namedExports) {
|
|
5723
|
-
if (
|
|
5719
|
+
if (exportDeclaration.exportClause?.kind !== SyntaxKind.NamedExports) continue;
|
|
5724
5720
|
for (const element of exportDeclaration.exportClause.elements) {
|
|
5725
5721
|
const localName = element.propertyName ? element.propertyName.text : element.name.text;
|
|
5726
5722
|
const exportedName = element.name.text;
|
|
@@ -5753,7 +5749,7 @@ var exportFromImports_default = ruleCreator.createRule(typescriptLanguage, {
|
|
|
5753
5749
|
}
|
|
5754
5750
|
}
|
|
5755
5751
|
for (const exportAssignment of exportAssignments) {
|
|
5756
|
-
if (
|
|
5752
|
+
if (exportAssignment.expression.kind !== SyntaxKind.Identifier) continue;
|
|
5757
5753
|
const localName = exportAssignment.expression.text;
|
|
5758
5754
|
const importInfo = imports.get(localName);
|
|
5759
5755
|
if (importInfo?.defaultImport !== localName) continue;
|
|
@@ -7147,8 +7143,8 @@ function isLiteralArgument(node, constructorName) {
|
|
|
7147
7143
|
switch (constructorName) {
|
|
7148
7144
|
case "BigInt": return isNumericLiteralForBigInt(node);
|
|
7149
7145
|
case "Boolean": return isLiteralExpression(node) || isBooleanLiteral(node);
|
|
7150
|
-
case "Number": return
|
|
7151
|
-
case "String": return
|
|
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;
|
|
7152
7148
|
default: return false;
|
|
7153
7149
|
}
|
|
7154
7150
|
}
|
|
@@ -7174,7 +7170,7 @@ var literalConstructorWrappers_default = ruleCreator.createRule(typescriptLangua
|
|
|
7174
7170
|
} },
|
|
7175
7171
|
setup(context) {
|
|
7176
7172
|
return { visitors: { CallExpression: (node, { program, sourceFile, typeChecker }) => {
|
|
7177
|
-
if (
|
|
7173
|
+
if (node.expression.kind !== SyntaxKind.Identifier) return;
|
|
7178
7174
|
const name = node.expression.text;
|
|
7179
7175
|
if (!literalConstructors.has(name) || node.arguments.length !== 1 || !isGlobalDeclarationOfName(node.expression, name, typeChecker, program)) return;
|
|
7180
7176
|
const argument = node.arguments[0];
|
|
@@ -8397,21 +8393,21 @@ function hasNoAssignmentBeforeNode(identifier, node, sourceFile, typeChecker) {
|
|
|
8397
8393
|
const nodeEnd = node.getEnd();
|
|
8398
8394
|
for (const declaration of declarations) {
|
|
8399
8395
|
if (declaration.getEnd() >= nodeEnd) continue;
|
|
8400
|
-
if (
|
|
8396
|
+
if (declaration.kind === SyntaxKind.VariableDeclaration) {
|
|
8401
8397
|
if (declaration.exclamationToken || declaration.initializer) return false;
|
|
8402
|
-
} else if (
|
|
8398
|
+
} else if (declaration.kind === SyntaxKind.Parameter && declaration.initializer) return false;
|
|
8403
8399
|
}
|
|
8404
8400
|
const valueDeclaration = symbol.valueDeclaration;
|
|
8405
8401
|
if (!valueDeclaration) return true;
|
|
8406
8402
|
function findModifyingReference(current) {
|
|
8407
|
-
if (
|
|
8403
|
+
if (current.kind === SyntaxKind.Identifier) {
|
|
8408
8404
|
if (typeChecker.getSymbolAtLocation(current)?.valueDeclaration === valueDeclaration) {
|
|
8409
8405
|
const parent = current.parent;
|
|
8410
|
-
if (
|
|
8411
|
-
if ((
|
|
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;
|
|
8412
8408
|
}
|
|
8413
8409
|
}
|
|
8414
|
-
return
|
|
8410
|
+
return forEachChild(current, findModifyingReference) ?? false;
|
|
8415
8411
|
}
|
|
8416
8412
|
return !findModifyingReference(sourceFile);
|
|
8417
8413
|
}
|
|
@@ -9158,16 +9154,16 @@ var numberMethodRanges_default = ruleCreator.createRule(typescriptLanguage, {
|
|
|
9158
9154
|
//#region src/rules/numberStaticMethods.ts
|
|
9159
9155
|
const globalReplacements = /* @__PURE__ */ new Map([["isFinite", "Number.isFinite"], ["isNaN", "Number.isNaN"]]);
|
|
9160
9156
|
function isDeclarationName(node) {
|
|
9161
|
-
return
|
|
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;
|
|
9162
9158
|
}
|
|
9163
9159
|
function isLeftHandSide(node) {
|
|
9164
9160
|
return node.parent.kind === SyntaxKind.BinaryExpression && node.parent.left === node && node.parent.operatorToken.kind >= SyntaxKind.FirstAssignment && node.parent.operatorToken.kind <= SyntaxKind.LastAssignment;
|
|
9165
9161
|
}
|
|
9166
9162
|
function isPropertyAccessOfNode(node) {
|
|
9167
|
-
return
|
|
9163
|
+
return node.parent.kind === SyntaxKind.PropertyAccessExpression && node.parent.name === node;
|
|
9168
9164
|
}
|
|
9169
9165
|
function isPropertyShorthandOfNode(node) {
|
|
9170
|
-
return
|
|
9166
|
+
return node.parent.kind === SyntaxKind.ShorthandPropertyAssignment && node.parent.name === node;
|
|
9171
9167
|
}
|
|
9172
9168
|
var numberStaticMethods_default = ruleCreator.createRule(typescriptLanguage, {
|
|
9173
9169
|
about: {
|
|
@@ -10160,7 +10156,7 @@ function getMethodDisplayName(method) {
|
|
|
10160
10156
|
function getNameFromPropertyName(name) {
|
|
10161
10157
|
switch (name.kind) {
|
|
10162
10158
|
case SyntaxKind.ComputedPropertyName:
|
|
10163
|
-
if (
|
|
10159
|
+
if (name.expression.kind === SyntaxKind.StringLiteral) return {
|
|
10164
10160
|
name: name.expression.text,
|
|
10165
10161
|
type: "quoted"
|
|
10166
10162
|
};
|
|
@@ -10551,7 +10547,7 @@ function isDescendantOf(node, potentialAncestor) {
|
|
|
10551
10547
|
}
|
|
10552
10548
|
function isNodeInsideReturnType(node) {
|
|
10553
10549
|
let current = node.parent;
|
|
10554
|
-
while (current) {
|
|
10550
|
+
while (current.kind !== SyntaxKind.SourceFile) {
|
|
10555
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);
|
|
10556
10552
|
current = current.parent;
|
|
10557
10553
|
}
|
|
@@ -15229,10 +15225,10 @@ function extractCallExpression(expression) {
|
|
|
15229
15225
|
function findAssignmentsToSymbol(symbol, sourceFile, typeChecker) {
|
|
15230
15226
|
const assignments = [];
|
|
15231
15227
|
function visit(node) {
|
|
15232
|
-
if (
|
|
15228
|
+
if (node.kind === SyntaxKind.BinaryExpression && node.operatorToken.kind === SyntaxKind.EqualsToken && node.left.kind === SyntaxKind.Identifier) {
|
|
15233
15229
|
if (typeChecker.getSymbolAtLocation(node.left) === symbol) assignments.push(node);
|
|
15234
15230
|
}
|
|
15235
|
-
|
|
15231
|
+
forEachChild(node, visit);
|
|
15236
15232
|
}
|
|
15237
15233
|
visit(sourceFile);
|
|
15238
15234
|
return assignments;
|
|
@@ -15312,7 +15308,7 @@ function getRegexInfoFromExpression(node, typeChecker, sourceFile) {
|
|
|
15312
15308
|
if (symbol) {
|
|
15313
15309
|
const declarations = symbol.getDeclarations();
|
|
15314
15310
|
if (declarations) {
|
|
15315
|
-
for (const declaration of declarations) if (
|
|
15311
|
+
for (const declaration of declarations) if (declaration.kind === SyntaxKind.VariableDeclaration && declaration.initializer) return getRegexInfoFromExpression(declaration.initializer, typeChecker, sourceFile);
|
|
15316
15312
|
}
|
|
15317
15313
|
}
|
|
15318
15314
|
}
|
|
@@ -15320,7 +15316,7 @@ function getRegexInfoFromExpression(node, typeChecker, sourceFile) {
|
|
|
15320
15316
|
function getRegexInfoFromSymbol(symbol, typeChecker, sourceFile) {
|
|
15321
15317
|
const declarations = symbol.getDeclarations();
|
|
15322
15318
|
if (declarations) for (const declaration of declarations) {
|
|
15323
|
-
if (
|
|
15319
|
+
if (declaration.kind === SyntaxKind.VariableDeclaration && declaration.initializer) {
|
|
15324
15320
|
const callExpression = extractCallExpression(declaration.initializer);
|
|
15325
15321
|
if (callExpression) {
|
|
15326
15322
|
const regexInfo = getRegexFromCall(callExpression, typeChecker, sourceFile);
|
|
@@ -15330,7 +15326,7 @@ function getRegexInfoFromSymbol(symbol, typeChecker, sourceFile) {
|
|
|
15330
15326
|
}
|
|
15331
15327
|
}
|
|
15332
15328
|
}
|
|
15333
|
-
if (
|
|
15329
|
+
if (declaration.kind === SyntaxKind.Parameter) continue;
|
|
15334
15330
|
}
|
|
15335
15331
|
const assignments = findAssignmentsToSymbol(symbol, sourceFile, typeChecker);
|
|
15336
15332
|
for (const assignment of assignments) {
|
|
@@ -18865,14 +18861,14 @@ function getSpecifierNames(specifier) {
|
|
|
18865
18861
|
function isFromFile(sourceFile, specifiedPath, program) {
|
|
18866
18862
|
if (specifiedPath === void 0) return !sourceFile.fileName.includes("/node_modules/") && !program.isSourceFileDefaultLibrary(sourceFile);
|
|
18867
18863
|
const caseSensitive = ts$1.sys.useCaseSensitiveFileNames;
|
|
18868
|
-
return pathKey(sourceFile.fileName, caseSensitive) === pathKey(
|
|
18864
|
+
return pathKey(sourceFile.fileName, caseSensitive) === pathKey(resolve(program.getCurrentDirectory(), specifiedPath), caseSensitive);
|
|
18869
18865
|
}
|
|
18870
18866
|
//#endregion
|
|
18871
18867
|
//#region src/type-utils/isDeclaredInModuleBlock.ts
|
|
18872
18868
|
function isDeclaredInModuleBlock(declaration, packageName) {
|
|
18873
18869
|
let current = declaration;
|
|
18874
|
-
while (
|
|
18875
|
-
if (
|
|
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;
|
|
18876
18872
|
current = current.parent;
|
|
18877
18873
|
}
|
|
18878
18874
|
return false;
|
|
@@ -19268,20 +19264,20 @@ var sequences_default = ruleCreator.createRule(typescriptLanguage, {
|
|
|
19268
19264
|
//#endregion
|
|
19269
19265
|
//#region src/rules/setSizeLengthChecks.ts
|
|
19270
19266
|
function isNewSetExpression(expression, typeChecker, program) {
|
|
19271
|
-
return
|
|
19267
|
+
return expression.kind === SyntaxKind.NewExpression && expression.expression.kind === SyntaxKind.Identifier && expression.expression.text === "Set" && isGlobalDeclarationOfName(expression.expression, "Set", typeChecker, program);
|
|
19272
19268
|
}
|
|
19273
19269
|
function isSetExpression(expression, typeChecker, program) {
|
|
19274
19270
|
const unwrapped = unwrapParentheses$1(expression);
|
|
19275
19271
|
if (isNewSetExpression(unwrapped, typeChecker, program)) return true;
|
|
19276
|
-
if (
|
|
19272
|
+
if (unwrapped.kind !== SyntaxKind.Identifier) return false;
|
|
19277
19273
|
const symbol = typeChecker.getSymbolAtLocation(unwrapped);
|
|
19278
|
-
if (
|
|
19274
|
+
if (symbol?.valueDeclaration?.kind !== SyntaxKind.VariableDeclaration) return false;
|
|
19279
19275
|
const declaration = symbol.valueDeclaration;
|
|
19280
19276
|
if (declaration.parent.kind !== SyntaxKind.VariableDeclarationList || !(declaration.parent.flags & NodeFlags.Const) || !declaration.initializer) return false;
|
|
19281
19277
|
return isNewSetExpression(unwrapParentheses$1(declaration.initializer), typeChecker, program);
|
|
19282
19278
|
}
|
|
19283
19279
|
function unwrapParentheses$1(expression) {
|
|
19284
|
-
while (
|
|
19280
|
+
while (expression.kind === SyntaxKind.ParenthesizedExpression) expression = expression.expression;
|
|
19285
19281
|
return expression;
|
|
19286
19282
|
}
|
|
19287
19283
|
var setSizeLengthChecks_default = ruleCreator.createRule(typescriptLanguage, {
|
|
@@ -19297,9 +19293,9 @@ var setSizeLengthChecks_default = ruleCreator.createRule(typescriptLanguage, {
|
|
|
19297
19293
|
} },
|
|
19298
19294
|
setup(context) {
|
|
19299
19295
|
return { visitors: { PropertyAccessExpression: (node, { program, sourceFile, typeChecker }) => {
|
|
19300
|
-
if (node.questionDotToken || node.name.text !== "length" ||
|
|
19296
|
+
if (node.questionDotToken || node.name.text !== "length" || node.expression.kind !== SyntaxKind.ArrayLiteralExpression || node.expression.elements.length !== 1) return;
|
|
19301
19297
|
const element = node.expression.elements[0];
|
|
19302
|
-
if (
|
|
19298
|
+
if (element.kind !== SyntaxKind.SpreadElement || !isSetExpression(element.expression, typeChecker, program)) return;
|
|
19303
19299
|
context.report({
|
|
19304
19300
|
message: "preferSize",
|
|
19305
19301
|
range: getTSNodeRange(node, sourceFile)
|
|
@@ -19613,7 +19609,7 @@ var sparseArrays_default = ruleCreator.createRule(typescriptLanguage, {
|
|
|
19613
19609
|
//#endregion
|
|
19614
19610
|
//#region src/rules/staticMemberOnlyClasses.ts
|
|
19615
19611
|
function hasDecorators(node) {
|
|
19616
|
-
return node.modifiers?.some(
|
|
19612
|
+
return node.modifiers?.some((modifier) => modifier.kind === SyntaxKind.Decorator) ?? false;
|
|
19617
19613
|
}
|
|
19618
19614
|
function hasExtendsClause(node) {
|
|
19619
19615
|
return node.heritageClauses?.some((clause) => clause.token === SyntaxKind.ExtendsKeyword) ?? false;
|
|
@@ -20121,8 +20117,8 @@ function hasExportModifier(node) {
|
|
|
20121
20117
|
}
|
|
20122
20118
|
function isInsideFunction(node) {
|
|
20123
20119
|
let current = node.parent;
|
|
20124
|
-
while (current) {
|
|
20125
|
-
if (
|
|
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;
|
|
20126
20122
|
current = current.parent;
|
|
20127
20123
|
}
|
|
20128
20124
|
return false;
|
|
@@ -20441,7 +20437,7 @@ function getImportSpecifiers(node) {
|
|
|
20441
20437
|
function getReferencedSymbol(typeChecker, node) {
|
|
20442
20438
|
let symbol;
|
|
20443
20439
|
const parent = node.parent;
|
|
20444
|
-
if (
|
|
20440
|
+
if (parent.kind === SyntaxKind.ShorthandPropertyAssignment) symbol = typeChecker.getShorthandAssignmentValueSymbol(parent);
|
|
20445
20441
|
else symbol = typeChecker.getSymbolAtLocation(node);
|
|
20446
20442
|
return symbol?.flags && (symbol.flags & SymbolFlags.Alias) !== 0 ? typeChecker.getAliasedSymbol(symbol) : symbol;
|
|
20447
20443
|
}
|
|
@@ -20493,7 +20489,7 @@ function getTypeKeywordRange(node, sourceFile) {
|
|
|
20493
20489
|
}
|
|
20494
20490
|
function isInImportDeclaration(node) {
|
|
20495
20491
|
let current = node;
|
|
20496
|
-
while (current) {
|
|
20492
|
+
while (current.kind !== SyntaxKind.SourceFile) {
|
|
20497
20493
|
if (current.kind === SyntaxKind.ImportDeclaration) return true;
|
|
20498
20494
|
current = current.parent;
|
|
20499
20495
|
}
|
|
@@ -20508,8 +20504,8 @@ function isOnlyTypeReference(node) {
|
|
|
20508
20504
|
let parent = node.parent;
|
|
20509
20505
|
while (parent) {
|
|
20510
20506
|
if (parent.kind === SyntaxKind.HeritageClause) return parent.token === SyntaxKind.ImplementsKeyword;
|
|
20511
|
-
if (parent.kind === SyntaxKind.TypeAliasDeclaration || parent.kind === SyntaxKind.InterfaceDeclaration ||
|
|
20512
|
-
if (isTypeNode(parent) &&
|
|
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;
|
|
20513
20509
|
current = parent;
|
|
20514
20510
|
parent = current.parent;
|
|
20515
20511
|
}
|
|
@@ -20876,23 +20872,23 @@ var unicodeBOMs_default = ruleCreator.createRule(typescriptLanguage, {
|
|
|
20876
20872
|
//#region src/rules/unnecessaryBinds.ts
|
|
20877
20873
|
function containsThis(node) {
|
|
20878
20874
|
if (node.kind === SyntaxKind.ThisKeyword) return true;
|
|
20879
|
-
if (
|
|
20875
|
+
if (node.kind === SyntaxKind.FunctionExpression || node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.ArrowFunction) return false;
|
|
20880
20876
|
let found = false;
|
|
20881
|
-
|
|
20877
|
+
forEachChild(node, (child) => {
|
|
20882
20878
|
if (containsThis(child)) found = true;
|
|
20883
20879
|
});
|
|
20884
20880
|
return found;
|
|
20885
20881
|
}
|
|
20886
20882
|
function isStaticValue(node) {
|
|
20887
|
-
if (
|
|
20888
|
-
if (
|
|
20889
|
-
if (
|
|
20890
|
-
if (
|
|
20891
|
-
if (
|
|
20892
|
-
return node.kind === SyntaxKind.ThisKeyword || node.kind === SyntaxKind.SuperKeyword || node.kind === SyntaxKind.TrueKeyword || node.kind === SyntaxKind.FalseKeyword || node.kind === SyntaxKind.NullKeyword ||
|
|
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;
|
|
20893
20889
|
}
|
|
20894
20890
|
function unwrapParentheses(node) {
|
|
20895
|
-
while (
|
|
20891
|
+
while (node.kind === SyntaxKind.ParenthesizedExpression) node = node.expression;
|
|
20896
20892
|
return node;
|
|
20897
20893
|
}
|
|
20898
20894
|
var unnecessaryBinds_default = ruleCreator.createRule(typescriptLanguage, {
|
|
@@ -20922,7 +20918,7 @@ var unnecessaryBinds_default = ruleCreator.createRule(typescriptLanguage, {
|
|
|
20922
20918
|
range: getTSNodeRange(node, sourceFile),
|
|
20923
20919
|
text: node.expression.expression.getText(sourceFile)
|
|
20924
20920
|
} : void 0;
|
|
20925
|
-
if (
|
|
20921
|
+
if (boundFunction.kind === SyntaxKind.ArrowFunction) {
|
|
20926
20922
|
context.report({
|
|
20927
20923
|
fix,
|
|
20928
20924
|
message: "arrowBind",
|
|
@@ -20933,7 +20929,7 @@ var unnecessaryBinds_default = ruleCreator.createRule(typescriptLanguage, {
|
|
|
20933
20929
|
});
|
|
20934
20930
|
return;
|
|
20935
20931
|
}
|
|
20936
|
-
if (
|
|
20932
|
+
if (boundFunction.kind === SyntaxKind.FunctionExpression && !containsThis(boundFunction.body)) context.report({
|
|
20937
20933
|
fix,
|
|
20938
20934
|
message: "unnecessaryBinds",
|
|
20939
20935
|
range: {
|