@flint.fyi/ts 0.14.6 → 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 -7
- package/lib/index.js +2 -7
- package/lib/plugin.d.ts +2160 -204
- package/lib/plugin.js +610 -107
- 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 +6 -2
- package/lib/rules/anyReturns.js +98 -183
- 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 +6 -2
- package/lib/rules/asyncPromiseExecutors.js +40 -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 +6 -2
- package/lib/rules/caseDeclarations.js +38 -51
- package/lib/rules/caseDuplicates.d.ts +6 -2
- package/lib/rules/caseDuplicates.js +35 -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 +6 -2
- package/lib/rules/chainedAssignments.js +31 -47
- package/lib/rules/charAtComparisons.d.ts +10 -0
- package/lib/rules/charAtComparisons.js +58 -0
- package/lib/rules/classAssignments.d.ts +6 -2
- package/lib/rules/classAssignments.js +31 -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 +6 -2
- package/lib/rules/consecutiveNonNullAssertions.js +38 -41
- package/lib/rules/consoleCalls.d.ts +9 -0
- package/lib/rules/consoleCalls.js +28 -0
- package/lib/rules/constantAssignments.d.ts +6 -2
- package/lib/rules/constantAssignments.js +43 -60
- package/lib/rules/constructorGenericCalls.d.ts +16 -0
- package/lib/rules/constructorGenericCalls.js +138 -0
- package/lib/rules/constructorReturns.d.ts +6 -2
- package/lib/rules/constructorReturns.js +39 -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 +6 -2
- package/lib/rules/debuggerStatements.js +32 -42
- package/lib/rules/defaultCaseLast.d.ts +6 -2
- package/lib/rules/defaultCaseLast.js +35 -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 +6 -2
- package/lib/rules/duplicateArguments.js +44 -50
- package/lib/rules/dynamicDeletes.d.ts +10 -0
- package/lib/rules/dynamicDeletes.js +37 -0
- package/lib/rules/elseIfDuplicates.d.ts +6 -2
- package/lib/rules/elseIfDuplicates.js +37 -52
- package/lib/rules/elseReturns.d.ts +10 -0
- package/lib/rules/elseReturns.js +67 -0
- package/lib/rules/emptyBlocks.d.ts +6 -2
- package/lib/rules/emptyBlocks.js +53 -63
- package/lib/rules/emptyDestructures.d.ts +6 -2
- package/lib/rules/emptyDestructures.js +33 -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 +6 -2
- package/lib/rules/emptyStaticBlocks.js +41 -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 +6 -2
- package/lib/rules/exceptionAssignments.js +41 -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 +10 -0
- package/lib/rules/finallyStatementSafety.js +47 -0
- package/lib/rules/forDirections.d.ts +6 -2
- package/lib/rules/forDirections.js +68 -124
- package/lib/rules/forInArrays.d.ts +6 -2
- package/lib/rules/forInArrays.js +43 -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 +6 -2
- package/lib/rules/functionAssignments.js +31 -41
- package/lib/rules/functionCurryingRedundancy.d.ts +10 -0
- package/lib/rules/functionCurryingRedundancy.js +53 -0
- 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 +6 -2
- package/lib/rules/functionNewCalls.js +41 -59
- package/lib/rules/generatorFunctionYields.d.ts +6 -2
- package/lib/rules/generatorFunctionYields.js +46 -53
- package/lib/rules/getterReturns.d.ts +10 -0
- package/lib/rules/getterReturns.js +65 -0
- package/lib/rules/globalAssignments.d.ts +6 -2
- package/lib/rules/globalAssignments.js +45 -57
- package/lib/rules/globalObjectCalls.d.ts +6 -2
- package/lib/rules/globalObjectCalls.js +41 -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 +7 -3
- package/lib/rules/namespaceDeclarations.js +35 -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 +6 -2
- package/lib/rules/negativeZeroComparisons.js +45 -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 +6 -2
- package/lib/rules/newExpressions.js +37 -53
- package/lib/rules/newNativeNonConstructors.d.ts +6 -2
- package/lib/rules/newNativeNonConstructors.js +38 -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 +6 -2
- package/lib/rules/nonOctalDecimalEscapes.js +46 -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 +6 -2
- package/lib/rules/numericLiteralParsing.js +59 -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 +10 -0
- package/lib/rules/objectCalls.js +38 -0
- package/lib/rules/objectEntriesMethods.d.ts +10 -0
- package/lib/rules/objectEntriesMethods.js +82 -0
- package/lib/rules/objectHasOwns.d.ts +10 -0
- package/lib/rules/objectHasOwns.js +50 -0
- package/lib/rules/objectKeyDuplicates.d.ts +10 -0
- package/lib/rules/objectKeyDuplicates.js +63 -0
- package/lib/rules/objectProto.d.ts +6 -2
- package/lib/rules/objectProto.js +49 -53
- package/lib/rules/objectPrototypeBuiltIns.d.ts +10 -0
- package/lib/rules/objectPrototypeBuiltIns.js +54 -0
- 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 +6 -2
- package/lib/rules/octalEscapes.js +54 -67
- package/lib/rules/octalNumbers.d.ts +6 -2
- package/lib/rules/octalNumbers.js +54 -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 +6 -2
- package/lib/rules/returnAssignments.js +36 -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 +6 -2
- package/lib/rules/selfAssignments.js +28 -43
- package/lib/rules/sequences.d.ts +6 -2
- package/lib/rules/sequences.js +27 -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 +6 -2
- package/lib/rules/shadowedRestrictedNames.js +65 -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 +6 -2
- package/lib/rules/sparseArrays.js +42 -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 +6 -2
- package/lib/rules/symbolDescriptions.js +31 -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 +6 -2
- package/lib/rules/typeofComparisons.js +51 -71
- package/lib/rules/unassignedVariables.d.ts +6 -2
- package/lib/rules/unassignedVariables.js +36 -54
- package/lib/rules/undefinedTypeofChecks.d.ts +10 -0
- package/lib/rules/undefinedTypeofChecks.js +41 -0
- package/lib/rules/undefinedVariables.d.ts +6 -2
- package/lib/rules/undefinedVariables.js +38 -75
- package/lib/rules/unicodeBOMs.d.ts +6 -2
- package/lib/rules/unicodeBOMs.js +38 -40
- package/lib/rules/unnecessaryBinds.d.ts +10 -0
- package/lib/rules/unnecessaryBinds.js +78 -0
- package/lib/rules/unnecessaryBlocks.d.ts +6 -2
- package/lib/rules/unnecessaryBlocks.js +59 -74
- package/lib/rules/unnecessaryBooleanCasts.d.ts +10 -0
- package/lib/rules/unnecessaryBooleanCasts.js +58 -0
- package/lib/rules/unnecessaryCatches.d.ts +6 -2
- package/lib/rules/unnecessaryCatches.js +47 -67
- package/lib/rules/unnecessaryComparisons.d.ts +10 -0
- package/lib/rules/unnecessaryComparisons.js +300 -0
- package/lib/rules/unnecessaryConcatenation.d.ts +6 -2
- package/lib/rules/unnecessaryConcatenation.js +27 -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 +6 -2
- package/lib/rules/unsafeNegations.js +37 -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 +13 -9
- package/lib/rules/utils/discriminateAnyType.js +34 -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 +3 -2
- package/lib/rules/utils/getConstrainedType.js +8 -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 +3 -2
- package/lib/rules/utils/getThisExpression.js +15 -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 +2 -1
- package/lib/rules/utils/isTypeRecursive.js +7 -4
- package/lib/rules/utils/isUnsafeAssignment.d.ts +4 -2
- package/lib/rules/utils/isUnsafeAssignment.js +41 -72
- package/lib/rules/utils/operators.d.ts +5 -4
- package/lib/rules/utils/operators.js +32 -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 +6 -2
- package/lib/rules/variableDeletions.js +34 -38
- package/lib/rules/voidOperator.d.ts +6 -2
- package/lib/rules/voidOperator.js +33 -35
- package/lib/rules/withStatements.d.ts +10 -0
- package/lib/rules/withStatements.js +30 -0
- package/lib/rules/wrapperObjects.d.ts +10 -0
- package/lib/rules/wrapperObjects.js +36 -0
- package/package.json +29 -13
- package/CHANGELOG.md +0 -91
- package/lib/collectReferencedFilePaths.d.ts +0 -2
- package/lib/collectReferencedFilePaths.js +0 -21
- package/lib/createTypeScriptFileFromProgram.d.ts +0 -3
- package/lib/createTypeScriptFileFromProgram.js +0 -63
- package/lib/createTypeScriptFileFromProjectService.d.ts +0 -10
- package/lib/createTypeScriptFileFromProjectService.js +0 -20
- package/lib/directives/parseDirectivesFromTypeScriptFile.d.ts +0 -5
- package/lib/directives/parseDirectivesFromTypeScriptFile.js +0 -21
- package/lib/directives/parseDirectivesFromTypeScriptFile.test.d.ts +0 -1
- package/lib/directives/parseDirectivesFromTypeScriptFile.test.js +0 -91
- package/lib/formatDiagnostic.d.ts +0 -10
- package/lib/formatDiagnostic.js +0 -121
- package/lib/getFirstEnumValues.d.ts +0 -35
- package/lib/getFirstEnumValues.js +0 -51
- package/lib/getFirstEnumValues.test.d.ts +0 -1
- package/lib/getFirstEnumValues.test.js +0 -45
- package/lib/getTSNodeRange.d.ts +0 -3
- package/lib/getTSNodeRange.js +0 -6
- package/lib/language.d.ts +0 -8
- package/lib/language.js +0 -65
- package/lib/nodes.d.ts +0 -142
- package/lib/nodes.js +0 -1
- package/lib/normalizeRange.d.ts +0 -3
- package/lib/normalizeRange.js +0 -13
- package/lib/prepareTypeScriptFile.d.ts +0 -7
- package/lib/prepareTypeScriptFile.js +0 -7
- package/lib/rules/anyReturns.test.d.ts +0 -1
- package/lib/rules/anyReturns.test.js +0 -647
- package/lib/rules/asyncPromiseExecutors.test.d.ts +0 -1
- package/lib/rules/asyncPromiseExecutors.test.js +0 -71
- package/lib/rules/caseDeclarations.test.d.ts +0 -1
- package/lib/rules/caseDeclarations.test.js +0 -227
- package/lib/rules/caseDuplicates.test.d.ts +0 -1
- package/lib/rules/caseDuplicates.test.js +0 -307
- package/lib/rules/chainedAssignments.test.d.ts +0 -1
- package/lib/rules/chainedAssignments.test.js +0 -262
- package/lib/rules/classAssignments.test.d.ts +0 -1
- package/lib/rules/classAssignments.test.js +0 -156
- package/lib/rules/consecutiveNonNullAssertions.test.d.ts +0 -1
- package/lib/rules/consecutiveNonNullAssertions.test.js +0 -32
- package/lib/rules/constantAssignments.test.d.ts +0 -1
- package/lib/rules/constantAssignments.test.js +0 -221
- package/lib/rules/constructorReturns.test.d.ts +0 -1
- package/lib/rules/constructorReturns.test.js +0 -96
- package/lib/rules/debuggerStatements.test.d.ts +0 -1
- package/lib/rules/debuggerStatements.test.js +0 -80
- package/lib/rules/defaultCaseLast.test.d.ts +0 -1
- package/lib/rules/defaultCaseLast.test.js +0 -195
- package/lib/rules/duplicateArguments.test.d.ts +0 -1
- package/lib/rules/duplicateArguments.test.js +0 -139
- package/lib/rules/elseIfDuplicates.test.d.ts +0 -1
- package/lib/rules/elseIfDuplicates.test.js +0 -176
- package/lib/rules/emptyBlocks.test.d.ts +0 -1
- package/lib/rules/emptyBlocks.test.js +0 -135
- package/lib/rules/emptyDestructures.test.d.ts +0 -1
- package/lib/rules/emptyDestructures.test.js +0 -186
- package/lib/rules/emptyStaticBlocks.test.d.ts +0 -1
- package/lib/rules/emptyStaticBlocks.test.js +0 -167
- package/lib/rules/exceptionAssignments.test.d.ts +0 -1
- package/lib/rules/exceptionAssignments.test.js +0 -264
- package/lib/rules/forDirections.test.d.ts +0 -1
- package/lib/rules/forDirections.test.js +0 -124
- package/lib/rules/forInArrays.test.d.ts +0 -1
- package/lib/rules/forInArrays.test.js +0 -24
- package/lib/rules/functionAssignments.test.d.ts +0 -1
- package/lib/rules/functionAssignments.test.js +0 -209
- package/lib/rules/functionNewCalls.test.d.ts +0 -1
- package/lib/rules/functionNewCalls.test.js +0 -115
- package/lib/rules/generatorFunctionYields.test.d.ts +0 -1
- package/lib/rules/generatorFunctionYields.test.js +0 -151
- package/lib/rules/globalAssignments.test.d.ts +0 -1
- package/lib/rules/globalAssignments.test.js +0 -215
- package/lib/rules/globalObjectCalls.test.d.ts +0 -1
- package/lib/rules/globalObjectCalls.test.js +0 -93
- package/lib/rules/namespaceDeclarations.test.d.ts +0 -1
- package/lib/rules/namespaceDeclarations.test.js +0 -40
- package/lib/rules/negativeZeroComparisons.test.d.ts +0 -1
- package/lib/rules/negativeZeroComparisons.test.js +0 -209
- package/lib/rules/newExpressions.test.d.ts +0 -1
- package/lib/rules/newExpressions.test.js +0 -79
- package/lib/rules/newNativeNonConstructors.test.d.ts +0 -1
- package/lib/rules/newNativeNonConstructors.test.js +0 -94
- package/lib/rules/nonOctalDecimalEscapes.test.d.ts +0 -1
- package/lib/rules/nonOctalDecimalEscapes.test.js +0 -69
- package/lib/rules/numericLiteralParsing.test.d.ts +0 -1
- package/lib/rules/numericLiteralParsing.test.js +0 -99
- package/lib/rules/objectProto.test.d.ts +0 -1
- package/lib/rules/objectProto.test.js +0 -96
- package/lib/rules/octalEscapes.test.d.ts +0 -1
- package/lib/rules/octalEscapes.test.js +0 -213
- package/lib/rules/octalNumbers.test.d.ts +0 -1
- package/lib/rules/octalNumbers.test.js +0 -245
- package/lib/rules/returnAssignments.test.d.ts +0 -1
- package/lib/rules/returnAssignments.test.js +0 -185
- package/lib/rules/ruleTester.d.ts +0 -2
- package/lib/rules/ruleTester.js +0 -3
- package/lib/rules/selfAssignments.test.d.ts +0 -1
- package/lib/rules/selfAssignments.test.js +0 -66
- package/lib/rules/selfComparisons.d.ts +0 -6
- package/lib/rules/selfComparisons.js +0 -41
- package/lib/rules/selfComparisons.test.d.ts +0 -1
- package/lib/rules/selfComparisons.test.js +0 -297
- package/lib/rules/sequences.test.d.ts +0 -1
- package/lib/rules/sequences.test.js +0 -48
- package/lib/rules/shadowedRestrictedNames.test.d.ts +0 -1
- package/lib/rules/shadowedRestrictedNames.test.js +0 -147
- package/lib/rules/sparseArrays.test.d.ts +0 -1
- package/lib/rules/sparseArrays.test.js +0 -110
- package/lib/rules/symbolDescriptions.test.d.ts +0 -1
- package/lib/rules/symbolDescriptions.test.js +0 -89
- package/lib/rules/typeofComparisons.test.d.ts +0 -1
- package/lib/rules/typeofComparisons.test.js +0 -85
- package/lib/rules/unassignedVariables.test.d.ts +0 -1
- package/lib/rules/unassignedVariables.test.js +0 -72
- package/lib/rules/undefinedVariables.test.d.ts +0 -1
- package/lib/rules/undefinedVariables.test.js +0 -80
- package/lib/rules/unicodeBOMs.test.d.ts +0 -1
- package/lib/rules/unicodeBOMs.test.js +0 -66
- package/lib/rules/unnecessaryBlocks.test.d.ts +0 -1
- package/lib/rules/unnecessaryBlocks.test.js +0 -147
- package/lib/rules/unnecessaryCatches.test.d.ts +0 -1
- package/lib/rules/unnecessaryCatches.test.js +0 -210
- package/lib/rules/unnecessaryConcatenation.test.d.ts +0 -1
- package/lib/rules/unnecessaryConcatenation.test.js +0 -87
- package/lib/rules/unsafeNegations.test.d.ts +0 -1
- package/lib/rules/unsafeNegations.test.js +0 -63
- package/lib/rules/variableDeletions.test.d.ts +0 -1
- package/lib/rules/variableDeletions.test.js +0 -75
- package/lib/rules/voidOperator.test.d.ts +0 -1
- package/lib/rules/voidOperator.test.js +0 -98
- package/lib/utils/declarationIncludesGlobal.d.ts +0 -2
- package/lib/utils/declarationIncludesGlobal.js +0 -5
- package/lib/utils/declarationsIncludeGlobal.d.ts +0 -2
- package/lib/utils/declarationsIncludeGlobal.js +0 -4
- package/lib/utils/getDeclarationsIfGlobal.d.ts +0 -2
- package/lib/utils/getDeclarationsIfGlobal.js +0 -7
- package/lib/utils/getModifyingReferences.d.ts +0 -8
- package/lib/utils/getModifyingReferences.js +0 -42
- package/lib/utils/hasSameTokens.d.ts +0 -2
- package/lib/utils/hasSameTokens.js +0 -30
- package/lib/utils/isGlobalDeclaration.d.ts +0 -2
- package/lib/utils/isGlobalDeclaration.js +0 -4
- package/lib/utils/isGlobalDeclarationOfName.d.ts +0 -5
- package/lib/utils/isGlobalDeclarationOfName.js +0 -35
- package/lib/utils/isGlobalVariable.d.ts +0 -8
- package/lib/utils/isGlobalVariable.js +0 -21
- package/lib/utils/unwrapParentParenthesizedExpressions.d.ts +0 -2
- package/lib/utils/unwrapParentParenthesizedExpressions.js +0 -6
- package/lib/utils/unwrapParenthesizedExpression.d.ts +0 -2
- package/lib/utils/unwrapParenthesizedExpression.js +0 -6
- 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,10 @@
|
|
|
1
|
+
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Reports capturing groups that only capture empty strings.";
|
|
3
|
+
readonly id: "regexEmptyCapturingGroups";
|
|
4
|
+
readonly presets: ["logical", "logicalStrict"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("javascript" | "logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "emptyCapture", import("@flint.fyi/core").AnyOptionalSchema>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=regexEmptyCapturingGroups.d.ts.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ruleCreator } from "./ruleCreator.js";
|
|
2
|
+
import { getRegExpConstruction } from "./utils/getRegExpConstruction.js";
|
|
3
|
+
import { getRegExpLiteralDetails } from "./utils/getRegExpLiteralDetails.js";
|
|
4
|
+
import { typescriptLanguage } from "@flint.fyi/typescript-language";
|
|
5
|
+
import { parseRegExpLiteral, visitRegExpAST } from "@eslint-community/regexpp";
|
|
6
|
+
import { isZeroLength } from "regexp-ast-analysis";
|
|
7
|
+
//#region src/rules/regexEmptyCapturingGroups.ts
|
|
8
|
+
function findEmptyCapturingGroups(pattern, flags) {
|
|
9
|
+
const results = [];
|
|
10
|
+
let ast;
|
|
11
|
+
try {
|
|
12
|
+
ast = parseRegExpLiteral(new RegExp(pattern, flags));
|
|
13
|
+
} catch {
|
|
14
|
+
return results;
|
|
15
|
+
}
|
|
16
|
+
visitRegExpAST(ast, { onCapturingGroupEnter(node) {
|
|
17
|
+
if (node.name) return;
|
|
18
|
+
if (isZeroLength(node, ast.flags)) results.push(node);
|
|
19
|
+
} });
|
|
20
|
+
return results;
|
|
21
|
+
}
|
|
22
|
+
var regexEmptyCapturingGroups_default = ruleCreator.createRule(typescriptLanguage, {
|
|
23
|
+
about: {
|
|
24
|
+
description: "Reports capturing groups that only capture empty strings.",
|
|
25
|
+
id: "regexEmptyCapturingGroups",
|
|
26
|
+
presets: ["logical", "logicalStrict"]
|
|
27
|
+
},
|
|
28
|
+
messages: { emptyCapture: {
|
|
29
|
+
primary: "This capturing group captures only empty strings.",
|
|
30
|
+
secondary: ["This capturing group will only ever match zero-length text.", "It may indicate a mistake in the pattern."],
|
|
31
|
+
suggestions: ["Add content to the capturing group.", "Convert the capturing group to a non-capturing group."]
|
|
32
|
+
} },
|
|
33
|
+
setup(context) {
|
|
34
|
+
function checkRegexLiteral(node, services) {
|
|
35
|
+
const { flags, pattern, start } = getRegExpLiteralDetails(node, services);
|
|
36
|
+
const emptyGroups = findEmptyCapturingGroups(pattern, flags);
|
|
37
|
+
for (const group of emptyGroups) context.report({
|
|
38
|
+
message: "emptyCapture",
|
|
39
|
+
range: {
|
|
40
|
+
begin: start + group.start - 1,
|
|
41
|
+
end: start + group.end - 1
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function checkRegExpConstructor(node, services) {
|
|
46
|
+
const construction = getRegExpConstruction(node, services);
|
|
47
|
+
if (!construction) return;
|
|
48
|
+
const emptyGroups = findEmptyCapturingGroups(construction.pattern.replace(/\\\\/g, "\\"), construction.flags);
|
|
49
|
+
for (const group of emptyGroups) context.report({
|
|
50
|
+
message: "emptyCapture",
|
|
51
|
+
range: {
|
|
52
|
+
begin: construction.start + group.start,
|
|
53
|
+
end: construction.start + group.end
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return { visitors: {
|
|
58
|
+
CallExpression: checkRegExpConstructor,
|
|
59
|
+
NewExpression: checkRegExpConstructor,
|
|
60
|
+
RegularExpressionLiteral: checkRegexLiteral
|
|
61
|
+
} };
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
//#endregion
|
|
65
|
+
export { regexEmptyCapturingGroups_default as default };
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=regexEmptyCapturingGroups.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Reports character classes that match no characters.";
|
|
3
|
+
readonly id: "regexEmptyCharacterClasses";
|
|
4
|
+
readonly presets: ["logical", "logicalStrict"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("javascript" | "logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "empty", import("@flint.fyi/core").AnyOptionalSchema>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=regexEmptyCharacterClasses.d.ts.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ruleCreator } from "./ruleCreator.js";
|
|
2
|
+
import { getRegExpConstruction } from "./utils/getRegExpConstruction.js";
|
|
3
|
+
import { getRegExpLiteralDetails } from "./utils/getRegExpLiteralDetails.js";
|
|
4
|
+
import { typescriptLanguage } from "@flint.fyi/typescript-language";
|
|
5
|
+
import { parseRegExpLiteral, visitRegExpAST } from "@eslint-community/regexpp";
|
|
6
|
+
//#region src/rules/regexEmptyCharacterClasses.ts
|
|
7
|
+
function characterClassIsEmpty(node) {
|
|
8
|
+
return !node.negate && !node.elements.length;
|
|
9
|
+
}
|
|
10
|
+
function findEmptyCharacterClasses(pattern, flags) {
|
|
11
|
+
const results = [];
|
|
12
|
+
let ast;
|
|
13
|
+
try {
|
|
14
|
+
ast = parseRegExpLiteral(new RegExp(pattern, flags));
|
|
15
|
+
} catch {
|
|
16
|
+
return results;
|
|
17
|
+
}
|
|
18
|
+
visitRegExpAST(ast, { onCharacterClassEnter(node) {
|
|
19
|
+
if (characterClassIsEmpty(node)) results.push(node);
|
|
20
|
+
} });
|
|
21
|
+
return results;
|
|
22
|
+
}
|
|
23
|
+
var regexEmptyCharacterClasses_default = ruleCreator.createRule(typescriptLanguage, {
|
|
24
|
+
about: {
|
|
25
|
+
description: "Reports character classes that match no characters.",
|
|
26
|
+
id: "regexEmptyCharacterClasses",
|
|
27
|
+
presets: ["logical", "logicalStrict"]
|
|
28
|
+
},
|
|
29
|
+
messages: { empty: {
|
|
30
|
+
primary: "This character class matches no characters because it is empty.",
|
|
31
|
+
secondary: ["An empty character class `[]` never matches anything.", "This often indicates a mistake in the regular expression."],
|
|
32
|
+
suggestions: ["Add characters to the class if it's meant to capture any.", "Remove the class if it is unintended."]
|
|
33
|
+
} },
|
|
34
|
+
setup(context) {
|
|
35
|
+
function checkRegexLiteral(node, services) {
|
|
36
|
+
const { flags, pattern, start } = getRegExpLiteralDetails(node, services);
|
|
37
|
+
const emptyClasses = findEmptyCharacterClasses(pattern, flags);
|
|
38
|
+
for (const charClass of emptyClasses) context.report({
|
|
39
|
+
message: "empty",
|
|
40
|
+
range: {
|
|
41
|
+
begin: start + charClass.start - 1,
|
|
42
|
+
end: start + charClass.end - 1
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function checkRegExpConstructor(node, services) {
|
|
47
|
+
const construction = getRegExpConstruction(node, services);
|
|
48
|
+
if (!construction) return;
|
|
49
|
+
const emptyClasses = findEmptyCharacterClasses(construction.pattern.replace(/\\\\/g, "\\"), construction.flags);
|
|
50
|
+
for (const charClass of emptyClasses) context.report({
|
|
51
|
+
message: "empty",
|
|
52
|
+
range: {
|
|
53
|
+
begin: construction.start + charClass.start,
|
|
54
|
+
end: construction.start + charClass.end
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return { visitors: {
|
|
59
|
+
CallExpression: checkRegExpConstructor,
|
|
60
|
+
NewExpression: checkRegExpConstructor,
|
|
61
|
+
RegularExpressionLiteral: checkRegexLiteral
|
|
62
|
+
} };
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
//#endregion
|
|
66
|
+
export { regexEmptyCharacterClasses_default as default };
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=regexEmptyCharacterClasses.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Reports empty groups in regular expressions.";
|
|
3
|
+
readonly id: "regexEmptyGroups";
|
|
4
|
+
readonly presets: ["logical", "logicalStrict"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("javascript" | "logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "emptyGroup", import("@flint.fyi/core").AnyOptionalSchema>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=regexEmptyGroups.d.ts.map
|
|
@@ -0,0 +1,66 @@
|
|
|
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/regexEmptyGroups.ts
|
|
8
|
+
function isEmptyGroup(group) {
|
|
9
|
+
return group.alternatives.every((alternative) => !alternative.elements.length);
|
|
10
|
+
}
|
|
11
|
+
var regexEmptyGroups_default = ruleCreator.createRule(typescriptLanguage, {
|
|
12
|
+
about: {
|
|
13
|
+
description: "Reports empty groups in regular expressions.",
|
|
14
|
+
id: "regexEmptyGroups",
|
|
15
|
+
presets: ["logical", "logicalStrict"]
|
|
16
|
+
},
|
|
17
|
+
messages: { emptyGroup: {
|
|
18
|
+
primary: "Empty {{ kind }} `{{ raw }}` matches nothing.",
|
|
19
|
+
secondary: ["Empty groups match the empty string and have no effect on the regex."],
|
|
20
|
+
suggestions: ["Remove the empty group.", "Replace the empty group with a non-capturing group."]
|
|
21
|
+
} },
|
|
22
|
+
setup(context) {
|
|
23
|
+
function reportEmptyGroup(group, kind, start) {
|
|
24
|
+
if (isEmptyGroup(group)) context.report({
|
|
25
|
+
data: {
|
|
26
|
+
kind,
|
|
27
|
+
raw: group.raw
|
|
28
|
+
},
|
|
29
|
+
message: "emptyGroup",
|
|
30
|
+
range: {
|
|
31
|
+
begin: start + group.start,
|
|
32
|
+
end: start + group.end
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function checkPattern(pattern, patternStart, flags) {
|
|
37
|
+
const regexpAst = parseRegexpAst(pattern, flags);
|
|
38
|
+
if (!regexpAst) return;
|
|
39
|
+
visitRegExpAST(regexpAst, {
|
|
40
|
+
onCapturingGroupEnter(group) {
|
|
41
|
+
reportEmptyGroup(group, "capturing group", patternStart);
|
|
42
|
+
},
|
|
43
|
+
onGroupEnter(group) {
|
|
44
|
+
reportEmptyGroup(group, "non-capturing group", patternStart);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function checkRegexLiteral(node, services) {
|
|
49
|
+
const details = getRegExpLiteralDetails(node, services);
|
|
50
|
+
checkPattern(details.pattern, details.start, details.flags);
|
|
51
|
+
}
|
|
52
|
+
function checkRegExpConstructor(node, services) {
|
|
53
|
+
const construction = getRegExpConstruction(node, services);
|
|
54
|
+
if (construction) checkPattern(construction.pattern, construction.start + 1, construction.flags);
|
|
55
|
+
}
|
|
56
|
+
return { visitors: {
|
|
57
|
+
CallExpression: checkRegExpConstructor,
|
|
58
|
+
NewExpression: checkRegExpConstructor,
|
|
59
|
+
RegularExpressionLiteral: checkRegexLiteral
|
|
60
|
+
} };
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
//#endregion
|
|
64
|
+
export { regexEmptyGroups_default as default };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=regexEmptyGroups.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Reports lazy quantifiers at the end of regular expressions.";
|
|
3
|
+
readonly id: "regexEmptyLazyQuantifiers";
|
|
4
|
+
readonly presets: ["logical"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("javascript" | "logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "uselessElement" | "uselessQuantifier" | "uselessRange", import("@flint.fyi/core").AnyOptionalSchema>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=regexEmptyLazyQuantifiers.d.ts.map
|
|
@@ -0,0 +1,92 @@
|
|
|
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/regexEmptyLazyQuantifiers.ts
|
|
8
|
+
function* extractLazyEndQuantifiers(alternatives) {
|
|
9
|
+
for (const { elements } of alternatives) {
|
|
10
|
+
if (!elements.length) continue;
|
|
11
|
+
const last = elements.at(-1);
|
|
12
|
+
if (!last) continue;
|
|
13
|
+
switch (last.type) {
|
|
14
|
+
case "CapturingGroup":
|
|
15
|
+
case "Group":
|
|
16
|
+
yield* extractLazyEndQuantifiers(last.alternatives);
|
|
17
|
+
break;
|
|
18
|
+
case "Quantifier":
|
|
19
|
+
if (!last.greedy && last.min !== last.max) yield last;
|
|
20
|
+
else if (last.max === 1) {
|
|
21
|
+
const element = last.element;
|
|
22
|
+
if (element.type === "Group" || element.type === "CapturingGroup") yield* extractLazyEndQuantifiers(element.alternatives);
|
|
23
|
+
}
|
|
24
|
+
break;
|
|
25
|
+
default: break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
var regexEmptyLazyQuantifiers_default = ruleCreator.createRule(typescriptLanguage, {
|
|
30
|
+
about: {
|
|
31
|
+
description: "Reports lazy quantifiers at the end of regular expressions.",
|
|
32
|
+
id: "regexEmptyLazyQuantifiers",
|
|
33
|
+
presets: ["logical"]
|
|
34
|
+
},
|
|
35
|
+
messages: {
|
|
36
|
+
uselessElement: {
|
|
37
|
+
primary: "Lazy quantifier '{{ raw }}' at end of pattern will only match the empty string.",
|
|
38
|
+
secondary: ["Lazy quantifiers at the end of a pattern with minimum 0 will match nothing because there's nothing after them to satisfy."],
|
|
39
|
+
suggestions: ["Remove the lazy quantifier.", "Add characters after the lazy quantifier to make it useful."]
|
|
40
|
+
},
|
|
41
|
+
uselessQuantifier: {
|
|
42
|
+
primary: "Lazy quantifier '{{ raw }}' at end of pattern will always match exactly once.",
|
|
43
|
+
secondary: ["Lazy quantifiers at the end of a pattern with minimum 1 will match exactly once because there's nothing after them to satisfy."],
|
|
44
|
+
suggestions: ["Remove the lazy quantifier.", "Add characters after the lazy quantifier to make it useful."]
|
|
45
|
+
},
|
|
46
|
+
uselessRange: {
|
|
47
|
+
primary: "Lazy quantifier '{{ raw }}' at end of pattern will always match exactly {{ min }} times.",
|
|
48
|
+
secondary: ["Lazy quantifiers at the end of a pattern will match only their minimum because there's nothing after them to satisfy."],
|
|
49
|
+
suggestions: ["Remove the lazy quantifier.", "Add characters after the lazy quantifier to make it useful."]
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
setup(context) {
|
|
53
|
+
function checkPattern(pattern, patternStart, flags) {
|
|
54
|
+
const regexpAst = parseRegexpAst(pattern, flags);
|
|
55
|
+
if (!regexpAst) return;
|
|
56
|
+
visitRegExpAST(regexpAst, { onPatternEnter(patternNode) {
|
|
57
|
+
for (const lazy of extractLazyEndQuantifiers(patternNode.alternatives)) {
|
|
58
|
+
const messageId = lazy.min === 0 ? "uselessElement" : lazy.min === 1 ? "uselessQuantifier" : "uselessRange";
|
|
59
|
+
context.report({
|
|
60
|
+
data: {
|
|
61
|
+
min: lazy.min,
|
|
62
|
+
raw: lazy.raw
|
|
63
|
+
},
|
|
64
|
+
message: messageId,
|
|
65
|
+
range: {
|
|
66
|
+
begin: patternStart + lazy.start,
|
|
67
|
+
end: patternStart + lazy.end
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
} });
|
|
72
|
+
}
|
|
73
|
+
function checkRegexLiteral(node, services) {
|
|
74
|
+
const details = getRegExpLiteralDetails(node, services);
|
|
75
|
+
checkPattern(details.pattern, details.start, details.flags);
|
|
76
|
+
}
|
|
77
|
+
function checkRegExpConstructor(node, services) {
|
|
78
|
+
const construction = getRegExpConstruction(node, services);
|
|
79
|
+
if (!construction) return;
|
|
80
|
+
checkPattern(construction.pattern, construction.start + 1, construction.flags);
|
|
81
|
+
}
|
|
82
|
+
return { visitors: {
|
|
83
|
+
CallExpression: checkRegExpConstructor,
|
|
84
|
+
NewExpression: checkRegExpConstructor,
|
|
85
|
+
RegularExpressionLiteral: checkRegexLiteral
|
|
86
|
+
} };
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
//#endregion
|
|
90
|
+
export { regexEmptyLazyQuantifiers_default as default };
|
|
91
|
+
|
|
92
|
+
//# sourceMappingURL=regexEmptyLazyQuantifiers.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Reports empty lookahead and lookbehind assertions in regular expressions.";
|
|
3
|
+
readonly id: "regexEmptyLookaroundsAssertions";
|
|
4
|
+
readonly presets: ["logical", "logicalStrict"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("javascript" | "logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "emptyLookaround", import("@flint.fyi/core").AnyOptionalSchema>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=regexEmptyLookaroundsAssertions.d.ts.map
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
import { isPotentiallyEmpty } from "regexp-ast-analysis";
|
|
8
|
+
//#region src/rules/regexEmptyLookaroundsAssertions.ts
|
|
9
|
+
var regexEmptyLookaroundsAssertions_default = ruleCreator.createRule(typescriptLanguage, {
|
|
10
|
+
about: {
|
|
11
|
+
description: "Reports empty lookahead and lookbehind assertions in regular expressions.",
|
|
12
|
+
id: "regexEmptyLookaroundsAssertions",
|
|
13
|
+
presets: ["logical", "logicalStrict"]
|
|
14
|
+
},
|
|
15
|
+
messages: { emptyLookaround: {
|
|
16
|
+
primary: "Empty {{ kind }} will trivially {{ result }} all inputs.",
|
|
17
|
+
secondary: ["Empty lookaround assertions match the empty string and will always succeed (or fail if negated) without checking anything meaningful."],
|
|
18
|
+
suggestions: []
|
|
19
|
+
} },
|
|
20
|
+
setup(context) {
|
|
21
|
+
function checkPattern(pattern, patternStart, flagsText) {
|
|
22
|
+
const regexpAst = parseRegexpAst(pattern, flagsText);
|
|
23
|
+
if (!regexpAst) return;
|
|
24
|
+
const flags = {
|
|
25
|
+
dotAll: flagsText.includes("s"),
|
|
26
|
+
global: flagsText.includes("g"),
|
|
27
|
+
hasIndices: flagsText.includes("d"),
|
|
28
|
+
ignoreCase: flagsText.includes("i"),
|
|
29
|
+
multiline: flagsText.includes("m"),
|
|
30
|
+
sticky: flagsText.includes("y"),
|
|
31
|
+
unicode: flagsText.includes("u"),
|
|
32
|
+
unicodeSets: flagsText.includes("v")
|
|
33
|
+
};
|
|
34
|
+
visitRegExpAST(regexpAst, { onAssertionEnter(assertion) {
|
|
35
|
+
if (assertion.kind !== "lookahead" && assertion.kind !== "lookbehind") return;
|
|
36
|
+
if (isPotentiallyEmpty(assertion.alternatives, flags)) context.report({
|
|
37
|
+
data: {
|
|
38
|
+
kind: assertion.kind,
|
|
39
|
+
result: assertion.negate ? "reject" : "accept"
|
|
40
|
+
},
|
|
41
|
+
message: "emptyLookaround",
|
|
42
|
+
range: {
|
|
43
|
+
begin: patternStart + assertion.start,
|
|
44
|
+
end: patternStart + assertion.end
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
} });
|
|
48
|
+
}
|
|
49
|
+
function checkRegexLiteral(node, services) {
|
|
50
|
+
const { flags, pattern, start } = getRegExpLiteralDetails(node, services);
|
|
51
|
+
checkPattern(pattern, start, flags);
|
|
52
|
+
}
|
|
53
|
+
function checkRegExpConstructor(node, services) {
|
|
54
|
+
const construction = getRegExpConstruction(node, services);
|
|
55
|
+
if (!construction) return;
|
|
56
|
+
checkPattern(construction.pattern.replace(/\\\\/g, "\\"), construction.start + 1, construction.flags);
|
|
57
|
+
}
|
|
58
|
+
return { visitors: {
|
|
59
|
+
CallExpression: checkRegExpConstructor,
|
|
60
|
+
NewExpression: checkRegExpConstructor,
|
|
61
|
+
RegularExpressionLiteral: checkRegexLiteral
|
|
62
|
+
} };
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
//#endregion
|
|
66
|
+
export { regexEmptyLookaroundsAssertions_default as default };
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=regexEmptyLookaroundsAssertions.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Reports empty string literals in character classes.";
|
|
3
|
+
readonly id: "regexEmptyStringLiterals";
|
|
4
|
+
readonly presets: ["logical", "logicalStrict"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("javascript" | "logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "emptyStringLiteral", import("@flint.fyi/core").AnyOptionalSchema>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=regexEmptyStringLiterals.d.ts.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ruleCreator } from "./ruleCreator.js";
|
|
2
|
+
import { getRegExpConstruction } from "./utils/getRegExpConstruction.js";
|
|
3
|
+
import { getRegExpLiteralDetails } from "./utils/getRegExpLiteralDetails.js";
|
|
4
|
+
import { typescriptLanguage } from "@flint.fyi/typescript-language";
|
|
5
|
+
import { parseRegExpLiteral, visitRegExpAST } from "@eslint-community/regexpp";
|
|
6
|
+
//#region src/rules/regexEmptyStringLiterals.ts
|
|
7
|
+
function findEmptyStringLiterals(pattern, flags) {
|
|
8
|
+
const results = [];
|
|
9
|
+
if (!flags.includes("v")) return results;
|
|
10
|
+
let ast;
|
|
11
|
+
try {
|
|
12
|
+
ast = parseRegExpLiteral(new RegExp(pattern, flags));
|
|
13
|
+
} catch {
|
|
14
|
+
return results;
|
|
15
|
+
}
|
|
16
|
+
visitRegExpAST(ast, { onClassStringDisjunctionEnter(node) {
|
|
17
|
+
if (node.alternatives.every((alternative) => !alternative.elements.length)) results.push(node);
|
|
18
|
+
} });
|
|
19
|
+
return results;
|
|
20
|
+
}
|
|
21
|
+
var regexEmptyStringLiterals_default = ruleCreator.createRule(typescriptLanguage, {
|
|
22
|
+
about: {
|
|
23
|
+
description: "Reports empty string literals in character classes.",
|
|
24
|
+
id: "regexEmptyStringLiterals",
|
|
25
|
+
presets: ["logical", "logicalStrict"]
|
|
26
|
+
},
|
|
27
|
+
messages: { emptyStringLiteral: {
|
|
28
|
+
primary: "This empty string literal in a character class will always match the empty string.",
|
|
29
|
+
secondary: ["The `\\q{}` string literal matches the empty string.", "This generally either does not benefit the regular expression or can cause unintended matches."],
|
|
30
|
+
suggestions: ["Remove the empty string literal if this was unintentional.", "Use a quantifier on the character class if this was intentional."]
|
|
31
|
+
} },
|
|
32
|
+
setup(context) {
|
|
33
|
+
function checkRegexLiteral(node, services) {
|
|
34
|
+
const { flags, pattern, start } = getRegExpLiteralDetails(node, services);
|
|
35
|
+
const emptyLiterals = findEmptyStringLiterals(pattern, flags);
|
|
36
|
+
for (const literal of emptyLiterals) context.report({
|
|
37
|
+
message: "emptyStringLiteral",
|
|
38
|
+
range: {
|
|
39
|
+
begin: start + literal.start - 1,
|
|
40
|
+
end: start + literal.end - 1
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function checkRegExpConstructor(node, services) {
|
|
45
|
+
const construction = getRegExpConstruction(node, services);
|
|
46
|
+
if (!construction) return;
|
|
47
|
+
const emptyLiterals = findEmptyStringLiterals(construction.pattern.replace(/\\\\/g, "\\"), construction.flags);
|
|
48
|
+
for (const literal of emptyLiterals) context.report({
|
|
49
|
+
message: "emptyStringLiteral",
|
|
50
|
+
range: {
|
|
51
|
+
begin: construction.start + literal.start,
|
|
52
|
+
end: construction.start + literal.end
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return { visitors: {
|
|
57
|
+
CallExpression: checkRegExpConstructor,
|
|
58
|
+
NewExpression: checkRegExpConstructor,
|
|
59
|
+
RegularExpressionLiteral: checkRegexLiteral
|
|
60
|
+
} };
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
//#endregion
|
|
64
|
+
export { regexEmptyStringLiterals_default as default };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=regexEmptyStringLiterals.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Reports escape backspace (`[\\b]`) in character classes.";
|
|
3
|
+
readonly id: "regexEscapeBackspaces";
|
|
4
|
+
readonly presets: ["stylistic", "stylisticStrict"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("javascript" | "logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "escapeBackspace", import("@flint.fyi/core").AnyOptionalSchema>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=regexEscapeBackspaces.d.ts.map
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ruleCreator } from "./ruleCreator.js";
|
|
2
|
+
import { getRegExpConstruction } from "./utils/getRegExpConstruction.js";
|
|
3
|
+
import { getRegExpLiteralDetails } from "./utils/getRegExpLiteralDetails.js";
|
|
4
|
+
import { typescriptLanguage } from "@flint.fyi/typescript-language";
|
|
5
|
+
import { parseRegExpLiteral, visitRegExpAST } from "@eslint-community/regexpp";
|
|
6
|
+
//#region src/rules/regexEscapeBackspaces.ts
|
|
7
|
+
function findEscapeBackspaces(pattern, flags) {
|
|
8
|
+
const results = [];
|
|
9
|
+
let ast;
|
|
10
|
+
try {
|
|
11
|
+
ast = parseRegExpLiteral(new RegExp(pattern, flags));
|
|
12
|
+
} catch {
|
|
13
|
+
return results;
|
|
14
|
+
}
|
|
15
|
+
visitRegExpAST(ast, { onCharacterEnter(node) {
|
|
16
|
+
if (node.raw === "\\b") results.push(node);
|
|
17
|
+
} });
|
|
18
|
+
return results;
|
|
19
|
+
}
|
|
20
|
+
var regexEscapeBackspaces_default = ruleCreator.createRule(typescriptLanguage, {
|
|
21
|
+
about: {
|
|
22
|
+
description: "Reports escape backspace (`[\\b]`) in character classes.",
|
|
23
|
+
id: "regexEscapeBackspaces",
|
|
24
|
+
presets: ["stylistic", "stylisticStrict"]
|
|
25
|
+
},
|
|
26
|
+
messages: { escapeBackspace: {
|
|
27
|
+
primary: "Prefer the clearer `\\u0008` instead of `[\\b]` for backspace character.",
|
|
28
|
+
secondary: [
|
|
29
|
+
"The `\\b` inside a character class matches the backspace character (U+0008).",
|
|
30
|
+
"Outside a character class, `\\b` is a word boundary assertion.",
|
|
31
|
+
"Using `\\u0008` makes the intent clearer."
|
|
32
|
+
],
|
|
33
|
+
suggestions: ["Replace `\\b` with `\\u0008`."]
|
|
34
|
+
} },
|
|
35
|
+
setup(context) {
|
|
36
|
+
function checkRegexLiteral(node, services) {
|
|
37
|
+
const { flags, pattern, start } = getRegExpLiteralDetails(node, services);
|
|
38
|
+
const backspaces = findEscapeBackspaces(pattern, flags);
|
|
39
|
+
for (const backspace of backspaces) context.report({
|
|
40
|
+
message: "escapeBackspace",
|
|
41
|
+
range: {
|
|
42
|
+
begin: start + backspace.start - 1,
|
|
43
|
+
end: start + backspace.end - 1
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function checkRegExpConstructor(node, services) {
|
|
48
|
+
const construction = getRegExpConstruction(node, services);
|
|
49
|
+
if (!construction) return;
|
|
50
|
+
const backspaces = findEscapeBackspaces(construction.pattern.replace(/\\\\/g, "\\"), construction.flags);
|
|
51
|
+
for (const backspace of backspaces) context.report({
|
|
52
|
+
message: "escapeBackspace",
|
|
53
|
+
range: {
|
|
54
|
+
begin: construction.start + backspace.start,
|
|
55
|
+
end: construction.start + backspace.end
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return { visitors: {
|
|
60
|
+
CallExpression: checkRegExpConstructor,
|
|
61
|
+
NewExpression: checkRegExpConstructor,
|
|
62
|
+
RegularExpressionLiteral: checkRegexLiteral
|
|
63
|
+
} };
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
//#endregion
|
|
67
|
+
export { regexEscapeBackspaces_default as default };
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=regexEscapeBackspaces.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Reports String.prototype.match calls that can be replaced with RegExp.prototype.exec.";
|
|
3
|
+
readonly id: "regexExecutors";
|
|
4
|
+
readonly presets: ["stylisticStrict"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("javascript" | "logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "preferExec", import("@flint.fyi/core").AnyOptionalSchema>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=regexExecutors.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ruleCreator } from "./ruleCreator.js";
|
|
2
|
+
import { getConstrainedTypeAtLocation } from "./utils/getConstrainedType.js";
|
|
3
|
+
import { getTSNodeRange, typescriptLanguage } from "@flint.fyi/typescript-language";
|
|
4
|
+
import ts from "typescript";
|
|
5
|
+
//#region src/rules/regexExecutors.ts
|
|
6
|
+
function getRegexFlags(node, sourceFile) {
|
|
7
|
+
switch (node.kind) {
|
|
8
|
+
case ts.SyntaxKind.CallExpression:
|
|
9
|
+
case ts.SyntaxKind.NewExpression:
|
|
10
|
+
if (ts.isIdentifier(node.expression) && node.expression.text === "RegExp" && node.arguments) {
|
|
11
|
+
if (node.arguments.length < 2) return "";
|
|
12
|
+
const flagsArg = node.arguments[1];
|
|
13
|
+
if (ts.isStringLiteral(flagsArg)) return flagsArg.text;
|
|
14
|
+
}
|
|
15
|
+
return;
|
|
16
|
+
case ts.SyntaxKind.RegularExpressionLiteral: {
|
|
17
|
+
const text = node.getText(sourceFile);
|
|
18
|
+
const lastSlash = text.lastIndexOf("/");
|
|
19
|
+
return lastSlash >= 0 ? text.slice(lastSlash + 1) : "";
|
|
20
|
+
}
|
|
21
|
+
default: return;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
var regexExecutors_default = ruleCreator.createRule(typescriptLanguage, {
|
|
25
|
+
about: {
|
|
26
|
+
description: "Reports String.prototype.match calls that can be replaced with RegExp.prototype.exec.",
|
|
27
|
+
id: "regexExecutors",
|
|
28
|
+
presets: ["stylisticStrict"]
|
|
29
|
+
},
|
|
30
|
+
messages: { preferExec: {
|
|
31
|
+
primary: "For consistency, prefer `RegExp.prototype.exec()` over `String.prototype.match()` when not using the global flag.",
|
|
32
|
+
secondary: ["`RegExp.prototype.exec()` is functionally identical to and slightly fewer characters than `String.prototype.match()` when the regex has no global flag.", "Choosing one by default leads to more consistent and therefore more readable code."],
|
|
33
|
+
suggestions: ["Switch from `String.prototype.match()` to `RegExp.prototype.exec()`.", "Add the global flag to the regular expression."]
|
|
34
|
+
} },
|
|
35
|
+
setup(context) {
|
|
36
|
+
return { visitors: { CallExpression: (node, { sourceFile, typeChecker }) => {
|
|
37
|
+
if (!ts.isPropertyAccessExpression(node.expression) || node.expression.name.text !== "match" || node.arguments.length < 1 || !(getConstrainedTypeAtLocation(node.expression.expression, typeChecker).flags & ts.TypeFlags.StringLike)) return;
|
|
38
|
+
const firstArgument = node.arguments[0];
|
|
39
|
+
if (!(typeChecker.getTypeAtLocation(node.expression.expression).flags & ts.TypeFlags.StringLike)) return;
|
|
40
|
+
const flags = getRegexFlags(firstArgument, sourceFile);
|
|
41
|
+
if (flags === void 0 || flags.includes("g")) return;
|
|
42
|
+
const range = getTSNodeRange(node, sourceFile);
|
|
43
|
+
const regexText = firstArgument.getText(sourceFile);
|
|
44
|
+
context.report({
|
|
45
|
+
fix: {
|
|
46
|
+
range,
|
|
47
|
+
text: `${regexText}.exec(${node.expression.expression.getText(sourceFile)})`
|
|
48
|
+
},
|
|
49
|
+
message: "preferExec",
|
|
50
|
+
range
|
|
51
|
+
});
|
|
52
|
+
} } };
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
//#endregion
|
|
56
|
+
export { regexExecutors_default as default };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=regexExecutors.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Reports string literals inside character classes with the `v` flag that contain multiple graphemes.";
|
|
3
|
+
readonly id: "regexGraphemeStringLiterals";
|
|
4
|
+
readonly presets: ["stylisticStrict"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("javascript" | "logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "multipleGraphemes", import("@flint.fyi/core").AnyOptionalSchema>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=regexGraphemeStringLiterals.d.ts.map
|