@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.
Files changed (813) hide show
  1. package/lib/index.d.ts +2 -13
  2. package/lib/index.js +2 -12
  3. package/lib/plugin.d.ts +2159 -232
  4. package/lib/plugin.js +609 -121
  5. package/lib/rules/accessorPairGroups.d.ts +10 -0
  6. package/lib/rules/accessorPairGroups.js +48 -0
  7. package/lib/rules/accessorPairTypes.d.ts +10 -0
  8. package/lib/rules/accessorPairTypes.js +72 -0
  9. package/lib/rules/accessorThisRecursion.d.ts +10 -0
  10. package/lib/rules/accessorThisRecursion.js +65 -0
  11. package/lib/rules/anyArguments.d.ts +10 -0
  12. package/lib/rules/anyArguments.js +234 -0
  13. package/lib/rules/anyAssignments.d.ts +10 -0
  14. package/lib/rules/anyAssignments.js +266 -0
  15. package/lib/rules/anyCalls.d.ts +10 -0
  16. package/lib/rules/anyCalls.js +68 -0
  17. package/lib/rules/anyMemberAccess.d.ts +10 -0
  18. package/lib/rules/anyMemberAccess.js +85 -0
  19. package/lib/rules/anyReturns.d.ts +5 -2
  20. package/lib/rules/anyReturns.js +97 -182
  21. package/lib/rules/arguments.d.ts +10 -0
  22. package/lib/rules/arguments.js +38 -0
  23. package/lib/rules/arrayCallbackReturns.d.ts +10 -0
  24. package/lib/rules/arrayCallbackReturns.js +73 -0
  25. package/lib/rules/arrayConstructors.d.ts +10 -0
  26. package/lib/rules/arrayConstructors.js +47 -0
  27. package/lib/rules/arrayDeleteUnnecessaryCounts.d.ts +10 -0
  28. package/lib/rules/arrayDeleteUnnecessaryCounts.js +54 -0
  29. package/lib/rules/arrayElementDeletions.d.ts +10 -0
  30. package/lib/rules/arrayElementDeletions.js +43 -0
  31. package/lib/rules/arrayEmptyCallbackSlots.d.ts +10 -0
  32. package/lib/rules/arrayEmptyCallbackSlots.js +45 -0
  33. package/lib/rules/arrayExistenceChecksConsistency.d.ts +10 -0
  34. package/lib/rules/arrayExistenceChecksConsistency.js +86 -0
  35. package/lib/rules/arrayFilteredFinds.d.ts +10 -0
  36. package/lib/rules/arrayFilteredFinds.js +80 -0
  37. package/lib/rules/arrayFinds.d.ts +10 -0
  38. package/lib/rules/arrayFinds.js +41 -0
  39. package/lib/rules/arrayFlatMapMethods.d.ts +10 -0
  40. package/lib/rules/arrayFlatMapMethods.js +47 -0
  41. package/lib/rules/arrayFlatMethods.d.ts +10 -0
  42. package/lib/rules/arrayFlatMethods.js +83 -0
  43. package/lib/rules/arrayFlatUnnecessaryDepths.d.ts +10 -0
  44. package/lib/rules/arrayFlatUnnecessaryDepths.js +33 -0
  45. package/lib/rules/arrayIncludes.d.ts +10 -0
  46. package/lib/rules/arrayIncludes.js +59 -0
  47. package/lib/rules/arrayIncludesMethods.d.ts +10 -0
  48. package/lib/rules/arrayIncludesMethods.js +37 -0
  49. package/lib/rules/arrayIndexOfMethods.d.ts +10 -0
  50. package/lib/rules/arrayIndexOfMethods.js +51 -0
  51. package/lib/rules/arrayLoops.d.ts +10 -0
  52. package/lib/rules/arrayLoops.js +36 -0
  53. package/lib/rules/arrayMapIdentities.d.ts +10 -0
  54. package/lib/rules/arrayMapIdentities.js +74 -0
  55. package/lib/rules/arrayMutableReverses.d.ts +10 -0
  56. package/lib/rules/arrayMutableReverses.js +39 -0
  57. package/lib/rules/arrayMutableSorts.d.ts +10 -0
  58. package/lib/rules/arrayMutableSorts.js +72 -0
  59. package/lib/rules/arrayReduceTypeArguments.d.ts +10 -0
  60. package/lib/rules/arrayReduceTypeArguments.js +64 -0
  61. package/lib/rules/arraySliceUnnecessaryEnd.d.ts +10 -0
  62. package/lib/rules/arraySliceUnnecessaryEnd.js +51 -0
  63. package/lib/rules/arraySomeMethods.d.ts +10 -0
  64. package/lib/rules/arraySomeMethods.js +77 -0
  65. package/lib/rules/arrayTernarySpreadingConsistency.d.ts +10 -0
  66. package/lib/rules/arrayTernarySpreadingConsistency.js +74 -0
  67. package/lib/rules/arrayTypes.d.ts +17 -0
  68. package/lib/rules/arrayTypes.js +111 -0
  69. package/lib/rules/arrayUnnecessaryLengthChecks.d.ts +10 -0
  70. package/lib/rules/arrayUnnecessaryLengthChecks.js +97 -0
  71. package/lib/rules/asConstAssertions.d.ts +10 -0
  72. package/lib/rules/asConstAssertions.js +57 -0
  73. package/lib/rules/assignmentOperatorShorthands.d.ts +10 -0
  74. package/lib/rules/assignmentOperatorShorthands.js +47 -0
  75. package/lib/rules/asyncPromiseExecutors.d.ts +5 -2
  76. package/lib/rules/asyncPromiseExecutors.js +39 -50
  77. package/lib/rules/asyncUnnecessaryPromiseWrappers.d.ts +10 -0
  78. package/lib/rules/asyncUnnecessaryPromiseWrappers.js +52 -0
  79. package/lib/rules/atAccesses.d.ts +10 -0
  80. package/lib/rules/atAccesses.js +52 -0
  81. package/lib/rules/builtinCoercions.d.ts +10 -0
  82. package/lib/rules/builtinCoercions.js +117 -0
  83. package/lib/rules/builtinConstructorNews.d.ts +10 -0
  84. package/lib/rules/builtinConstructorNews.js +89 -0
  85. package/lib/rules/caseDeclarations.d.ts +5 -3
  86. package/lib/rules/caseDeclarations.js +37 -51
  87. package/lib/rules/caseDuplicates.d.ts +5 -2
  88. package/lib/rules/caseDuplicates.js +34 -48
  89. package/lib/rules/caseFallthroughs.d.ts +10 -0
  90. package/lib/rules/caseFallthroughs.js +76 -0
  91. package/lib/rules/catchCallbackTypes.d.ts +10 -0
  92. package/lib/rules/catchCallbackTypes.js +67 -0
  93. package/lib/rules/caughtVariableNames.d.ts +10 -0
  94. package/lib/rules/caughtVariableNames.js +40 -0
  95. package/lib/rules/chainedAssignments.d.ts +5 -2
  96. package/lib/rules/chainedAssignments.js +30 -47
  97. package/lib/rules/charAtComparisons.d.ts +10 -0
  98. package/lib/rules/charAtComparisons.js +58 -0
  99. package/lib/rules/classAssignments.d.ts +5 -2
  100. package/lib/rules/classAssignments.js +30 -41
  101. package/lib/rules/classFieldDeclarations.d.ts +10 -0
  102. package/lib/rules/classFieldDeclarations.js +40 -0
  103. package/lib/rules/classLiteralProperties.d.ts +10 -0
  104. package/lib/rules/classLiteralProperties.js +45 -0
  105. package/lib/rules/classMemberDuplicates.d.ts +10 -0
  106. package/lib/rules/classMemberDuplicates.js +71 -0
  107. package/lib/rules/classMethodsThis.d.ts +14 -0
  108. package/lib/rules/classMethodsThis.js +124 -0
  109. package/lib/rules/combinedPushes.d.ts +10 -0
  110. package/lib/rules/combinedPushes.js +56 -0
  111. package/lib/rules/consecutiveNonNullAssertions.d.ts +5 -2
  112. package/lib/rules/consecutiveNonNullAssertions.js +37 -41
  113. package/lib/rules/consoleCalls.d.ts +9 -0
  114. package/lib/rules/consoleCalls.js +28 -0
  115. package/lib/rules/constantAssignments.d.ts +5 -2
  116. package/lib/rules/constantAssignments.js +42 -60
  117. package/lib/rules/constructorGenericCalls.d.ts +16 -0
  118. package/lib/rules/constructorGenericCalls.js +138 -0
  119. package/lib/rules/constructorReturns.d.ts +5 -2
  120. package/lib/rules/constructorReturns.js +38 -50
  121. package/lib/rules/constructorSupers.d.ts +10 -0
  122. package/lib/rules/constructorSupers.js +77 -0
  123. package/lib/rules/dateConstructorClones.d.ts +10 -0
  124. package/lib/rules/dateConstructorClones.js +37 -0
  125. package/lib/rules/dateNowTimestamps.d.ts +10 -0
  126. package/lib/rules/dateNowTimestamps.js +57 -0
  127. package/lib/rules/debuggerStatements.d.ts +5 -2
  128. package/lib/rules/debuggerStatements.js +31 -42
  129. package/lib/rules/defaultCaseLast.d.ts +5 -2
  130. package/lib/rules/defaultCaseLast.js +34 -42
  131. package/lib/rules/defaultParameterLast.d.ts +10 -0
  132. package/lib/rules/defaultParameterLast.js +42 -0
  133. package/lib/rules/deprecated.d.ts +10 -0
  134. package/lib/rules/deprecated.js +243 -0
  135. package/lib/rules/destructuringConsistency.d.ts +10 -0
  136. package/lib/rules/destructuringConsistency.js +112 -0
  137. package/lib/rules/duplicateArguments.d.ts +5 -3
  138. package/lib/rules/duplicateArguments.js +43 -50
  139. package/lib/rules/dynamicDeletes.d.ts +10 -0
  140. package/lib/rules/dynamicDeletes.js +37 -0
  141. package/lib/rules/elseIfDuplicates.d.ts +5 -2
  142. package/lib/rules/elseIfDuplicates.js +36 -52
  143. package/lib/rules/elseReturns.d.ts +10 -0
  144. package/lib/rules/elseReturns.js +67 -0
  145. package/lib/rules/emptyBlocks.d.ts +5 -2
  146. package/lib/rules/emptyBlocks.js +52 -64
  147. package/lib/rules/emptyDestructures.d.ts +5 -3
  148. package/lib/rules/emptyDestructures.js +32 -39
  149. package/lib/rules/emptyEnums.d.ts +10 -0
  150. package/lib/rules/emptyEnums.js +30 -0
  151. package/lib/rules/emptyExports.d.ts +10 -0
  152. package/lib/rules/emptyExports.js +60 -0
  153. package/lib/rules/emptyFiles.d.ts +10 -0
  154. package/lib/rules/emptyFiles.js +44 -0
  155. package/lib/rules/emptyFunctions.d.ts +10 -0
  156. package/lib/rules/emptyFunctions.js +61 -0
  157. package/lib/rules/emptyModuleAttributes.d.ts +10 -0
  158. package/lib/rules/emptyModuleAttributes.js +35 -0
  159. package/lib/rules/emptyObjectTypes.d.ts +10 -0
  160. package/lib/rules/emptyObjectTypes.js +47 -0
  161. package/lib/rules/emptyStaticBlocks.d.ts +5 -2
  162. package/lib/rules/emptyStaticBlocks.js +40 -53
  163. package/lib/rules/emptyTypeParameterLists.d.ts +10 -0
  164. package/lib/rules/emptyTypeParameterLists.js +31 -0
  165. package/lib/rules/enumInitializers.d.ts +10 -0
  166. package/lib/rules/enumInitializers.js +54 -0
  167. package/lib/rules/enumMemberLiterals.d.ts +10 -0
  168. package/lib/rules/enumMemberLiterals.js +39 -0
  169. package/lib/rules/enumValueConsistency.d.ts +10 -0
  170. package/lib/rules/enumValueConsistency.js +56 -0
  171. package/lib/rules/enumValueDuplicates.d.ts +10 -0
  172. package/lib/rules/enumValueDuplicates.js +60 -0
  173. package/lib/rules/equalityOperatorNegations.d.ts +9 -0
  174. package/lib/rules/equalityOperatorNegations.js +60 -0
  175. package/lib/rules/equalityOperators.d.ts +10 -0
  176. package/lib/rules/equalityOperators.js +44 -0
  177. package/lib/rules/errorMessages.d.ts +10 -0
  178. package/lib/rules/errorMessages.js +60 -0
  179. package/lib/rules/errorSubclassProperties.d.ts +10 -0
  180. package/lib/rules/errorSubclassProperties.js +144 -0
  181. package/lib/rules/errorUnnecessaryCaptureStackTraces.d.ts +10 -0
  182. package/lib/rules/errorUnnecessaryCaptureStackTraces.js +55 -0
  183. package/lib/rules/escapeSequenceCasing.d.ts +10 -0
  184. package/lib/rules/escapeSequenceCasing.js +75 -0
  185. package/lib/rules/evals.d.ts +10 -0
  186. package/lib/rules/evals.js +31 -0
  187. package/lib/rules/evolvingVariableTypes.d.ts +10 -0
  188. package/lib/rules/evolvingVariableTypes.js +33 -0
  189. package/lib/rules/exceptionAssignments.d.ts +5 -2
  190. package/lib/rules/exceptionAssignments.js +40 -60
  191. package/lib/rules/explicitAnys.d.ts +10 -0
  192. package/lib/rules/explicitAnys.js +55 -0
  193. package/lib/rules/exponentiationOperators.d.ts +10 -0
  194. package/lib/rules/exponentiationOperators.js +34 -0
  195. package/lib/rules/exportFromImports.d.ts +10 -0
  196. package/lib/rules/exportFromImports.js +119 -0
  197. package/lib/rules/exportMutables.d.ts +10 -0
  198. package/lib/rules/exportMutables.js +33 -0
  199. package/lib/rules/exportUniqueNames.d.ts +10 -0
  200. package/lib/rules/exportUniqueNames.js +65 -0
  201. package/lib/rules/extraneousClasses.d.ts +16 -0
  202. package/lib/rules/extraneousClasses.js +111 -0
  203. package/lib/rules/fetchMethodBodies.d.ts +10 -0
  204. package/lib/rules/fetchMethodBodies.js +72 -0
  205. package/lib/rules/finallyStatementSafety.d.ts +5 -2
  206. package/lib/rules/finallyStatementSafety.js +45 -69
  207. package/lib/rules/forDirections.d.ts +5 -2
  208. package/lib/rules/forDirections.js +67 -124
  209. package/lib/rules/forInArrays.d.ts +5 -2
  210. package/lib/rules/forInArrays.js +42 -50
  211. package/lib/rules/forInGuards.d.ts +9 -0
  212. package/lib/rules/forInGuards.js +44 -0
  213. package/lib/rules/functionApplySpreads.d.ts +10 -0
  214. package/lib/rules/functionApplySpreads.js +63 -0
  215. package/lib/rules/functionAssignments.d.ts +5 -2
  216. package/lib/rules/functionAssignments.js +30 -41
  217. package/lib/rules/functionCurryingRedundancy.d.ts +5 -2
  218. package/lib/rules/functionCurryingRedundancy.js +47 -71
  219. package/lib/rules/functionDeclarationStyles.d.ts +16 -0
  220. package/lib/rules/functionDeclarationStyles.js +67 -0
  221. package/lib/rules/functionNameMatches.d.ts +10 -0
  222. package/lib/rules/functionNameMatches.js +74 -0
  223. package/lib/rules/functionNewCalls.d.ts +5 -3
  224. package/lib/rules/functionNewCalls.js +40 -59
  225. package/lib/rules/generatorFunctionYields.d.ts +5 -3
  226. package/lib/rules/generatorFunctionYields.js +45 -53
  227. package/lib/rules/getterReturns.d.ts +10 -0
  228. package/lib/rules/getterReturns.js +65 -0
  229. package/lib/rules/globalAssignments.d.ts +5 -2
  230. package/lib/rules/globalAssignments.js +44 -57
  231. package/lib/rules/globalObjectCalls.d.ts +5 -3
  232. package/lib/rules/globalObjectCalls.js +40 -42
  233. package/lib/rules/globalThisAliases.d.ts +10 -0
  234. package/lib/rules/globalThisAliases.js +47 -0
  235. package/lib/rules/impliedEvals.d.ts +10 -0
  236. package/lib/rules/impliedEvals.js +130 -0
  237. package/lib/rules/importEmptyBlocks.d.ts +10 -0
  238. package/lib/rules/importEmptyBlocks.js +53 -0
  239. package/lib/rules/importTypeSideEffects.d.ts +10 -0
  240. package/lib/rules/importTypeSideEffects.js +31 -0
  241. package/lib/rules/indexedObjectTypes.d.ts +16 -0
  242. package/lib/rules/indexedObjectTypes.js +83 -0
  243. package/lib/rules/instanceOfArrays.d.ts +10 -0
  244. package/lib/rules/instanceOfArrays.js +31 -0
  245. package/lib/rules/irregularWhitespaces.d.ts +16 -0
  246. package/lib/rules/irregularWhitespaces.js +97 -0
  247. package/lib/rules/isNaNComparisons.d.ts +10 -0
  248. package/lib/rules/isNaNComparisons.js +43 -0
  249. package/lib/rules/literalConstructorWrappers.d.ts +10 -0
  250. package/lib/rules/literalConstructorWrappers.js +64 -0
  251. package/lib/rules/mathMethods.d.ts +10 -0
  252. package/lib/rules/mathMethods.js +128 -0
  253. package/lib/rules/meaninglessVoidOperators.d.ts +10 -0
  254. package/lib/rules/meaninglessVoidOperators.js +39 -0
  255. package/lib/rules/misleadingVoidExpressions.d.ts +10 -0
  256. package/lib/rules/misleadingVoidExpressions.js +128 -0
  257. package/lib/rules/moduleSpecifierLists.d.ts +10 -0
  258. package/lib/rules/moduleSpecifierLists.js +92 -0
  259. package/lib/rules/multilineAmbiguities.d.ts +10 -0
  260. package/lib/rules/multilineAmbiguities.js +64 -0
  261. package/lib/rules/namedDefaultExports.d.ts +10 -0
  262. package/lib/rules/namedDefaultExports.js +60 -0
  263. package/lib/rules/namespaceDeclarations.d.ts +6 -3
  264. package/lib/rules/namespaceDeclarations.js +34 -55
  265. package/lib/rules/namespaceImplicitAmbientImports.d.ts +10 -0
  266. package/lib/rules/namespaceImplicitAmbientImports.js +40 -0
  267. package/lib/rules/namespaceKeywords.d.ts +10 -0
  268. package/lib/rules/namespaceKeywords.js +40 -0
  269. package/lib/rules/nativeObjectExtensions.d.ts +10 -0
  270. package/lib/rules/nativeObjectExtensions.js +114 -0
  271. package/lib/rules/negativeIndexLengthMethods.d.ts +10 -0
  272. package/lib/rules/negativeIndexLengthMethods.js +180 -0
  273. package/lib/rules/negativeZeroComparisons.d.ts +5 -2
  274. package/lib/rules/negativeZeroComparisons.js +44 -62
  275. package/lib/rules/nestedStandaloneIfs.d.ts +10 -0
  276. package/lib/rules/nestedStandaloneIfs.js +105 -0
  277. package/lib/rules/newDefinitions.d.ts +10 -0
  278. package/lib/rules/newDefinitions.js +84 -0
  279. package/lib/rules/newExpressions.d.ts +5 -2
  280. package/lib/rules/newExpressions.js +36 -53
  281. package/lib/rules/newNativeNonConstructors.d.ts +5 -2
  282. package/lib/rules/newNativeNonConstructors.js +37 -48
  283. package/lib/rules/nonNullAssertedNullishCoalesces.d.ts +10 -0
  284. package/lib/rules/nonNullAssertedNullishCoalesces.js +63 -0
  285. package/lib/rules/nonNullAssertedOptionalChains.d.ts +10 -0
  286. package/lib/rules/nonNullAssertedOptionalChains.js +69 -0
  287. package/lib/rules/nonNullAssertionPlacement.d.ts +10 -0
  288. package/lib/rules/nonNullAssertionPlacement.js +94 -0
  289. package/lib/rules/nonNullableTypeAssertions.d.ts +10 -0
  290. package/lib/rules/nonNullableTypeAssertions.js +78 -0
  291. package/lib/rules/nonOctalDecimalEscapes.d.ts +5 -3
  292. package/lib/rules/nonOctalDecimalEscapes.js +45 -55
  293. package/lib/rules/nullishCheckStyle.d.ts +21 -0
  294. package/lib/rules/nullishCheckStyle.js +144 -0
  295. package/lib/rules/nullishCoalescingOperators.d.ts +22 -0
  296. package/lib/rules/nullishCoalescingOperators.js +311 -0
  297. package/lib/rules/numberMethodRanges.d.ts +10 -0
  298. package/lib/rules/numberMethodRanges.js +74 -0
  299. package/lib/rules/numberStaticMethods.d.ts +10 -0
  300. package/lib/rules/numberStaticMethods.js +53 -0
  301. package/lib/rules/numericErasingOperations.d.ts +10 -0
  302. package/lib/rules/numericErasingOperations.js +46 -0
  303. package/lib/rules/numericLiteralParsing.d.ts +5 -2
  304. package/lib/rules/numericLiteralParsing.js +58 -90
  305. package/lib/rules/numericPrecision.d.ts +10 -0
  306. package/lib/rules/numericPrecision.js +102 -0
  307. package/lib/rules/numericSeparatorGroups.d.ts +10 -0
  308. package/lib/rules/numericSeparatorGroups.js +101 -0
  309. package/lib/rules/objectAssignSpreads.d.ts +10 -0
  310. package/lib/rules/objectAssignSpreads.js +53 -0
  311. package/lib/rules/objectCalls.d.ts +5 -2
  312. package/lib/rules/objectCalls.js +36 -45
  313. package/lib/rules/objectEntriesMethods.d.ts +10 -0
  314. package/lib/rules/objectEntriesMethods.js +82 -0
  315. package/lib/rules/objectHasOwns.d.ts +5 -2
  316. package/lib/rules/objectHasOwns.js +48 -72
  317. package/lib/rules/objectKeyDuplicates.d.ts +5 -2
  318. package/lib/rules/objectKeyDuplicates.js +57 -85
  319. package/lib/rules/objectProto.d.ts +5 -2
  320. package/lib/rules/objectProto.js +48 -53
  321. package/lib/rules/objectPrototypeBuiltIns.d.ts +5 -2
  322. package/lib/rules/objectPrototypeBuiltIns.js +48 -59
  323. package/lib/rules/objectShorthand.d.ts +10 -0
  324. package/lib/rules/objectShorthand.js +84 -0
  325. package/lib/rules/objectSpreadUnnecessaryFallbacks.d.ts +10 -0
  326. package/lib/rules/objectSpreadUnnecessaryFallbacks.js +43 -0
  327. package/lib/rules/objectTypeDefinitions.d.ts +10 -0
  328. package/lib/rules/objectTypeDefinitions.js +34 -0
  329. package/lib/rules/octalEscapes.d.ts +5 -2
  330. package/lib/rules/octalEscapes.js +53 -71
  331. package/lib/rules/octalNumbers.d.ts +5 -2
  332. package/lib/rules/octalNumbers.js +53 -67
  333. package/lib/rules/operatorAssignmentShorthand.d.ts +10 -0
  334. package/lib/rules/operatorAssignmentShorthand.js +77 -0
  335. package/lib/rules/overloadSignaturesAdjacent.d.ts +10 -0
  336. package/lib/rules/overloadSignaturesAdjacent.js +140 -0
  337. package/lib/rules/parameterReassignments.d.ts +10 -0
  338. package/lib/rules/parameterReassignments.js +76 -0
  339. package/lib/rules/parseIntRadixes.d.ts +10 -0
  340. package/lib/rules/parseIntRadixes.js +62 -0
  341. package/lib/rules/propertyAccessNotation.d.ts +13 -0
  342. package/lib/rules/propertyAccessNotation.js +119 -0
  343. package/lib/rules/recursionOnlyArguments.d.ts +10 -0
  344. package/lib/rules/recursionOnlyArguments.js +71 -0
  345. package/lib/rules/redundantTypeConstituents.d.ts +10 -0
  346. package/lib/rules/redundantTypeConstituents.js +277 -0
  347. package/lib/rules/regexAllGlobalFlags.d.ts +10 -0
  348. package/lib/rules/regexAllGlobalFlags.js +56 -0
  349. package/lib/rules/regexAmbiguousInvalidity.d.ts +10 -0
  350. package/lib/rules/regexAmbiguousInvalidity.js +297 -0
  351. package/lib/rules/regexCharacterClassRanges.d.ts +10 -0
  352. package/lib/rules/regexCharacterClassRanges.js +137 -0
  353. package/lib/rules/regexCharacterClassSetOperations.d.ts +10 -0
  354. package/lib/rules/regexCharacterClassSetOperations.js +81 -0
  355. package/lib/rules/regexCharacterClasses.d.ts +10 -0
  356. package/lib/rules/regexCharacterClasses.js +234 -0
  357. package/lib/rules/regexConciseCharacterClassNegations.d.ts +10 -0
  358. package/lib/rules/regexConciseCharacterClassNegations.js +52 -0
  359. package/lib/rules/regexContradictoryAssertions.d.ts +10 -0
  360. package/lib/rules/regexContradictoryAssertions.js +210 -0
  361. package/lib/rules/regexControlCharacterEscapes.d.ts +10 -0
  362. package/lib/rules/regexControlCharacterEscapes.js +130 -0
  363. package/lib/rules/regexControlCharacters.d.ts +10 -0
  364. package/lib/rules/regexControlCharacters.js +95 -0
  365. package/lib/rules/regexDigitMatchers.d.ts +10 -0
  366. package/lib/rules/regexDigitMatchers.js +180 -0
  367. package/lib/rules/regexDollarEscapes.d.ts +10 -0
  368. package/lib/rules/regexDollarEscapes.js +91 -0
  369. package/lib/rules/regexDuplicateCharacterClassCharacters.d.ts +10 -0
  370. package/lib/rules/regexDuplicateCharacterClassCharacters.js +128 -0
  371. package/lib/rules/regexEmptyAlternatives.d.ts +10 -0
  372. package/lib/rules/regexEmptyAlternatives.js +140 -0
  373. package/lib/rules/regexEmptyCapturingGroups.d.ts +10 -0
  374. package/lib/rules/regexEmptyCapturingGroups.js +67 -0
  375. package/lib/rules/regexEmptyCharacterClasses.d.ts +10 -0
  376. package/lib/rules/regexEmptyCharacterClasses.js +68 -0
  377. package/lib/rules/regexEmptyGroups.d.ts +10 -0
  378. package/lib/rules/regexEmptyGroups.js +66 -0
  379. package/lib/rules/regexEmptyLazyQuantifiers.d.ts +10 -0
  380. package/lib/rules/regexEmptyLazyQuantifiers.js +92 -0
  381. package/lib/rules/regexEmptyLookaroundsAssertions.d.ts +10 -0
  382. package/lib/rules/regexEmptyLookaroundsAssertions.js +68 -0
  383. package/lib/rules/regexEmptyStringLiterals.d.ts +10 -0
  384. package/lib/rules/regexEmptyStringLiterals.js +66 -0
  385. package/lib/rules/regexEscapeBackspaces.d.ts +10 -0
  386. package/lib/rules/regexEscapeBackspaces.js +69 -0
  387. package/lib/rules/regexExecutors.d.ts +10 -0
  388. package/lib/rules/regexExecutors.js +58 -0
  389. package/lib/rules/regexGraphemeStringLiterals.d.ts +10 -0
  390. package/lib/rules/regexGraphemeStringLiterals.js +51 -0
  391. package/lib/rules/regexHexadecimalEscapes.d.ts +10 -0
  392. package/lib/rules/regexHexadecimalEscapes.js +71 -0
  393. package/lib/rules/regexIgnoreCaseFlags.d.ts +10 -0
  394. package/lib/rules/regexIgnoreCaseFlags.js +145 -0
  395. package/lib/rules/regexInvisibleCharacters.d.ts +10 -0
  396. package/lib/rules/regexInvisibleCharacters.js +90 -0
  397. package/lib/rules/regexLetterCasing.d.ts +10 -0
  398. package/lib/rules/regexLetterCasing.js +186 -0
  399. package/lib/rules/regexLiterals.d.ts +10 -0
  400. package/lib/rules/regexLiterals.js +92 -0
  401. package/lib/rules/regexLookaroundAssertions.d.ts +10 -0
  402. package/lib/rules/regexLookaroundAssertions.js +163 -0
  403. package/lib/rules/regexLookaroundQuantifierOptimizations.d.ts +10 -0
  404. package/lib/rules/regexLookaroundQuantifierOptimizations.js +94 -0
  405. package/lib/rules/regexMatchNotation.d.ts +10 -0
  406. package/lib/rules/regexMatchNotation.js +139 -0
  407. package/lib/rules/regexMisleadingCapturingGroups.d.ts +10 -0
  408. package/lib/rules/regexMisleadingCapturingGroups.js +229 -0
  409. package/lib/rules/regexMisleadingQuantifiers.d.ts +10 -0
  410. package/lib/rules/regexMisleadingQuantifiers.js +78 -0
  411. package/lib/rules/regexMisleadingUnicodeCharacters.d.ts +10 -0
  412. package/lib/rules/regexMisleadingUnicodeCharacters.js +203 -0
  413. package/lib/rules/regexNamedBackreferences.d.ts +10 -0
  414. package/lib/rules/regexNamedBackreferences.js +48 -0
  415. package/lib/rules/regexNamedCaptureGroups.d.ts +9 -0
  416. package/lib/rules/regexNamedCaptureGroups.js +67 -0
  417. package/lib/rules/regexNamedReplacements.d.ts +10 -0
  418. package/lib/rules/regexNamedReplacements.js +93 -0
  419. package/lib/rules/regexNonStandardFlags.d.ts +10 -0
  420. package/lib/rules/regexNonStandardFlags.js +66 -0
  421. package/lib/rules/regexObscureRanges.d.ts +10 -0
  422. package/lib/rules/regexObscureRanges.js +93 -0
  423. package/lib/rules/regexOctalEscapes.d.ts +10 -0
  424. package/lib/rules/regexOctalEscapes.js +70 -0
  425. package/lib/rules/regexPlusQuantifiers.d.ts +10 -0
  426. package/lib/rules/regexPlusQuantifiers.js +68 -0
  427. package/lib/rules/regexPredefinedAssertions.d.ts +10 -0
  428. package/lib/rules/regexPredefinedAssertions.js +127 -0
  429. package/lib/rules/regexQuestionQuantifiers.d.ts +10 -0
  430. package/lib/rules/regexQuestionQuantifiers.js +104 -0
  431. package/lib/rules/regexRepeatQuantifiers.d.ts +10 -0
  432. package/lib/rules/regexRepeatQuantifiers.js +96 -0
  433. package/lib/rules/regexResultArrayGroups.d.ts +10 -0
  434. package/lib/rules/regexResultArrayGroups.js +187 -0
  435. package/lib/rules/regexSetOperationOptimizations.d.ts +10 -0
  436. package/lib/rules/regexSetOperationOptimizations.js +177 -0
  437. package/lib/rules/regexStandaloneBackslashes.d.ts +10 -0
  438. package/lib/rules/regexStandaloneBackslashes.js +59 -0
  439. package/lib/rules/regexStarQuantifiers.d.ts +10 -0
  440. package/lib/rules/regexStarQuantifiers.js +68 -0
  441. package/lib/rules/regexSuperLinearBacktracking.d.ts +10 -0
  442. package/lib/rules/regexSuperLinearBacktracking.js +98 -0
  443. package/lib/rules/regexSuperLinearMoves.d.ts +10 -0
  444. package/lib/rules/regexSuperLinearMoves.js +142 -0
  445. package/lib/rules/regexTestMethods.d.ts +10 -0
  446. package/lib/rules/regexTestMethods.js +83 -0
  447. package/lib/rules/regexUnicodeCodepointEscapes.d.ts +10 -0
  448. package/lib/rules/regexUnicodeCodepointEscapes.js +107 -0
  449. package/lib/rules/regexUnicodeEscapes.d.ts +9 -0
  450. package/lib/rules/regexUnicodeEscapes.js +97 -0
  451. package/lib/rules/regexUnicodeFlag.d.ts +9 -0
  452. package/lib/rules/regexUnicodeFlag.js +97 -0
  453. package/lib/rules/regexUnicodeProperties.d.ts +10 -0
  454. package/lib/rules/regexUnicodeProperties.js +133 -0
  455. package/lib/rules/regexUnnecessaryAssertions.d.ts +10 -0
  456. package/lib/rules/regexUnnecessaryAssertions.js +223 -0
  457. package/lib/rules/regexUnnecessaryBackreferences.d.ts +10 -0
  458. package/lib/rules/regexUnnecessaryBackreferences.js +125 -0
  459. package/lib/rules/regexUnnecessaryCharacterClasses.d.ts +10 -0
  460. package/lib/rules/regexUnnecessaryCharacterClasses.js +74 -0
  461. package/lib/rules/regexUnnecessaryCharacterRanges.d.ts +10 -0
  462. package/lib/rules/regexUnnecessaryCharacterRanges.js +108 -0
  463. package/lib/rules/regexUnnecessaryDisjunctions.d.ts +10 -0
  464. package/lib/rules/regexUnnecessaryDisjunctions.js +118 -0
  465. package/lib/rules/regexUnnecessaryDollarReplacements.d.ts +10 -0
  466. package/lib/rules/regexUnnecessaryDollarReplacements.js +144 -0
  467. package/lib/rules/regexUnnecessaryEscapes.d.ts +10 -0
  468. package/lib/rules/regexUnnecessaryEscapes.js +136 -0
  469. package/lib/rules/regexUnnecessaryLookaroundAssertions.d.ts +10 -0
  470. package/lib/rules/regexUnnecessaryLookaroundAssertions.js +80 -0
  471. package/lib/rules/regexUnnecessaryNestedAssertions.d.ts +10 -0
  472. package/lib/rules/regexUnnecessaryNestedAssertions.js +198 -0
  473. package/lib/rules/regexUnnecessaryNestedQuantifiers.d.ts +10 -0
  474. package/lib/rules/regexUnnecessaryNestedQuantifiers.js +93 -0
  475. package/lib/rules/regexUnnecessaryNonCapturingGroups.d.ts +10 -0
  476. package/lib/rules/regexUnnecessaryNonCapturingGroups.js +104 -0
  477. package/lib/rules/regexUnnecessaryNumericQuantifiers.d.ts +10 -0
  478. package/lib/rules/regexUnnecessaryNumericQuantifiers.js +69 -0
  479. package/lib/rules/regexUnnecessaryOptionalAssertions.d.ts +10 -0
  480. package/lib/rules/regexUnnecessaryOptionalAssertions.js +137 -0
  481. package/lib/rules/regexUnnecessaryReferentialBackreferences.d.ts +10 -0
  482. package/lib/rules/regexUnnecessaryReferentialBackreferences.js +123 -0
  483. package/lib/rules/regexUnnecessarySetOperands.d.ts +10 -0
  484. package/lib/rules/regexUnnecessarySetOperands.js +136 -0
  485. package/lib/rules/regexUnusedCapturingGroups.d.ts +10 -0
  486. package/lib/rules/regexUnusedCapturingGroups.js +69 -0
  487. package/lib/rules/regexUnusedFlags.d.ts +10 -0
  488. package/lib/rules/regexUnusedFlags.js +116 -0
  489. package/lib/rules/regexUnusedLazyQuantifiers.d.ts +10 -0
  490. package/lib/rules/regexUnusedLazyQuantifiers.js +63 -0
  491. package/lib/rules/regexUnusedQuantifiers.d.ts +10 -0
  492. package/lib/rules/regexUnusedQuantifiers.js +63 -0
  493. package/lib/rules/regexValidity.d.ts +10 -0
  494. package/lib/rules/regexValidity.js +146 -0
  495. package/lib/rules/regexWordMatchers.d.ts +10 -0
  496. package/lib/rules/regexWordMatchers.js +146 -0
  497. package/lib/rules/regexZeroQuantifiers.d.ts +10 -0
  498. package/lib/rules/regexZeroQuantifiers.js +60 -0
  499. package/lib/rules/responseJsonMethods.d.ts +10 -0
  500. package/lib/rules/responseJsonMethods.js +51 -0
  501. package/lib/rules/restrictedIdentifiers.d.ts +13 -0
  502. package/lib/rules/restrictedIdentifiers.js +41 -0
  503. package/lib/rules/returnAssignments.d.ts +5 -2
  504. package/lib/rules/returnAssignments.js +35 -48
  505. package/lib/rules/returnThisTypes.d.ts +10 -0
  506. package/lib/rules/returnThisTypes.js +94 -0
  507. package/lib/rules/ruleCreator.d.ts +3 -0
  508. package/lib/rules/ruleCreator.js +17 -0
  509. package/lib/rules/selfAssignments.d.ts +5 -2
  510. package/lib/rules/selfAssignments.js +27 -43
  511. package/lib/rules/sequences.d.ts +5 -2
  512. package/lib/rules/sequences.js +26 -33
  513. package/lib/rules/setSizeLengthChecks.d.ts +10 -0
  514. package/lib/rules/setSizeLengthChecks.js +48 -0
  515. package/lib/rules/setterReturns.d.ts +10 -0
  516. package/lib/rules/setterReturns.js +41 -0
  517. package/lib/rules/shadowedRestrictedNames.d.ts +5 -2
  518. package/lib/rules/shadowedRestrictedNames.js +64 -92
  519. package/lib/rules/singleVariableDeclarations.d.ts +10 -0
  520. package/lib/rules/singleVariableDeclarations.js +36 -0
  521. package/lib/rules/sizeComparisonOperators.d.ts +16 -0
  522. package/lib/rules/sizeComparisonOperators.js +148 -0
  523. package/lib/rules/sparseArrays.d.ts +5 -2
  524. package/lib/rules/sparseArrays.js +41 -53
  525. package/lib/rules/staticMemberOnlyClasses.d.ts +10 -0
  526. package/lib/rules/staticMemberOnlyClasses.js +77 -0
  527. package/lib/rules/stringCaseMismatches.d.ts +10 -0
  528. package/lib/rules/stringCaseMismatches.js +58 -0
  529. package/lib/rules/stringCodePoints.d.ts +10 -0
  530. package/lib/rules/stringCodePoints.js +50 -0
  531. package/lib/rules/stringSliceMethods.d.ts +10 -0
  532. package/lib/rules/stringSliceMethods.js +47 -0
  533. package/lib/rules/stringStartsEndsWith.d.ts +10 -0
  534. package/lib/rules/stringStartsEndsWith.js +79 -0
  535. package/lib/rules/structuredCloneMethods.d.ts +10 -0
  536. package/lib/rules/structuredCloneMethods.js +39 -0
  537. package/lib/rules/symbolDescriptions.d.ts +5 -2
  538. package/lib/rules/symbolDescriptions.js +30 -40
  539. package/lib/rules/thisAliases.d.ts +10 -0
  540. package/lib/rules/thisAliases.js +44 -0
  541. package/lib/rules/thisBeforeSuper.d.ts +10 -0
  542. package/lib/rules/thisBeforeSuper.js +86 -0
  543. package/lib/rules/throwErrors.d.ts +10 -0
  544. package/lib/rules/throwErrors.js +61 -0
  545. package/lib/rules/topLevelAwaits.d.ts +10 -0
  546. package/lib/rules/topLevelAwaits.js +49 -0
  547. package/lib/rules/tripleSlashReferenceValidity.d.ts +10 -0
  548. package/lib/rules/tripleSlashReferenceValidity.js +54 -0
  549. package/lib/rules/tripleSlashReferences.d.ts +10 -0
  550. package/lib/rules/tripleSlashReferences.js +34 -0
  551. package/lib/rules/tsComments.d.ts +22 -0
  552. package/lib/rules/tsComments.js +130 -0
  553. package/lib/rules/tslintComments.d.ts +10 -0
  554. package/lib/rules/tslintComments.js +36 -0
  555. package/lib/rules/typeAssertionStyles.d.ts +10 -0
  556. package/lib/rules/typeAssertionStyles.js +32 -0
  557. package/lib/rules/typeofComparisons.d.ts +5 -2
  558. package/lib/rules/typeofComparisons.js +50 -71
  559. package/lib/rules/unassignedVariables.d.ts +5 -2
  560. package/lib/rules/unassignedVariables.js +35 -54
  561. package/lib/rules/undefinedTypeofChecks.d.ts +10 -0
  562. package/lib/rules/undefinedTypeofChecks.js +41 -0
  563. package/lib/rules/undefinedVariables.d.ts +5 -2
  564. package/lib/rules/undefinedVariables.js +37 -75
  565. package/lib/rules/unicodeBOMs.d.ts +5 -2
  566. package/lib/rules/unicodeBOMs.js +37 -46
  567. package/lib/rules/unnecessaryBinds.d.ts +10 -0
  568. package/lib/rules/unnecessaryBinds.js +78 -0
  569. package/lib/rules/unnecessaryBlocks.d.ts +5 -2
  570. package/lib/rules/unnecessaryBlocks.js +58 -74
  571. package/lib/rules/unnecessaryBooleanCasts.d.ts +10 -0
  572. package/lib/rules/unnecessaryBooleanCasts.js +58 -0
  573. package/lib/rules/unnecessaryCatches.d.ts +5 -2
  574. package/lib/rules/unnecessaryCatches.js +46 -67
  575. package/lib/rules/unnecessaryComparisons.d.ts +10 -0
  576. package/lib/rules/unnecessaryComparisons.js +300 -0
  577. package/lib/rules/unnecessaryConcatenation.d.ts +5 -2
  578. package/lib/rules/unnecessaryConcatenation.js +26 -37
  579. package/lib/rules/unnecessaryEscapes.d.ts +10 -0
  580. package/lib/rules/unnecessaryEscapes.js +134 -0
  581. package/lib/rules/unnecessaryMathClamps.d.ts +10 -0
  582. package/lib/rules/unnecessaryMathClamps.js +114 -0
  583. package/lib/rules/unnecessaryNumericFractions.d.ts +10 -0
  584. package/lib/rules/unnecessaryNumericFractions.js +50 -0
  585. package/lib/rules/unnecessaryRenames.d.ts +10 -0
  586. package/lib/rules/unnecessaryRenames.js +92 -0
  587. package/lib/rules/unnecessaryTernaries.d.ts +10 -0
  588. package/lib/rules/unnecessaryTernaries.js +88 -0
  589. package/lib/rules/unnecessaryUseStricts.d.ts +10 -0
  590. package/lib/rules/unnecessaryUseStricts.js +40 -0
  591. package/lib/rules/unsafeNegations.d.ts +5 -2
  592. package/lib/rules/unsafeNegations.js +36 -49
  593. package/lib/rules/utils/collectAccessorPairs.d.ts +12 -0
  594. package/lib/rules/utils/collectAccessorPairs.js +29 -0
  595. package/lib/rules/utils/countCommentsInRange.d.ts +3 -0
  596. package/lib/rules/utils/countCommentsInRange.js +12 -0
  597. package/lib/rules/utils/discriminateAnyType.d.ts +12 -9
  598. package/lib/rules/utils/discriminateAnyType.js +33 -37
  599. package/lib/rules/utils/equalityOperators.d.ts +9 -0
  600. package/lib/rules/utils/equalityOperators.js +36 -0
  601. package/lib/rules/utils/forEachReturnStatement.d.ts +3 -0
  602. package/lib/rules/utils/forEachReturnStatement.js +29 -0
  603. package/lib/rules/utils/formatReportedType.d.ts +4 -0
  604. package/lib/rules/utils/formatReportedType.js +9 -0
  605. package/lib/rules/utils/getConstrainedType.d.ts +2 -2
  606. package/lib/rules/utils/getConstrainedType.js +7 -3
  607. package/lib/rules/utils/getFunctionName.d.ts +3 -0
  608. package/lib/rules/utils/getFunctionName.js +16 -0
  609. package/lib/rules/utils/getRegExpConstruction.d.ts +10 -0
  610. package/lib/rules/utils/getRegExpConstruction.js +26 -0
  611. package/lib/rules/utils/getRegExpLiteralDetails.d.ts +7 -0
  612. package/lib/rules/utils/getRegExpLiteralDetails.js +13 -0
  613. package/lib/rules/utils/getThisExpression.d.ts +2 -2
  614. package/lib/rules/utils/getThisExpression.js +14 -22
  615. package/lib/rules/utils/isArrayOrTupleTypeAtLocation.d.ts +3 -0
  616. package/lib/rules/utils/isArrayOrTupleTypeAtLocation.js +13 -0
  617. package/lib/rules/utils/isBuiltinSymbolLike.d.ts +3 -0
  618. package/lib/rules/utils/isBuiltinSymbolLike.js +33 -0
  619. package/lib/rules/utils/isDirectEqualityCheck.d.ts +4 -0
  620. package/lib/rules/utils/isDirectEqualityCheck.js +29 -0
  621. package/lib/rules/utils/isErrorSubclass.d.ts +3 -0
  622. package/lib/rules/utils/isErrorSubclass.js +27 -0
  623. package/lib/rules/utils/isInBooleanContext.d.ts +3 -0
  624. package/lib/rules/utils/isInBooleanContext.js +22 -0
  625. package/lib/rules/utils/isTypeRecursive.d.ts +1 -1
  626. package/lib/rules/utils/isTypeRecursive.js +6 -4
  627. package/lib/rules/utils/isUnsafeAssignment.d.ts +3 -2
  628. package/lib/rules/utils/isUnsafeAssignment.js +40 -72
  629. package/lib/rules/utils/operators.d.ts +4 -4
  630. package/lib/rules/utils/operators.js +31 -33
  631. package/lib/rules/utils/parseRegexpAst.d.ts +2 -0
  632. package/lib/rules/utils/parseRegexpAst.js +17 -0
  633. package/lib/rules/utils/parseRegexpAstFull.d.ts +3 -0
  634. package/lib/rules/utils/parseRegexpAstFull.js +18 -0
  635. package/lib/rules/utils/skipParentheses.d.ts +3 -0
  636. package/lib/rules/utils/skipParentheses.js +10 -0
  637. package/lib/rules/variableDeletions.d.ts +5 -2
  638. package/lib/rules/variableDeletions.js +33 -38
  639. package/lib/rules/voidOperator.d.ts +5 -2
  640. package/lib/rules/voidOperator.js +32 -35
  641. package/lib/rules/withStatements.d.ts +5 -2
  642. package/lib/rules/withStatements.js +28 -35
  643. package/lib/rules/wrapperObjects.d.ts +10 -0
  644. package/lib/rules/wrapperObjects.js +36 -0
  645. package/package.json +17 -11
  646. package/lib/collectReferencedFilePaths.d.ts +0 -3
  647. package/lib/collectReferencedFilePaths.js +0 -22
  648. package/lib/convertTypeScriptDiagnosticToLanguageFileDiagnostic.d.ts +0 -14
  649. package/lib/convertTypeScriptDiagnosticToLanguageFileDiagnostic.js +0 -129
  650. package/lib/createTypeScriptFileFromProgram.d.ts +0 -6
  651. package/lib/createTypeScriptFileFromProgram.js +0 -58
  652. package/lib/createTypeScriptFileFromProjectService.d.ts +0 -7
  653. package/lib/createTypeScriptFileFromProjectService.js +0 -14
  654. package/lib/directives/parseDirectivesFromTypeScriptFile.d.ts +0 -13
  655. package/lib/directives/parseDirectivesFromTypeScriptFile.js +0 -29
  656. package/lib/directives/parseDirectivesFromTypeScriptFile.test.d.ts +0 -2
  657. package/lib/directives/parseDirectivesFromTypeScriptFile.test.js +0 -92
  658. package/lib/getFirstEnumValues.d.ts +0 -36
  659. package/lib/getFirstEnumValues.js +0 -52
  660. package/lib/getFirstEnumValues.test.d.ts +0 -2
  661. package/lib/getFirstEnumValues.test.js +0 -46
  662. package/lib/getTSNodeRange.d.ts +0 -4
  663. package/lib/getTSNodeRange.js +0 -7
  664. package/lib/language.d.ts +0 -9
  665. package/lib/language.js +0 -20
  666. package/lib/nodes.d.ts +0 -143
  667. package/lib/nodes.js +0 -2
  668. package/lib/normalizeRange.d.ts +0 -4
  669. package/lib/normalizeRange.js +0 -14
  670. package/lib/prepareTypeScriptBasedLanguage.d.ts +0 -11
  671. package/lib/prepareTypeScriptBasedLanguage.js +0 -59
  672. package/lib/prepareTypeScriptFile.d.ts +0 -12
  673. package/lib/prepareTypeScriptFile.js +0 -13
  674. package/lib/rules/anyReturns.test.d.ts +0 -2
  675. package/lib/rules/anyReturns.test.js +0 -648
  676. package/lib/rules/asyncPromiseExecutors.test.d.ts +0 -2
  677. package/lib/rules/asyncPromiseExecutors.test.js +0 -72
  678. package/lib/rules/caseDeclarations.test.d.ts +0 -2
  679. package/lib/rules/caseDeclarations.test.js +0 -228
  680. package/lib/rules/caseDuplicates.test.d.ts +0 -2
  681. package/lib/rules/caseDuplicates.test.js +0 -308
  682. package/lib/rules/chainedAssignments.test.d.ts +0 -2
  683. package/lib/rules/chainedAssignments.test.js +0 -263
  684. package/lib/rules/classAssignments.test.d.ts +0 -2
  685. package/lib/rules/classAssignments.test.js +0 -157
  686. package/lib/rules/consecutiveNonNullAssertions.test.d.ts +0 -2
  687. package/lib/rules/consecutiveNonNullAssertions.test.js +0 -33
  688. package/lib/rules/constantAssignments.test.d.ts +0 -2
  689. package/lib/rules/constantAssignments.test.js +0 -222
  690. package/lib/rules/constructorReturns.test.d.ts +0 -2
  691. package/lib/rules/constructorReturns.test.js +0 -97
  692. package/lib/rules/debuggerStatements.test.d.ts +0 -2
  693. package/lib/rules/debuggerStatements.test.js +0 -81
  694. package/lib/rules/defaultCaseLast.test.d.ts +0 -2
  695. package/lib/rules/defaultCaseLast.test.js +0 -196
  696. package/lib/rules/duplicateArguments.test.d.ts +0 -2
  697. package/lib/rules/duplicateArguments.test.js +0 -140
  698. package/lib/rules/elseIfDuplicates.test.d.ts +0 -2
  699. package/lib/rules/elseIfDuplicates.test.js +0 -177
  700. package/lib/rules/emptyBlocks.test.d.ts +0 -2
  701. package/lib/rules/emptyBlocks.test.js +0 -136
  702. package/lib/rules/emptyDestructures.test.d.ts +0 -2
  703. package/lib/rules/emptyDestructures.test.js +0 -187
  704. package/lib/rules/emptyStaticBlocks.test.d.ts +0 -2
  705. package/lib/rules/emptyStaticBlocks.test.js +0 -168
  706. package/lib/rules/exceptionAssignments.test.d.ts +0 -2
  707. package/lib/rules/exceptionAssignments.test.js +0 -265
  708. package/lib/rules/finallyStatementSafety.test.d.ts +0 -2
  709. package/lib/rules/finallyStatementSafety.test.js +0 -307
  710. package/lib/rules/forDirections.test.d.ts +0 -2
  711. package/lib/rules/forDirections.test.js +0 -125
  712. package/lib/rules/forInArrays.test.d.ts +0 -2
  713. package/lib/rules/forInArrays.test.js +0 -25
  714. package/lib/rules/functionAssignments.test.d.ts +0 -2
  715. package/lib/rules/functionAssignments.test.js +0 -210
  716. package/lib/rules/functionCurryingRedundancy.test.d.ts +0 -2
  717. package/lib/rules/functionCurryingRedundancy.test.js +0 -172
  718. package/lib/rules/functionNewCalls.test.d.ts +0 -2
  719. package/lib/rules/functionNewCalls.test.js +0 -116
  720. package/lib/rules/generatorFunctionYields.test.d.ts +0 -2
  721. package/lib/rules/generatorFunctionYields.test.js +0 -152
  722. package/lib/rules/globalAssignments.test.d.ts +0 -2
  723. package/lib/rules/globalAssignments.test.js +0 -216
  724. package/lib/rules/globalObjectCalls.test.d.ts +0 -2
  725. package/lib/rules/globalObjectCalls.test.js +0 -94
  726. package/lib/rules/namespaceDeclarations.test.d.ts +0 -2
  727. package/lib/rules/namespaceDeclarations.test.js +0 -41
  728. package/lib/rules/negativeZeroComparisons.test.d.ts +0 -2
  729. package/lib/rules/negativeZeroComparisons.test.js +0 -210
  730. package/lib/rules/newExpressions.test.d.ts +0 -2
  731. package/lib/rules/newExpressions.test.js +0 -80
  732. package/lib/rules/newNativeNonConstructors.test.d.ts +0 -2
  733. package/lib/rules/newNativeNonConstructors.test.js +0 -95
  734. package/lib/rules/nonOctalDecimalEscapes.test.d.ts +0 -2
  735. package/lib/rules/nonOctalDecimalEscapes.test.js +0 -70
  736. package/lib/rules/numericLiteralParsing.test.d.ts +0 -2
  737. package/lib/rules/numericLiteralParsing.test.js +0 -100
  738. package/lib/rules/objectCalls.test.d.ts +0 -2
  739. package/lib/rules/objectCalls.test.js +0 -172
  740. package/lib/rules/objectHasOwns.test.d.ts +0 -2
  741. package/lib/rules/objectHasOwns.test.js +0 -112
  742. package/lib/rules/objectKeyDuplicates.test.d.ts +0 -2
  743. package/lib/rules/objectKeyDuplicates.test.js +0 -180
  744. package/lib/rules/objectProto.test.d.ts +0 -2
  745. package/lib/rules/objectProto.test.js +0 -97
  746. package/lib/rules/objectPrototypeBuiltIns.test.d.ts +0 -2
  747. package/lib/rules/objectPrototypeBuiltIns.test.js +0 -146
  748. package/lib/rules/octalEscapes.test.d.ts +0 -2
  749. package/lib/rules/octalEscapes.test.js +0 -214
  750. package/lib/rules/octalNumbers.test.d.ts +0 -2
  751. package/lib/rules/octalNumbers.test.js +0 -246
  752. package/lib/rules/returnAssignments.test.d.ts +0 -2
  753. package/lib/rules/returnAssignments.test.js +0 -186
  754. package/lib/rules/ruleTester.d.ts +0 -3
  755. package/lib/rules/ruleTester.js +0 -8
  756. package/lib/rules/selfAssignments.test.d.ts +0 -2
  757. package/lib/rules/selfAssignments.test.js +0 -67
  758. package/lib/rules/selfComparisons.d.ts +0 -7
  759. package/lib/rules/selfComparisons.js +0 -42
  760. package/lib/rules/selfComparisons.test.d.ts +0 -2
  761. package/lib/rules/selfComparisons.test.js +0 -298
  762. package/lib/rules/sequences.test.d.ts +0 -2
  763. package/lib/rules/sequences.test.js +0 -49
  764. package/lib/rules/shadowedRestrictedNames.test.d.ts +0 -2
  765. package/lib/rules/shadowedRestrictedNames.test.js +0 -148
  766. package/lib/rules/sparseArrays.test.d.ts +0 -2
  767. package/lib/rules/sparseArrays.test.js +0 -111
  768. package/lib/rules/symbolDescriptions.test.d.ts +0 -2
  769. package/lib/rules/symbolDescriptions.test.js +0 -90
  770. package/lib/rules/typeofComparisons.test.d.ts +0 -2
  771. package/lib/rules/typeofComparisons.test.js +0 -86
  772. package/lib/rules/unassignedVariables.test.d.ts +0 -2
  773. package/lib/rules/unassignedVariables.test.js +0 -73
  774. package/lib/rules/undefinedVariables.test.d.ts +0 -2
  775. package/lib/rules/undefinedVariables.test.js +0 -81
  776. package/lib/rules/unicodeBOMs.test.d.ts +0 -2
  777. package/lib/rules/unicodeBOMs.test.js +0 -67
  778. package/lib/rules/unnecessaryBlocks.test.d.ts +0 -2
  779. package/lib/rules/unnecessaryBlocks.test.js +0 -148
  780. package/lib/rules/unnecessaryCatches.test.d.ts +0 -2
  781. package/lib/rules/unnecessaryCatches.test.js +0 -211
  782. package/lib/rules/unnecessaryConcatenation.test.d.ts +0 -2
  783. package/lib/rules/unnecessaryConcatenation.test.js +0 -88
  784. package/lib/rules/unsafeNegations.test.d.ts +0 -2
  785. package/lib/rules/unsafeNegations.test.js +0 -64
  786. package/lib/rules/variableDeletions.test.d.ts +0 -2
  787. package/lib/rules/variableDeletions.test.js +0 -76
  788. package/lib/rules/voidOperator.test.d.ts +0 -2
  789. package/lib/rules/voidOperator.test.js +0 -99
  790. package/lib/rules/withStatements.test.d.ts +0 -2
  791. package/lib/rules/withStatements.test.js +0 -27
  792. package/lib/utils/declarationIncludesGlobal.d.ts +0 -3
  793. package/lib/utils/declarationIncludesGlobal.js +0 -6
  794. package/lib/utils/declarationsIncludeGlobal.d.ts +0 -3
  795. package/lib/utils/declarationsIncludeGlobal.js +0 -5
  796. package/lib/utils/getDeclarationsIfGlobal.d.ts +0 -3
  797. package/lib/utils/getDeclarationsIfGlobal.js +0 -8
  798. package/lib/utils/getModifyingReferences.d.ts +0 -9
  799. package/lib/utils/getModifyingReferences.js +0 -43
  800. package/lib/utils/hasSameTokens.d.ts +0 -3
  801. package/lib/utils/hasSameTokens.js +0 -31
  802. package/lib/utils/isFunction.d.ts +0 -3
  803. package/lib/utils/isFunction.js +0 -6
  804. package/lib/utils/isGlobalDeclaration.d.ts +0 -3
  805. package/lib/utils/isGlobalDeclaration.js +0 -5
  806. package/lib/utils/isGlobalDeclarationOfName.d.ts +0 -6
  807. package/lib/utils/isGlobalDeclarationOfName.js +0 -36
  808. package/lib/utils/isGlobalVariable.d.ts +0 -9
  809. package/lib/utils/isGlobalVariable.js +0 -22
  810. package/lib/utils/unwrapParentParenthesizedExpressions.d.ts +0 -3
  811. package/lib/utils/unwrapParentParenthesizedExpressions.js +0 -7
  812. package/lib/utils/unwrapParenthesizedExpression.d.ts +0 -3
  813. package/lib/utils/unwrapParenthesizedExpression.js +0 -7
@@ -1,187 +1,102 @@
1
- import * as tsutils from "ts-api-utils";
2
- import * as ts from "typescript";
3
- import { typescriptLanguage } from "../language.js";
1
+ import { ruleCreator } from "./ruleCreator.js";
4
2
  import { AnyType, discriminateAnyType } from "./utils/discriminateAnyType.js";
3
+ import { isUnsafeAssignment } from "./utils/isUnsafeAssignment.js";
5
4
  import { getConstrainedTypeAtLocation } from "./utils/getConstrainedType.js";
6
5
  import { getThisExpression } from "./utils/getThisExpression.js";
7
- import { isUnsafeAssignment } from "./utils/isUnsafeAssignment.js";
8
- export default typescriptLanguage.createRule({
9
- about: {
10
- description: "Reports returning a value with type `any` from a function.",
11
- id: "anyReturns",
12
- preset: "logical",
13
- },
14
- messages: {
15
- unsafeReturn: {
16
- primary: "Unsafe return of a value of type {{ type }}.",
17
- secondary: [
18
- "Returning a value of type `any` or a similar unsafe type defeats TypeScript's type safety guarantees.",
19
- "This can allow unexpected types to propagate through your codebase, potentially causing runtime errors.",
20
- ],
21
- suggestions: [
22
- "Ensure the returned value has a well-defined, specific type.",
23
- ],
24
- },
25
- unsafeReturnAssignment: {
26
- primary: "Unsafe return of type `{{ sender }}` from function with return type `{{ receiver }}`.",
27
- secondary: [
28
- "The function's declared return type does not safely accept the value being returned.",
29
- "This can allow unexpected types to propagate through your codebase, potentially causing runtime errors.",
30
- ],
31
- suggestions: [
32
- "Adjust the return type of the function to match the returned value, if appropriate.",
33
- "Otherwise, refine the returned value to ensure it matches the expected return type.",
34
- ],
35
- },
36
- unsafeReturnThis: {
37
- primary: "Unsafe return of a value of type `{{ type }}`. `this` is typed as `any`.",
38
- secondary: [
39
- "Returning `this` when it is implicitly typed as `any` introduces type-unsafe behavior.",
40
- "This can allow unexpected types to propagate through your codebase, potentially causing runtime errors.",
41
- ],
42
- suggestions: [
43
- "Enable the `noImplicitThis` compiler option to enforce explicit `this` types.",
44
- "Add an explicit `this` parameter to the function to clarify its type.",
45
- ],
46
- },
47
- },
48
- setup(context) {
49
- function checkReturn(returnNode, reportingNode, program, typeChecker) {
50
- const type = typeChecker.getTypeAtLocation(returnNode);
51
- const anyType = discriminateAnyType(type, typeChecker, program, returnNode);
52
- const functionNode = ts.findAncestor(returnNode,
53
- // TODO: I believe isFunctionLikeDeclaration was incorrectly marked
54
- // as deprecated in https://github.com/JoshuaKGoldberg/ts-api-utils/pull/124
55
- // It says "With TypeScript v5, in favor of typescript's `isFunctionLike`."
56
- // However, isFunctionLike also checks for signature-like nodes,
57
- // whereas isFunctionLikeDeclaration checks only for function-like nodes.
58
- // eslint-disable-next-line @typescript-eslint/no-deprecated
59
- tsutils.isFunctionLikeDeclaration);
60
- if (!functionNode) {
61
- return;
62
- }
63
- // function has an explicit return type, so ensure it's a safe return
64
- const returnNodeType = getConstrainedTypeAtLocation(returnNode, typeChecker);
65
- // function expressions will not have their return type modified based on receiver typing
66
- // so we have to use the contextual typing in these cases, i.e.
67
- // const foo1: () => Set<string> = () => new Set<any>();
68
- // the return type of the arrow function is Set<any> even though the variable is typed as Set<string>
69
- let functionType = ts.isFunctionExpression(functionNode) ||
70
- ts.isArrowFunction(functionNode)
71
- ? typeChecker.getContextualType(functionNode)
72
- : typeChecker.getTypeAtLocation(functionNode);
73
- functionType ??= typeChecker.getTypeAtLocation(functionNode);
74
- const callSignatures = tsutils.getCallSignaturesOfType(functionType);
75
- // If there is an explicit type annotation *and* that type matches the actual
76
- // function return type, we shouldn't complain (it's intentional, even if unsafe)
77
- if (functionNode.type) {
78
- for (const signature of callSignatures) {
79
- const signatureReturnType = signature.getReturnType();
80
- if (returnNodeType === signatureReturnType ||
81
- tsutils.isTypeFlagSet(signatureReturnType, ts.TypeFlags.Any | ts.TypeFlags.Unknown)) {
82
- return;
83
- }
84
- if (tsutils.includesModifier(functionNode.modifiers, ts.SyntaxKind.AsyncKeyword)) {
85
- const awaitedSignatureReturnType = typeChecker.getAwaitedType(signatureReturnType);
86
- const awaitedReturnNodeType = typeChecker.getAwaitedType(returnNodeType);
87
- if (awaitedReturnNodeType === awaitedSignatureReturnType ||
88
- (awaitedSignatureReturnType &&
89
- tsutils.isTypeFlagSet(awaitedSignatureReturnType, ts.TypeFlags.Any | ts.TypeFlags.Unknown))) {
90
- return;
91
- }
92
- }
93
- }
94
- }
95
- if (anyType !== AnyType.Safe) {
96
- // Allow cases when the declared return type of the function is either unknown or unknown[]
97
- // and the function is returning any or any[].
98
- for (const signature of callSignatures) {
99
- const functionReturnType = signature.getReturnType();
100
- if (anyType === AnyType.Any &&
101
- tsutils.isTypeFlagSet(functionReturnType, ts.TypeFlags.Unknown)) {
102
- return;
103
- }
104
- if (anyType === AnyType.AnyArray &&
105
- typeChecker.isArrayType(functionReturnType) &&
106
- tsutils.isTypeFlagSet(typeChecker.getTypeArguments(functionReturnType)[0], ts.TypeFlags.Unknown)) {
107
- return;
108
- }
109
- const awaitedType = typeChecker.getAwaitedType(functionReturnType);
110
- if (awaitedType &&
111
- anyType === AnyType.PromiseAny &&
112
- tsutils.isTypeFlagSet(awaitedType, ts.TypeFlags.Unknown)) {
113
- return;
114
- }
115
- }
116
- if (anyType === AnyType.PromiseAny &&
117
- !tsutils.includesModifier(functionNode.modifiers, ts.SyntaxKind.AsyncKeyword)) {
118
- return;
119
- }
120
- let message = "unsafeReturn";
121
- const isErrorType = tsutils.isIntrinsicErrorType(returnNodeType);
122
- if (!tsutils.isStrictCompilerOptionEnabled(program.getCompilerOptions(), "noImplicitThis")) {
123
- // `return this`
124
- const thisExpression = getThisExpression(returnNode);
125
- if (thisExpression &&
126
- tsutils.isTypeFlagSet(getConstrainedTypeAtLocation(thisExpression, typeChecker), ts.TypeFlags.Any)) {
127
- message = "unsafeReturnThis";
128
- }
129
- }
130
- // If the function return type was not unknown/unknown[], mark usage as unsafeReturn.
131
- context.report({
132
- data: {
133
- type: isErrorType
134
- ? "error"
135
- : anyType === AnyType.Any
136
- ? "`any`"
137
- : anyType === AnyType.PromiseAny
138
- ? "`Promise<any>`"
139
- : "`any[]`",
140
- },
141
- message,
142
- range: {
143
- begin: reportingNode.getStart(),
144
- end: reportingNode.getEnd(),
145
- },
146
- });
147
- return;
148
- }
149
- const signature = functionType.getCallSignatures().at(0);
150
- if (signature) {
151
- const functionReturnType = signature.getReturnType();
152
- const result = isUnsafeAssignment(returnNodeType, functionReturnType, typeChecker, returnNode);
153
- if (!result) {
154
- return;
155
- }
156
- const { receiver, sender } = result;
157
- context.report({
158
- data: {
159
- receiver: typeChecker.typeToString(receiver),
160
- sender: typeChecker.typeToString(sender),
161
- },
162
- message: "unsafeReturnAssignment",
163
- range: {
164
- begin: reportingNode.getStart(),
165
- end: reportingNode.getEnd(),
166
- },
167
- });
168
- return;
169
- }
170
- }
171
- return {
172
- visitors: {
173
- ArrowFunction: (node, { program, typeChecker }) => {
174
- if (!ts.isBlock(node.body)) {
175
- checkReturn(node.body, node.body, program, typeChecker);
176
- }
177
- },
178
- ReturnStatement: (node, { program, typeChecker }) => {
179
- if (node.expression != null) {
180
- checkReturn(node.expression, node, program, typeChecker);
181
- }
182
- },
183
- },
184
- };
185
- },
6
+ import { getTSNodeRange, typescriptLanguage } from "@flint.fyi/typescript-language";
7
+ import ts, { SyntaxKind } from "typescript";
8
+ import * as tsutils from "ts-api-utils";
9
+ import { nullThrows } from "@flint.fyi/utils";
10
+ //#region src/rules/anyReturns.ts
11
+ var anyReturns_default = ruleCreator.createRule(typescriptLanguage, {
12
+ about: {
13
+ description: "Reports returning a value with type `any` from a function.",
14
+ id: "anyReturns",
15
+ presets: ["logical", "logicalStrict"]
16
+ },
17
+ messages: {
18
+ unsafeReturn: {
19
+ primary: "Unsafe return of a value of type `{{ type }}`.",
20
+ secondary: ["Returning a value of type `any` or a similar unsafe type defeats TypeScript's type safety guarantees.", "This can allow unexpected types to propagate through your codebase, potentially causing runtime errors."],
21
+ suggestions: ["Ensure the returned value has a well-defined, specific type."]
22
+ },
23
+ unsafeReturnAssignment: {
24
+ primary: "Unsafe return of type `{{ sender }}` from function with return type `{{ receiver }}`.",
25
+ secondary: ["The function's declared return type does not safely accept the value being returned.", "This can allow unexpected types to propagate through your codebase, potentially causing runtime errors."],
26
+ suggestions: ["Adjust the return type of the function to match the returned value, if appropriate.", "Otherwise, refine the returned value to ensure it matches the expected return type."]
27
+ },
28
+ unsafeReturnThis: {
29
+ primary: "Unsafe return of a value of type `{{ type }}`. `this` is typed as `any`.",
30
+ secondary: ["Returning `this` when it is implicitly typed as `any` introduces type-unsafe behavior.", "This can allow unexpected types to propagate through your codebase, potentially causing runtime errors."],
31
+ suggestions: ["Enable the `noImplicitThis` compiler option to enforce explicit `this` types.", "Add an explicit `this` parameter to the function to clarify its type."]
32
+ }
33
+ },
34
+ setup(context) {
35
+ function checkReturn(returnNode, reportingNode, { program, sourceFile, typeChecker }) {
36
+ const type = typeChecker.getTypeAtLocation(returnNode);
37
+ const functionNode = ts.findAncestor(returnNode, tsutils.isFunctionLikeDeclaration);
38
+ if (!functionNode) return;
39
+ const returnNodeType = getConstrainedTypeAtLocation(returnNode, typeChecker);
40
+ const anyType = tsutils.isIntrinsicErrorType(returnNodeType) ? AnyType.Error : discriminateAnyType(type, typeChecker, returnNode);
41
+ let functionType = functionNode.kind === SyntaxKind.FunctionExpression || functionNode.kind === SyntaxKind.ArrowFunction ? typeChecker.getContextualType(functionNode) : typeChecker.getTypeAtLocation(functionNode);
42
+ functionType ??= typeChecker.getTypeAtLocation(functionNode);
43
+ const callSignatures = tsutils.getCallSignaturesOfType(functionType);
44
+ if (functionNode.type) for (const signature of callSignatures) {
45
+ const signatureReturnType = signature.getReturnType();
46
+ if (returnNodeType === signatureReturnType || tsutils.isTypeFlagSet(signatureReturnType, ts.TypeFlags.Any | ts.TypeFlags.Unknown)) return;
47
+ if (tsutils.includesModifier(functionNode.modifiers, SyntaxKind.AsyncKeyword)) {
48
+ const awaitedSignatureReturnType = typeChecker.getAwaitedType(signatureReturnType);
49
+ if (typeChecker.getAwaitedType(returnNodeType) === awaitedSignatureReturnType || awaitedSignatureReturnType && tsutils.isTypeFlagSet(awaitedSignatureReturnType, ts.TypeFlags.Any | ts.TypeFlags.Unknown)) return;
50
+ }
51
+ }
52
+ if (anyType !== AnyType.Safe) {
53
+ for (const signature of callSignatures) {
54
+ const functionReturnType = signature.getReturnType();
55
+ if ((anyType === AnyType.Any || anyType === AnyType.Error) && tsutils.isTypeFlagSet(functionReturnType, ts.TypeFlags.Unknown)) return;
56
+ if (anyType === AnyType.AnyArray && typeChecker.isArrayType(functionReturnType) && tsutils.isTypeFlagSet(nullThrows(typeChecker.getTypeArguments(functionReturnType)[0], "Array type should have at least one type argument"), ts.TypeFlags.Unknown)) return;
57
+ const awaitedType = typeChecker.getAwaitedType(functionReturnType);
58
+ if (awaitedType && anyType === AnyType.PromiseAny && tsutils.isTypeFlagSet(awaitedType, ts.TypeFlags.Unknown)) return;
59
+ }
60
+ if (anyType === AnyType.PromiseAny && !tsutils.includesModifier(functionNode.modifiers, SyntaxKind.AsyncKeyword)) return;
61
+ let message = "unsafeReturn";
62
+ if (!tsutils.isStrictCompilerOptionEnabled(program.getCompilerOptions(), "noImplicitThis")) {
63
+ const thisExpression = getThisExpression(returnNode);
64
+ if (thisExpression && tsutils.isTypeFlagSet(getConstrainedTypeAtLocation(thisExpression, typeChecker), ts.TypeFlags.Any)) message = "unsafeReturnThis";
65
+ }
66
+ context.report({
67
+ data: { type: anyType },
68
+ message,
69
+ range: getTSNodeRange(reportingNode, sourceFile)
70
+ });
71
+ return;
72
+ }
73
+ const signature = functionType.getCallSignatures().at(0);
74
+ if (signature) {
75
+ const result = isUnsafeAssignment(returnNodeType, signature.getReturnType(), returnNode);
76
+ if (!result) return;
77
+ const { receiver, sender } = result;
78
+ context.report({
79
+ data: {
80
+ receiver: typeChecker.typeToString(receiver),
81
+ sender: typeChecker.typeToString(sender)
82
+ },
83
+ message: "unsafeReturnAssignment",
84
+ range: getTSNodeRange(reportingNode, sourceFile)
85
+ });
86
+ return;
87
+ }
88
+ }
89
+ return { visitors: {
90
+ ArrowFunction: (node, fileService) => {
91
+ if (node.body.kind !== SyntaxKind.Block) checkReturn(node.body, node.body, fileService);
92
+ },
93
+ ReturnStatement: (node, fileService) => {
94
+ if (node.expression != null) checkReturn(node.expression, node, fileService);
95
+ }
96
+ } };
97
+ }
186
98
  });
99
+ //#endregion
100
+ export { anyReturns_default as default };
101
+
187
102
  //# sourceMappingURL=anyReturns.js.map
@@ -0,0 +1,10 @@
1
+ declare const _default: import("@flint.fyi/core").Rule<{
2
+ readonly description: "Reports using the arguments object instead of rest parameters.";
3
+ readonly id: "arguments";
4
+ readonly presets: ["logical", "logicalStrict"];
5
+ } & {
6
+ presets?: ("javascript" | "logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
7
+ url: string;
8
+ }, object, object, "preferRestParameters", import("@flint.fyi/core").AnyOptionalSchema>;
9
+ export default _default;
10
+ //# sourceMappingURL=arguments.d.ts.map
@@ -0,0 +1,38 @@
1
+ import { ruleCreator } from "./ruleCreator.js";
2
+ import { getTSNodeRange, typescriptLanguage } from "@flint.fyi/typescript-language";
3
+ import * as ts$1 from "typescript";
4
+ //#region src/rules/arguments.ts
5
+ function isNonArrowFunctionBoundary(node) {
6
+ if (ts$1.isArrowFunction(node)) return "quit";
7
+ return ts$1.isFunctionDeclaration(node) || ts$1.isFunctionExpression(node) || ts$1.isMethodDeclaration(node) || ts$1.isGetAccessorDeclaration(node) || ts$1.isSetAccessorDeclaration(node) || ts$1.isConstructorDeclaration(node);
8
+ }
9
+ var arguments_default = ruleCreator.createRule(typescriptLanguage, {
10
+ about: {
11
+ description: "Reports using the arguments object instead of rest parameters.",
12
+ id: "arguments",
13
+ presets: ["logical", "logicalStrict"]
14
+ },
15
+ messages: { preferRestParameters: {
16
+ primary: "Use rest parameters instead of the `arguments` object.",
17
+ secondary: ["The `arguments` object is an array-like object that doesn't have Array methods like `map`, `filter`, or `forEach`.", "Rest parameters provide a real Array, making it easier to work with variadic functions."],
18
+ suggestions: ["Replace usage of `arguments` with a rest parameter like `...args`."]
19
+ } },
20
+ setup(context) {
21
+ return { visitors: { Identifier: (node, { sourceFile, typeChecker }) => {
22
+ if (node.text !== "arguments") return;
23
+ const { parent } = node;
24
+ if ((ts$1.isPropertyAccessExpression(parent) || ts$1.isPropertyAssignment(parent) || ts$1.isShorthandPropertyAssignment(parent) || ts$1.isParameter(parent) || ts$1.isVariableDeclaration(parent) || ts$1.isPropertyDeclaration(parent) || ts$1.isBindingElement(parent) || ts$1.isPropertySignature(parent)) && parent.name === node) return;
25
+ if (!ts$1.findAncestor(node, isNonArrowFunctionBoundary)) return;
26
+ const symbol = typeChecker.getSymbolAtLocation(node);
27
+ if (!symbol || symbol.getDeclarations()?.some((declaration) => ts$1.isParameter(declaration) || ts$1.isVariableDeclaration(declaration) || ts$1.isPropertyDeclaration(declaration) || ts$1.isBindingElement(declaration))) return;
28
+ context.report({
29
+ message: "preferRestParameters",
30
+ range: getTSNodeRange(node, sourceFile)
31
+ });
32
+ } } };
33
+ }
34
+ });
35
+ //#endregion
36
+ export { arguments_default as default };
37
+
38
+ //# sourceMappingURL=arguments.js.map
@@ -0,0 +1,10 @@
1
+ declare const _default: import("@flint.fyi/core").Rule<{
2
+ readonly description: "Reports missing return statements in callbacks of array methods.";
3
+ readonly id: "arrayCallbackReturns";
4
+ readonly presets: ["javascript"];
5
+ } & {
6
+ presets?: ("javascript" | "logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
7
+ url: string;
8
+ }, object, object, "missingReturn", import("@flint.fyi/core").AnyOptionalSchema>;
9
+ export default _default;
10
+ //# sourceMappingURL=arrayCallbackReturns.d.ts.map
@@ -0,0 +1,73 @@
1
+ import { ruleCreator } from "./ruleCreator.js";
2
+ import { typescriptLanguage } from "@flint.fyi/typescript-language";
3
+ import * as ts$1 from "typescript";
4
+ import * as tsutils from "ts-api-utils";
5
+ //#region src/rules/arrayCallbackReturns.ts
6
+ const arrayMethodsRequiringReturn = new Set([
7
+ "every",
8
+ "filter",
9
+ "find",
10
+ "findIndex",
11
+ "findLast",
12
+ "findLastIndex",
13
+ "flatMap",
14
+ "map",
15
+ "reduce",
16
+ "reduceRight",
17
+ "some",
18
+ "sort",
19
+ "toSorted"
20
+ ]);
21
+ var arrayCallbackReturns_default = ruleCreator.createRule(typescriptLanguage, {
22
+ about: {
23
+ description: "Reports missing return statements in callbacks of array methods.",
24
+ id: "arrayCallbackReturns",
25
+ presets: ["javascript"]
26
+ },
27
+ messages: { missingReturn: {
28
+ primary: "Array method `{{ method }}` callback expects a return value.",
29
+ secondary: ["Array methods like `map`, `filter`, `find`, and `reduce` rely on return values from their callbacks.", "A missing return statement is often a mistake that causes the array method to produce unexpected results."],
30
+ suggestions: ["Add a return statement to the callback function.", "If you don't need the return value, consider using `forEach` instead."]
31
+ } },
32
+ setup(context) {
33
+ return { visitors: { CallExpression: (node, { sourceFile }) => {
34
+ if (!ts$1.isPropertyAccessExpression(node.expression)) return;
35
+ const methodName = node.expression.name.text;
36
+ if (!arrayMethodsRequiringReturn.has(methodName)) return;
37
+ const callback = node.arguments[0];
38
+ if (!callback) return;
39
+ const body = getCallbackBody(callback);
40
+ if (!body) return;
41
+ if (!hasReturnWithValue(body)) context.report({
42
+ data: { method: methodName },
43
+ message: "missingReturn",
44
+ range: {
45
+ begin: callback.getStart(sourceFile),
46
+ end: callback.getEnd()
47
+ }
48
+ });
49
+ } } };
50
+ }
51
+ });
52
+ function getCallbackBody(node) {
53
+ if (ts$1.isArrowFunction(node)) return ts$1.isBlock(node.body) ? node.body : void 0;
54
+ if (ts$1.isFunctionExpression(node)) return node.body;
55
+ }
56
+ function hasReturnWithValue(block) {
57
+ let hasReturn = false;
58
+ function visit(node) {
59
+ if (hasReturn) return;
60
+ if (ts$1.isReturnStatement(node) && node.expression) {
61
+ hasReturn = true;
62
+ return;
63
+ }
64
+ if (tsutils.isFunctionScopeBoundary(node)) return;
65
+ ts$1.forEachChild(node, visit);
66
+ }
67
+ ts$1.forEachChild(block, visit);
68
+ return hasReturn;
69
+ }
70
+ //#endregion
71
+ export { arrayCallbackReturns_default as default };
72
+
73
+ //# sourceMappingURL=arrayCallbackReturns.js.map
@@ -0,0 +1,10 @@
1
+ declare const _default: import("@flint.fyi/core").Rule<{
2
+ readonly description: "Reports using the `Array` constructor to create arrays instead of array literal syntax.";
3
+ readonly id: "arrayConstructors";
4
+ readonly presets: ["logical", "logicalStrict"];
5
+ } & {
6
+ presets?: ("javascript" | "logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
7
+ url: string;
8
+ }, object, object, "preferLiteral", import("@flint.fyi/core").AnyOptionalSchema>;
9
+ export default _default;
10
+ //# sourceMappingURL=arrayConstructors.d.ts.map
@@ -0,0 +1,47 @@
1
+ import { ruleCreator } from "./ruleCreator.js";
2
+ import { getTSNodeRange, isGlobalDeclarationOfName, typescriptLanguage } from "@flint.fyi/typescript-language";
3
+ import * as ts$1 from "typescript";
4
+ //#region src/rules/arrayConstructors.ts
5
+ var arrayConstructors_default = ruleCreator.createRule(typescriptLanguage, {
6
+ about: {
7
+ description: "Reports using the `Array` constructor to create arrays instead of array literal syntax.",
8
+ id: "arrayConstructors",
9
+ presets: ["logical", "logicalStrict"]
10
+ },
11
+ messages: { preferLiteral: {
12
+ primary: "Prefer array literal syntax over the `Array` constructor.",
13
+ secondary: ["The `Array` constructor has confusing behavior with a single numeric argument, creating a sparse array instead of an array containing that number.", "Array literal syntax is clearer and avoids potential pitfalls."],
14
+ suggestions: ["Use array literal syntax like `[]` or `[1, 2, 3]`."]
15
+ } },
16
+ setup(context) {
17
+ function checkNode(node, { sourceFile, typeChecker }) {
18
+ if (!ts$1.isIdentifier(node.expression) || node.expression.text !== "Array" || shouldAllowCallOrNew(node) || !isGlobalDeclarationOfName(node.expression, "Array", typeChecker)) return;
19
+ const argumentsText = node.arguments?.map((arg) => arg.getText(sourceFile)).join(", ");
20
+ const range = getTSNodeRange(node, sourceFile);
21
+ context.report({
22
+ fix: {
23
+ range,
24
+ text: `[${argumentsText}]`
25
+ },
26
+ message: "preferLiteral",
27
+ range
28
+ });
29
+ }
30
+ return { visitors: {
31
+ CallExpression: checkNode,
32
+ NewExpression: checkNode
33
+ } };
34
+ }
35
+ });
36
+ function getSoleArgument(node) {
37
+ return node.arguments?.length === 1 ? node.arguments[0] : void 0;
38
+ }
39
+ function shouldAllowCallOrNew(node) {
40
+ if (node.typeArguments && !!node.typeArguments.length) return true;
41
+ const soleArgument = getSoleArgument(node);
42
+ return !!soleArgument && ts$1.isNumericLiteral(soleArgument);
43
+ }
44
+ //#endregion
45
+ export { arrayConstructors_default as default };
46
+
47
+ //# sourceMappingURL=arrayConstructors.js.map
@@ -0,0 +1,10 @@
1
+ declare const _default: import("@flint.fyi/core").Rule<{
2
+ readonly description: "Reports using `.length` or `Infinity` as the `deleteCount` or `skipCount` argument of `Array#splice()` or `Array#toSpliced()`.";
3
+ readonly id: "arrayDeleteUnnecessaryCounts";
4
+ readonly presets: ["stylistic", "stylisticStrict"];
5
+ } & {
6
+ presets?: ("javascript" | "logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
7
+ url: string;
8
+ }, object, object, "unnecessaryCount", import("@flint.fyi/core").AnyOptionalSchema>;
9
+ export default _default;
10
+ //# sourceMappingURL=arrayDeleteUnnecessaryCounts.d.ts.map
@@ -0,0 +1,54 @@
1
+ import { ruleCreator } from "./ruleCreator.js";
2
+ import { getConstrainedTypeAtLocation } from "./utils/getConstrainedType.js";
3
+ import { getTSNodeRange, hasSameTokens, typescriptLanguage, unwrapParenthesizedNode } from "@flint.fyi/typescript-language";
4
+ import * as ts$1 from "typescript";
5
+ //#region src/rules/arrayDeleteUnnecessaryCounts.ts
6
+ function isUnnecessaryCountArgument(argumentRoot, calleeObject, sourceFile) {
7
+ const argument = unwrapParenthesizedNode(argumentRoot);
8
+ switch (argument.kind) {
9
+ case ts$1.SyntaxKind.Identifier: return argument.text === "Infinity" ? "`Infinity`" : void 0;
10
+ case ts$1.SyntaxKind.PropertyAccessExpression:
11
+ if (ts$1.isIdentifier(argument.expression) && argument.expression.text === "Number" && ts$1.isIdentifier(argument.name) && argument.name.text === "POSITIVE_INFINITY") return "`Number.POSITIVE_INFINITY`";
12
+ if (ts$1.isIdentifier(argument.name) && argument.name.text === "length" && hasSameTokens(argument.expression, calleeObject, sourceFile)) return `\`${ts$1.isIdentifier(calleeObject) ? calleeObject.text : "…"}${argument.questionDotToken ? "?." : "."}length\``;
13
+ }
14
+ }
15
+ var arrayDeleteUnnecessaryCounts_default = ruleCreator.createRule(typescriptLanguage, {
16
+ about: {
17
+ description: "Reports using `.length` or `Infinity` as the `deleteCount` or `skipCount` argument of `Array#splice()` or `Array#toSpliced()`.",
18
+ id: "arrayDeleteUnnecessaryCounts",
19
+ presets: ["stylistic", "stylisticStrict"]
20
+ },
21
+ messages: { unnecessaryCount: {
22
+ primary: "Passing {{ description }} as the {{ argumentName }} argument is unnecessary.",
23
+ secondary: ["When calling `splice` or `toSpliced`, omitting the second argument will delete or skip all elements after the start index.", "Using `.length` or `Infinity` is redundant and makes the code less clear."],
24
+ suggestions: ["Omit the second argument to achieve the same result."]
25
+ } },
26
+ setup(context) {
27
+ return { visitors: { CallExpression: (node, { sourceFile, typeChecker }) => {
28
+ if (!ts$1.isPropertyAccessExpression(node.expression) || !ts$1.isIdentifier(node.expression.name)) return;
29
+ const methodName = node.expression.name.text;
30
+ if (methodName !== "splice" && methodName !== "toSpliced") return;
31
+ if (!typeChecker.isArrayType(getConstrainedTypeAtLocation(node.expression.expression, typeChecker))) return;
32
+ if (node.arguments.length !== 2) return;
33
+ const firstArg = node.arguments[0];
34
+ if (ts$1.isSpreadElement(firstArg)) return;
35
+ const secondArg = node.arguments[1];
36
+ if (ts$1.isSpreadElement(secondArg)) return;
37
+ const description = isUnnecessaryCountArgument(secondArg, node.expression.expression, sourceFile);
38
+ if (!description) return;
39
+ const argumentName = methodName === "splice" ? "`deleteCount`" : "`skipCount`";
40
+ context.report({
41
+ data: {
42
+ argumentName,
43
+ description
44
+ },
45
+ message: "unnecessaryCount",
46
+ range: getTSNodeRange(secondArg, sourceFile)
47
+ });
48
+ } } };
49
+ }
50
+ });
51
+ //#endregion
52
+ export { arrayDeleteUnnecessaryCounts_default as default };
53
+
54
+ //# sourceMappingURL=arrayDeleteUnnecessaryCounts.js.map
@@ -0,0 +1,10 @@
1
+ declare const _default: import("@flint.fyi/core").Rule<{
2
+ readonly description: "Reports using the `delete` operator on array values.";
3
+ readonly id: "arrayElementDeletions";
4
+ readonly presets: ["logical", "logicalStrict"];
5
+ } & {
6
+ presets?: ("javascript" | "logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
7
+ url: string;
8
+ }, object, object, "noArrayDelete", import("@flint.fyi/core").AnyOptionalSchema>;
9
+ export default _default;
10
+ //# sourceMappingURL=arrayElementDeletions.d.ts.map
@@ -0,0 +1,43 @@
1
+ import { ruleCreator } from "./ruleCreator.js";
2
+ import { isArrayOrTupleTypeAtLocation } from "./utils/isArrayOrTupleTypeAtLocation.js";
3
+ import { getTSNodeRange, typescriptLanguage } from "@flint.fyi/typescript-language";
4
+ import * as ts$1 from "typescript";
5
+ //#region src/rules/arrayElementDeletions.ts
6
+ function buildSpliceReplacement(node, elementAccess, sourceFile) {
7
+ const children = elementAccess.getChildren(sourceFile);
8
+ const openBracket = children.find((child) => child.kind === ts$1.SyntaxKind.OpenBracketToken);
9
+ const closeBracket = children.find((child) => child.kind === ts$1.SyntaxKind.CloseBracketToken);
10
+ return `${sourceFile.text.slice(node.getStart(sourceFile) + 6, openBracket?.getStart(sourceFile) ?? elementAccess.expression.getEnd())}.splice(${sourceFile.text.slice(openBracket?.getEnd() ?? elementAccess.argumentExpression.getStart(sourceFile), closeBracket?.getStart(sourceFile) ?? elementAccess.argumentExpression.getEnd())}, 1)`;
11
+ }
12
+ var arrayElementDeletions_default = ruleCreator.createRule(typescriptLanguage, {
13
+ about: {
14
+ description: "Reports using the `delete` operator on array values.",
15
+ id: "arrayElementDeletions",
16
+ presets: ["logical", "logicalStrict"]
17
+ },
18
+ messages: { noArrayDelete: {
19
+ primary: "Avoid using the `delete` operator on arrays.",
20
+ secondary: ["Using `delete` on an array element removes it but leaves an empty slot, which can lead to unexpected behavior.", "The array's `length` property is not affected, and the element becomes `undefined` with a hole in the array."],
21
+ suggestions: ["Use `Array#splice()` to remove elements."]
22
+ } },
23
+ setup(context) {
24
+ return { visitors: { DeleteExpression: (node, { sourceFile, typeChecker }) => {
25
+ if (!ts$1.isElementAccessExpression(node.expression) || !isArrayOrTupleTypeAtLocation(node.expression.expression, typeChecker)) return;
26
+ const range = getTSNodeRange(node, sourceFile);
27
+ const spliceText = buildSpliceReplacement(node, node.expression, sourceFile);
28
+ context.report({
29
+ message: "noArrayDelete",
30
+ range,
31
+ suggestions: [{
32
+ id: "useSplice",
33
+ range,
34
+ text: spliceText
35
+ }]
36
+ });
37
+ } } };
38
+ }
39
+ });
40
+ //#endregion
41
+ export { arrayElementDeletions_default as default };
42
+
43
+ //# sourceMappingURL=arrayElementDeletions.js.map
@@ -0,0 +1,10 @@
1
+ declare const _default: import("@flint.fyi/core").Rule<{
2
+ readonly description: "Reports array methods with callbacks that will never be invoked on arrays with empty slots.";
3
+ readonly id: "arrayEmptyCallbackSlots";
4
+ readonly presets: ["logical", "logicalStrict"];
5
+ } & {
6
+ presets?: ("javascript" | "logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
7
+ url: string;
8
+ }, object, object, "neverInvoked", import("@flint.fyi/core").AnyOptionalSchema>;
9
+ export default _default;
10
+ //# sourceMappingURL=arrayEmptyCallbackSlots.d.ts.map