@flint.fyi/ts 0.15.0 → 0.18.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/index.d.ts +2 -13
- package/lib/index.js +2 -12
- package/lib/plugin.d.ts +2159 -232
- package/lib/plugin.js +609 -121
- package/lib/rules/accessorPairGroups.d.ts +10 -0
- package/lib/rules/accessorPairGroups.js +48 -0
- package/lib/rules/accessorPairTypes.d.ts +10 -0
- package/lib/rules/accessorPairTypes.js +72 -0
- package/lib/rules/accessorThisRecursion.d.ts +10 -0
- package/lib/rules/accessorThisRecursion.js +65 -0
- package/lib/rules/anyArguments.d.ts +10 -0
- package/lib/rules/anyArguments.js +234 -0
- package/lib/rules/anyAssignments.d.ts +10 -0
- package/lib/rules/anyAssignments.js +266 -0
- package/lib/rules/anyCalls.d.ts +10 -0
- package/lib/rules/anyCalls.js +68 -0
- package/lib/rules/anyMemberAccess.d.ts +10 -0
- package/lib/rules/anyMemberAccess.js +85 -0
- package/lib/rules/anyReturns.d.ts +5 -2
- package/lib/rules/anyReturns.js +97 -182
- package/lib/rules/arguments.d.ts +10 -0
- package/lib/rules/arguments.js +38 -0
- package/lib/rules/arrayCallbackReturns.d.ts +10 -0
- package/lib/rules/arrayCallbackReturns.js +73 -0
- package/lib/rules/arrayConstructors.d.ts +10 -0
- package/lib/rules/arrayConstructors.js +47 -0
- package/lib/rules/arrayDeleteUnnecessaryCounts.d.ts +10 -0
- package/lib/rules/arrayDeleteUnnecessaryCounts.js +54 -0
- package/lib/rules/arrayElementDeletions.d.ts +10 -0
- package/lib/rules/arrayElementDeletions.js +43 -0
- package/lib/rules/arrayEmptyCallbackSlots.d.ts +10 -0
- package/lib/rules/arrayEmptyCallbackSlots.js +45 -0
- package/lib/rules/arrayExistenceChecksConsistency.d.ts +10 -0
- package/lib/rules/arrayExistenceChecksConsistency.js +86 -0
- package/lib/rules/arrayFilteredFinds.d.ts +10 -0
- package/lib/rules/arrayFilteredFinds.js +80 -0
- package/lib/rules/arrayFinds.d.ts +10 -0
- package/lib/rules/arrayFinds.js +41 -0
- package/lib/rules/arrayFlatMapMethods.d.ts +10 -0
- package/lib/rules/arrayFlatMapMethods.js +47 -0
- package/lib/rules/arrayFlatMethods.d.ts +10 -0
- package/lib/rules/arrayFlatMethods.js +83 -0
- package/lib/rules/arrayFlatUnnecessaryDepths.d.ts +10 -0
- package/lib/rules/arrayFlatUnnecessaryDepths.js +33 -0
- package/lib/rules/arrayIncludes.d.ts +10 -0
- package/lib/rules/arrayIncludes.js +59 -0
- package/lib/rules/arrayIncludesMethods.d.ts +10 -0
- package/lib/rules/arrayIncludesMethods.js +37 -0
- package/lib/rules/arrayIndexOfMethods.d.ts +10 -0
- package/lib/rules/arrayIndexOfMethods.js +51 -0
- package/lib/rules/arrayLoops.d.ts +10 -0
- package/lib/rules/arrayLoops.js +36 -0
- package/lib/rules/arrayMapIdentities.d.ts +10 -0
- package/lib/rules/arrayMapIdentities.js +74 -0
- package/lib/rules/arrayMutableReverses.d.ts +10 -0
- package/lib/rules/arrayMutableReverses.js +39 -0
- package/lib/rules/arrayMutableSorts.d.ts +10 -0
- package/lib/rules/arrayMutableSorts.js +72 -0
- package/lib/rules/arrayReduceTypeArguments.d.ts +10 -0
- package/lib/rules/arrayReduceTypeArguments.js +64 -0
- package/lib/rules/arraySliceUnnecessaryEnd.d.ts +10 -0
- package/lib/rules/arraySliceUnnecessaryEnd.js +51 -0
- package/lib/rules/arraySomeMethods.d.ts +10 -0
- package/lib/rules/arraySomeMethods.js +77 -0
- package/lib/rules/arrayTernarySpreadingConsistency.d.ts +10 -0
- package/lib/rules/arrayTernarySpreadingConsistency.js +74 -0
- package/lib/rules/arrayTypes.d.ts +17 -0
- package/lib/rules/arrayTypes.js +111 -0
- package/lib/rules/arrayUnnecessaryLengthChecks.d.ts +10 -0
- package/lib/rules/arrayUnnecessaryLengthChecks.js +97 -0
- package/lib/rules/asConstAssertions.d.ts +10 -0
- package/lib/rules/asConstAssertions.js +57 -0
- package/lib/rules/assignmentOperatorShorthands.d.ts +10 -0
- package/lib/rules/assignmentOperatorShorthands.js +47 -0
- package/lib/rules/asyncPromiseExecutors.d.ts +5 -2
- package/lib/rules/asyncPromiseExecutors.js +39 -50
- package/lib/rules/asyncUnnecessaryPromiseWrappers.d.ts +10 -0
- package/lib/rules/asyncUnnecessaryPromiseWrappers.js +52 -0
- package/lib/rules/atAccesses.d.ts +10 -0
- package/lib/rules/atAccesses.js +52 -0
- package/lib/rules/builtinCoercions.d.ts +10 -0
- package/lib/rules/builtinCoercions.js +117 -0
- package/lib/rules/builtinConstructorNews.d.ts +10 -0
- package/lib/rules/builtinConstructorNews.js +89 -0
- package/lib/rules/caseDeclarations.d.ts +5 -3
- package/lib/rules/caseDeclarations.js +37 -51
- package/lib/rules/caseDuplicates.d.ts +5 -2
- package/lib/rules/caseDuplicates.js +34 -48
- package/lib/rules/caseFallthroughs.d.ts +10 -0
- package/lib/rules/caseFallthroughs.js +76 -0
- package/lib/rules/catchCallbackTypes.d.ts +10 -0
- package/lib/rules/catchCallbackTypes.js +67 -0
- package/lib/rules/caughtVariableNames.d.ts +10 -0
- package/lib/rules/caughtVariableNames.js +40 -0
- package/lib/rules/chainedAssignments.d.ts +5 -2
- package/lib/rules/chainedAssignments.js +30 -47
- package/lib/rules/charAtComparisons.d.ts +10 -0
- package/lib/rules/charAtComparisons.js +58 -0
- package/lib/rules/classAssignments.d.ts +5 -2
- package/lib/rules/classAssignments.js +30 -41
- package/lib/rules/classFieldDeclarations.d.ts +10 -0
- package/lib/rules/classFieldDeclarations.js +40 -0
- package/lib/rules/classLiteralProperties.d.ts +10 -0
- package/lib/rules/classLiteralProperties.js +45 -0
- package/lib/rules/classMemberDuplicates.d.ts +10 -0
- package/lib/rules/classMemberDuplicates.js +71 -0
- package/lib/rules/classMethodsThis.d.ts +14 -0
- package/lib/rules/classMethodsThis.js +124 -0
- package/lib/rules/combinedPushes.d.ts +10 -0
- package/lib/rules/combinedPushes.js +56 -0
- package/lib/rules/consecutiveNonNullAssertions.d.ts +5 -2
- package/lib/rules/consecutiveNonNullAssertions.js +37 -41
- package/lib/rules/consoleCalls.d.ts +9 -0
- package/lib/rules/consoleCalls.js +28 -0
- package/lib/rules/constantAssignments.d.ts +5 -2
- package/lib/rules/constantAssignments.js +42 -60
- package/lib/rules/constructorGenericCalls.d.ts +16 -0
- package/lib/rules/constructorGenericCalls.js +138 -0
- package/lib/rules/constructorReturns.d.ts +5 -2
- package/lib/rules/constructorReturns.js +38 -50
- package/lib/rules/constructorSupers.d.ts +10 -0
- package/lib/rules/constructorSupers.js +77 -0
- package/lib/rules/dateConstructorClones.d.ts +10 -0
- package/lib/rules/dateConstructorClones.js +37 -0
- package/lib/rules/dateNowTimestamps.d.ts +10 -0
- package/lib/rules/dateNowTimestamps.js +57 -0
- package/lib/rules/debuggerStatements.d.ts +5 -2
- package/lib/rules/debuggerStatements.js +31 -42
- package/lib/rules/defaultCaseLast.d.ts +5 -2
- package/lib/rules/defaultCaseLast.js +34 -42
- package/lib/rules/defaultParameterLast.d.ts +10 -0
- package/lib/rules/defaultParameterLast.js +42 -0
- package/lib/rules/deprecated.d.ts +10 -0
- package/lib/rules/deprecated.js +243 -0
- package/lib/rules/destructuringConsistency.d.ts +10 -0
- package/lib/rules/destructuringConsistency.js +112 -0
- package/lib/rules/duplicateArguments.d.ts +5 -3
- package/lib/rules/duplicateArguments.js +43 -50
- package/lib/rules/dynamicDeletes.d.ts +10 -0
- package/lib/rules/dynamicDeletes.js +37 -0
- package/lib/rules/elseIfDuplicates.d.ts +5 -2
- package/lib/rules/elseIfDuplicates.js +36 -52
- package/lib/rules/elseReturns.d.ts +10 -0
- package/lib/rules/elseReturns.js +67 -0
- package/lib/rules/emptyBlocks.d.ts +5 -2
- package/lib/rules/emptyBlocks.js +52 -64
- package/lib/rules/emptyDestructures.d.ts +5 -3
- package/lib/rules/emptyDestructures.js +32 -39
- package/lib/rules/emptyEnums.d.ts +10 -0
- package/lib/rules/emptyEnums.js +30 -0
- package/lib/rules/emptyExports.d.ts +10 -0
- package/lib/rules/emptyExports.js +60 -0
- package/lib/rules/emptyFiles.d.ts +10 -0
- package/lib/rules/emptyFiles.js +44 -0
- package/lib/rules/emptyFunctions.d.ts +10 -0
- package/lib/rules/emptyFunctions.js +61 -0
- package/lib/rules/emptyModuleAttributes.d.ts +10 -0
- package/lib/rules/emptyModuleAttributes.js +35 -0
- package/lib/rules/emptyObjectTypes.d.ts +10 -0
- package/lib/rules/emptyObjectTypes.js +47 -0
- package/lib/rules/emptyStaticBlocks.d.ts +5 -2
- package/lib/rules/emptyStaticBlocks.js +40 -53
- package/lib/rules/emptyTypeParameterLists.d.ts +10 -0
- package/lib/rules/emptyTypeParameterLists.js +31 -0
- package/lib/rules/enumInitializers.d.ts +10 -0
- package/lib/rules/enumInitializers.js +54 -0
- package/lib/rules/enumMemberLiterals.d.ts +10 -0
- package/lib/rules/enumMemberLiterals.js +39 -0
- package/lib/rules/enumValueConsistency.d.ts +10 -0
- package/lib/rules/enumValueConsistency.js +56 -0
- package/lib/rules/enumValueDuplicates.d.ts +10 -0
- package/lib/rules/enumValueDuplicates.js +60 -0
- package/lib/rules/equalityOperatorNegations.d.ts +9 -0
- package/lib/rules/equalityOperatorNegations.js +60 -0
- package/lib/rules/equalityOperators.d.ts +10 -0
- package/lib/rules/equalityOperators.js +44 -0
- package/lib/rules/errorMessages.d.ts +10 -0
- package/lib/rules/errorMessages.js +60 -0
- package/lib/rules/errorSubclassProperties.d.ts +10 -0
- package/lib/rules/errorSubclassProperties.js +144 -0
- package/lib/rules/errorUnnecessaryCaptureStackTraces.d.ts +10 -0
- package/lib/rules/errorUnnecessaryCaptureStackTraces.js +55 -0
- package/lib/rules/escapeSequenceCasing.d.ts +10 -0
- package/lib/rules/escapeSequenceCasing.js +75 -0
- package/lib/rules/evals.d.ts +10 -0
- package/lib/rules/evals.js +31 -0
- package/lib/rules/evolvingVariableTypes.d.ts +10 -0
- package/lib/rules/evolvingVariableTypes.js +33 -0
- package/lib/rules/exceptionAssignments.d.ts +5 -2
- package/lib/rules/exceptionAssignments.js +40 -60
- package/lib/rules/explicitAnys.d.ts +10 -0
- package/lib/rules/explicitAnys.js +55 -0
- package/lib/rules/exponentiationOperators.d.ts +10 -0
- package/lib/rules/exponentiationOperators.js +34 -0
- package/lib/rules/exportFromImports.d.ts +10 -0
- package/lib/rules/exportFromImports.js +119 -0
- package/lib/rules/exportMutables.d.ts +10 -0
- package/lib/rules/exportMutables.js +33 -0
- package/lib/rules/exportUniqueNames.d.ts +10 -0
- package/lib/rules/exportUniqueNames.js +65 -0
- package/lib/rules/extraneousClasses.d.ts +16 -0
- package/lib/rules/extraneousClasses.js +111 -0
- package/lib/rules/fetchMethodBodies.d.ts +10 -0
- package/lib/rules/fetchMethodBodies.js +72 -0
- package/lib/rules/finallyStatementSafety.d.ts +5 -2
- package/lib/rules/finallyStatementSafety.js +45 -69
- package/lib/rules/forDirections.d.ts +5 -2
- package/lib/rules/forDirections.js +67 -124
- package/lib/rules/forInArrays.d.ts +5 -2
- package/lib/rules/forInArrays.js +42 -50
- package/lib/rules/forInGuards.d.ts +9 -0
- package/lib/rules/forInGuards.js +44 -0
- package/lib/rules/functionApplySpreads.d.ts +10 -0
- package/lib/rules/functionApplySpreads.js +63 -0
- package/lib/rules/functionAssignments.d.ts +5 -2
- package/lib/rules/functionAssignments.js +30 -41
- package/lib/rules/functionCurryingRedundancy.d.ts +5 -2
- package/lib/rules/functionCurryingRedundancy.js +47 -71
- package/lib/rules/functionDeclarationStyles.d.ts +16 -0
- package/lib/rules/functionDeclarationStyles.js +67 -0
- package/lib/rules/functionNameMatches.d.ts +10 -0
- package/lib/rules/functionNameMatches.js +74 -0
- package/lib/rules/functionNewCalls.d.ts +5 -3
- package/lib/rules/functionNewCalls.js +40 -59
- package/lib/rules/generatorFunctionYields.d.ts +5 -3
- package/lib/rules/generatorFunctionYields.js +45 -53
- package/lib/rules/getterReturns.d.ts +10 -0
- package/lib/rules/getterReturns.js +65 -0
- package/lib/rules/globalAssignments.d.ts +5 -2
- package/lib/rules/globalAssignments.js +44 -57
- package/lib/rules/globalObjectCalls.d.ts +5 -3
- package/lib/rules/globalObjectCalls.js +40 -42
- package/lib/rules/globalThisAliases.d.ts +10 -0
- package/lib/rules/globalThisAliases.js +47 -0
- package/lib/rules/impliedEvals.d.ts +10 -0
- package/lib/rules/impliedEvals.js +130 -0
- package/lib/rules/importEmptyBlocks.d.ts +10 -0
- package/lib/rules/importEmptyBlocks.js +53 -0
- package/lib/rules/importTypeSideEffects.d.ts +10 -0
- package/lib/rules/importTypeSideEffects.js +31 -0
- package/lib/rules/indexedObjectTypes.d.ts +16 -0
- package/lib/rules/indexedObjectTypes.js +83 -0
- package/lib/rules/instanceOfArrays.d.ts +10 -0
- package/lib/rules/instanceOfArrays.js +31 -0
- package/lib/rules/irregularWhitespaces.d.ts +16 -0
- package/lib/rules/irregularWhitespaces.js +97 -0
- package/lib/rules/isNaNComparisons.d.ts +10 -0
- package/lib/rules/isNaNComparisons.js +43 -0
- package/lib/rules/literalConstructorWrappers.d.ts +10 -0
- package/lib/rules/literalConstructorWrappers.js +64 -0
- package/lib/rules/mathMethods.d.ts +10 -0
- package/lib/rules/mathMethods.js +128 -0
- package/lib/rules/meaninglessVoidOperators.d.ts +10 -0
- package/lib/rules/meaninglessVoidOperators.js +39 -0
- package/lib/rules/misleadingVoidExpressions.d.ts +10 -0
- package/lib/rules/misleadingVoidExpressions.js +128 -0
- package/lib/rules/moduleSpecifierLists.d.ts +10 -0
- package/lib/rules/moduleSpecifierLists.js +92 -0
- package/lib/rules/multilineAmbiguities.d.ts +10 -0
- package/lib/rules/multilineAmbiguities.js +64 -0
- package/lib/rules/namedDefaultExports.d.ts +10 -0
- package/lib/rules/namedDefaultExports.js +60 -0
- package/lib/rules/namespaceDeclarations.d.ts +6 -3
- package/lib/rules/namespaceDeclarations.js +34 -55
- package/lib/rules/namespaceImplicitAmbientImports.d.ts +10 -0
- package/lib/rules/namespaceImplicitAmbientImports.js +40 -0
- package/lib/rules/namespaceKeywords.d.ts +10 -0
- package/lib/rules/namespaceKeywords.js +40 -0
- package/lib/rules/nativeObjectExtensions.d.ts +10 -0
- package/lib/rules/nativeObjectExtensions.js +114 -0
- package/lib/rules/negativeIndexLengthMethods.d.ts +10 -0
- package/lib/rules/negativeIndexLengthMethods.js +180 -0
- package/lib/rules/negativeZeroComparisons.d.ts +5 -2
- package/lib/rules/negativeZeroComparisons.js +44 -62
- package/lib/rules/nestedStandaloneIfs.d.ts +10 -0
- package/lib/rules/nestedStandaloneIfs.js +105 -0
- package/lib/rules/newDefinitions.d.ts +10 -0
- package/lib/rules/newDefinitions.js +84 -0
- package/lib/rules/newExpressions.d.ts +5 -2
- package/lib/rules/newExpressions.js +36 -53
- package/lib/rules/newNativeNonConstructors.d.ts +5 -2
- package/lib/rules/newNativeNonConstructors.js +37 -48
- package/lib/rules/nonNullAssertedNullishCoalesces.d.ts +10 -0
- package/lib/rules/nonNullAssertedNullishCoalesces.js +63 -0
- package/lib/rules/nonNullAssertedOptionalChains.d.ts +10 -0
- package/lib/rules/nonNullAssertedOptionalChains.js +69 -0
- package/lib/rules/nonNullAssertionPlacement.d.ts +10 -0
- package/lib/rules/nonNullAssertionPlacement.js +94 -0
- package/lib/rules/nonNullableTypeAssertions.d.ts +10 -0
- package/lib/rules/nonNullableTypeAssertions.js +78 -0
- package/lib/rules/nonOctalDecimalEscapes.d.ts +5 -3
- package/lib/rules/nonOctalDecimalEscapes.js +45 -55
- package/lib/rules/nullishCheckStyle.d.ts +21 -0
- package/lib/rules/nullishCheckStyle.js +144 -0
- package/lib/rules/nullishCoalescingOperators.d.ts +22 -0
- package/lib/rules/nullishCoalescingOperators.js +311 -0
- package/lib/rules/numberMethodRanges.d.ts +10 -0
- package/lib/rules/numberMethodRanges.js +74 -0
- package/lib/rules/numberStaticMethods.d.ts +10 -0
- package/lib/rules/numberStaticMethods.js +53 -0
- package/lib/rules/numericErasingOperations.d.ts +10 -0
- package/lib/rules/numericErasingOperations.js +46 -0
- package/lib/rules/numericLiteralParsing.d.ts +5 -2
- package/lib/rules/numericLiteralParsing.js +58 -90
- package/lib/rules/numericPrecision.d.ts +10 -0
- package/lib/rules/numericPrecision.js +102 -0
- package/lib/rules/numericSeparatorGroups.d.ts +10 -0
- package/lib/rules/numericSeparatorGroups.js +101 -0
- package/lib/rules/objectAssignSpreads.d.ts +10 -0
- package/lib/rules/objectAssignSpreads.js +53 -0
- package/lib/rules/objectCalls.d.ts +5 -2
- package/lib/rules/objectCalls.js +36 -45
- package/lib/rules/objectEntriesMethods.d.ts +10 -0
- package/lib/rules/objectEntriesMethods.js +82 -0
- package/lib/rules/objectHasOwns.d.ts +5 -2
- package/lib/rules/objectHasOwns.js +48 -72
- package/lib/rules/objectKeyDuplicates.d.ts +5 -2
- package/lib/rules/objectKeyDuplicates.js +57 -85
- package/lib/rules/objectProto.d.ts +5 -2
- package/lib/rules/objectProto.js +48 -53
- package/lib/rules/objectPrototypeBuiltIns.d.ts +5 -2
- package/lib/rules/objectPrototypeBuiltIns.js +48 -59
- package/lib/rules/objectShorthand.d.ts +10 -0
- package/lib/rules/objectShorthand.js +84 -0
- package/lib/rules/objectSpreadUnnecessaryFallbacks.d.ts +10 -0
- package/lib/rules/objectSpreadUnnecessaryFallbacks.js +43 -0
- package/lib/rules/objectTypeDefinitions.d.ts +10 -0
- package/lib/rules/objectTypeDefinitions.js +34 -0
- package/lib/rules/octalEscapes.d.ts +5 -2
- package/lib/rules/octalEscapes.js +53 -71
- package/lib/rules/octalNumbers.d.ts +5 -2
- package/lib/rules/octalNumbers.js +53 -67
- package/lib/rules/operatorAssignmentShorthand.d.ts +10 -0
- package/lib/rules/operatorAssignmentShorthand.js +77 -0
- package/lib/rules/overloadSignaturesAdjacent.d.ts +10 -0
- package/lib/rules/overloadSignaturesAdjacent.js +140 -0
- package/lib/rules/parameterReassignments.d.ts +10 -0
- package/lib/rules/parameterReassignments.js +76 -0
- package/lib/rules/parseIntRadixes.d.ts +10 -0
- package/lib/rules/parseIntRadixes.js +62 -0
- package/lib/rules/propertyAccessNotation.d.ts +13 -0
- package/lib/rules/propertyAccessNotation.js +119 -0
- package/lib/rules/recursionOnlyArguments.d.ts +10 -0
- package/lib/rules/recursionOnlyArguments.js +71 -0
- package/lib/rules/redundantTypeConstituents.d.ts +10 -0
- package/lib/rules/redundantTypeConstituents.js +277 -0
- package/lib/rules/regexAllGlobalFlags.d.ts +10 -0
- package/lib/rules/regexAllGlobalFlags.js +56 -0
- package/lib/rules/regexAmbiguousInvalidity.d.ts +10 -0
- package/lib/rules/regexAmbiguousInvalidity.js +297 -0
- package/lib/rules/regexCharacterClassRanges.d.ts +10 -0
- package/lib/rules/regexCharacterClassRanges.js +137 -0
- package/lib/rules/regexCharacterClassSetOperations.d.ts +10 -0
- package/lib/rules/regexCharacterClassSetOperations.js +81 -0
- package/lib/rules/regexCharacterClasses.d.ts +10 -0
- package/lib/rules/regexCharacterClasses.js +234 -0
- package/lib/rules/regexConciseCharacterClassNegations.d.ts +10 -0
- package/lib/rules/regexConciseCharacterClassNegations.js +52 -0
- package/lib/rules/regexContradictoryAssertions.d.ts +10 -0
- package/lib/rules/regexContradictoryAssertions.js +210 -0
- package/lib/rules/regexControlCharacterEscapes.d.ts +10 -0
- package/lib/rules/regexControlCharacterEscapes.js +130 -0
- package/lib/rules/regexControlCharacters.d.ts +10 -0
- package/lib/rules/regexControlCharacters.js +95 -0
- package/lib/rules/regexDigitMatchers.d.ts +10 -0
- package/lib/rules/regexDigitMatchers.js +180 -0
- package/lib/rules/regexDollarEscapes.d.ts +10 -0
- package/lib/rules/regexDollarEscapes.js +91 -0
- package/lib/rules/regexDuplicateCharacterClassCharacters.d.ts +10 -0
- package/lib/rules/regexDuplicateCharacterClassCharacters.js +128 -0
- package/lib/rules/regexEmptyAlternatives.d.ts +10 -0
- package/lib/rules/regexEmptyAlternatives.js +140 -0
- package/lib/rules/regexEmptyCapturingGroups.d.ts +10 -0
- package/lib/rules/regexEmptyCapturingGroups.js +67 -0
- package/lib/rules/regexEmptyCharacterClasses.d.ts +10 -0
- package/lib/rules/regexEmptyCharacterClasses.js +68 -0
- package/lib/rules/regexEmptyGroups.d.ts +10 -0
- package/lib/rules/regexEmptyGroups.js +66 -0
- package/lib/rules/regexEmptyLazyQuantifiers.d.ts +10 -0
- package/lib/rules/regexEmptyLazyQuantifiers.js +92 -0
- package/lib/rules/regexEmptyLookaroundsAssertions.d.ts +10 -0
- package/lib/rules/regexEmptyLookaroundsAssertions.js +68 -0
- package/lib/rules/regexEmptyStringLiterals.d.ts +10 -0
- package/lib/rules/regexEmptyStringLiterals.js +66 -0
- package/lib/rules/regexEscapeBackspaces.d.ts +10 -0
- package/lib/rules/regexEscapeBackspaces.js +69 -0
- package/lib/rules/regexExecutors.d.ts +10 -0
- package/lib/rules/regexExecutors.js +58 -0
- package/lib/rules/regexGraphemeStringLiterals.d.ts +10 -0
- package/lib/rules/regexGraphemeStringLiterals.js +51 -0
- package/lib/rules/regexHexadecimalEscapes.d.ts +10 -0
- package/lib/rules/regexHexadecimalEscapes.js +71 -0
- package/lib/rules/regexIgnoreCaseFlags.d.ts +10 -0
- package/lib/rules/regexIgnoreCaseFlags.js +145 -0
- package/lib/rules/regexInvisibleCharacters.d.ts +10 -0
- package/lib/rules/regexInvisibleCharacters.js +90 -0
- package/lib/rules/regexLetterCasing.d.ts +10 -0
- package/lib/rules/regexLetterCasing.js +186 -0
- package/lib/rules/regexLiterals.d.ts +10 -0
- package/lib/rules/regexLiterals.js +92 -0
- package/lib/rules/regexLookaroundAssertions.d.ts +10 -0
- package/lib/rules/regexLookaroundAssertions.js +163 -0
- package/lib/rules/regexLookaroundQuantifierOptimizations.d.ts +10 -0
- package/lib/rules/regexLookaroundQuantifierOptimizations.js +94 -0
- package/lib/rules/regexMatchNotation.d.ts +10 -0
- package/lib/rules/regexMatchNotation.js +139 -0
- package/lib/rules/regexMisleadingCapturingGroups.d.ts +10 -0
- package/lib/rules/regexMisleadingCapturingGroups.js +229 -0
- package/lib/rules/regexMisleadingQuantifiers.d.ts +10 -0
- package/lib/rules/regexMisleadingQuantifiers.js +78 -0
- package/lib/rules/regexMisleadingUnicodeCharacters.d.ts +10 -0
- package/lib/rules/regexMisleadingUnicodeCharacters.js +203 -0
- package/lib/rules/regexNamedBackreferences.d.ts +10 -0
- package/lib/rules/regexNamedBackreferences.js +48 -0
- package/lib/rules/regexNamedCaptureGroups.d.ts +9 -0
- package/lib/rules/regexNamedCaptureGroups.js +67 -0
- package/lib/rules/regexNamedReplacements.d.ts +10 -0
- package/lib/rules/regexNamedReplacements.js +93 -0
- package/lib/rules/regexNonStandardFlags.d.ts +10 -0
- package/lib/rules/regexNonStandardFlags.js +66 -0
- package/lib/rules/regexObscureRanges.d.ts +10 -0
- package/lib/rules/regexObscureRanges.js +93 -0
- package/lib/rules/regexOctalEscapes.d.ts +10 -0
- package/lib/rules/regexOctalEscapes.js +70 -0
- package/lib/rules/regexPlusQuantifiers.d.ts +10 -0
- package/lib/rules/regexPlusQuantifiers.js +68 -0
- package/lib/rules/regexPredefinedAssertions.d.ts +10 -0
- package/lib/rules/regexPredefinedAssertions.js +127 -0
- package/lib/rules/regexQuestionQuantifiers.d.ts +10 -0
- package/lib/rules/regexQuestionQuantifiers.js +104 -0
- package/lib/rules/regexRepeatQuantifiers.d.ts +10 -0
- package/lib/rules/regexRepeatQuantifiers.js +96 -0
- package/lib/rules/regexResultArrayGroups.d.ts +10 -0
- package/lib/rules/regexResultArrayGroups.js +187 -0
- package/lib/rules/regexSetOperationOptimizations.d.ts +10 -0
- package/lib/rules/regexSetOperationOptimizations.js +177 -0
- package/lib/rules/regexStandaloneBackslashes.d.ts +10 -0
- package/lib/rules/regexStandaloneBackslashes.js +59 -0
- package/lib/rules/regexStarQuantifiers.d.ts +10 -0
- package/lib/rules/regexStarQuantifiers.js +68 -0
- package/lib/rules/regexSuperLinearBacktracking.d.ts +10 -0
- package/lib/rules/regexSuperLinearBacktracking.js +98 -0
- package/lib/rules/regexSuperLinearMoves.d.ts +10 -0
- package/lib/rules/regexSuperLinearMoves.js +142 -0
- package/lib/rules/regexTestMethods.d.ts +10 -0
- package/lib/rules/regexTestMethods.js +83 -0
- package/lib/rules/regexUnicodeCodepointEscapes.d.ts +10 -0
- package/lib/rules/regexUnicodeCodepointEscapes.js +107 -0
- package/lib/rules/regexUnicodeEscapes.d.ts +9 -0
- package/lib/rules/regexUnicodeEscapes.js +97 -0
- package/lib/rules/regexUnicodeFlag.d.ts +9 -0
- package/lib/rules/regexUnicodeFlag.js +97 -0
- package/lib/rules/regexUnicodeProperties.d.ts +10 -0
- package/lib/rules/regexUnicodeProperties.js +133 -0
- package/lib/rules/regexUnnecessaryAssertions.d.ts +10 -0
- package/lib/rules/regexUnnecessaryAssertions.js +223 -0
- package/lib/rules/regexUnnecessaryBackreferences.d.ts +10 -0
- package/lib/rules/regexUnnecessaryBackreferences.js +125 -0
- package/lib/rules/regexUnnecessaryCharacterClasses.d.ts +10 -0
- package/lib/rules/regexUnnecessaryCharacterClasses.js +74 -0
- package/lib/rules/regexUnnecessaryCharacterRanges.d.ts +10 -0
- package/lib/rules/regexUnnecessaryCharacterRanges.js +108 -0
- package/lib/rules/regexUnnecessaryDisjunctions.d.ts +10 -0
- package/lib/rules/regexUnnecessaryDisjunctions.js +118 -0
- package/lib/rules/regexUnnecessaryDollarReplacements.d.ts +10 -0
- package/lib/rules/regexUnnecessaryDollarReplacements.js +144 -0
- package/lib/rules/regexUnnecessaryEscapes.d.ts +10 -0
- package/lib/rules/regexUnnecessaryEscapes.js +136 -0
- package/lib/rules/regexUnnecessaryLookaroundAssertions.d.ts +10 -0
- package/lib/rules/regexUnnecessaryLookaroundAssertions.js +80 -0
- package/lib/rules/regexUnnecessaryNestedAssertions.d.ts +10 -0
- package/lib/rules/regexUnnecessaryNestedAssertions.js +198 -0
- package/lib/rules/regexUnnecessaryNestedQuantifiers.d.ts +10 -0
- package/lib/rules/regexUnnecessaryNestedQuantifiers.js +93 -0
- package/lib/rules/regexUnnecessaryNonCapturingGroups.d.ts +10 -0
- package/lib/rules/regexUnnecessaryNonCapturingGroups.js +104 -0
- package/lib/rules/regexUnnecessaryNumericQuantifiers.d.ts +10 -0
- package/lib/rules/regexUnnecessaryNumericQuantifiers.js +69 -0
- package/lib/rules/regexUnnecessaryOptionalAssertions.d.ts +10 -0
- package/lib/rules/regexUnnecessaryOptionalAssertions.js +137 -0
- package/lib/rules/regexUnnecessaryReferentialBackreferences.d.ts +10 -0
- package/lib/rules/regexUnnecessaryReferentialBackreferences.js +123 -0
- package/lib/rules/regexUnnecessarySetOperands.d.ts +10 -0
- package/lib/rules/regexUnnecessarySetOperands.js +136 -0
- package/lib/rules/regexUnusedCapturingGroups.d.ts +10 -0
- package/lib/rules/regexUnusedCapturingGroups.js +69 -0
- package/lib/rules/regexUnusedFlags.d.ts +10 -0
- package/lib/rules/regexUnusedFlags.js +116 -0
- package/lib/rules/regexUnusedLazyQuantifiers.d.ts +10 -0
- package/lib/rules/regexUnusedLazyQuantifiers.js +63 -0
- package/lib/rules/regexUnusedQuantifiers.d.ts +10 -0
- package/lib/rules/regexUnusedQuantifiers.js +63 -0
- package/lib/rules/regexValidity.d.ts +10 -0
- package/lib/rules/regexValidity.js +146 -0
- package/lib/rules/regexWordMatchers.d.ts +10 -0
- package/lib/rules/regexWordMatchers.js +146 -0
- package/lib/rules/regexZeroQuantifiers.d.ts +10 -0
- package/lib/rules/regexZeroQuantifiers.js +60 -0
- package/lib/rules/responseJsonMethods.d.ts +10 -0
- package/lib/rules/responseJsonMethods.js +51 -0
- package/lib/rules/restrictedIdentifiers.d.ts +13 -0
- package/lib/rules/restrictedIdentifiers.js +41 -0
- package/lib/rules/returnAssignments.d.ts +5 -2
- package/lib/rules/returnAssignments.js +35 -48
- package/lib/rules/returnThisTypes.d.ts +10 -0
- package/lib/rules/returnThisTypes.js +94 -0
- package/lib/rules/ruleCreator.d.ts +3 -0
- package/lib/rules/ruleCreator.js +17 -0
- package/lib/rules/selfAssignments.d.ts +5 -2
- package/lib/rules/selfAssignments.js +27 -43
- package/lib/rules/sequences.d.ts +5 -2
- package/lib/rules/sequences.js +26 -33
- package/lib/rules/setSizeLengthChecks.d.ts +10 -0
- package/lib/rules/setSizeLengthChecks.js +48 -0
- package/lib/rules/setterReturns.d.ts +10 -0
- package/lib/rules/setterReturns.js +41 -0
- package/lib/rules/shadowedRestrictedNames.d.ts +5 -2
- package/lib/rules/shadowedRestrictedNames.js +64 -92
- package/lib/rules/singleVariableDeclarations.d.ts +10 -0
- package/lib/rules/singleVariableDeclarations.js +36 -0
- package/lib/rules/sizeComparisonOperators.d.ts +16 -0
- package/lib/rules/sizeComparisonOperators.js +148 -0
- package/lib/rules/sparseArrays.d.ts +5 -2
- package/lib/rules/sparseArrays.js +41 -53
- package/lib/rules/staticMemberOnlyClasses.d.ts +10 -0
- package/lib/rules/staticMemberOnlyClasses.js +77 -0
- package/lib/rules/stringCaseMismatches.d.ts +10 -0
- package/lib/rules/stringCaseMismatches.js +58 -0
- package/lib/rules/stringCodePoints.d.ts +10 -0
- package/lib/rules/stringCodePoints.js +50 -0
- package/lib/rules/stringSliceMethods.d.ts +10 -0
- package/lib/rules/stringSliceMethods.js +47 -0
- package/lib/rules/stringStartsEndsWith.d.ts +10 -0
- package/lib/rules/stringStartsEndsWith.js +79 -0
- package/lib/rules/structuredCloneMethods.d.ts +10 -0
- package/lib/rules/structuredCloneMethods.js +39 -0
- package/lib/rules/symbolDescriptions.d.ts +5 -2
- package/lib/rules/symbolDescriptions.js +30 -40
- package/lib/rules/thisAliases.d.ts +10 -0
- package/lib/rules/thisAliases.js +44 -0
- package/lib/rules/thisBeforeSuper.d.ts +10 -0
- package/lib/rules/thisBeforeSuper.js +86 -0
- package/lib/rules/throwErrors.d.ts +10 -0
- package/lib/rules/throwErrors.js +61 -0
- package/lib/rules/topLevelAwaits.d.ts +10 -0
- package/lib/rules/topLevelAwaits.js +49 -0
- package/lib/rules/tripleSlashReferenceValidity.d.ts +10 -0
- package/lib/rules/tripleSlashReferenceValidity.js +54 -0
- package/lib/rules/tripleSlashReferences.d.ts +10 -0
- package/lib/rules/tripleSlashReferences.js +34 -0
- package/lib/rules/tsComments.d.ts +22 -0
- package/lib/rules/tsComments.js +130 -0
- package/lib/rules/tslintComments.d.ts +10 -0
- package/lib/rules/tslintComments.js +36 -0
- package/lib/rules/typeAssertionStyles.d.ts +10 -0
- package/lib/rules/typeAssertionStyles.js +32 -0
- package/lib/rules/typeofComparisons.d.ts +5 -2
- package/lib/rules/typeofComparisons.js +50 -71
- package/lib/rules/unassignedVariables.d.ts +5 -2
- package/lib/rules/unassignedVariables.js +35 -54
- package/lib/rules/undefinedTypeofChecks.d.ts +10 -0
- package/lib/rules/undefinedTypeofChecks.js +41 -0
- package/lib/rules/undefinedVariables.d.ts +5 -2
- package/lib/rules/undefinedVariables.js +37 -75
- package/lib/rules/unicodeBOMs.d.ts +5 -2
- package/lib/rules/unicodeBOMs.js +37 -46
- package/lib/rules/unnecessaryBinds.d.ts +10 -0
- package/lib/rules/unnecessaryBinds.js +78 -0
- package/lib/rules/unnecessaryBlocks.d.ts +5 -2
- package/lib/rules/unnecessaryBlocks.js +58 -74
- package/lib/rules/unnecessaryBooleanCasts.d.ts +10 -0
- package/lib/rules/unnecessaryBooleanCasts.js +58 -0
- package/lib/rules/unnecessaryCatches.d.ts +5 -2
- package/lib/rules/unnecessaryCatches.js +46 -67
- package/lib/rules/unnecessaryComparisons.d.ts +10 -0
- package/lib/rules/unnecessaryComparisons.js +300 -0
- package/lib/rules/unnecessaryConcatenation.d.ts +5 -2
- package/lib/rules/unnecessaryConcatenation.js +26 -37
- package/lib/rules/unnecessaryEscapes.d.ts +10 -0
- package/lib/rules/unnecessaryEscapes.js +134 -0
- package/lib/rules/unnecessaryMathClamps.d.ts +10 -0
- package/lib/rules/unnecessaryMathClamps.js +114 -0
- package/lib/rules/unnecessaryNumericFractions.d.ts +10 -0
- package/lib/rules/unnecessaryNumericFractions.js +50 -0
- package/lib/rules/unnecessaryRenames.d.ts +10 -0
- package/lib/rules/unnecessaryRenames.js +92 -0
- package/lib/rules/unnecessaryTernaries.d.ts +10 -0
- package/lib/rules/unnecessaryTernaries.js +88 -0
- package/lib/rules/unnecessaryUseStricts.d.ts +10 -0
- package/lib/rules/unnecessaryUseStricts.js +40 -0
- package/lib/rules/unsafeNegations.d.ts +5 -2
- package/lib/rules/unsafeNegations.js +36 -49
- package/lib/rules/utils/collectAccessorPairs.d.ts +12 -0
- package/lib/rules/utils/collectAccessorPairs.js +29 -0
- package/lib/rules/utils/countCommentsInRange.d.ts +3 -0
- package/lib/rules/utils/countCommentsInRange.js +12 -0
- package/lib/rules/utils/discriminateAnyType.d.ts +12 -9
- package/lib/rules/utils/discriminateAnyType.js +33 -37
- package/lib/rules/utils/equalityOperators.d.ts +9 -0
- package/lib/rules/utils/equalityOperators.js +36 -0
- package/lib/rules/utils/forEachReturnStatement.d.ts +3 -0
- package/lib/rules/utils/forEachReturnStatement.js +29 -0
- package/lib/rules/utils/formatReportedType.d.ts +4 -0
- package/lib/rules/utils/formatReportedType.js +9 -0
- package/lib/rules/utils/getConstrainedType.d.ts +2 -2
- package/lib/rules/utils/getConstrainedType.js +7 -3
- package/lib/rules/utils/getFunctionName.d.ts +3 -0
- package/lib/rules/utils/getFunctionName.js +16 -0
- package/lib/rules/utils/getRegExpConstruction.d.ts +10 -0
- package/lib/rules/utils/getRegExpConstruction.js +26 -0
- package/lib/rules/utils/getRegExpLiteralDetails.d.ts +7 -0
- package/lib/rules/utils/getRegExpLiteralDetails.js +13 -0
- package/lib/rules/utils/getThisExpression.d.ts +2 -2
- package/lib/rules/utils/getThisExpression.js +14 -22
- package/lib/rules/utils/isArrayOrTupleTypeAtLocation.d.ts +3 -0
- package/lib/rules/utils/isArrayOrTupleTypeAtLocation.js +13 -0
- package/lib/rules/utils/isBuiltinSymbolLike.d.ts +3 -0
- package/lib/rules/utils/isBuiltinSymbolLike.js +33 -0
- package/lib/rules/utils/isDirectEqualityCheck.d.ts +4 -0
- package/lib/rules/utils/isDirectEqualityCheck.js +29 -0
- package/lib/rules/utils/isErrorSubclass.d.ts +3 -0
- package/lib/rules/utils/isErrorSubclass.js +27 -0
- package/lib/rules/utils/isInBooleanContext.d.ts +3 -0
- package/lib/rules/utils/isInBooleanContext.js +22 -0
- package/lib/rules/utils/isTypeRecursive.d.ts +1 -1
- package/lib/rules/utils/isTypeRecursive.js +6 -4
- package/lib/rules/utils/isUnsafeAssignment.d.ts +3 -2
- package/lib/rules/utils/isUnsafeAssignment.js +40 -72
- package/lib/rules/utils/operators.d.ts +4 -4
- package/lib/rules/utils/operators.js +31 -33
- package/lib/rules/utils/parseRegexpAst.d.ts +2 -0
- package/lib/rules/utils/parseRegexpAst.js +17 -0
- package/lib/rules/utils/parseRegexpAstFull.d.ts +3 -0
- package/lib/rules/utils/parseRegexpAstFull.js +18 -0
- package/lib/rules/utils/skipParentheses.d.ts +3 -0
- package/lib/rules/utils/skipParentheses.js +10 -0
- package/lib/rules/variableDeletions.d.ts +5 -2
- package/lib/rules/variableDeletions.js +33 -38
- package/lib/rules/voidOperator.d.ts +5 -2
- package/lib/rules/voidOperator.js +32 -35
- package/lib/rules/withStatements.d.ts +5 -2
- package/lib/rules/withStatements.js +28 -35
- package/lib/rules/wrapperObjects.d.ts +10 -0
- package/lib/rules/wrapperObjects.js +36 -0
- package/package.json +17 -11
- package/lib/collectReferencedFilePaths.d.ts +0 -3
- package/lib/collectReferencedFilePaths.js +0 -22
- package/lib/convertTypeScriptDiagnosticToLanguageFileDiagnostic.d.ts +0 -14
- package/lib/convertTypeScriptDiagnosticToLanguageFileDiagnostic.js +0 -129
- package/lib/createTypeScriptFileFromProgram.d.ts +0 -6
- package/lib/createTypeScriptFileFromProgram.js +0 -58
- package/lib/createTypeScriptFileFromProjectService.d.ts +0 -7
- package/lib/createTypeScriptFileFromProjectService.js +0 -14
- package/lib/directives/parseDirectivesFromTypeScriptFile.d.ts +0 -13
- package/lib/directives/parseDirectivesFromTypeScriptFile.js +0 -29
- package/lib/directives/parseDirectivesFromTypeScriptFile.test.d.ts +0 -2
- package/lib/directives/parseDirectivesFromTypeScriptFile.test.js +0 -92
- package/lib/getFirstEnumValues.d.ts +0 -36
- package/lib/getFirstEnumValues.js +0 -52
- package/lib/getFirstEnumValues.test.d.ts +0 -2
- package/lib/getFirstEnumValues.test.js +0 -46
- package/lib/getTSNodeRange.d.ts +0 -4
- package/lib/getTSNodeRange.js +0 -7
- package/lib/language.d.ts +0 -9
- package/lib/language.js +0 -20
- package/lib/nodes.d.ts +0 -143
- package/lib/nodes.js +0 -2
- package/lib/normalizeRange.d.ts +0 -4
- package/lib/normalizeRange.js +0 -14
- package/lib/prepareTypeScriptBasedLanguage.d.ts +0 -11
- package/lib/prepareTypeScriptBasedLanguage.js +0 -59
- package/lib/prepareTypeScriptFile.d.ts +0 -12
- package/lib/prepareTypeScriptFile.js +0 -13
- package/lib/rules/anyReturns.test.d.ts +0 -2
- package/lib/rules/anyReturns.test.js +0 -648
- package/lib/rules/asyncPromiseExecutors.test.d.ts +0 -2
- package/lib/rules/asyncPromiseExecutors.test.js +0 -72
- package/lib/rules/caseDeclarations.test.d.ts +0 -2
- package/lib/rules/caseDeclarations.test.js +0 -228
- package/lib/rules/caseDuplicates.test.d.ts +0 -2
- package/lib/rules/caseDuplicates.test.js +0 -308
- package/lib/rules/chainedAssignments.test.d.ts +0 -2
- package/lib/rules/chainedAssignments.test.js +0 -263
- package/lib/rules/classAssignments.test.d.ts +0 -2
- package/lib/rules/classAssignments.test.js +0 -157
- package/lib/rules/consecutiveNonNullAssertions.test.d.ts +0 -2
- package/lib/rules/consecutiveNonNullAssertions.test.js +0 -33
- package/lib/rules/constantAssignments.test.d.ts +0 -2
- package/lib/rules/constantAssignments.test.js +0 -222
- package/lib/rules/constructorReturns.test.d.ts +0 -2
- package/lib/rules/constructorReturns.test.js +0 -97
- package/lib/rules/debuggerStatements.test.d.ts +0 -2
- package/lib/rules/debuggerStatements.test.js +0 -81
- package/lib/rules/defaultCaseLast.test.d.ts +0 -2
- package/lib/rules/defaultCaseLast.test.js +0 -196
- package/lib/rules/duplicateArguments.test.d.ts +0 -2
- package/lib/rules/duplicateArguments.test.js +0 -140
- package/lib/rules/elseIfDuplicates.test.d.ts +0 -2
- package/lib/rules/elseIfDuplicates.test.js +0 -177
- package/lib/rules/emptyBlocks.test.d.ts +0 -2
- package/lib/rules/emptyBlocks.test.js +0 -136
- package/lib/rules/emptyDestructures.test.d.ts +0 -2
- package/lib/rules/emptyDestructures.test.js +0 -187
- package/lib/rules/emptyStaticBlocks.test.d.ts +0 -2
- package/lib/rules/emptyStaticBlocks.test.js +0 -168
- package/lib/rules/exceptionAssignments.test.d.ts +0 -2
- package/lib/rules/exceptionAssignments.test.js +0 -265
- package/lib/rules/finallyStatementSafety.test.d.ts +0 -2
- package/lib/rules/finallyStatementSafety.test.js +0 -307
- package/lib/rules/forDirections.test.d.ts +0 -2
- package/lib/rules/forDirections.test.js +0 -125
- package/lib/rules/forInArrays.test.d.ts +0 -2
- package/lib/rules/forInArrays.test.js +0 -25
- package/lib/rules/functionAssignments.test.d.ts +0 -2
- package/lib/rules/functionAssignments.test.js +0 -210
- package/lib/rules/functionCurryingRedundancy.test.d.ts +0 -2
- package/lib/rules/functionCurryingRedundancy.test.js +0 -172
- package/lib/rules/functionNewCalls.test.d.ts +0 -2
- package/lib/rules/functionNewCalls.test.js +0 -116
- package/lib/rules/generatorFunctionYields.test.d.ts +0 -2
- package/lib/rules/generatorFunctionYields.test.js +0 -152
- package/lib/rules/globalAssignments.test.d.ts +0 -2
- package/lib/rules/globalAssignments.test.js +0 -216
- package/lib/rules/globalObjectCalls.test.d.ts +0 -2
- package/lib/rules/globalObjectCalls.test.js +0 -94
- package/lib/rules/namespaceDeclarations.test.d.ts +0 -2
- package/lib/rules/namespaceDeclarations.test.js +0 -41
- package/lib/rules/negativeZeroComparisons.test.d.ts +0 -2
- package/lib/rules/negativeZeroComparisons.test.js +0 -210
- package/lib/rules/newExpressions.test.d.ts +0 -2
- package/lib/rules/newExpressions.test.js +0 -80
- package/lib/rules/newNativeNonConstructors.test.d.ts +0 -2
- package/lib/rules/newNativeNonConstructors.test.js +0 -95
- package/lib/rules/nonOctalDecimalEscapes.test.d.ts +0 -2
- package/lib/rules/nonOctalDecimalEscapes.test.js +0 -70
- package/lib/rules/numericLiteralParsing.test.d.ts +0 -2
- package/lib/rules/numericLiteralParsing.test.js +0 -100
- package/lib/rules/objectCalls.test.d.ts +0 -2
- package/lib/rules/objectCalls.test.js +0 -172
- package/lib/rules/objectHasOwns.test.d.ts +0 -2
- package/lib/rules/objectHasOwns.test.js +0 -112
- package/lib/rules/objectKeyDuplicates.test.d.ts +0 -2
- package/lib/rules/objectKeyDuplicates.test.js +0 -180
- package/lib/rules/objectProto.test.d.ts +0 -2
- package/lib/rules/objectProto.test.js +0 -97
- package/lib/rules/objectPrototypeBuiltIns.test.d.ts +0 -2
- package/lib/rules/objectPrototypeBuiltIns.test.js +0 -146
- package/lib/rules/octalEscapes.test.d.ts +0 -2
- package/lib/rules/octalEscapes.test.js +0 -214
- package/lib/rules/octalNumbers.test.d.ts +0 -2
- package/lib/rules/octalNumbers.test.js +0 -246
- package/lib/rules/returnAssignments.test.d.ts +0 -2
- package/lib/rules/returnAssignments.test.js +0 -186
- package/lib/rules/ruleTester.d.ts +0 -3
- package/lib/rules/ruleTester.js +0 -8
- package/lib/rules/selfAssignments.test.d.ts +0 -2
- package/lib/rules/selfAssignments.test.js +0 -67
- package/lib/rules/selfComparisons.d.ts +0 -7
- package/lib/rules/selfComparisons.js +0 -42
- package/lib/rules/selfComparisons.test.d.ts +0 -2
- package/lib/rules/selfComparisons.test.js +0 -298
- package/lib/rules/sequences.test.d.ts +0 -2
- package/lib/rules/sequences.test.js +0 -49
- package/lib/rules/shadowedRestrictedNames.test.d.ts +0 -2
- package/lib/rules/shadowedRestrictedNames.test.js +0 -148
- package/lib/rules/sparseArrays.test.d.ts +0 -2
- package/lib/rules/sparseArrays.test.js +0 -111
- package/lib/rules/symbolDescriptions.test.d.ts +0 -2
- package/lib/rules/symbolDescriptions.test.js +0 -90
- package/lib/rules/typeofComparisons.test.d.ts +0 -2
- package/lib/rules/typeofComparisons.test.js +0 -86
- package/lib/rules/unassignedVariables.test.d.ts +0 -2
- package/lib/rules/unassignedVariables.test.js +0 -73
- package/lib/rules/undefinedVariables.test.d.ts +0 -2
- package/lib/rules/undefinedVariables.test.js +0 -81
- package/lib/rules/unicodeBOMs.test.d.ts +0 -2
- package/lib/rules/unicodeBOMs.test.js +0 -67
- package/lib/rules/unnecessaryBlocks.test.d.ts +0 -2
- package/lib/rules/unnecessaryBlocks.test.js +0 -148
- package/lib/rules/unnecessaryCatches.test.d.ts +0 -2
- package/lib/rules/unnecessaryCatches.test.js +0 -211
- package/lib/rules/unnecessaryConcatenation.test.d.ts +0 -2
- package/lib/rules/unnecessaryConcatenation.test.js +0 -88
- package/lib/rules/unsafeNegations.test.d.ts +0 -2
- package/lib/rules/unsafeNegations.test.js +0 -64
- package/lib/rules/variableDeletions.test.d.ts +0 -2
- package/lib/rules/variableDeletions.test.js +0 -76
- package/lib/rules/voidOperator.test.d.ts +0 -2
- package/lib/rules/voidOperator.test.js +0 -99
- package/lib/rules/withStatements.test.d.ts +0 -2
- package/lib/rules/withStatements.test.js +0 -27
- package/lib/utils/declarationIncludesGlobal.d.ts +0 -3
- package/lib/utils/declarationIncludesGlobal.js +0 -6
- package/lib/utils/declarationsIncludeGlobal.d.ts +0 -3
- package/lib/utils/declarationsIncludeGlobal.js +0 -5
- package/lib/utils/getDeclarationsIfGlobal.d.ts +0 -3
- package/lib/utils/getDeclarationsIfGlobal.js +0 -8
- package/lib/utils/getModifyingReferences.d.ts +0 -9
- package/lib/utils/getModifyingReferences.js +0 -43
- package/lib/utils/hasSameTokens.d.ts +0 -3
- package/lib/utils/hasSameTokens.js +0 -31
- package/lib/utils/isFunction.d.ts +0 -3
- package/lib/utils/isFunction.js +0 -6
- package/lib/utils/isGlobalDeclaration.d.ts +0 -3
- package/lib/utils/isGlobalDeclaration.js +0 -5
- package/lib/utils/isGlobalDeclarationOfName.d.ts +0 -6
- package/lib/utils/isGlobalDeclarationOfName.js +0 -36
- package/lib/utils/isGlobalVariable.d.ts +0 -9
- package/lib/utils/isGlobalVariable.js +0 -22
- package/lib/utils/unwrapParentParenthesizedExpressions.d.ts +0 -3
- package/lib/utils/unwrapParentParenthesizedExpressions.js +0 -7
- package/lib/utils/unwrapParenthesizedExpression.d.ts +0 -3
- package/lib/utils/unwrapParenthesizedExpression.js +0 -7
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { ruleCreator } from "./ruleCreator.js";
|
|
2
|
+
import { getConstrainedTypeAtLocation } from "./utils/getConstrainedType.js";
|
|
3
|
+
import { parseRegexpAst } from "./utils/parseRegexpAst.js";
|
|
4
|
+
import { getTSNodeRange, typescriptLanguage } from "@flint.fyi/typescript-language";
|
|
5
|
+
import ts from "typescript";
|
|
6
|
+
import { visitRegExpAST } from "@eslint-community/regexpp";
|
|
7
|
+
//#region src/rules/regexLookaroundAssertions.ts
|
|
8
|
+
function buildFixedPattern(originalPattern, boundaryGroups) {
|
|
9
|
+
let result = originalPattern;
|
|
10
|
+
for (const { group, position } of [...boundaryGroups].reverse()) {
|
|
11
|
+
const replacement = `${position === "start" ? "(?<=" : "(?="}${groupToRaw(group)})`;
|
|
12
|
+
result = result.slice(0, group.start) + replacement + result.slice(group.end);
|
|
13
|
+
}
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
function buildFixedReplacement(originalText, boundaryGroups) {
|
|
17
|
+
let result = originalText;
|
|
18
|
+
for (let i = boundaryGroups.length; i >= 1; i--) result = result.replaceAll(`$${i}`, "");
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
function getBoundaryGroups(pattern, groups) {
|
|
22
|
+
if (!groups.length || groups.length > 2 || groups.some((group) => group.name != null)) return;
|
|
23
|
+
const alternatives = pattern.alternatives;
|
|
24
|
+
if (alternatives.length !== 1) return;
|
|
25
|
+
const elements = alternatives[0].elements;
|
|
26
|
+
if (elements.length < 2) return;
|
|
27
|
+
const result = [];
|
|
28
|
+
const firstElement = elements[0];
|
|
29
|
+
const lastElement = elements.at(-1);
|
|
30
|
+
if (groups.length === 1) {
|
|
31
|
+
const group = groups[0];
|
|
32
|
+
if (firstElement === group) result.push({
|
|
33
|
+
group,
|
|
34
|
+
position: "start"
|
|
35
|
+
});
|
|
36
|
+
else if (lastElement === group) result.push({
|
|
37
|
+
group,
|
|
38
|
+
position: "end"
|
|
39
|
+
});
|
|
40
|
+
else return;
|
|
41
|
+
} else {
|
|
42
|
+
const [first, second] = groups;
|
|
43
|
+
if (firstElement === first && lastElement === second) result.push({
|
|
44
|
+
group: first,
|
|
45
|
+
position: "start"
|
|
46
|
+
}, {
|
|
47
|
+
group: second,
|
|
48
|
+
position: "end"
|
|
49
|
+
});
|
|
50
|
+
else return;
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
function getCapturingGroups(pattern) {
|
|
55
|
+
const groups = [];
|
|
56
|
+
visitRegExpAST(pattern, { onCapturingGroupEnter(groupNode) {
|
|
57
|
+
groups.push(groupNode);
|
|
58
|
+
} });
|
|
59
|
+
return groups;
|
|
60
|
+
}
|
|
61
|
+
function getRegexPatternAndFlags(node) {
|
|
62
|
+
if (node.kind !== ts.SyntaxKind.RegularExpressionLiteral) return;
|
|
63
|
+
const match = /^\/(.+)\/([dgimsuyv]*)$/.exec(node.text);
|
|
64
|
+
if (!match) return;
|
|
65
|
+
return {
|
|
66
|
+
flags: match[2],
|
|
67
|
+
pattern: match[1]
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function groupToRaw(group) {
|
|
71
|
+
return group.alternatives.flatMap((alternative) => alternative.elements.flatMap((element) => element.raw)).join("");
|
|
72
|
+
}
|
|
73
|
+
function hasBackreferences(pattern) {
|
|
74
|
+
let found = false;
|
|
75
|
+
visitRegExpAST(pattern, { onBackreferenceEnter() {
|
|
76
|
+
found = true;
|
|
77
|
+
} });
|
|
78
|
+
return found;
|
|
79
|
+
}
|
|
80
|
+
function hasSpecialDollarSyntax(text) {
|
|
81
|
+
return /\$[$&'`]|\$<[^>]+>/.test(text);
|
|
82
|
+
}
|
|
83
|
+
function hasVariableLengthContent(node) {
|
|
84
|
+
let found = false;
|
|
85
|
+
visitRegExpAST(node, { onQuantifierEnter(quantifier) {
|
|
86
|
+
if (quantifier.min !== quantifier.max) found = true;
|
|
87
|
+
} });
|
|
88
|
+
return found;
|
|
89
|
+
}
|
|
90
|
+
function parseReplacementReferences(text) {
|
|
91
|
+
const references = /* @__PURE__ */ new Map();
|
|
92
|
+
const pattern = /\$(\d+)/g;
|
|
93
|
+
let match;
|
|
94
|
+
while (match = pattern.exec(text)) {
|
|
95
|
+
const index = parseInt(match[1], 10);
|
|
96
|
+
if (index > 0) references.set(index, (references.get(index) ?? 0) + 1);
|
|
97
|
+
}
|
|
98
|
+
return references;
|
|
99
|
+
}
|
|
100
|
+
var regexLookaroundAssertions_default = ruleCreator.createRule(typescriptLanguage, {
|
|
101
|
+
about: {
|
|
102
|
+
description: "Reports capturing groups at pattern boundaries that can be replaced with lookaround assertions.",
|
|
103
|
+
id: "regexLookaroundAssertions",
|
|
104
|
+
presets: ["stylisticStrict"]
|
|
105
|
+
},
|
|
106
|
+
messages: { preferLookaround: {
|
|
107
|
+
primary: "This capturing group can be optimized by switching to a lookaround assertion.",
|
|
108
|
+
secondary: ["Lookaround assertions avoid re-inserting captured content in the replacement string.", "Using them allows engines to more easily optimize regular expressions."],
|
|
109
|
+
suggestions: ["Convert to a lookahead or lookbehind assertion."]
|
|
110
|
+
} },
|
|
111
|
+
setup(context) {
|
|
112
|
+
return { visitors: { CallExpression: (node, { sourceFile, typeChecker }) => {
|
|
113
|
+
if (!ts.isPropertyAccessExpression(node.expression) || node.expression.name.text !== "replace" && node.expression.name.text !== "replaceAll" || node.arguments.length < 2) return;
|
|
114
|
+
if (!(getConstrainedTypeAtLocation(node.expression.expression, typeChecker).flags & ts.TypeFlags.StringLike)) return;
|
|
115
|
+
const regexArgument = node.arguments[0];
|
|
116
|
+
const replacementArgument = node.arguments[1];
|
|
117
|
+
if (!ts.isStringLiteral(replacementArgument) || hasSpecialDollarSyntax(replacementArgument.text)) return;
|
|
118
|
+
const regexInfo = getRegexPatternAndFlags(regexArgument);
|
|
119
|
+
if (!regexInfo) return;
|
|
120
|
+
const regexpAst = parseRegexpAst(regexInfo.pattern, regexInfo.flags);
|
|
121
|
+
if (!regexpAst || hasBackreferences(regexpAst)) return;
|
|
122
|
+
const capturingGroups = getCapturingGroups(regexpAst);
|
|
123
|
+
if (!capturingGroups.length || capturingGroups.length > 2) return;
|
|
124
|
+
const boundaryGroups = getBoundaryGroups(regexpAst, capturingGroups);
|
|
125
|
+
if (!boundaryGroups) return;
|
|
126
|
+
const references = parseReplacementReferences(replacementArgument.text);
|
|
127
|
+
for (let i = 0; i < boundaryGroups.length; i++) if (references.get(i + 1) !== 1) return;
|
|
128
|
+
for (const { group, position } of boundaryGroups) if (position === "start" && hasVariableLengthContent(group)) return;
|
|
129
|
+
const regexRange = getTSNodeRange(regexArgument, sourceFile);
|
|
130
|
+
const replacementRange = getTSNodeRange(replacementArgument, sourceFile);
|
|
131
|
+
const fixedPattern = buildFixedPattern(regexInfo.pattern, boundaryGroups);
|
|
132
|
+
const fixedReplacement = buildFixedReplacement(replacementArgument.text, boundaryGroups);
|
|
133
|
+
const fix = [{
|
|
134
|
+
range: {
|
|
135
|
+
begin: regexRange.begin + 1,
|
|
136
|
+
end: regexRange.end - 1 - regexInfo.flags.length
|
|
137
|
+
},
|
|
138
|
+
text: fixedPattern
|
|
139
|
+
}, {
|
|
140
|
+
range: {
|
|
141
|
+
begin: replacementRange.begin + 1,
|
|
142
|
+
end: replacementRange.end - 1
|
|
143
|
+
},
|
|
144
|
+
text: fixedReplacement
|
|
145
|
+
}];
|
|
146
|
+
for (const { group } of boundaryGroups) {
|
|
147
|
+
const groupRange = {
|
|
148
|
+
begin: regexRange.begin + 1 + group.start,
|
|
149
|
+
end: regexRange.begin + 1 + group.end
|
|
150
|
+
};
|
|
151
|
+
context.report({
|
|
152
|
+
fix,
|
|
153
|
+
message: "preferLookaround",
|
|
154
|
+
range: groupRange
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
} } };
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
//#endregion
|
|
161
|
+
export { regexLookaroundAssertions_default as default };
|
|
162
|
+
|
|
163
|
+
//# sourceMappingURL=regexLookaroundAssertions.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Reports non-constant quantifiers in lookaround assertions that could be simplified.";
|
|
3
|
+
readonly id: "regexLookaroundQuantifierOptimizations";
|
|
4
|
+
readonly presets: ["logical"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("javascript" | "logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "replace" | "remove", import("@flint.fyi/core").AnyOptionalSchema>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=regexLookaroundQuantifierOptimizations.d.ts.map
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { ruleCreator } from "./ruleCreator.js";
|
|
2
|
+
import { parseRegexpAst } from "./utils/parseRegexpAst.js";
|
|
3
|
+
import { getRegExpConstruction } from "./utils/getRegExpConstruction.js";
|
|
4
|
+
import { getRegExpLiteralDetails } from "./utils/getRegExpLiteralDetails.js";
|
|
5
|
+
import { typescriptLanguage } from "@flint.fyi/typescript-language";
|
|
6
|
+
import { visitRegExpAST } from "@eslint-community/regexpp";
|
|
7
|
+
//#region src/rules/regexLookaroundQuantifierOptimizations.ts
|
|
8
|
+
function* extractInvalidQuantifiers(alternatives, kind) {
|
|
9
|
+
for (const { elements } of alternatives) {
|
|
10
|
+
if (!elements.length) continue;
|
|
11
|
+
const last = elements[kind === "lookahead" ? elements.length - 1 : 0];
|
|
12
|
+
switch (last.type) {
|
|
13
|
+
case "Group":
|
|
14
|
+
yield* extractInvalidQuantifiers(last.alternatives, kind);
|
|
15
|
+
break;
|
|
16
|
+
case "Quantifier":
|
|
17
|
+
if (last.min !== last.max && !hasCapturingGroupDescendant(last.element)) yield last;
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function hasCapturingGroupDescendant(element) {
|
|
23
|
+
switch (element.type) {
|
|
24
|
+
case "CapturingGroup": return true;
|
|
25
|
+
case "Group":
|
|
26
|
+
for (const alternative of element.alternatives) for (const child of alternative.elements) if (hasCapturingGroupDescendant(child)) return true;
|
|
27
|
+
return false;
|
|
28
|
+
case "Quantifier": return hasCapturingGroupDescendant(element.element);
|
|
29
|
+
default: return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
var regexLookaroundQuantifierOptimizations_default = ruleCreator.createRule(typescriptLanguage, {
|
|
33
|
+
about: {
|
|
34
|
+
description: "Reports non-constant quantifiers in lookaround assertions that could be simplified.",
|
|
35
|
+
id: "regexLookaroundQuantifierOptimizations",
|
|
36
|
+
presets: ["logical"]
|
|
37
|
+
},
|
|
38
|
+
messages: {
|
|
39
|
+
remove: {
|
|
40
|
+
primary: "Quantifier '{{ raw }}' at the {{ endOrStart }} of the {{ kind }} can be removed.",
|
|
41
|
+
secondary: ["Non-constant quantifiers at the end of lookaheads or start of lookbehinds only match their minimum because the lookaround only checks for a match, not how much is matched."],
|
|
42
|
+
suggestions: ["Remove the quantifier."]
|
|
43
|
+
},
|
|
44
|
+
replace: {
|
|
45
|
+
primary: "Quantifier '{{ raw }}' at the {{ endOrStart }} of the {{ kind }} can be replaced with '{{ replacer }}'.",
|
|
46
|
+
secondary: ["Non-constant quantifiers at the end of lookaheads or start of lookbehinds only match their minimum because the lookaround only checks for a match, not how much is matched."],
|
|
47
|
+
suggestions: ["Replace the quantifier with the constant minimum."]
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
setup(context) {
|
|
51
|
+
function checkPattern(pattern, start, flags) {
|
|
52
|
+
const regexpAst = parseRegexpAst(pattern, flags);
|
|
53
|
+
if (!regexpAst) return;
|
|
54
|
+
visitRegExpAST(regexpAst, { onAssertionEnter(assertionNode) {
|
|
55
|
+
if (assertionNode.kind !== "lookahead" && assertionNode.kind !== "lookbehind") return;
|
|
56
|
+
const endOrStart = assertionNode.kind === "lookahead" ? "end" : "start";
|
|
57
|
+
const kind = assertionNode.negate ? `negative ${assertionNode.kind}` : assertionNode.kind;
|
|
58
|
+
for (const quantifier of extractInvalidQuantifiers(assertionNode.alternatives, assertionNode.kind)) {
|
|
59
|
+
const replacer = quantifier.min === 0 ? "" : quantifier.min === 1 ? quantifier.element.raw : `${quantifier.element.raw}{${quantifier.min}}`;
|
|
60
|
+
context.report({
|
|
61
|
+
data: {
|
|
62
|
+
endOrStart,
|
|
63
|
+
kind,
|
|
64
|
+
raw: quantifier.raw,
|
|
65
|
+
replacer
|
|
66
|
+
},
|
|
67
|
+
message: quantifier.min === 0 ? "remove" : "replace",
|
|
68
|
+
range: {
|
|
69
|
+
begin: start + quantifier.start,
|
|
70
|
+
end: start + quantifier.end
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
} });
|
|
75
|
+
}
|
|
76
|
+
function checkRegexLiteral(node, services) {
|
|
77
|
+
const details = getRegExpLiteralDetails(node, services);
|
|
78
|
+
checkPattern(details.pattern, details.start, details.flags);
|
|
79
|
+
}
|
|
80
|
+
function checkRegExpConstructor(node, services) {
|
|
81
|
+
const construction = getRegExpConstruction(node, services);
|
|
82
|
+
if (construction) checkPattern(construction.pattern, construction.start + 1, construction.flags);
|
|
83
|
+
}
|
|
84
|
+
return { visitors: {
|
|
85
|
+
CallExpression: checkRegExpConstructor,
|
|
86
|
+
NewExpression: checkRegExpConstructor,
|
|
87
|
+
RegularExpressionLiteral: checkRegexLiteral
|
|
88
|
+
} };
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
//#endregion
|
|
92
|
+
export { regexLookaroundQuantifierOptimizations_default as default };
|
|
93
|
+
|
|
94
|
+
//# sourceMappingURL=regexLookaroundQuantifierOptimizations.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Reports inconsistent notations for matching any character in regular expressions.";
|
|
3
|
+
readonly id: "regexMatchNotation";
|
|
4
|
+
readonly presets: ["stylisticStrict"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("javascript" | "logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "unexpected", import("@flint.fyi/core").AnyOptionalSchema>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=regexMatchNotation.d.ts.map
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { ruleCreator } from "./ruleCreator.js";
|
|
2
|
+
import { parseRegexpAst } from "./utils/parseRegexpAst.js";
|
|
3
|
+
import { typescriptLanguage } from "@flint.fyi/typescript-language";
|
|
4
|
+
import * as ts$1 from "typescript";
|
|
5
|
+
import { visitRegExpAST } from "@eslint-community/regexpp";
|
|
6
|
+
//#region src/rules/regexMatchNotation.ts
|
|
7
|
+
const allowedNotation = String.raw`[\s\S]`;
|
|
8
|
+
function isMatchAnyCharacterClass(node, flags) {
|
|
9
|
+
if (node.negate) return !node.elements.length;
|
|
10
|
+
const positiveElements = [];
|
|
11
|
+
const negativeElements = [];
|
|
12
|
+
for (const element of node.elements) if (element.type === "CharacterSet") switch (element.kind) {
|
|
13
|
+
case "digit":
|
|
14
|
+
if (element.negate) negativeElements.push({
|
|
15
|
+
kind: "digit",
|
|
16
|
+
type: "CharacterSet"
|
|
17
|
+
});
|
|
18
|
+
else positiveElements.push({
|
|
19
|
+
kind: "digit",
|
|
20
|
+
type: "CharacterSet"
|
|
21
|
+
});
|
|
22
|
+
break;
|
|
23
|
+
case "property": {
|
|
24
|
+
if (!flags.unicode && !flags.unicodeSets) break;
|
|
25
|
+
const key = `property:${element.key}:${element.value ?? ""}`;
|
|
26
|
+
if (element.negate) negativeElements.push({
|
|
27
|
+
kind: key,
|
|
28
|
+
negate: true,
|
|
29
|
+
type: "CharacterSet"
|
|
30
|
+
});
|
|
31
|
+
else positiveElements.push({
|
|
32
|
+
kind: key,
|
|
33
|
+
type: "CharacterSet"
|
|
34
|
+
});
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
case "space":
|
|
38
|
+
if (element.negate) negativeElements.push({
|
|
39
|
+
kind: "space",
|
|
40
|
+
type: "CharacterSet"
|
|
41
|
+
});
|
|
42
|
+
else positiveElements.push({
|
|
43
|
+
kind: "space",
|
|
44
|
+
type: "CharacterSet"
|
|
45
|
+
});
|
|
46
|
+
break;
|
|
47
|
+
case "word":
|
|
48
|
+
if (element.negate) negativeElements.push({
|
|
49
|
+
kind: "word",
|
|
50
|
+
type: "CharacterSet"
|
|
51
|
+
});
|
|
52
|
+
else positiveElements.push({
|
|
53
|
+
kind: "word",
|
|
54
|
+
type: "CharacterSet"
|
|
55
|
+
});
|
|
56
|
+
break;
|
|
57
|
+
default: break;
|
|
58
|
+
}
|
|
59
|
+
else if (element.type === "CharacterClassRange" && element.min.value === 0 && (element.max.value === 65535 || element.max.value === 1114111 || flags.unicode && element.max.value >= 1114111)) return true;
|
|
60
|
+
for (const positive of positiveElements) if (negativeElements.find((negative) => negative.kind === positive.kind)) return true;
|
|
61
|
+
const hasSpace = positiveElements.some((e) => e.kind === "space");
|
|
62
|
+
const hasNonSpace = negativeElements.some((e) => e.kind === "space");
|
|
63
|
+
if (hasSpace && hasNonSpace) return true;
|
|
64
|
+
const hasDigit = positiveElements.some((e) => e.kind === "digit");
|
|
65
|
+
const hasNonDigit = negativeElements.some((e) => e.kind === "digit");
|
|
66
|
+
if (hasDigit && hasNonDigit) return true;
|
|
67
|
+
const hasWord = positiveElements.some((e) => e.kind === "word");
|
|
68
|
+
const hasNonWord = negativeElements.some((e) => e.kind === "word");
|
|
69
|
+
if (hasWord && hasNonWord) return true;
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
var regexMatchNotation_default = ruleCreator.createRule(typescriptLanguage, {
|
|
73
|
+
about: {
|
|
74
|
+
description: "Reports inconsistent notations for matching any character in regular expressions.",
|
|
75
|
+
id: "regexMatchNotation",
|
|
76
|
+
presets: ["stylisticStrict"]
|
|
77
|
+
},
|
|
78
|
+
messages: { unexpected: {
|
|
79
|
+
primary: "For consistency, prefer '{{ preferred }}' over '{{ raw }}' to match any character.",
|
|
80
|
+
secondary: ["Using a consistent notation for matching any character improves readability."],
|
|
81
|
+
suggestions: ["Replace with the standard notation."]
|
|
82
|
+
} },
|
|
83
|
+
setup(context) {
|
|
84
|
+
function checkPattern(pattern, patternStart, flags) {
|
|
85
|
+
const regexpAst = parseRegexpAst(pattern, flags);
|
|
86
|
+
if (!regexpAst) return;
|
|
87
|
+
const flagsInfo = {
|
|
88
|
+
dotAll: flags.includes("s"),
|
|
89
|
+
unicode: flags.includes("u"),
|
|
90
|
+
unicodeSets: flags.includes("v")
|
|
91
|
+
};
|
|
92
|
+
visitRegExpAST(regexpAst, { onCharacterClassEnter(ccNode) {
|
|
93
|
+
if (isMatchAnyCharacterClass(ccNode, flagsInfo) && ccNode.raw !== allowedNotation) {
|
|
94
|
+
const preferred = flagsInfo.dotAll ? "." : allowedNotation;
|
|
95
|
+
context.report({
|
|
96
|
+
data: {
|
|
97
|
+
preferred,
|
|
98
|
+
raw: ccNode.raw
|
|
99
|
+
},
|
|
100
|
+
message: "unexpected",
|
|
101
|
+
range: {
|
|
102
|
+
begin: patternStart + ccNode.start,
|
|
103
|
+
end: patternStart + ccNode.end
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
} });
|
|
108
|
+
}
|
|
109
|
+
function checkRegexLiteral(node, { sourceFile }) {
|
|
110
|
+
const text = node.getText(sourceFile);
|
|
111
|
+
const match = /^\/(.*)\/([dgimsuyv]*)$/.exec(text);
|
|
112
|
+
if (!match) return;
|
|
113
|
+
const [, pattern, flags] = match;
|
|
114
|
+
if (!pattern) return;
|
|
115
|
+
checkPattern(pattern, node.getStart(sourceFile) + 1, flags ?? "");
|
|
116
|
+
}
|
|
117
|
+
function checkRegExpConstructor(node, { sourceFile }) {
|
|
118
|
+
if (node.expression.kind !== ts$1.SyntaxKind.Identifier || node.expression.text !== "RegExp") return;
|
|
119
|
+
const args = node.arguments;
|
|
120
|
+
if (!args?.length) return;
|
|
121
|
+
const firstArgument = args[0];
|
|
122
|
+
if (firstArgument?.kind !== ts$1.SyntaxKind.StringLiteral) return;
|
|
123
|
+
const patternStart = firstArgument.getStart(sourceFile) + 1;
|
|
124
|
+
let flags = "";
|
|
125
|
+
const secondArgument = args[1];
|
|
126
|
+
if (secondArgument?.kind === ts$1.SyntaxKind.StringLiteral) flags = secondArgument.text;
|
|
127
|
+
checkPattern(firstArgument.text, patternStart, flags);
|
|
128
|
+
}
|
|
129
|
+
return { visitors: {
|
|
130
|
+
CallExpression: checkRegExpConstructor,
|
|
131
|
+
NewExpression: checkRegExpConstructor,
|
|
132
|
+
RegularExpressionLiteral: checkRegexLiteral
|
|
133
|
+
} };
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
//#endregion
|
|
137
|
+
export { regexMatchNotation_default as default };
|
|
138
|
+
|
|
139
|
+
//# sourceMappingURL=regexMatchNotation.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Reports capturing groups that capture less text than their pattern suggests.";
|
|
3
|
+
readonly id: "regexMisleadingCapturingGroups";
|
|
4
|
+
readonly presets: ["logical", "logicalStrict"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("javascript" | "logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "misleadingEnd" | "misleadingStart", import("@flint.fyi/core").AnyOptionalSchema>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=regexMisleadingCapturingGroups.d.ts.map
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { ruleCreator } from "./ruleCreator.js";
|
|
2
|
+
import { parseRegexpAst } from "./utils/parseRegexpAst.js";
|
|
3
|
+
import { getRegExpConstruction } from "./utils/getRegExpConstruction.js";
|
|
4
|
+
import { getRegExpLiteralDetails } from "./utils/getRegExpLiteralDetails.js";
|
|
5
|
+
import { typescriptLanguage } from "@flint.fyi/typescript-language";
|
|
6
|
+
import { visitRegExpAST } from "@eslint-community/regexpp";
|
|
7
|
+
//#region src/rules/regexMisleadingCapturingGroups.ts
|
|
8
|
+
function collectFromElement(element, collector) {
|
|
9
|
+
const result = /* @__PURE__ */ new Set();
|
|
10
|
+
forEachInGroup(element, (element) => {
|
|
11
|
+
for (const item of collector(element)) result.add(item);
|
|
12
|
+
});
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
function elementContainsPositiveSet(element, kind) {
|
|
16
|
+
return forEachInGroup(element, (el) => el.type === "CharacterSet" && hasNegate(el) && el.kind === kind && !el.negate);
|
|
17
|
+
}
|
|
18
|
+
function findFollowingElement(capturingGroup) {
|
|
19
|
+
const info = getAlternativeIndex(capturingGroup);
|
|
20
|
+
return info?.elements[info.index + 1];
|
|
21
|
+
}
|
|
22
|
+
function findPrecedingQuantifier(capturingGroup) {
|
|
23
|
+
const info = getAlternativeIndex(capturingGroup);
|
|
24
|
+
if (!info || info.index <= 0) return;
|
|
25
|
+
const previous = info.elements[info.index - 1];
|
|
26
|
+
return previous?.type === "Quantifier" && previous.max > previous.min ? previous : void 0;
|
|
27
|
+
}
|
|
28
|
+
function forEachInGroup(element, callback) {
|
|
29
|
+
switch (element.type) {
|
|
30
|
+
case "CapturingGroup":
|
|
31
|
+
case "Group":
|
|
32
|
+
for (const alt of element.alternatives) for (const el of alt.elements) if (forEachInGroup(el, callback)) return true;
|
|
33
|
+
return false;
|
|
34
|
+
case "Quantifier": return forEachInGroup(element.element, callback);
|
|
35
|
+
default: return callback(element) === true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function getAlternativeIndex(capturingGroup) {
|
|
39
|
+
const parent = capturingGroup.parent;
|
|
40
|
+
if (parent.type !== "Alternative") return;
|
|
41
|
+
const index = parent.elements.indexOf(capturingGroup);
|
|
42
|
+
return index === -1 ? void 0 : {
|
|
43
|
+
elements: parent.elements,
|
|
44
|
+
index
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function getCharacterSetType(el) {
|
|
48
|
+
if (el.kind === "any") return "set:any";
|
|
49
|
+
if (!hasNegate(el)) return "";
|
|
50
|
+
return `set:${el.kind}${el.negate ? ":negated" : ""}`;
|
|
51
|
+
}
|
|
52
|
+
function getCharacterValues(elements) {
|
|
53
|
+
const result = [];
|
|
54
|
+
for (const el of elements) if (el.type === "Character") result.push(el.value);
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
function getClassExcludedChars(element) {
|
|
58
|
+
if (element.type !== "CharacterClass" || !element.negate) return /* @__PURE__ */ new Set();
|
|
59
|
+
return new Set(getCharacterValues(element.elements));
|
|
60
|
+
}
|
|
61
|
+
function getElementCharacters(element) {
|
|
62
|
+
return collectFromElement(element, (el) => {
|
|
63
|
+
if (el.type === "Character") return [el.value];
|
|
64
|
+
if (el.type === "CharacterClass") return getCharacterValues(el.elements);
|
|
65
|
+
return [];
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function getEndQuantifier(capturingGroup) {
|
|
69
|
+
for (const alternative of capturingGroup.alternatives) {
|
|
70
|
+
if (!alternative.elements.length) continue;
|
|
71
|
+
const last = alternative.elements.at(-1);
|
|
72
|
+
if (last.type === "Quantifier" && last.max > last.min) return last;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function getFirstElementInGroup(element) {
|
|
76
|
+
let current = element;
|
|
77
|
+
while (current) {
|
|
78
|
+
if (current.type === "Quantifier") {
|
|
79
|
+
current = current.element;
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
if (current.type === "Group" || current.type === "CapturingGroup") {
|
|
83
|
+
const alternative = current.alternatives[0];
|
|
84
|
+
if (!alternative) return;
|
|
85
|
+
current = alternative.elements[0];
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
return current;
|
|
91
|
+
}
|
|
92
|
+
function getMatchableCharacterTypes(element) {
|
|
93
|
+
return collectFromElement(element, (el) => {
|
|
94
|
+
if (el.type === "Character") return [`char:${el.value}`];
|
|
95
|
+
if (el.type === "CharacterSet") {
|
|
96
|
+
const type = getCharacterSetType(el);
|
|
97
|
+
return type ? [type] : [];
|
|
98
|
+
}
|
|
99
|
+
if (el.type === "CharacterClass") return el.elements.flatMap((child) => {
|
|
100
|
+
if (child.type === "Character") return [`char:${child.value}`];
|
|
101
|
+
if (child.type === "CharacterSet" && hasNegate(child)) return [`set:${child.kind}${child.negate ? ":negated" : ""}`];
|
|
102
|
+
if (child.type === "CharacterClassRange") return [`range:${child.min.value}-${child.max.value}`];
|
|
103
|
+
return [];
|
|
104
|
+
});
|
|
105
|
+
return [];
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function getStartQuantifier(alternative, direction) {
|
|
109
|
+
const elements = alternative.elements;
|
|
110
|
+
if (!elements.length) return;
|
|
111
|
+
const first = direction === "ltr" ? elements[0] : elements.at(-1);
|
|
112
|
+
if (!first) return;
|
|
113
|
+
if (first.type === "Quantifier") return first;
|
|
114
|
+
if (first.type === "Group") for (const alt of first.alternatives) {
|
|
115
|
+
const quantifier = getStartQuantifier(alt, direction);
|
|
116
|
+
if (quantifier) return quantifier;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function hasNegate(node) {
|
|
120
|
+
return "negate" in node;
|
|
121
|
+
}
|
|
122
|
+
function hasOverlap(a, b) {
|
|
123
|
+
if (a.has("set:any") || b.has("set:any")) return true;
|
|
124
|
+
for (const type of a) if (b.has(type)) return true;
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
function isAllowedEndPattern(endQuantifier, followingElement) {
|
|
128
|
+
return isDotDelimiterPattern(endQuantifier, followingElement) || isNegatedSetFollowedByPositive(endQuantifier, followingElement) || isExcludedDelimiterPattern(endQuantifier, followingElement);
|
|
129
|
+
}
|
|
130
|
+
function isDotDelimiterPattern(endQuantifier, followingElement) {
|
|
131
|
+
return endQuantifier.element.type === "CharacterSet" && endQuantifier.element.kind === "any" && followingElement.type === "Character";
|
|
132
|
+
}
|
|
133
|
+
function isExcludedDelimiterPattern(endQuantifier, followingElement) {
|
|
134
|
+
if (endQuantifier.element.type !== "CharacterClass" || !endQuantifier.element.negate) return false;
|
|
135
|
+
const excluded = getClassExcludedChars(endQuantifier.element);
|
|
136
|
+
if (!excluded.size) return false;
|
|
137
|
+
const followingChars = getElementCharacters(followingElement);
|
|
138
|
+
for (const character of followingChars) if (excluded.has(character)) return true;
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
function isNegatedSetFollowedByPositive(endQuantifier, followingElement) {
|
|
142
|
+
return endQuantifier.element.type === "CharacterSet" && hasNegate(endQuantifier.element) && endQuantifier.element.negate && elementContainsPositiveSet(followingElement, endQuantifier.element.kind);
|
|
143
|
+
}
|
|
144
|
+
var regexMisleadingCapturingGroups_default = ruleCreator.createRule(typescriptLanguage, {
|
|
145
|
+
about: {
|
|
146
|
+
description: "Reports capturing groups that capture less text than their pattern suggests.",
|
|
147
|
+
id: "regexMisleadingCapturingGroups",
|
|
148
|
+
presets: ["logical", "logicalStrict"]
|
|
149
|
+
},
|
|
150
|
+
messages: {
|
|
151
|
+
misleadingEnd: {
|
|
152
|
+
primary: "Quantifier '{{ quantifierRaw }}' at the end of capturing group may capture less than expected due to backtracking.",
|
|
153
|
+
secondary: ["The quantifier at the end of this capturing group may give up characters during backtracking to satisfy a following pattern."],
|
|
154
|
+
suggestions: ["Use an atomic group.", "Rewrite the pattern."]
|
|
155
|
+
},
|
|
156
|
+
misleadingStart: {
|
|
157
|
+
primary: "Capturing group with '{{ captureRaw }}' will always capture {{ behavior }} because '{{ precedingRaw }}' consumes matching characters first.",
|
|
158
|
+
secondary: ["The quantifier in this capturing group can never match as much as expected because a preceding quantifier already consumed the characters."],
|
|
159
|
+
suggestions: ["Remove the quantifier in the capturing group.", "Simplify the quantifier in the capturing group."]
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
setup(context) {
|
|
163
|
+
function checkPattern(pattern, patternStart, flags) {
|
|
164
|
+
const regexpAst = parseRegexpAst(pattern, flags);
|
|
165
|
+
if (!regexpAst) return;
|
|
166
|
+
visitRegExpAST(regexpAst, { onCapturingGroupEnter(cgNode) {
|
|
167
|
+
checkMisleadingStart(cgNode, patternStart);
|
|
168
|
+
checkMisleadingEnd(cgNode, patternStart);
|
|
169
|
+
} });
|
|
170
|
+
}
|
|
171
|
+
function checkMisleadingStart(capturingGroupNode, patternStart) {
|
|
172
|
+
const precedingQuantifier = findPrecedingQuantifier(capturingGroupNode);
|
|
173
|
+
const firstAlternative = capturingGroupNode.alternatives[0];
|
|
174
|
+
if (!precedingQuantifier || !firstAlternative) return;
|
|
175
|
+
const startQuantifier = getStartQuantifier(firstAlternative, "ltr");
|
|
176
|
+
if (!startQuantifier) return;
|
|
177
|
+
if (startQuantifier.element.type === "CharacterSet" && startQuantifier.element.kind === "any") return;
|
|
178
|
+
if (!hasOverlap(getMatchableCharacterTypes(precedingQuantifier.element), getMatchableCharacterTypes(startQuantifier.element))) return;
|
|
179
|
+
const behavior = startQuantifier.min === 0 ? "the empty string" : `only ${startQuantifier.min} character${startQuantifier.min > 1 ? "s" : ""}`;
|
|
180
|
+
context.report({
|
|
181
|
+
data: {
|
|
182
|
+
behavior,
|
|
183
|
+
captureRaw: startQuantifier.raw,
|
|
184
|
+
precedingRaw: precedingQuantifier.raw
|
|
185
|
+
},
|
|
186
|
+
message: "misleadingStart",
|
|
187
|
+
range: {
|
|
188
|
+
begin: patternStart + startQuantifier.start,
|
|
189
|
+
end: patternStart + startQuantifier.end
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
function checkMisleadingEnd(capturingGroupNode, patternStart) {
|
|
194
|
+
const endQuantifier = getEndQuantifier(capturingGroupNode);
|
|
195
|
+
if (!endQuantifier) return;
|
|
196
|
+
const followingElement = findFollowingElement(capturingGroupNode);
|
|
197
|
+
if (!followingElement || isAllowedEndPattern(endQuantifier, followingElement)) return;
|
|
198
|
+
const endTypes = getMatchableCharacterTypes(endQuantifier.element);
|
|
199
|
+
const firstFollowing = getFirstElementInGroup(followingElement);
|
|
200
|
+
if (!hasOverlap(endTypes, firstFollowing ? getMatchableCharacterTypes(firstFollowing) : /* @__PURE__ */ new Set())) return;
|
|
201
|
+
context.report({
|
|
202
|
+
data: { quantifierRaw: endQuantifier.raw },
|
|
203
|
+
message: "misleadingEnd",
|
|
204
|
+
range: {
|
|
205
|
+
begin: patternStart + endQuantifier.start,
|
|
206
|
+
end: patternStart + endQuantifier.end
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
function checkRegexLiteral(node, services) {
|
|
211
|
+
const details = getRegExpLiteralDetails(node, services);
|
|
212
|
+
checkPattern(details.pattern, details.start, details.flags);
|
|
213
|
+
}
|
|
214
|
+
function checkRegExpConstructor(node, services) {
|
|
215
|
+
const construction = getRegExpConstruction(node, services);
|
|
216
|
+
if (!construction) return;
|
|
217
|
+
checkPattern(construction.raw, construction.start + 1, construction.flags);
|
|
218
|
+
}
|
|
219
|
+
return { visitors: {
|
|
220
|
+
CallExpression: checkRegExpConstructor,
|
|
221
|
+
NewExpression: checkRegExpConstructor,
|
|
222
|
+
RegularExpressionLiteral: checkRegexLiteral
|
|
223
|
+
} };
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
//#endregion
|
|
227
|
+
export { regexMisleadingCapturingGroups_default as default };
|
|
228
|
+
|
|
229
|
+
//# sourceMappingURL=regexMisleadingCapturingGroups.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Reports quantifiers whose minimum implies they must match but whose element can match empty.";
|
|
3
|
+
readonly id: "regexMisleadingQuantifiers";
|
|
4
|
+
readonly presets: ["logical"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("javascript" | "logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "confusing", import("@flint.fyi/core").AnyOptionalSchema>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=regexMisleadingQuantifiers.d.ts.map
|