@flint.fyi/ts 0.14.5 → 0.15.0
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/lib/collectReferencedFilePaths.d.ts +1 -0
- package/lib/collectReferencedFilePaths.js +3 -2
- package/lib/convertTypeScriptDiagnosticToLanguageFileDiagnostic.d.ts +14 -0
- package/lib/{formatDiagnostic.js → convertTypeScriptDiagnosticToLanguageFileDiagnostic.js} +23 -15
- package/lib/createTypeScriptFileFromProgram.d.ts +4 -1
- package/lib/createTypeScriptFileFromProgram.js +25 -30
- package/lib/createTypeScriptFileFromProjectService.d.ts +3 -6
- package/lib/createTypeScriptFileFromProjectService.js +5 -11
- package/lib/directives/parseDirectivesFromTypeScriptFile.d.ts +8 -0
- package/lib/directives/parseDirectivesFromTypeScriptFile.js +12 -4
- package/lib/directives/parseDirectivesFromTypeScriptFile.test.d.ts +1 -0
- package/lib/directives/parseDirectivesFromTypeScriptFile.test.js +1 -0
- package/lib/getFirstEnumValues.d.ts +1 -0
- package/lib/getFirstEnumValues.js +1 -0
- package/lib/getFirstEnumValues.test.d.ts +1 -0
- package/lib/getFirstEnumValues.test.js +1 -0
- package/lib/getTSNodeRange.d.ts +1 -0
- package/lib/getTSNodeRange.js +1 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +5 -0
- package/lib/language.d.ts +3 -2
- package/lib/language.js +7 -52
- package/lib/nodes.d.ts +1 -0
- package/lib/nodes.js +1 -0
- package/lib/normalizeRange.d.ts +1 -0
- package/lib/normalizeRange.js +4 -6
- package/lib/plugin.d.ts +79 -50
- package/lib/plugin.js +16 -1
- package/lib/prepareTypeScriptBasedLanguage.d.ts +11 -0
- package/lib/prepareTypeScriptBasedLanguage.js +59 -0
- package/lib/prepareTypeScriptFile.d.ts +9 -4
- package/lib/prepareTypeScriptFile.js +8 -2
- package/lib/rules/anyReturns.d.ts +2 -1
- package/lib/rules/anyReturns.js +22 -22
- package/lib/rules/anyReturns.test.d.ts +1 -0
- package/lib/rules/anyReturns.test.js +1 -0
- package/lib/rules/asyncPromiseExecutors.d.ts +2 -1
- package/lib/rules/asyncPromiseExecutors.js +4 -3
- package/lib/rules/asyncPromiseExecutors.test.d.ts +1 -0
- package/lib/rules/asyncPromiseExecutors.test.js +1 -0
- package/lib/rules/caseDeclarations.d.ts +3 -1
- package/lib/rules/caseDeclarations.js +7 -6
- package/lib/rules/caseDeclarations.test.d.ts +1 -0
- package/lib/rules/caseDeclarations.test.js +1 -0
- package/lib/rules/caseDuplicates.d.ts +2 -1
- package/lib/rules/caseDuplicates.js +4 -3
- package/lib/rules/caseDuplicates.test.d.ts +1 -0
- package/lib/rules/caseDuplicates.test.js +1 -0
- package/lib/rules/chainedAssignments.d.ts +2 -1
- package/lib/rules/chainedAssignments.js +3 -2
- package/lib/rules/chainedAssignments.test.d.ts +1 -0
- package/lib/rules/chainedAssignments.test.js +1 -0
- package/lib/rules/classAssignments.d.ts +2 -1
- package/lib/rules/classAssignments.js +4 -3
- package/lib/rules/classAssignments.test.d.ts +1 -0
- package/lib/rules/classAssignments.test.js +1 -0
- package/lib/rules/consecutiveNonNullAssertions.d.ts +2 -1
- package/lib/rules/consecutiveNonNullAssertions.js +1 -0
- package/lib/rules/consecutiveNonNullAssertions.test.d.ts +1 -0
- package/lib/rules/consecutiveNonNullAssertions.test.js +1 -0
- package/lib/rules/constantAssignments.d.ts +2 -1
- package/lib/rules/constantAssignments.js +4 -3
- package/lib/rules/constantAssignments.test.d.ts +1 -0
- package/lib/rules/constantAssignments.test.js +1 -0
- package/lib/rules/constructorReturns.d.ts +2 -1
- package/lib/rules/constructorReturns.js +3 -2
- package/lib/rules/constructorReturns.test.d.ts +1 -0
- package/lib/rules/constructorReturns.test.js +1 -0
- package/lib/rules/debuggerStatements.d.ts +2 -1
- package/lib/rules/debuggerStatements.js +1 -0
- package/lib/rules/debuggerStatements.test.d.ts +1 -0
- package/lib/rules/debuggerStatements.test.js +1 -0
- package/lib/rules/defaultCaseLast.d.ts +2 -1
- package/lib/rules/defaultCaseLast.js +4 -3
- package/lib/rules/defaultCaseLast.test.d.ts +1 -0
- package/lib/rules/defaultCaseLast.test.js +1 -0
- package/lib/rules/duplicateArguments.d.ts +3 -1
- package/lib/rules/duplicateArguments.js +3 -2
- package/lib/rules/duplicateArguments.test.d.ts +1 -0
- package/lib/rules/duplicateArguments.test.js +1 -0
- package/lib/rules/elseIfDuplicates.d.ts +2 -1
- package/lib/rules/elseIfDuplicates.js +6 -5
- package/lib/rules/elseIfDuplicates.test.d.ts +1 -0
- package/lib/rules/elseIfDuplicates.test.js +1 -0
- package/lib/rules/emptyBlocks.d.ts +2 -1
- package/lib/rules/emptyBlocks.js +12 -10
- package/lib/rules/emptyBlocks.test.d.ts +1 -0
- package/lib/rules/emptyBlocks.test.js +1 -0
- package/lib/rules/emptyDestructures.d.ts +3 -1
- package/lib/rules/emptyDestructures.js +3 -2
- package/lib/rules/emptyDestructures.test.d.ts +1 -0
- package/lib/rules/emptyDestructures.test.js +1 -0
- package/lib/rules/emptyStaticBlocks.d.ts +2 -1
- package/lib/rules/emptyStaticBlocks.js +5 -4
- package/lib/rules/emptyStaticBlocks.test.d.ts +1 -0
- package/lib/rules/emptyStaticBlocks.test.js +1 -0
- package/lib/rules/exceptionAssignments.d.ts +2 -1
- package/lib/rules/exceptionAssignments.js +4 -3
- package/lib/rules/exceptionAssignments.test.d.ts +1 -0
- package/lib/rules/exceptionAssignments.test.js +1 -0
- package/lib/rules/finallyStatementSafety.d.ts +7 -0
- package/lib/rules/finallyStatementSafety.js +71 -0
- package/lib/rules/finallyStatementSafety.test.d.ts +2 -0
- package/lib/rules/finallyStatementSafety.test.js +307 -0
- package/lib/rules/forDirections.d.ts +2 -1
- package/lib/rules/forDirections.js +18 -10
- package/lib/rules/forDirections.test.d.ts +1 -0
- package/lib/rules/forDirections.test.js +26 -0
- package/lib/rules/forInArrays.d.ts +2 -1
- package/lib/rules/forInArrays.js +8 -7
- package/lib/rules/forInArrays.test.d.ts +1 -0
- package/lib/rules/forInArrays.test.js +1 -0
- package/lib/rules/functionAssignments.d.ts +2 -1
- package/lib/rules/functionAssignments.js +4 -3
- package/lib/rules/functionAssignments.test.d.ts +1 -0
- package/lib/rules/functionAssignments.test.js +1 -0
- package/lib/rules/functionCurryingRedundancy.d.ts +7 -0
- package/lib/rules/functionCurryingRedundancy.js +77 -0
- package/lib/rules/functionCurryingRedundancy.test.d.ts +2 -0
- package/lib/rules/functionCurryingRedundancy.test.js +172 -0
- package/lib/rules/functionNewCalls.d.ts +3 -1
- package/lib/rules/functionNewCalls.js +7 -6
- package/lib/rules/functionNewCalls.test.d.ts +1 -0
- package/lib/rules/functionNewCalls.test.js +1 -0
- package/lib/rules/generatorFunctionYields.d.ts +3 -1
- package/lib/rules/generatorFunctionYields.js +3 -2
- package/lib/rules/generatorFunctionYields.test.d.ts +1 -0
- package/lib/rules/generatorFunctionYields.test.js +1 -0
- package/lib/rules/globalAssignments.d.ts +2 -1
- package/lib/rules/globalAssignments.js +10 -9
- package/lib/rules/globalAssignments.test.d.ts +1 -0
- package/lib/rules/globalAssignments.test.js +1 -0
- package/lib/rules/globalObjectCalls.d.ts +3 -1
- package/lib/rules/globalObjectCalls.js +5 -4
- package/lib/rules/globalObjectCalls.test.d.ts +1 -0
- package/lib/rules/globalObjectCalls.test.js +1 -0
- package/lib/rules/namespaceDeclarations.d.ts +2 -1
- package/lib/rules/namespaceDeclarations.js +7 -6
- package/lib/rules/namespaceDeclarations.test.d.ts +1 -0
- package/lib/rules/namespaceDeclarations.test.js +1 -0
- package/lib/rules/negativeZeroComparisons.d.ts +2 -1
- package/lib/rules/negativeZeroComparisons.js +8 -7
- package/lib/rules/negativeZeroComparisons.test.d.ts +1 -0
- package/lib/rules/negativeZeroComparisons.test.js +1 -0
- package/lib/rules/newExpressions.d.ts +2 -1
- package/lib/rules/newExpressions.js +3 -2
- package/lib/rules/newExpressions.test.d.ts +1 -0
- package/lib/rules/newExpressions.test.js +1 -0
- package/lib/rules/newNativeNonConstructors.d.ts +2 -1
- package/lib/rules/newNativeNonConstructors.js +6 -5
- package/lib/rules/newNativeNonConstructors.test.d.ts +1 -0
- package/lib/rules/newNativeNonConstructors.test.js +1 -0
- package/lib/rules/nonOctalDecimalEscapes.d.ts +3 -1
- package/lib/rules/nonOctalDecimalEscapes.js +4 -3
- package/lib/rules/nonOctalDecimalEscapes.test.d.ts +1 -0
- package/lib/rules/nonOctalDecimalEscapes.test.js +1 -0
- package/lib/rules/numericLiteralParsing.d.ts +2 -1
- package/lib/rules/numericLiteralParsing.js +8 -7
- package/lib/rules/numericLiteralParsing.test.d.ts +1 -0
- package/lib/rules/numericLiteralParsing.test.js +1 -0
- package/lib/rules/objectCalls.d.ts +7 -0
- package/lib/rules/objectCalls.js +47 -0
- package/lib/rules/objectCalls.test.d.ts +2 -0
- package/lib/rules/objectCalls.test.js +172 -0
- package/lib/rules/objectHasOwns.d.ts +7 -0
- package/lib/rules/objectHasOwns.js +74 -0
- package/lib/rules/objectHasOwns.test.d.ts +2 -0
- package/lib/rules/objectHasOwns.test.js +112 -0
- package/lib/rules/objectKeyDuplicates.d.ts +7 -0
- package/lib/rules/objectKeyDuplicates.js +91 -0
- package/lib/rules/objectKeyDuplicates.test.d.ts +2 -0
- package/lib/rules/objectKeyDuplicates.test.js +180 -0
- package/lib/rules/objectProto.d.ts +2 -1
- package/lib/rules/objectProto.js +5 -4
- package/lib/rules/objectProto.test.d.ts +1 -0
- package/lib/rules/objectProto.test.js +1 -0
- package/lib/rules/objectPrototypeBuiltIns.d.ts +7 -0
- package/lib/rules/objectPrototypeBuiltIns.js +65 -0
- package/lib/rules/objectPrototypeBuiltIns.test.d.ts +2 -0
- package/lib/rules/objectPrototypeBuiltIns.test.js +146 -0
- package/lib/rules/octalEscapes.d.ts +2 -1
- package/lib/rules/octalEscapes.js +13 -8
- package/lib/rules/octalEscapes.test.d.ts +1 -0
- package/lib/rules/octalEscapes.test.js +1 -0
- package/lib/rules/octalNumbers.d.ts +2 -1
- package/lib/rules/octalNumbers.js +4 -3
- package/lib/rules/octalNumbers.test.d.ts +1 -0
- package/lib/rules/octalNumbers.test.js +1 -0
- package/lib/rules/returnAssignments.d.ts +2 -1
- package/lib/rules/returnAssignments.js +7 -6
- package/lib/rules/returnAssignments.test.d.ts +1 -0
- package/lib/rules/returnAssignments.test.js +1 -0
- package/lib/rules/ruleTester.d.ts +1 -0
- package/lib/rules/ruleTester.js +6 -1
- package/lib/rules/selfAssignments.d.ts +2 -1
- package/lib/rules/selfAssignments.js +4 -3
- package/lib/rules/selfAssignments.test.d.ts +1 -0
- package/lib/rules/selfAssignments.test.js +1 -0
- package/lib/rules/selfComparisons.d.ts +2 -1
- package/lib/rules/selfComparisons.js +4 -3
- package/lib/rules/selfComparisons.test.d.ts +1 -0
- package/lib/rules/selfComparisons.test.js +1 -0
- package/lib/rules/sequences.d.ts +2 -1
- package/lib/rules/sequences.js +3 -2
- package/lib/rules/sequences.test.d.ts +1 -0
- package/lib/rules/sequences.test.js +1 -0
- package/lib/rules/shadowedRestrictedNames.d.ts +2 -1
- package/lib/rules/shadowedRestrictedNames.js +24 -23
- package/lib/rules/shadowedRestrictedNames.test.d.ts +1 -0
- package/lib/rules/shadowedRestrictedNames.test.js +1 -0
- package/lib/rules/sparseArrays.d.ts +2 -1
- package/lib/rules/sparseArrays.js +5 -4
- package/lib/rules/sparseArrays.test.d.ts +1 -0
- package/lib/rules/sparseArrays.test.js +1 -0
- package/lib/rules/symbolDescriptions.d.ts +2 -1
- package/lib/rules/symbolDescriptions.js +3 -2
- package/lib/rules/symbolDescriptions.test.d.ts +1 -0
- package/lib/rules/symbolDescriptions.test.js +1 -0
- package/lib/rules/typeofComparisons.d.ts +2 -1
- package/lib/rules/typeofComparisons.js +5 -4
- package/lib/rules/typeofComparisons.test.d.ts +1 -0
- package/lib/rules/typeofComparisons.test.js +1 -0
- package/lib/rules/unassignedVariables.d.ts +2 -1
- package/lib/rules/unassignedVariables.js +4 -3
- package/lib/rules/unassignedVariables.test.d.ts +1 -0
- package/lib/rules/unassignedVariables.test.js +1 -0
- package/lib/rules/undefinedVariables.d.ts +2 -1
- package/lib/rules/undefinedVariables.js +5 -4
- package/lib/rules/undefinedVariables.test.d.ts +1 -0
- package/lib/rules/undefinedVariables.test.js +1 -0
- package/lib/rules/unicodeBOMs.d.ts +2 -1
- package/lib/rules/unicodeBOMs.js +27 -20
- package/lib/rules/unicodeBOMs.test.d.ts +1 -0
- package/lib/rules/unicodeBOMs.test.js +1 -0
- package/lib/rules/unnecessaryBlocks.d.ts +2 -1
- package/lib/rules/unnecessaryBlocks.js +4 -3
- package/lib/rules/unnecessaryBlocks.test.d.ts +1 -0
- package/lib/rules/unnecessaryBlocks.test.js +1 -0
- package/lib/rules/unnecessaryCatches.d.ts +2 -1
- package/lib/rules/unnecessaryCatches.js +4 -3
- package/lib/rules/unnecessaryCatches.test.d.ts +1 -0
- package/lib/rules/unnecessaryCatches.test.js +1 -0
- package/lib/rules/unnecessaryConcatenation.d.ts +2 -1
- package/lib/rules/unnecessaryConcatenation.js +3 -2
- package/lib/rules/unnecessaryConcatenation.test.d.ts +1 -0
- package/lib/rules/unnecessaryConcatenation.test.js +1 -0
- package/lib/rules/unsafeNegations.d.ts +2 -1
- package/lib/rules/unsafeNegations.js +3 -2
- package/lib/rules/unsafeNegations.test.d.ts +1 -0
- package/lib/rules/unsafeNegations.test.js +1 -0
- package/lib/rules/utils/discriminateAnyType.d.ts +1 -0
- package/lib/rules/utils/discriminateAnyType.js +1 -0
- package/lib/rules/utils/getConstrainedType.d.ts +1 -0
- package/lib/rules/utils/getConstrainedType.js +1 -0
- package/lib/rules/utils/getThisExpression.d.ts +1 -0
- package/lib/rules/utils/getThisExpression.js +1 -0
- package/lib/rules/utils/isTypeRecursive.d.ts +1 -0
- package/lib/rules/utils/isTypeRecursive.js +1 -0
- package/lib/rules/utils/isUnsafeAssignment.d.ts +1 -0
- package/lib/rules/utils/isUnsafeAssignment.js +1 -0
- package/lib/rules/utils/operators.d.ts +1 -0
- package/lib/rules/utils/operators.js +1 -0
- package/lib/rules/variableDeletions.d.ts +2 -1
- package/lib/rules/variableDeletions.js +3 -2
- package/lib/rules/variableDeletions.test.d.ts +1 -0
- package/lib/rules/variableDeletions.test.js +1 -0
- package/lib/rules/voidOperator.d.ts +2 -1
- package/lib/rules/voidOperator.js +3 -2
- package/lib/rules/voidOperator.test.d.ts +1 -0
- package/lib/rules/voidOperator.test.js +1 -0
- package/lib/rules/withStatements.d.ts +7 -0
- package/lib/rules/withStatements.js +37 -0
- package/lib/rules/withStatements.test.d.ts +2 -0
- package/lib/rules/withStatements.test.js +27 -0
- package/lib/utils/declarationIncludesGlobal.d.ts +1 -0
- package/lib/utils/declarationIncludesGlobal.js +1 -0
- package/lib/utils/declarationsIncludeGlobal.d.ts +1 -0
- package/lib/utils/declarationsIncludeGlobal.js +1 -0
- package/lib/utils/getDeclarationsIfGlobal.d.ts +1 -0
- package/lib/utils/getDeclarationsIfGlobal.js +1 -0
- package/lib/utils/getModifyingReferences.d.ts +1 -0
- package/lib/utils/getModifyingReferences.js +1 -0
- package/lib/utils/hasSameTokens.d.ts +1 -0
- package/lib/utils/hasSameTokens.js +1 -0
- package/lib/utils/isFunction.d.ts +3 -0
- package/lib/utils/isFunction.js +6 -0
- package/lib/utils/isGlobalDeclaration.d.ts +1 -0
- package/lib/utils/isGlobalDeclaration.js +1 -0
- package/lib/utils/isGlobalDeclarationOfName.d.ts +1 -0
- package/lib/utils/isGlobalDeclarationOfName.js +1 -0
- package/lib/utils/isGlobalVariable.d.ts +1 -0
- package/lib/utils/isGlobalVariable.js +1 -0
- package/lib/utils/unwrapParentParenthesizedExpressions.d.ts +1 -0
- package/lib/utils/unwrapParentParenthesizedExpressions.js +1 -0
- package/lib/utils/unwrapParenthesizedExpression.d.ts +1 -0
- package/lib/utils/unwrapParenthesizedExpression.js +1 -0
- package/package.json +17 -7
- package/CHANGELOG.md +0 -82
- package/lib/formatDiagnostic.d.ts +0 -10
- package/src/collectReferencedFilePaths.ts +0 -37
- package/src/createTypeScriptFileFromProgram.ts +0 -86
- package/src/createTypeScriptFileFromProjectService.ts +0 -31
- package/src/directives/parseDirectivesFromTypeScriptFile.test.ts +0 -108
- package/src/directives/parseDirectivesFromTypeScriptFile.ts +0 -31
- package/src/formatDiagnostic.ts +0 -166
- package/src/getFirstEnumValues.test.ts +0 -51
- package/src/getFirstEnumValues.ts +0 -59
- package/src/getTSNodeRange.ts +0 -13
- package/src/index.ts +0 -7
- package/src/language.ts +0 -122
- package/src/nodes.ts +0 -146
- package/src/normalizeRange.ts +0 -30
- package/src/plugin.ts +0 -111
- package/src/prepareTypeScriptFile.ts +0 -14
- package/src/rules/anyReturns.test.ts +0 -649
- package/src/rules/anyReturns.ts +0 -263
- package/src/rules/asyncPromiseExecutors.test.ts +0 -72
- package/src/rules/asyncPromiseExecutors.ts +0 -61
- package/src/rules/caseDeclarations.test.ts +0 -228
- package/src/rules/caseDeclarations.ts +0 -70
- package/src/rules/caseDuplicates.test.ts +0 -308
- package/src/rules/caseDuplicates.ts +0 -57
- package/src/rules/chainedAssignments.test.ts +0 -263
- package/src/rules/chainedAssignments.ts +0 -58
- package/src/rules/classAssignments.test.ts +0 -157
- package/src/rules/classAssignments.ts +0 -50
- package/src/rules/consecutiveNonNullAssertions.test.ts +0 -33
- package/src/rules/consecutiveNonNullAssertions.ts +0 -46
- package/src/rules/constantAssignments.test.ts +0 -222
- package/src/rules/constantAssignments.ts +0 -78
- package/src/rules/constructorReturns.test.ts +0 -97
- package/src/rules/constructorReturns.ts +0 -59
- package/src/rules/debuggerStatements.test.ts +0 -81
- package/src/rules/debuggerStatements.ts +0 -45
- package/src/rules/defaultCaseLast.test.ts +0 -196
- package/src/rules/defaultCaseLast.ts +0 -54
- package/src/rules/duplicateArguments.test.ts +0 -140
- package/src/rules/duplicateArguments.ts +0 -58
- package/src/rules/elseIfDuplicates.test.ts +0 -177
- package/src/rules/elseIfDuplicates.ts +0 -69
- package/src/rules/emptyBlocks.test.ts +0 -136
- package/src/rules/emptyBlocks.ts +0 -73
- package/src/rules/emptyDestructures.test.ts +0 -187
- package/src/rules/emptyDestructures.ts +0 -48
- package/src/rules/emptyStaticBlocks.test.ts +0 -168
- package/src/rules/emptyStaticBlocks.ts +0 -60
- package/src/rules/exceptionAssignments.test.ts +0 -265
- package/src/rules/exceptionAssignments.ts +0 -77
- package/src/rules/forDirections.test.ts +0 -100
- package/src/rules/forDirections.ts +0 -163
- package/src/rules/forInArrays.test.ts +0 -25
- package/src/rules/forInArrays.ts +0 -70
- package/src/rules/functionAssignments.test.ts +0 -210
- package/src/rules/functionAssignments.ts +0 -51
- package/src/rules/functionNewCalls.test.ts +0 -116
- package/src/rules/functionNewCalls.ts +0 -75
- package/src/rules/generatorFunctionYields.test.ts +0 -152
- package/src/rules/generatorFunctionYields.ts +0 -71
- package/src/rules/globalAssignments.test.ts +0 -216
- package/src/rules/globalAssignments.ts +0 -67
- package/src/rules/globalObjectCalls.test.ts +0 -94
- package/src/rules/globalObjectCalls.ts +0 -52
- package/src/rules/namespaceDeclarations.test.ts +0 -41
- package/src/rules/namespaceDeclarations.ts +0 -74
- package/src/rules/negativeZeroComparisons.test.ts +0 -210
- package/src/rules/negativeZeroComparisons.ts +0 -87
- package/src/rules/newExpressions.test.ts +0 -80
- package/src/rules/newExpressions.ts +0 -67
- package/src/rules/newNativeNonConstructors.test.ts +0 -95
- package/src/rules/newNativeNonConstructors.ts +0 -59
- package/src/rules/nonOctalDecimalEscapes.test.ts +0 -70
- package/src/rules/nonOctalDecimalEscapes.ts +0 -70
- package/src/rules/numericLiteralParsing.test.ts +0 -100
- package/src/rules/numericLiteralParsing.ts +0 -116
- package/src/rules/objectProto.test.ts +0 -97
- package/src/rules/objectProto.ts +0 -62
- package/src/rules/octalEscapes.test.ts +0 -214
- package/src/rules/octalEscapes.ts +0 -85
- package/src/rules/octalNumbers.test.ts +0 -246
- package/src/rules/octalNumbers.ts +0 -75
- package/src/rules/returnAssignments.test.ts +0 -186
- package/src/rules/returnAssignments.ts +0 -57
- package/src/rules/ruleTester.ts +0 -4
- package/src/rules/selfAssignments.test.ts +0 -67
- package/src/rules/selfAssignments.ts +0 -50
- package/src/rules/selfComparisons.test.ts +0 -298
- package/src/rules/selfComparisons.ts +0 -45
- package/src/rules/sequences.test.ts +0 -49
- package/src/rules/sequences.ts +0 -37
- package/src/rules/shadowedRestrictedNames.test.ts +0 -148
- package/src/rules/shadowedRestrictedNames.ts +0 -105
- package/src/rules/sparseArrays.test.ts +0 -111
- package/src/rules/sparseArrays.ts +0 -61
- package/src/rules/symbolDescriptions.test.ts +0 -90
- package/src/rules/symbolDescriptions.ts +0 -47
- package/src/rules/typeofComparisons.test.ts +0 -86
- package/src/rules/typeofComparisons.ts +0 -88
- package/src/rules/unassignedVariables.test.ts +0 -73
- package/src/rules/unassignedVariables.ts +0 -69
- package/src/rules/undefinedVariables.test.ts +0 -81
- package/src/rules/undefinedVariables.ts +0 -97
- package/src/rules/unicodeBOMs.test.ts +0 -67
- package/src/rules/unicodeBOMs.ts +0 -44
- package/src/rules/unnecessaryBlocks.test.ts +0 -148
- package/src/rules/unnecessaryBlocks.ts +0 -89
- package/src/rules/unnecessaryCatches.test.ts +0 -211
- package/src/rules/unnecessaryCatches.ts +0 -84
- package/src/rules/unnecessaryConcatenation.test.ts +0 -88
- package/src/rules/unnecessaryConcatenation.ts +0 -44
- package/src/rules/unsafeNegations.test.ts +0 -64
- package/src/rules/unsafeNegations.ts +0 -59
- package/src/rules/utils/discriminateAnyType.ts +0 -66
- package/src/rules/utils/getConstrainedType.ts +0 -9
- package/src/rules/utils/getThisExpression.ts +0 -24
- package/src/rules/utils/isTypeRecursive.ts +0 -10
- package/src/rules/utils/isUnsafeAssignment.ts +0 -113
- package/src/rules/utils/operators.ts +0 -39
- package/src/rules/variableDeletions.test.ts +0 -76
- package/src/rules/variableDeletions.ts +0 -43
- package/src/rules/voidOperator.test.ts +0 -99
- package/src/rules/voidOperator.ts +0 -38
- package/src/utils/declarationIncludesGlobal.ts +0 -9
- package/src/utils/declarationsIncludeGlobal.ts +0 -7
- package/src/utils/getDeclarationsIfGlobal.ts +0 -14
- package/src/utils/getModifyingReferences.ts +0 -58
- package/src/utils/hasSameTokens.ts +0 -45
- package/src/utils/isGlobalDeclaration.ts +0 -10
- package/src/utils/isGlobalDeclarationOfName.ts +0 -56
- package/src/utils/isGlobalVariable.ts +0 -30
- package/src/utils/unwrapParentParenthesizedExpressions.ts +0 -7
- package/src/utils/unwrapParenthesizedExpression.ts +0 -9
- package/tsconfig.json +0 -9
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -19,12 +19,12 @@ export default typescriptLanguage.createRule({
|
|
|
19
19
|
},
|
|
20
20
|
},
|
|
21
21
|
setup(context) {
|
|
22
|
-
function checkBindingPattern(node) {
|
|
22
|
+
function checkBindingPattern(node, { sourceFile }) {
|
|
23
23
|
if (node.elements.length === 0) {
|
|
24
24
|
context.report({
|
|
25
25
|
message: "emptyPattern",
|
|
26
26
|
range: {
|
|
27
|
-
begin: node.getStart(
|
|
27
|
+
begin: node.getStart(sourceFile),
|
|
28
28
|
end: node.getEnd(),
|
|
29
29
|
},
|
|
30
30
|
});
|
|
@@ -38,3 +38,4 @@ export default typescriptLanguage.createRule({
|
|
|
38
38
|
};
|
|
39
39
|
},
|
|
40
40
|
});
|
|
41
|
+
//# sourceMappingURL=emptyDestructures.js.map
|
|
@@ -2,5 +2,6 @@ declare const _default: import("@flint.fyi/core").Rule<{
|
|
|
2
2
|
readonly description: "Reports empty static initialization blocks within class declarations.";
|
|
3
3
|
readonly id: "emptyStaticBlocks";
|
|
4
4
|
readonly preset: "stylistic";
|
|
5
|
-
}, import("../nodes.js").TSNodesByName, import("../language.js").
|
|
5
|
+
}, import("../nodes.js").TSNodesByName, import("../language.js").TypeScriptFileServices, "emptyStaticBlock", undefined>;
|
|
6
6
|
export default _default;
|
|
7
|
+
//# sourceMappingURL=emptyStaticBlocks.d.ts.map
|
|
@@ -20,17 +20,17 @@ export default typescriptLanguage.createRule({
|
|
|
20
20
|
setup(context) {
|
|
21
21
|
return {
|
|
22
22
|
visitors: {
|
|
23
|
-
ClassStaticBlockDeclaration: (node) => {
|
|
23
|
+
ClassStaticBlockDeclaration: (node, { sourceFile }) => {
|
|
24
24
|
const statements = node.body.statements;
|
|
25
25
|
if (statements.length) {
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
|
-
const openBrace = node.body.getFirstToken(
|
|
28
|
+
const openBrace = node.body.getFirstToken(sourceFile);
|
|
29
29
|
if (!openBrace) {
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
const range = {
|
|
33
|
-
begin: node.getStart(
|
|
33
|
+
begin: node.getStart(sourceFile),
|
|
34
34
|
end: openBrace.getEnd(),
|
|
35
35
|
};
|
|
36
36
|
context.report({
|
|
@@ -40,7 +40,7 @@ export default typescriptLanguage.createRule({
|
|
|
40
40
|
{
|
|
41
41
|
id: "removeEmptyStaticBlock",
|
|
42
42
|
range: {
|
|
43
|
-
begin: node.getStart(
|
|
43
|
+
begin: node.getStart(sourceFile),
|
|
44
44
|
end: node.getEnd(),
|
|
45
45
|
},
|
|
46
46
|
text: "",
|
|
@@ -52,3 +52,4 @@ export default typescriptLanguage.createRule({
|
|
|
52
52
|
};
|
|
53
53
|
},
|
|
54
54
|
});
|
|
55
|
+
//# sourceMappingURL=emptyStaticBlocks.js.map
|
|
@@ -2,5 +2,6 @@ declare const _default: import("@flint.fyi/core").Rule<{
|
|
|
2
2
|
readonly description: "Reports reassigning exception parameters in catch clauses.";
|
|
3
3
|
readonly id: "exceptionAssignments";
|
|
4
4
|
readonly preset: "logical";
|
|
5
|
-
}, import("../nodes.js").TSNodesByName, import("../language.js").
|
|
5
|
+
}, import("../nodes.js").TSNodesByName, import("../language.js").TypeScriptFileServices, "noExAssign", undefined>;
|
|
6
6
|
export default _default;
|
|
7
|
+
//# sourceMappingURL=exceptionAssignments.d.ts.map
|
|
@@ -37,18 +37,18 @@ export default typescriptLanguage.createRule({
|
|
|
37
37
|
}
|
|
38
38
|
return {
|
|
39
39
|
visitors: {
|
|
40
|
-
CatchClause: (node) => {
|
|
40
|
+
CatchClause: (node, { sourceFile, typeChecker }) => {
|
|
41
41
|
if (!node.variableDeclaration?.name) {
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
const identifiers = collectBindingElements(node.variableDeclaration.name);
|
|
45
45
|
for (const identifier of identifiers) {
|
|
46
|
-
const modifyingReferences = getModifyingReferences(identifier,
|
|
46
|
+
const modifyingReferences = getModifyingReferences(identifier, sourceFile, typeChecker);
|
|
47
47
|
for (const reference of modifyingReferences) {
|
|
48
48
|
context.report({
|
|
49
49
|
message: "noExAssign",
|
|
50
50
|
range: {
|
|
51
|
-
begin: reference.getStart(
|
|
51
|
+
begin: reference.getStart(sourceFile),
|
|
52
52
|
end: reference.getEnd(),
|
|
53
53
|
},
|
|
54
54
|
});
|
|
@@ -59,3 +59,4 @@ export default typescriptLanguage.createRule({
|
|
|
59
59
|
};
|
|
60
60
|
},
|
|
61
61
|
});
|
|
62
|
+
//# sourceMappingURL=exceptionAssignments.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Reports control flow statements in `finally` blocks that can override control flow in `try`/`catch` blocks.";
|
|
3
|
+
readonly id: "finallyStatementSafety";
|
|
4
|
+
readonly preset: "logical";
|
|
5
|
+
}, import("../nodes.js").TSNodesByName, import("../language.js").TypeScriptFileServices, "unsafeFinally", undefined>;
|
|
6
|
+
export default _default;
|
|
7
|
+
//# sourceMappingURL=finallyStatementSafety.d.ts.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as ts from "typescript";
|
|
2
|
+
import { typescriptLanguage } from "../language.js";
|
|
3
|
+
export default typescriptLanguage.createRule({
|
|
4
|
+
about: {
|
|
5
|
+
description: "Reports control flow statements in `finally` blocks that can override control flow in `try`/`catch` blocks.",
|
|
6
|
+
id: "finallyStatementSafety",
|
|
7
|
+
preset: "logical",
|
|
8
|
+
},
|
|
9
|
+
messages: {
|
|
10
|
+
unsafeFinally: {
|
|
11
|
+
primary: "Control flow statements in `finally` blocks misleadingly override control flow from `try`/`catch` blocks.",
|
|
12
|
+
secondary: [
|
|
13
|
+
"Control flow statements like `break`, `continue`, `return`, and `throw` in finally blocks can override control flow statements in the try or catch blocks.",
|
|
14
|
+
"This can lead to unexpected behavior, as the `finally` block will execute regardless of what happens in `try`/`catch`, and its control flow takes precedence.",
|
|
15
|
+
],
|
|
16
|
+
suggestions: [
|
|
17
|
+
"Move the control flow statement out of the `finally` block.",
|
|
18
|
+
"Remove the control flow statement if the `finally` block is only used for cleanup operations.",
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
setup(context) {
|
|
23
|
+
return {
|
|
24
|
+
visitors: {
|
|
25
|
+
TryStatement: (node) => {
|
|
26
|
+
if (!node.finallyBlock) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
function checkStatement(statement) {
|
|
30
|
+
if (ts.isReturnStatement(statement) ||
|
|
31
|
+
ts.isThrowStatement(statement) ||
|
|
32
|
+
ts.isBreakStatement(statement) ||
|
|
33
|
+
ts.isContinueStatement(statement)) {
|
|
34
|
+
const firstToken = statement.getFirstToken(context.sourceFile);
|
|
35
|
+
if (!firstToken) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
context.report({
|
|
39
|
+
message: "unsafeFinally",
|
|
40
|
+
range: {
|
|
41
|
+
begin: statement.getStart(context.sourceFile),
|
|
42
|
+
end: statement.getStart(context.sourceFile) +
|
|
43
|
+
firstToken.getText().length,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (ts.isBlock(statement)) {
|
|
48
|
+
statement.statements.forEach(checkStatement);
|
|
49
|
+
}
|
|
50
|
+
else if (ts.isIfStatement(statement)) {
|
|
51
|
+
checkStatement(statement.thenStatement);
|
|
52
|
+
if (statement.elseStatement) {
|
|
53
|
+
checkStatement(statement.elseStatement);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else if (ts.isSwitchStatement(statement)) {
|
|
57
|
+
statement.caseBlock.clauses.forEach((clause) => {
|
|
58
|
+
clause.statements.forEach(checkStatement);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
else if (ts.isLabeledStatement(statement)) {
|
|
62
|
+
checkStatement(statement.statement);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
checkStatement(node.finallyBlock);
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
//# sourceMappingURL=finallyStatementSafety.js.map
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import rule from "./finallyStatementSafety.js";
|
|
2
|
+
import { ruleTester } from "./ruleTester.js";
|
|
3
|
+
ruleTester.describe(rule, {
|
|
4
|
+
invalid: [
|
|
5
|
+
{
|
|
6
|
+
code: `
|
|
7
|
+
try {
|
|
8
|
+
doSomething();
|
|
9
|
+
} finally {
|
|
10
|
+
return 1;
|
|
11
|
+
}
|
|
12
|
+
`,
|
|
13
|
+
snapshot: `
|
|
14
|
+
try {
|
|
15
|
+
doSomething();
|
|
16
|
+
} finally {
|
|
17
|
+
return 1;
|
|
18
|
+
~~~~~~
|
|
19
|
+
Control flow statements in \`finally\` blocks misleadingly override control flow from \`try\`/\`catch\` blocks.
|
|
20
|
+
}
|
|
21
|
+
`,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
code: `
|
|
25
|
+
try {
|
|
26
|
+
doSomething();
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.error(error);
|
|
29
|
+
} finally {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
`,
|
|
33
|
+
snapshot: `
|
|
34
|
+
try {
|
|
35
|
+
doSomething();
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error(error);
|
|
38
|
+
} finally {
|
|
39
|
+
return;
|
|
40
|
+
~~~~~~
|
|
41
|
+
Control flow statements in \`finally\` blocks misleadingly override control flow from \`try\`/\`catch\` blocks.
|
|
42
|
+
}
|
|
43
|
+
`,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
code: `
|
|
47
|
+
try {
|
|
48
|
+
doSomething();
|
|
49
|
+
} finally {
|
|
50
|
+
throw new Error("Error");
|
|
51
|
+
}
|
|
52
|
+
`,
|
|
53
|
+
snapshot: `
|
|
54
|
+
try {
|
|
55
|
+
doSomething();
|
|
56
|
+
} finally {
|
|
57
|
+
throw new Error("Error");
|
|
58
|
+
~~~~~
|
|
59
|
+
Control flow statements in \`finally\` blocks misleadingly override control flow from \`try\`/\`catch\` blocks.
|
|
60
|
+
}
|
|
61
|
+
`,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
code: `
|
|
65
|
+
while (condition) {
|
|
66
|
+
try {
|
|
67
|
+
doSomething();
|
|
68
|
+
} finally {
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
`,
|
|
73
|
+
snapshot: `
|
|
74
|
+
while (condition) {
|
|
75
|
+
try {
|
|
76
|
+
doSomething();
|
|
77
|
+
} finally {
|
|
78
|
+
break;
|
|
79
|
+
~~~~~
|
|
80
|
+
Control flow statements in \`finally\` blocks misleadingly override control flow from \`try\`/\`catch\` blocks.
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
`,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
code: `
|
|
87
|
+
for (let i = 0; i < 10; i++) {
|
|
88
|
+
try {
|
|
89
|
+
doSomething();
|
|
90
|
+
} finally {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
`,
|
|
95
|
+
snapshot: `
|
|
96
|
+
for (let i = 0; i < 10; i++) {
|
|
97
|
+
try {
|
|
98
|
+
doSomething();
|
|
99
|
+
} finally {
|
|
100
|
+
continue;
|
|
101
|
+
~~~~~~~~
|
|
102
|
+
Control flow statements in \`finally\` blocks misleadingly override control flow from \`try\`/\`catch\` blocks.
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
`,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
code: `
|
|
109
|
+
function test() {
|
|
110
|
+
try {
|
|
111
|
+
doSomething();
|
|
112
|
+
return "success";
|
|
113
|
+
} finally {
|
|
114
|
+
return "override";
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
`,
|
|
118
|
+
snapshot: `
|
|
119
|
+
function test() {
|
|
120
|
+
try {
|
|
121
|
+
doSomething();
|
|
122
|
+
return "success";
|
|
123
|
+
} finally {
|
|
124
|
+
return "override";
|
|
125
|
+
~~~~~~
|
|
126
|
+
Control flow statements in \`finally\` blocks misleadingly override control flow from \`try\`/\`catch\` blocks.
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
`,
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
code: `
|
|
133
|
+
try {
|
|
134
|
+
doSomething();
|
|
135
|
+
} finally {
|
|
136
|
+
if (condition) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
`,
|
|
141
|
+
snapshot: `
|
|
142
|
+
try {
|
|
143
|
+
doSomething();
|
|
144
|
+
} finally {
|
|
145
|
+
if (condition) {
|
|
146
|
+
return;
|
|
147
|
+
~~~~~~
|
|
148
|
+
Control flow statements in \`finally\` blocks misleadingly override control flow from \`try\`/\`catch\` blocks.
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
`,
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
code: `
|
|
155
|
+
try {
|
|
156
|
+
doSomething();
|
|
157
|
+
} finally {
|
|
158
|
+
switch (value) {
|
|
159
|
+
case 1:
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
`,
|
|
164
|
+
snapshot: `
|
|
165
|
+
try {
|
|
166
|
+
doSomething();
|
|
167
|
+
} finally {
|
|
168
|
+
switch (value) {
|
|
169
|
+
case 1:
|
|
170
|
+
return;
|
|
171
|
+
~~~~~~
|
|
172
|
+
Control flow statements in \`finally\` blocks misleadingly override control flow from \`try\`/\`catch\` blocks.
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
`,
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
code: `
|
|
179
|
+
try {
|
|
180
|
+
doSomething();
|
|
181
|
+
} finally {
|
|
182
|
+
label: {
|
|
183
|
+
break label;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
`,
|
|
187
|
+
snapshot: `
|
|
188
|
+
try {
|
|
189
|
+
doSomething();
|
|
190
|
+
} finally {
|
|
191
|
+
label: {
|
|
192
|
+
break label;
|
|
193
|
+
~~~~~
|
|
194
|
+
Control flow statements in \`finally\` blocks misleadingly override control flow from \`try\`/\`catch\` blocks.
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
`,
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
valid: [
|
|
201
|
+
`try { doSomething(); } finally { cleanup(); }`,
|
|
202
|
+
`try { doSomething(); } catch (error) { console.error(error); } finally { cleanup(); }`,
|
|
203
|
+
`try { return 1; } finally { cleanup(); }`,
|
|
204
|
+
`try { throw new Error("Error"); } finally { cleanup(); }`,
|
|
205
|
+
`
|
|
206
|
+
try {
|
|
207
|
+
doSomething();
|
|
208
|
+
} finally {
|
|
209
|
+
console.log("cleanup");
|
|
210
|
+
}
|
|
211
|
+
`,
|
|
212
|
+
`
|
|
213
|
+
function test() {
|
|
214
|
+
try {
|
|
215
|
+
return doSomething();
|
|
216
|
+
} finally {
|
|
217
|
+
cleanup();
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
`,
|
|
221
|
+
`
|
|
222
|
+
while (condition) {
|
|
223
|
+
try {
|
|
224
|
+
break;
|
|
225
|
+
} finally {
|
|
226
|
+
cleanup();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
`,
|
|
230
|
+
`
|
|
231
|
+
for (let i = 0; i < 10; i++) {
|
|
232
|
+
try {
|
|
233
|
+
continue;
|
|
234
|
+
} finally {
|
|
235
|
+
cleanup();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
`,
|
|
239
|
+
`
|
|
240
|
+
try {
|
|
241
|
+
doSomething();
|
|
242
|
+
} finally {
|
|
243
|
+
if (condition) {
|
|
244
|
+
cleanup();
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
`,
|
|
248
|
+
`
|
|
249
|
+
try {
|
|
250
|
+
doSomething();
|
|
251
|
+
} finally {
|
|
252
|
+
for (let i = 0; i < 10; i++) {
|
|
253
|
+
cleanup();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
`,
|
|
257
|
+
`
|
|
258
|
+
try {
|
|
259
|
+
doSomething();
|
|
260
|
+
} finally {
|
|
261
|
+
while (condition) {
|
|
262
|
+
cleanup();
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
`,
|
|
266
|
+
`
|
|
267
|
+
try {
|
|
268
|
+
doSomething();
|
|
269
|
+
} finally {
|
|
270
|
+
for (let i = 0; i < 10; i++) {
|
|
271
|
+
if (i === 5) break;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
`,
|
|
275
|
+
`
|
|
276
|
+
try {
|
|
277
|
+
doSomething();
|
|
278
|
+
} finally {
|
|
279
|
+
while (condition) {
|
|
280
|
+
if (shouldExit) break;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
`,
|
|
284
|
+
`
|
|
285
|
+
try {
|
|
286
|
+
doSomething();
|
|
287
|
+
} finally {
|
|
288
|
+
for (let i = 0; i < 10; i++) {
|
|
289
|
+
if (i === 0) continue;
|
|
290
|
+
process(i);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
`,
|
|
294
|
+
`
|
|
295
|
+
try {
|
|
296
|
+
doSomething();
|
|
297
|
+
} finally {
|
|
298
|
+
try {
|
|
299
|
+
cleanup();
|
|
300
|
+
} finally {
|
|
301
|
+
log();
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
`,
|
|
305
|
+
],
|
|
306
|
+
});
|
|
307
|
+
//# sourceMappingURL=finallyStatementSafety.test.js.map
|
|
@@ -2,5 +2,6 @@ declare const _default: import("@flint.fyi/core").Rule<{
|
|
|
2
2
|
readonly description: "Reports for loops with counter variables that move in the wrong direction.";
|
|
3
3
|
readonly id: "forDirections";
|
|
4
4
|
readonly preset: "stylistic";
|
|
5
|
-
}, import("../nodes.js").TSNodesByName, import("../language.js").
|
|
5
|
+
}, import("../nodes.js").TSNodesByName, import("../language.js").TypeScriptFileServices, "wrongDirection", undefined>;
|
|
6
6
|
export default _default;
|
|
7
|
+
//# sourceMappingURL=forDirections.d.ts.map
|
|
@@ -7,6 +7,13 @@ function getConditionDirection(condition, counterName) {
|
|
|
7
7
|
}
|
|
8
8
|
const leftName = getCounterName(condition.left);
|
|
9
9
|
const rightName = getCounterName(condition.right);
|
|
10
|
+
if (!leftName && !rightName) {
|
|
11
|
+
return condition.operatorToken.kind ===
|
|
12
|
+
ts.SyntaxKind.AmpersandAmpersandToken
|
|
13
|
+
? (getConditionDirection(condition.left, counterName) ??
|
|
14
|
+
getConditionDirection(condition.right, counterName))
|
|
15
|
+
: undefined;
|
|
16
|
+
}
|
|
10
17
|
const isCounterLeft = leftName === counterName;
|
|
11
18
|
const isCounterRight = rightName === counterName;
|
|
12
19
|
if (!isCounterLeft && !isCounterRight) {
|
|
@@ -38,10 +45,10 @@ function getConditionDirection(condition, counterName) {
|
|
|
38
45
|
function getCounterName(node) {
|
|
39
46
|
return ts.isIdentifier(node) ? node.text : undefined;
|
|
40
47
|
}
|
|
41
|
-
function
|
|
42
|
-
if (ts.isPostfixUnaryExpression(
|
|
43
|
-
ts.isPrefixUnaryExpression(
|
|
44
|
-
switch (
|
|
48
|
+
function getIncrementorDirection(incrementor) {
|
|
49
|
+
if (ts.isPostfixUnaryExpression(incrementor) ||
|
|
50
|
+
ts.isPrefixUnaryExpression(incrementor)) {
|
|
51
|
+
switch (incrementor.operator) {
|
|
45
52
|
case ts.SyntaxKind.MinusMinusToken:
|
|
46
53
|
return -1;
|
|
47
54
|
case ts.SyntaxKind.PlusPlusToken:
|
|
@@ -50,8 +57,8 @@ function getUpdateDirection(update) {
|
|
|
50
57
|
return undefined;
|
|
51
58
|
}
|
|
52
59
|
}
|
|
53
|
-
if (ts.isBinaryExpression(
|
|
54
|
-
const { operatorToken, right } =
|
|
60
|
+
if (ts.isBinaryExpression(incrementor)) {
|
|
61
|
+
const { operatorToken, right } = incrementor;
|
|
55
62
|
if (operatorToken.kind === ts.SyntaxKind.PlusEqualsToken ||
|
|
56
63
|
operatorToken.kind === ts.SyntaxKind.MinusEqualsToken) {
|
|
57
64
|
if (ts.isNumericLiteral(right)) {
|
|
@@ -95,7 +102,7 @@ export default typescriptLanguage.createRule({
|
|
|
95
102
|
setup(context) {
|
|
96
103
|
return {
|
|
97
104
|
visitors: {
|
|
98
|
-
ForStatement: (node) => {
|
|
105
|
+
ForStatement: (node, { sourceFile }) => {
|
|
99
106
|
if (!node.condition ||
|
|
100
107
|
!node.incrementor ||
|
|
101
108
|
!node.initializer ||
|
|
@@ -106,15 +113,15 @@ export default typescriptLanguage.createRule({
|
|
|
106
113
|
if (!declaration || !ts.isIdentifier(declaration.name)) {
|
|
107
114
|
return;
|
|
108
115
|
}
|
|
109
|
-
const updateDirection =
|
|
116
|
+
const updateDirection = getIncrementorDirection(node.incrementor);
|
|
110
117
|
if (!updateDirection) {
|
|
111
118
|
return;
|
|
112
119
|
}
|
|
113
120
|
const conditionDirection = getConditionDirection(node.condition, declaration.name.text);
|
|
114
|
-
if (
|
|
121
|
+
if (conditionDirection && conditionDirection !== updateDirection) {
|
|
115
122
|
context.report({
|
|
116
123
|
message: "wrongDirection",
|
|
117
|
-
range: getTSNodeRange(node.incrementor,
|
|
124
|
+
range: getTSNodeRange(node.incrementor, sourceFile),
|
|
118
125
|
});
|
|
119
126
|
}
|
|
120
127
|
},
|
|
@@ -122,3 +129,4 @@ export default typescriptLanguage.createRule({
|
|
|
122
129
|
};
|
|
123
130
|
},
|
|
124
131
|
});
|
|
132
|
+
//# sourceMappingURL=forDirections.js.map
|
|
@@ -80,6 +80,30 @@ for (let index = 0; index < 10; index += -1) {}
|
|
|
80
80
|
for (let index = 0; index < 10; index += -1) {}
|
|
81
81
|
~~~~~~~~~~~
|
|
82
82
|
The update moves the counter in the wrong direction for this loop condition.
|
|
83
|
+
`,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
code: `
|
|
87
|
+
declare context text: string;
|
|
88
|
+
for (let i = 10; i >= 0 && text[i] !== " "; i++) { }
|
|
89
|
+
`,
|
|
90
|
+
snapshot: `
|
|
91
|
+
declare context text: string;
|
|
92
|
+
for (let i = 10; i >= 0 && text[i] !== " "; i++) { }
|
|
93
|
+
~~~
|
|
94
|
+
The update moves the counter in the wrong direction for this loop condition.
|
|
95
|
+
`,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
code: `
|
|
99
|
+
declare context text: string;
|
|
100
|
+
for (let i = 10; text[i] !== " " && i >= 0; i++) { }
|
|
101
|
+
`,
|
|
102
|
+
snapshot: `
|
|
103
|
+
declare context text: string;
|
|
104
|
+
for (let i = 10; text[i] !== " " && i >= 0; i++) { }
|
|
105
|
+
~~~
|
|
106
|
+
The update moves the counter in the wrong direction for this loop condition.
|
|
83
107
|
`,
|
|
84
108
|
},
|
|
85
109
|
],
|
|
@@ -95,5 +119,7 @@ for (let index = 0; index < 10; index += -1) {}
|
|
|
95
119
|
`for (let index = 10; index > 0; index -= 1) { }`,
|
|
96
120
|
`for (let index = 0; index < 10; index += 2) { }`,
|
|
97
121
|
`for (let index = 10; index > 0; index -= 2) { }`,
|
|
122
|
+
`for (let i = 10; i >= 0 && text[i] === "\\"; i--) { }`,
|
|
98
123
|
],
|
|
99
124
|
});
|
|
125
|
+
//# sourceMappingURL=forDirections.test.js.map
|
|
@@ -2,5 +2,6 @@ declare const _default: import("@flint.fyi/core").Rule<{
|
|
|
2
2
|
readonly description: "Reports iterating over an array with a for-in loop.";
|
|
3
3
|
readonly id: "forInArrays";
|
|
4
4
|
readonly preset: "logical";
|
|
5
|
-
}, import("../nodes.js").TSNodesByName, import("../language.js").
|
|
5
|
+
}, import("../nodes.js").TSNodesByName, import("../language.js").TypeScriptFileServices, "forIn", undefined>;
|
|
6
6
|
export default _default;
|
|
7
|
+
//# sourceMappingURL=forInArrays.d.ts.map
|