@flint.fyi/ts 0.14.6 → 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} +22 -14
- 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 +1 -0
- package/lib/plugin.d.ts +79 -50
- package/lib/plugin.js +15 -0
- 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 +3 -2
- package/lib/rules/forDirections.test.d.ts +1 -0
- package/lib/rules/forDirections.test.js +1 -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 -91
- 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 -25
- 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 -125
- package/src/rules/forDirections.ts +0 -174
- 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
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as ts from "typescript";
|
|
2
|
+
import { getTSNodeRange } from "../getTSNodeRange.js";
|
|
3
|
+
import { typescriptLanguage } from "../language.js";
|
|
4
|
+
export default typescriptLanguage.createRule({
|
|
5
|
+
about: {
|
|
6
|
+
description: "Reports unnecessary duplicate keys that override previous values.",
|
|
7
|
+
id: "objectKeyDuplicates",
|
|
8
|
+
preset: "untyped",
|
|
9
|
+
},
|
|
10
|
+
messages: {
|
|
11
|
+
duplicateKey: {
|
|
12
|
+
primary: "This key is made redundant by an identical key later in the object.",
|
|
13
|
+
secondary: [
|
|
14
|
+
"Duplicate object keys are legal in JavaScript, but they can lead to unexpected behavior.",
|
|
15
|
+
"When duplicate keys exist, only the last value for a given key is used.",
|
|
16
|
+
"This can cause confusion and bugs, especially when maintaining the code.",
|
|
17
|
+
],
|
|
18
|
+
suggestions: [
|
|
19
|
+
"If both values are meant to exist, change one of the keys to be different.",
|
|
20
|
+
"If only the last value is meant to exist, remove any prior values.",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
setup(context) {
|
|
25
|
+
return {
|
|
26
|
+
visitors: {
|
|
27
|
+
ObjectLiteralExpression(node, { sourceFile }) {
|
|
28
|
+
const seenKeys = {
|
|
29
|
+
getters: new Map(),
|
|
30
|
+
setters: new Map(),
|
|
31
|
+
values: new Map(),
|
|
32
|
+
};
|
|
33
|
+
for (const property of node.properties.toReversed()) {
|
|
34
|
+
const key = getPropertyKeyName(property);
|
|
35
|
+
if (!key) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const existingNode = seenKeys[key.group].get(key.text);
|
|
39
|
+
if (existingNode) {
|
|
40
|
+
context.report({
|
|
41
|
+
message: "duplicateKey",
|
|
42
|
+
range: getTSNodeRange(key.node, sourceFile),
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
seenKeys[key.group].set(key.text, property);
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
// TODO: Reuse a shared getStaticValue-style utility?
|
|
53
|
+
function getNameText(name) {
|
|
54
|
+
if (ts.isIdentifier(name) ||
|
|
55
|
+
ts.isStringLiteral(name) ||
|
|
56
|
+
ts.isNumericLiteral(name) ||
|
|
57
|
+
ts.isLiteralExpression(name)) {
|
|
58
|
+
return name.text;
|
|
59
|
+
}
|
|
60
|
+
if (ts.isPrivateIdentifier(name)) {
|
|
61
|
+
return `#${name.text}`;
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
function getPropertyKeyName(property) {
|
|
66
|
+
if (ts.isShorthandPropertyAssignment(property)) {
|
|
67
|
+
return {
|
|
68
|
+
group: "values",
|
|
69
|
+
node: property.name,
|
|
70
|
+
text: property.name.text,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
if (ts.isPropertyAssignment(property) ||
|
|
74
|
+
ts.isMethodDeclaration(property) ||
|
|
75
|
+
ts.isGetAccessorDeclaration(property) ||
|
|
76
|
+
ts.isSetAccessorDeclaration(property)) {
|
|
77
|
+
const { name } = property;
|
|
78
|
+
const text = getNameText(name);
|
|
79
|
+
if (!text) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
const group = ts.isGetAccessorDeclaration(property)
|
|
83
|
+
? "getters"
|
|
84
|
+
: ts.isSetAccessorDeclaration(property)
|
|
85
|
+
? "setters"
|
|
86
|
+
: "values";
|
|
87
|
+
return { group, node: name, text };
|
|
88
|
+
}
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=objectKeyDuplicates.js.map
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import rule from "./objectKeyDuplicates.js";
|
|
2
|
+
import { ruleTester } from "./ruleTester.js";
|
|
3
|
+
ruleTester.describe(rule, {
|
|
4
|
+
invalid: [
|
|
5
|
+
{
|
|
6
|
+
code: `
|
|
7
|
+
const object = { a: 1, a: 2 };
|
|
8
|
+
`,
|
|
9
|
+
snapshot: `
|
|
10
|
+
const object = { a: 1, a: 2 };
|
|
11
|
+
~
|
|
12
|
+
This key is made redundant by an identical key later in the object.
|
|
13
|
+
`,
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
code: `
|
|
17
|
+
const object = { "a": 1, "a": 2 };
|
|
18
|
+
`,
|
|
19
|
+
snapshot: `
|
|
20
|
+
const object = { "a": 1, "a": 2 };
|
|
21
|
+
~~~
|
|
22
|
+
This key is made redundant by an identical key later in the object.
|
|
23
|
+
`,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
code: `
|
|
27
|
+
const object = { a: 1, "a": 2 };
|
|
28
|
+
`,
|
|
29
|
+
snapshot: `
|
|
30
|
+
const object = { a: 1, "a": 2 };
|
|
31
|
+
~
|
|
32
|
+
This key is made redundant by an identical key later in the object.
|
|
33
|
+
`,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
code: `
|
|
37
|
+
const object = { "a": 1, a: 2 };
|
|
38
|
+
`,
|
|
39
|
+
snapshot: `
|
|
40
|
+
const object = { "a": 1, a: 2 };
|
|
41
|
+
~~~
|
|
42
|
+
This key is made redundant by an identical key later in the object.
|
|
43
|
+
`,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
code: `
|
|
47
|
+
const object = { 123: "first", 123: "second" };
|
|
48
|
+
`,
|
|
49
|
+
snapshot: `
|
|
50
|
+
const object = { 123: "first", 123: "second" };
|
|
51
|
+
~~~
|
|
52
|
+
This key is made redundant by an identical key later in the object.
|
|
53
|
+
`,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
code: `
|
|
57
|
+
const object = {
|
|
58
|
+
value: "first",
|
|
59
|
+
value: "second",
|
|
60
|
+
};
|
|
61
|
+
`,
|
|
62
|
+
snapshot: `
|
|
63
|
+
const object = {
|
|
64
|
+
value: "first",
|
|
65
|
+
~~~~~
|
|
66
|
+
This key is made redundant by an identical key later in the object.
|
|
67
|
+
value: "second",
|
|
68
|
+
};
|
|
69
|
+
`,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
code: `
|
|
73
|
+
const object = {
|
|
74
|
+
key: 1,
|
|
75
|
+
other: 2,
|
|
76
|
+
key: 3,
|
|
77
|
+
};
|
|
78
|
+
`,
|
|
79
|
+
snapshot: `
|
|
80
|
+
const object = {
|
|
81
|
+
key: 1,
|
|
82
|
+
~~~
|
|
83
|
+
This key is made redundant by an identical key later in the object.
|
|
84
|
+
other: 2,
|
|
85
|
+
key: 3,
|
|
86
|
+
};
|
|
87
|
+
`,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
code: `
|
|
91
|
+
const first = { a: 1, a: 2 };
|
|
92
|
+
const second = { b: 1, b: 2 };
|
|
93
|
+
`,
|
|
94
|
+
snapshot: `
|
|
95
|
+
const first = { a: 1, a: 2 };
|
|
96
|
+
~
|
|
97
|
+
This key is made redundant by an identical key later in the object.
|
|
98
|
+
const second = { b: 1, b: 2 };
|
|
99
|
+
~
|
|
100
|
+
This key is made redundant by an identical key later in the object.
|
|
101
|
+
`,
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
code: `
|
|
105
|
+
const object = {
|
|
106
|
+
method() { return 1; },
|
|
107
|
+
method() { return 2; },
|
|
108
|
+
};
|
|
109
|
+
`,
|
|
110
|
+
snapshot: `
|
|
111
|
+
const object = {
|
|
112
|
+
method() { return 1; },
|
|
113
|
+
~~~~~~
|
|
114
|
+
This key is made redundant by an identical key later in the object.
|
|
115
|
+
method() { return 2; },
|
|
116
|
+
};
|
|
117
|
+
`,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
code: `
|
|
121
|
+
const object = {
|
|
122
|
+
get accessor() { return 1; },
|
|
123
|
+
get accessor() { return 2; },
|
|
124
|
+
};
|
|
125
|
+
`,
|
|
126
|
+
snapshot: `
|
|
127
|
+
const object = {
|
|
128
|
+
get accessor() { return 1; },
|
|
129
|
+
~~~~~~~~
|
|
130
|
+
This key is made redundant by an identical key later in the object.
|
|
131
|
+
get accessor() { return 2; },
|
|
132
|
+
};
|
|
133
|
+
`,
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
code: `
|
|
137
|
+
const object = {
|
|
138
|
+
set accessor(value: number) {},
|
|
139
|
+
set accessor(value: number) {},
|
|
140
|
+
};
|
|
141
|
+
`,
|
|
142
|
+
snapshot: `
|
|
143
|
+
const object = {
|
|
144
|
+
set accessor(value: number) {},
|
|
145
|
+
~~~~~~~~
|
|
146
|
+
This key is made redundant by an identical key later in the object.
|
|
147
|
+
set accessor(value: number) {},
|
|
148
|
+
};
|
|
149
|
+
`,
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
code: `
|
|
153
|
+
const nested = { outer: { inner: 1, inner: 2 } };
|
|
154
|
+
`,
|
|
155
|
+
snapshot: `
|
|
156
|
+
const nested = { outer: { inner: 1, inner: 2 } };
|
|
157
|
+
~~~~~
|
|
158
|
+
This key is made redundant by an identical key later in the object.
|
|
159
|
+
`,
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
valid: [
|
|
163
|
+
`const object = {};`,
|
|
164
|
+
`const object = { a: 1 };`,
|
|
165
|
+
`const object = { a: 1, b: 2 };`,
|
|
166
|
+
`const object = { a: 1, b: 2, c: 3 };`,
|
|
167
|
+
`const object = { "a": 1, "b": 2 };`,
|
|
168
|
+
`const object = { 123: 1, 456: 2 };`,
|
|
169
|
+
`const object = { a: 1, ...spread };`,
|
|
170
|
+
`const object = { [key]: 1, [key]: 2 };`,
|
|
171
|
+
`const object = { ["computed"]: 1, ["computed"]: 2 };`,
|
|
172
|
+
`const object = { a, b };`,
|
|
173
|
+
`const object = { a: 1, b };`,
|
|
174
|
+
`const object = { method() { return 1; } };`,
|
|
175
|
+
`const object = { get accessor() { return 1; } };`,
|
|
176
|
+
`const object = { set accessor(value: number) {} };`,
|
|
177
|
+
`const object = { get accessor() { return 1; }, set accessor(value: number) {} };`,
|
|
178
|
+
],
|
|
179
|
+
});
|
|
180
|
+
//# sourceMappingURL=objectKeyDuplicates.test.js.map
|
|
@@ -2,5 +2,6 @@ declare const _default: import("@flint.fyi/core").Rule<{
|
|
|
2
2
|
readonly description: "Reports using the deprecated __proto__ property to access or modify an object's prototype.";
|
|
3
3
|
readonly id: "objectProto";
|
|
4
4
|
readonly preset: "untyped";
|
|
5
|
-
}, import("../nodes.js").TSNodesByName, import("../language.js").
|
|
5
|
+
}, import("../nodes.js").TSNodesByName, import("../language.js").TypeScriptFileServices, "noProto", undefined>;
|
|
6
6
|
export default _default;
|
|
7
|
+
//# sourceMappingURL=objectProto.d.ts.map
|
package/lib/rules/objectProto.js
CHANGED
|
@@ -24,25 +24,25 @@ export default typescriptLanguage.createRule({
|
|
|
24
24
|
setup(context) {
|
|
25
25
|
return {
|
|
26
26
|
visitors: {
|
|
27
|
-
ElementAccessExpression: (node) => {
|
|
27
|
+
ElementAccessExpression: (node, { sourceFile }) => {
|
|
28
28
|
if (ts.isStringLiteral(node.argumentExpression) &&
|
|
29
29
|
node.argumentExpression.text === "__proto__") {
|
|
30
30
|
context.report({
|
|
31
31
|
message: "noProto",
|
|
32
32
|
range: {
|
|
33
|
-
begin: node.argumentExpression.getStart(
|
|
33
|
+
begin: node.argumentExpression.getStart(sourceFile),
|
|
34
34
|
end: node.argumentExpression.getEnd(),
|
|
35
35
|
},
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
|
-
PropertyAccessExpression: (node) => {
|
|
39
|
+
PropertyAccessExpression: (node, { sourceFile }) => {
|
|
40
40
|
if (node.name.kind === ts.SyntaxKind.Identifier &&
|
|
41
41
|
node.name.text === "__proto__") {
|
|
42
42
|
context.report({
|
|
43
43
|
message: "noProto",
|
|
44
44
|
range: {
|
|
45
|
-
begin: node.name.getStart(
|
|
45
|
+
begin: node.name.getStart(sourceFile),
|
|
46
46
|
end: node.name.getEnd(),
|
|
47
47
|
},
|
|
48
48
|
});
|
|
@@ -52,3 +52,4 @@ export default typescriptLanguage.createRule({
|
|
|
52
52
|
};
|
|
53
53
|
},
|
|
54
54
|
});
|
|
55
|
+
//# sourceMappingURL=objectProto.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Reports direct calls to Object.prototype methods on object instances.";
|
|
3
|
+
readonly id: "objectPrototypeBuiltIns";
|
|
4
|
+
readonly preset: "logical";
|
|
5
|
+
}, import("../nodes.js").TSNodesByName, import("../language.js").TypeScriptFileServices, "prototypeBuiltIn", undefined>;
|
|
6
|
+
export default _default;
|
|
7
|
+
//# sourceMappingURL=objectPrototypeBuiltIns.d.ts.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as ts from "typescript";
|
|
2
|
+
import { getTSNodeRange } from "../getTSNodeRange.js";
|
|
3
|
+
import { typescriptLanguage } from "../language.js";
|
|
4
|
+
const prototypeMethods = new Set([
|
|
5
|
+
"hasOwnProperty",
|
|
6
|
+
"isPrototypeOf",
|
|
7
|
+
"propertyIsEnumerable",
|
|
8
|
+
]);
|
|
9
|
+
export default typescriptLanguage.createRule({
|
|
10
|
+
about: {
|
|
11
|
+
description: "Reports direct calls to Object.prototype methods on object instances.",
|
|
12
|
+
id: "objectPrototypeBuiltIns",
|
|
13
|
+
preset: "logical",
|
|
14
|
+
},
|
|
15
|
+
messages: {
|
|
16
|
+
prototypeBuiltIn: {
|
|
17
|
+
primary: "Prefer the safer `Object.prototype.{{ method }}.call()` over calling `{{ method }}()` directly on objects.",
|
|
18
|
+
secondary: [
|
|
19
|
+
"Objects can have properties that shadow built-in methods from `Object.prototype` such as `{{ method }}()`.",
|
|
20
|
+
"Objects created with `Object.create(null)` do not inherit from `Object.prototype` and will not have these methods.",
|
|
21
|
+
"Calling these methods directly can fail or execute unintended code if the object has shadowing properties.",
|
|
22
|
+
],
|
|
23
|
+
suggestions: [
|
|
24
|
+
"Call the method through `Object.prototype` using `.call()`.",
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
setup(context) {
|
|
29
|
+
return {
|
|
30
|
+
visitors: {
|
|
31
|
+
CallExpression: (node, { sourceFile }) => {
|
|
32
|
+
if (!ts.isPropertyAccessExpression(node.expression) ||
|
|
33
|
+
!ts.isIdentifier(node.expression.name)) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const method = node.expression.name.text;
|
|
37
|
+
if (!prototypeMethods.has(method)) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const openParenthesisToken = findToken(node, ts.SyntaxKind.OpenParenToken, sourceFile);
|
|
41
|
+
const closeParenthesisToken = findToken(node, ts.SyntaxKind.CloseParenToken, sourceFile);
|
|
42
|
+
const objectText = sourceFile.text.slice(node.expression.expression.getStart(sourceFile), node.expression.expression.getEnd());
|
|
43
|
+
const argumentsText = sourceFile.text.slice(openParenthesisToken.getEnd(), closeParenthesisToken.getStart(sourceFile));
|
|
44
|
+
context.report({
|
|
45
|
+
data: { method },
|
|
46
|
+
message: "prototypeBuiltIn",
|
|
47
|
+
range: getTSNodeRange(node, sourceFile),
|
|
48
|
+
suggestions: [
|
|
49
|
+
{
|
|
50
|
+
id: "usePrototypeCall",
|
|
51
|
+
range: getTSNodeRange(node, sourceFile),
|
|
52
|
+
text: `Object.prototype.${method}.call(${objectText}, ${argumentsText})`,
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
function findToken(node, token, sourceFile) {
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
63
|
+
return node.getChildren(sourceFile).find((child) => child.kind === token);
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=objectPrototypeBuiltIns.js.map
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import rule from "./objectPrototypeBuiltIns.js";
|
|
2
|
+
import { ruleTester } from "./ruleTester.js";
|
|
3
|
+
ruleTester.describe(rule, {
|
|
4
|
+
invalid: [
|
|
5
|
+
{
|
|
6
|
+
code: `
|
|
7
|
+
const has = object.hasOwnProperty("key");
|
|
8
|
+
`,
|
|
9
|
+
snapshot: `
|
|
10
|
+
const has = object.hasOwnProperty("key");
|
|
11
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
12
|
+
Prefer the safer \`Object.prototype.hasOwnProperty.call()\` over calling \`hasOwnProperty()\` directly on objects.
|
|
13
|
+
`,
|
|
14
|
+
suggestions: [
|
|
15
|
+
{
|
|
16
|
+
id: "usePrototypeCall",
|
|
17
|
+
updated: `
|
|
18
|
+
const has = Object.prototype.hasOwnProperty.call(object, "key");
|
|
19
|
+
`,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
code: `
|
|
25
|
+
const isPrototype = object.isPrototypeOf(other);
|
|
26
|
+
`,
|
|
27
|
+
snapshot: `
|
|
28
|
+
const isPrototype = object.isPrototypeOf(other);
|
|
29
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
30
|
+
Prefer the safer \`Object.prototype.isPrototypeOf.call()\` over calling \`isPrototypeOf()\` directly on objects.
|
|
31
|
+
`,
|
|
32
|
+
suggestions: [
|
|
33
|
+
{
|
|
34
|
+
id: "usePrototypeCall",
|
|
35
|
+
updated: `
|
|
36
|
+
const isPrototype = Object.prototype.isPrototypeOf.call(object, other);
|
|
37
|
+
`,
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
code: `
|
|
43
|
+
const isEnum = object.propertyIsEnumerable("prop");
|
|
44
|
+
`,
|
|
45
|
+
snapshot: `
|
|
46
|
+
const isEnum = object.propertyIsEnumerable("prop");
|
|
47
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
48
|
+
Prefer the safer \`Object.prototype.propertyIsEnumerable.call()\` over calling \`propertyIsEnumerable()\` directly on objects.
|
|
49
|
+
`,
|
|
50
|
+
suggestions: [
|
|
51
|
+
{
|
|
52
|
+
id: "usePrototypeCall",
|
|
53
|
+
updated: `
|
|
54
|
+
const isEnum = Object.prototype.propertyIsEnumerable.call(object, "prop");
|
|
55
|
+
`,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
code: `
|
|
61
|
+
if (data.hasOwnProperty(key)) {
|
|
62
|
+
process(data[key]);
|
|
63
|
+
}
|
|
64
|
+
`,
|
|
65
|
+
snapshot: `
|
|
66
|
+
if (data.hasOwnProperty(key)) {
|
|
67
|
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
68
|
+
Prefer the safer \`Object.prototype.hasOwnProperty.call()\` over calling \`hasOwnProperty()\` directly on objects.
|
|
69
|
+
process(data[key]);
|
|
70
|
+
}
|
|
71
|
+
`,
|
|
72
|
+
suggestions: [
|
|
73
|
+
{
|
|
74
|
+
id: "usePrototypeCall",
|
|
75
|
+
updated: `
|
|
76
|
+
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
77
|
+
process(data[key]);
|
|
78
|
+
}
|
|
79
|
+
`,
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
code: `
|
|
85
|
+
const has = object.hasOwnProperty/* comment */("key");
|
|
86
|
+
`,
|
|
87
|
+
snapshot: `
|
|
88
|
+
const has = object.hasOwnProperty/* comment */("key");
|
|
89
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
90
|
+
Prefer the safer \`Object.prototype.hasOwnProperty.call()\` over calling \`hasOwnProperty()\` directly on objects.
|
|
91
|
+
`,
|
|
92
|
+
suggestions: [
|
|
93
|
+
{
|
|
94
|
+
id: "usePrototypeCall",
|
|
95
|
+
updated: `
|
|
96
|
+
const has = Object.prototype.hasOwnProperty.call(object, "key");
|
|
97
|
+
`,
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
code: `
|
|
103
|
+
const has = object.hasOwnProperty/* :( */("key");
|
|
104
|
+
`,
|
|
105
|
+
snapshot: `
|
|
106
|
+
const has = object.hasOwnProperty/* :( */("key");
|
|
107
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
108
|
+
Prefer the safer \`Object.prototype.hasOwnProperty.call()\` over calling \`hasOwnProperty()\` directly on objects.
|
|
109
|
+
`,
|
|
110
|
+
suggestions: [
|
|
111
|
+
{
|
|
112
|
+
id: "usePrototypeCall",
|
|
113
|
+
updated: `
|
|
114
|
+
const has = Object.prototype.hasOwnProperty.call(object, "key");
|
|
115
|
+
`,
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
code: `
|
|
121
|
+
const has = object.hasOwnProperty(/* comment */ "key");
|
|
122
|
+
`,
|
|
123
|
+
snapshot: `
|
|
124
|
+
const has = object.hasOwnProperty(/* comment */ "key");
|
|
125
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
126
|
+
Prefer the safer \`Object.prototype.hasOwnProperty.call()\` over calling \`hasOwnProperty()\` directly on objects.
|
|
127
|
+
`,
|
|
128
|
+
suggestions: [
|
|
129
|
+
{
|
|
130
|
+
id: "usePrototypeCall",
|
|
131
|
+
updated: `
|
|
132
|
+
const has = Object.prototype.hasOwnProperty.call(object, /* comment */ "key");
|
|
133
|
+
`,
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
valid: [
|
|
139
|
+
`const has = Object.prototype.hasOwnProperty.call(object, "key");`,
|
|
140
|
+
`const isPrototype = Object.prototype.isPrototypeOf.call(object, other);`,
|
|
141
|
+
`const isEnum = {}.propertyIsEnumerable.call(object, "prop");`,
|
|
142
|
+
`const value = object.someOtherMethod("key");`,
|
|
143
|
+
`const result = hasOwnProperty("key");`,
|
|
144
|
+
],
|
|
145
|
+
});
|
|
146
|
+
//# sourceMappingURL=objectPrototypeBuiltIns.test.js.map
|
|
@@ -2,5 +2,6 @@ declare const _default: import("@flint.fyi/core").Rule<{
|
|
|
2
2
|
readonly description: "Reports using octal escape sequences in string literals.";
|
|
3
3
|
readonly id: "octalEscapes";
|
|
4
4
|
readonly preset: "logical";
|
|
5
|
-
}, import("../nodes.js").TSNodesByName, import("../language.js").
|
|
5
|
+
}, import("../nodes.js").TSNodesByName, import("../language.js").TypeScriptFileServices, "noOctalEscape", undefined>;
|
|
6
6
|
export default _default;
|
|
7
|
+
//# sourceMappingURL=octalEscapes.d.ts.map
|
|
@@ -38,13 +38,13 @@ export default typescriptLanguage.createRule({
|
|
|
38
38
|
},
|
|
39
39
|
},
|
|
40
40
|
setup(context) {
|
|
41
|
-
function checkNode(node) {
|
|
42
|
-
const text = node.getText(
|
|
41
|
+
function checkNode(node, sourceFile) {
|
|
42
|
+
const text = node.getText(sourceFile);
|
|
43
43
|
const octalEscape = findOctalEscape(text);
|
|
44
44
|
if (!octalEscape) {
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
|
-
const nodeStart = node.getStart(
|
|
47
|
+
const nodeStart = node.getStart(sourceFile);
|
|
48
48
|
context.report({
|
|
49
49
|
message: "noOctalEscape",
|
|
50
50
|
range: {
|
|
@@ -55,17 +55,22 @@ export default typescriptLanguage.createRule({
|
|
|
55
55
|
}
|
|
56
56
|
return {
|
|
57
57
|
visitors: {
|
|
58
|
-
NoSubstitutionTemplateLiteral:
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
NoSubstitutionTemplateLiteral: (node, { sourceFile }) => {
|
|
59
|
+
checkNode(node, sourceFile);
|
|
60
|
+
},
|
|
61
|
+
StringLiteral: (node, { sourceFile }) => {
|
|
62
|
+
checkNode(node, sourceFile);
|
|
63
|
+
},
|
|
64
|
+
TemplateExpression: (node, { sourceFile }) => {
|
|
61
65
|
// Check the head of the template
|
|
62
|
-
checkNode(node.head);
|
|
66
|
+
checkNode(node.head, sourceFile);
|
|
63
67
|
// Check each template span
|
|
64
68
|
for (const span of node.templateSpans) {
|
|
65
|
-
checkNode(span.literal);
|
|
69
|
+
checkNode(span.literal, sourceFile);
|
|
66
70
|
}
|
|
67
71
|
},
|
|
68
72
|
},
|
|
69
73
|
};
|
|
70
74
|
},
|
|
71
75
|
});
|
|
76
|
+
//# sourceMappingURL=octalEscapes.js.map
|
|
@@ -2,5 +2,6 @@ declare const _default: import("@flint.fyi/core").Rule<{
|
|
|
2
2
|
readonly description: "Reports using legacy octal numeric literals.";
|
|
3
3
|
readonly id: "octalNumbers";
|
|
4
4
|
readonly preset: "untyped";
|
|
5
|
-
}, import("../nodes.js").TSNodesByName, import("../language.js").
|
|
5
|
+
}, import("../nodes.js").TSNodesByName, import("../language.js").TypeScriptFileServices, "noOctalNumber", undefined>;
|
|
6
6
|
export default _default;
|
|
7
|
+
//# sourceMappingURL=octalNumbers.d.ts.map
|
|
@@ -22,8 +22,8 @@ export default typescriptLanguage.createRule({
|
|
|
22
22
|
setup(context) {
|
|
23
23
|
return {
|
|
24
24
|
visitors: {
|
|
25
|
-
NumericLiteral: (node) => {
|
|
26
|
-
const text = node.getText(
|
|
25
|
+
NumericLiteral: (node, { sourceFile }) => {
|
|
26
|
+
const text = node.getText(sourceFile);
|
|
27
27
|
// Check for legacy octal literal: starts with 0 followed by octal digits (0-7)
|
|
28
28
|
// But not just "0" alone, and not modern formats like 0x, 0o, 0b
|
|
29
29
|
// cspell:ignore xobi
|
|
@@ -33,7 +33,7 @@ export default typescriptLanguage.createRule({
|
|
|
33
33
|
text[1] <= "7" &&
|
|
34
34
|
!/^0[xobi]/i.test(text)) {
|
|
35
35
|
const range = {
|
|
36
|
-
begin: node.getStart(
|
|
36
|
+
begin: node.getStart(sourceFile),
|
|
37
37
|
end: node.getEnd(),
|
|
38
38
|
};
|
|
39
39
|
// Parse the octal value
|
|
@@ -66,3 +66,4 @@ export default typescriptLanguage.createRule({
|
|
|
66
66
|
};
|
|
67
67
|
},
|
|
68
68
|
});
|
|
69
|
+
//# sourceMappingURL=octalNumbers.js.map
|
|
@@ -2,5 +2,6 @@ declare const _default: import("@flint.fyi/core").Rule<{
|
|
|
2
2
|
readonly description: "Reports using assignment expressions in return statements.";
|
|
3
3
|
readonly id: "returnAssignments";
|
|
4
4
|
readonly preset: "stylistic";
|
|
5
|
-
}, import("../nodes.js").TSNodesByName, import("../language.js").
|
|
5
|
+
}, import("../nodes.js").TSNodesByName, import("../language.js").TypeScriptFileServices, "noReturnAssign", undefined>;
|
|
6
6
|
export default _default;
|
|
7
|
+
//# sourceMappingURL=returnAssignments.d.ts.map
|