eslint-config-typed 1.0.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 (490) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +6 -0
  3. package/dist/configs/cypress.d.mts +3 -0
  4. package/dist/configs/cypress.d.mts.map +1 -0
  5. package/dist/configs/cypress.mjs +28 -0
  6. package/dist/configs/cypress.mjs.map +1 -0
  7. package/dist/configs/index.d.mts +12 -0
  8. package/dist/configs/index.d.mts.map +1 -0
  9. package/dist/configs/index.mjs +12 -0
  10. package/dist/configs/index.mjs.map +1 -0
  11. package/dist/configs/jest.d.mts +3 -0
  12. package/dist/configs/jest.d.mts.map +1 -0
  13. package/dist/configs/jest.mjs +24 -0
  14. package/dist/configs/jest.mjs.map +1 -0
  15. package/dist/configs/playwright.d.mts +3 -0
  16. package/dist/configs/playwright.d.mts.map +1 -0
  17. package/dist/configs/playwright.mjs +29 -0
  18. package/dist/configs/playwright.mjs.map +1 -0
  19. package/dist/configs/plugins.d.mts +3 -0
  20. package/dist/configs/plugins.d.mts.map +1 -0
  21. package/dist/configs/plugins.mjs +81 -0
  22. package/dist/configs/plugins.mjs.map +1 -0
  23. package/dist/configs/preact.d.mts +3 -0
  24. package/dist/configs/preact.d.mts.map +1 -0
  25. package/dist/configs/preact.mjs +17 -0
  26. package/dist/configs/preact.mjs.map +1 -0
  27. package/dist/configs/react-base.d.mts +3 -0
  28. package/dist/configs/react-base.d.mts.map +1 -0
  29. package/dist/configs/react-base.mjs +38 -0
  30. package/dist/configs/react-base.mjs.map +1 -0
  31. package/dist/configs/react.d.mts +3 -0
  32. package/dist/configs/react.d.mts.map +1 -0
  33. package/dist/configs/react.mjs +16 -0
  34. package/dist/configs/react.mjs.map +1 -0
  35. package/dist/configs/testing-library.d.mts +3 -0
  36. package/dist/configs/testing-library.d.mts.map +1 -0
  37. package/dist/configs/testing-library.mjs +22 -0
  38. package/dist/configs/testing-library.mjs.map +1 -0
  39. package/dist/configs/typescript-without-rules.d.mts +6 -0
  40. package/dist/configs/typescript-without-rules.d.mts.map +1 -0
  41. package/dist/configs/typescript-without-rules.mjs +89 -0
  42. package/dist/configs/typescript-without-rules.mjs.map +1 -0
  43. package/dist/configs/typescript.d.mts +8 -0
  44. package/dist/configs/typescript.d.mts.map +1 -0
  45. package/dist/configs/typescript.mjs +80 -0
  46. package/dist/configs/typescript.mjs.map +1 -0
  47. package/dist/configs/vitest.d.mts +3 -0
  48. package/dist/configs/vitest.d.mts.map +1 -0
  49. package/dist/configs/vitest.mjs +20 -0
  50. package/dist/configs/vitest.mjs.map +1 -0
  51. package/dist/custom-rules/custom.d.mts +3 -0
  52. package/dist/custom-rules/custom.d.mts.map +1 -0
  53. package/dist/custom-rules/custom.mjs +10 -0
  54. package/dist/custom-rules/custom.mjs.map +1 -0
  55. package/dist/custom-rules/index.d.mts +3 -0
  56. package/dist/custom-rules/index.d.mts.map +1 -0
  57. package/dist/custom-rules/index.mjs +3 -0
  58. package/dist/custom-rules/index.mjs.map +1 -0
  59. package/dist/custom-rules/no-restricted-syntax2.d.mts +3 -0
  60. package/dist/custom-rules/no-restricted-syntax2.d.mts.map +1 -0
  61. package/dist/custom-rules/no-restricted-syntax2.mjs +61 -0
  62. package/dist/custom-rules/no-restricted-syntax2.mjs.map +1 -0
  63. package/dist/globals.d.mts +3 -0
  64. package/dist/index.d.mts +6 -0
  65. package/dist/index.d.mts.map +1 -0
  66. package/dist/index.mjs +58 -0
  67. package/dist/index.mjs.map +1 -0
  68. package/dist/plugins/index.d.mts +3 -0
  69. package/dist/plugins/index.d.mts.map +1 -0
  70. package/dist/plugins/index.mjs +23 -0
  71. package/dist/plugins/index.mjs.map +1 -0
  72. package/dist/plugins/total-functions/index.d.mts +3 -0
  73. package/dist/plugins/total-functions/index.d.mts.map +1 -0
  74. package/dist/plugins/total-functions/index.mjs +20 -0
  75. package/dist/plugins/total-functions/index.mjs.map +1 -0
  76. package/dist/plugins/total-functions/plugin.d.mts +3 -0
  77. package/dist/plugins/total-functions/plugin.d.mts.map +1 -0
  78. package/dist/plugins/total-functions/plugin.mjs +26 -0
  79. package/dist/plugins/total-functions/plugin.mjs.map +1 -0
  80. package/dist/plugins/total-functions/rules/common.d.mts +16 -0
  81. package/dist/plugins/total-functions/rules/common.d.mts.map +1 -0
  82. package/dist/plugins/total-functions/rules/common.mjs +49 -0
  83. package/dist/plugins/total-functions/rules/common.mjs.map +1 -0
  84. package/dist/plugins/total-functions/rules/fp-ts.d.mts +9 -0
  85. package/dist/plugins/total-functions/rules/fp-ts.d.mts.map +1 -0
  86. package/dist/plugins/total-functions/rules/fp-ts.mjs +42 -0
  87. package/dist/plugins/total-functions/rules/fp-ts.mjs.map +1 -0
  88. package/dist/plugins/total-functions/rules/index.d.mts +19 -0
  89. package/dist/plugins/total-functions/rules/index.d.mts.map +1 -0
  90. package/dist/plugins/total-functions/rules/index.mjs +19 -0
  91. package/dist/plugins/total-functions/rules/index.mjs.map +1 -0
  92. package/dist/plugins/total-functions/rules/no-enums.d.mts +3 -0
  93. package/dist/plugins/total-functions/rules/no-enums.d.mts.map +1 -0
  94. package/dist/plugins/total-functions/rules/no-enums.mjs +28 -0
  95. package/dist/plugins/total-functions/rules/no-enums.mjs.map +1 -0
  96. package/dist/plugins/total-functions/rules/no-hidden-type-assertions.d.mts +4 -0
  97. package/dist/plugins/total-functions/rules/no-hidden-type-assertions.d.mts.map +1 -0
  98. package/dist/plugins/total-functions/rules/no-hidden-type-assertions.mjs +133 -0
  99. package/dist/plugins/total-functions/rules/no-hidden-type-assertions.mjs.map +1 -0
  100. package/dist/plugins/total-functions/rules/no-nested-fp-ts-effects.d.mts +4 -0
  101. package/dist/plugins/total-functions/rules/no-nested-fp-ts-effects.d.mts.map +1 -0
  102. package/dist/plugins/total-functions/rules/no-nested-fp-ts-effects.mjs +53 -0
  103. package/dist/plugins/total-functions/rules/no-nested-fp-ts-effects.mjs.map +1 -0
  104. package/dist/plugins/total-functions/rules/no-partial-array-reduce.d.mts +4 -0
  105. package/dist/plugins/total-functions/rules/no-partial-array-reduce.d.mts.map +1 -0
  106. package/dist/plugins/total-functions/rules/no-partial-array-reduce.mjs +91 -0
  107. package/dist/plugins/total-functions/rules/no-partial-array-reduce.mjs.map +1 -0
  108. package/dist/plugins/total-functions/rules/no-partial-division.d.mts +4 -0
  109. package/dist/plugins/total-functions/rules/no-partial-division.d.mts.map +1 -0
  110. package/dist/plugins/total-functions/rules/no-partial-division.mjs +78 -0
  111. package/dist/plugins/total-functions/rules/no-partial-division.mjs.map +1 -0
  112. package/dist/plugins/total-functions/rules/no-partial-string-normalize.d.mts +4 -0
  113. package/dist/plugins/total-functions/rules/no-partial-string-normalize.d.mts.map +1 -0
  114. package/dist/plugins/total-functions/rules/no-partial-string-normalize.mjs +94 -0
  115. package/dist/plugins/total-functions/rules/no-partial-string-normalize.mjs.map +1 -0
  116. package/dist/plugins/total-functions/rules/no-partial-url-constructor.d.mts +4 -0
  117. package/dist/plugins/total-functions/rules/no-partial-url-constructor.d.mts.map +1 -0
  118. package/dist/plugins/total-functions/rules/no-partial-url-constructor.mjs +84 -0
  119. package/dist/plugins/total-functions/rules/no-partial-url-constructor.mjs.map +1 -0
  120. package/dist/plugins/total-functions/rules/no-premature-fp-ts-effects.d.mts +4 -0
  121. package/dist/plugins/total-functions/rules/no-premature-fp-ts-effects.d.mts.map +1 -0
  122. package/dist/plugins/total-functions/rules/no-premature-fp-ts-effects.mjs +44 -0
  123. package/dist/plugins/total-functions/rules/no-premature-fp-ts-effects.mjs.map +1 -0
  124. package/dist/plugins/total-functions/rules/no-unsafe-enum-assignment.d.mts +3 -0
  125. package/dist/plugins/total-functions/rules/no-unsafe-enum-assignment.d.mts.map +1 -0
  126. package/dist/plugins/total-functions/rules/no-unsafe-enum-assignment.mjs +20 -0
  127. package/dist/plugins/total-functions/rules/no-unsafe-enum-assignment.mjs.map +1 -0
  128. package/dist/plugins/total-functions/rules/no-unsafe-mutable-readonly-assignment.d.mts +3 -0
  129. package/dist/plugins/total-functions/rules/no-unsafe-mutable-readonly-assignment.d.mts.map +1 -0
  130. package/dist/plugins/total-functions/rules/no-unsafe-mutable-readonly-assignment.mjs +59 -0
  131. package/dist/plugins/total-functions/rules/no-unsafe-mutable-readonly-assignment.mjs.map +1 -0
  132. package/dist/plugins/total-functions/rules/no-unsafe-optional-property-assignment.d.mts +3 -0
  133. package/dist/plugins/total-functions/rules/no-unsafe-optional-property-assignment.d.mts.map +1 -0
  134. package/dist/plugins/total-functions/rules/no-unsafe-optional-property-assignment.mjs +20 -0
  135. package/dist/plugins/total-functions/rules/no-unsafe-optional-property-assignment.mjs.map +1 -0
  136. package/dist/plugins/total-functions/rules/no-unsafe-readonly-mutable-assignment.d.mts +3 -0
  137. package/dist/plugins/total-functions/rules/no-unsafe-readonly-mutable-assignment.d.mts.map +1 -0
  138. package/dist/plugins/total-functions/rules/no-unsafe-readonly-mutable-assignment.mjs +59 -0
  139. package/dist/plugins/total-functions/rules/no-unsafe-readonly-mutable-assignment.mjs.map +1 -0
  140. package/dist/plugins/total-functions/rules/no-unsafe-type-assertion.d.mts +4 -0
  141. package/dist/plugins/total-functions/rules/no-unsafe-type-assertion.d.mts.map +1 -0
  142. package/dist/plugins/total-functions/rules/no-unsafe-type-assertion.mjs +53 -0
  143. package/dist/plugins/total-functions/rules/no-unsafe-type-assertion.mjs.map +1 -0
  144. package/dist/plugins/total-functions/rules/require-strict-mode.d.mts +4 -0
  145. package/dist/plugins/total-functions/rules/require-strict-mode.d.mts.map +1 -0
  146. package/dist/plugins/total-functions/rules/require-strict-mode.mjs +59 -0
  147. package/dist/plugins/total-functions/rules/require-strict-mode.mjs.map +1 -0
  148. package/dist/plugins/total-functions/rules/rules.d.mts +15 -0
  149. package/dist/plugins/total-functions/rules/rules.d.mts.map +1 -0
  150. package/dist/plugins/total-functions/rules/rules.mjs +30 -0
  151. package/dist/plugins/total-functions/rules/rules.mjs.map +1 -0
  152. package/dist/plugins/total-functions/rules/unsafe-assignment-rule.d.mts +5 -0
  153. package/dist/plugins/total-functions/rules/unsafe-assignment-rule.d.mts.map +1 -0
  154. package/dist/plugins/total-functions/rules/unsafe-assignment-rule.mjs +234 -0
  155. package/dist/plugins/total-functions/rules/unsafe-assignment-rule.mjs.map +1 -0
  156. package/dist/plugins/tree-shakable/index.d.mts +3 -0
  157. package/dist/plugins/tree-shakable/index.d.mts.map +1 -0
  158. package/dist/plugins/tree-shakable/index.mjs +4 -0
  159. package/dist/plugins/tree-shakable/index.mjs.map +1 -0
  160. package/dist/plugins/tree-shakable/plugin.d.mts +3 -0
  161. package/dist/plugins/tree-shakable/plugin.d.mts.map +1 -0
  162. package/dist/plugins/tree-shakable/plugin.mjs +10 -0
  163. package/dist/plugins/tree-shakable/plugin.mjs.map +1 -0
  164. package/dist/plugins/tree-shakable/rules/import-star.d.mts +5 -0
  165. package/dist/plugins/tree-shakable/rules/import-star.d.mts.map +1 -0
  166. package/dist/plugins/tree-shakable/rules/import-star.mjs +249 -0
  167. package/dist/plugins/tree-shakable/rules/import-star.mjs.map +1 -0
  168. package/dist/plugins/tree-shakable/rules/index.d.mts +3 -0
  169. package/dist/plugins/tree-shakable/rules/index.d.mts.map +1 -0
  170. package/dist/plugins/tree-shakable/rules/index.mjs +3 -0
  171. package/dist/plugins/tree-shakable/rules/index.mjs.map +1 -0
  172. package/dist/plugins/tree-shakable/rules/rules.d.mts +4 -0
  173. package/dist/plugins/tree-shakable/rules/rules.d.mts.map +1 -0
  174. package/dist/plugins/tree-shakable/rules/rules.mjs +8 -0
  175. package/dist/plugins/tree-shakable/rules/rules.mjs.map +1 -0
  176. package/dist/rules/eslint-array-func-rules.d.mts +3 -0
  177. package/dist/rules/eslint-array-func-rules.d.mts.map +1 -0
  178. package/dist/rules/eslint-array-func-rules.mjs +11 -0
  179. package/dist/rules/eslint-array-func-rules.mjs.map +1 -0
  180. package/dist/rules/eslint-cypress-rules.d.mts +3 -0
  181. package/dist/rules/eslint-cypress-rules.d.mts.map +1 -0
  182. package/dist/rules/eslint-cypress-rules.mjs +15 -0
  183. package/dist/rules/eslint-cypress-rules.mjs.map +1 -0
  184. package/dist/rules/eslint-functional-rules.d.mts +7 -0
  185. package/dist/rules/eslint-functional-rules.d.mts.map +1 -0
  186. package/dist/rules/eslint-functional-rules.mjs +133 -0
  187. package/dist/rules/eslint-functional-rules.mjs.map +1 -0
  188. package/dist/rules/eslint-import-rules.d.mts +3 -0
  189. package/dist/rules/eslint-import-rules.d.mts.map +1 -0
  190. package/dist/rules/eslint-import-rules.mjs +112 -0
  191. package/dist/rules/eslint-import-rules.mjs.map +1 -0
  192. package/dist/rules/eslint-jest-rules.d.mts +3 -0
  193. package/dist/rules/eslint-jest-rules.d.mts.map +1 -0
  194. package/dist/rules/eslint-jest-rules.mjs +82 -0
  195. package/dist/rules/eslint-jest-rules.mjs.map +1 -0
  196. package/dist/rules/eslint-jsx-a11y-rules.d.mts +4 -0
  197. package/dist/rules/eslint-jsx-a11y-rules.d.mts.map +1 -0
  198. package/dist/rules/eslint-jsx-a11y-rules.mjs +167 -0
  199. package/dist/rules/eslint-jsx-a11y-rules.mjs.map +1 -0
  200. package/dist/rules/eslint-playwright-rules.d.mts +3 -0
  201. package/dist/rules/eslint-playwright-rules.d.mts.map +1 -0
  202. package/dist/rules/eslint-playwright-rules.mjs +62 -0
  203. package/dist/rules/eslint-playwright-rules.mjs.map +1 -0
  204. package/dist/rules/eslint-plugin-rules.d.mts +3 -0
  205. package/dist/rules/eslint-plugin-rules.d.mts.map +1 -0
  206. package/dist/rules/eslint-plugin-rules.mjs +36 -0
  207. package/dist/rules/eslint-plugin-rules.mjs.map +1 -0
  208. package/dist/rules/eslint-prefer-arrow-functions-rules.d.mts +3 -0
  209. package/dist/rules/eslint-prefer-arrow-functions-rules.d.mts.map +1 -0
  210. package/dist/rules/eslint-prefer-arrow-functions-rules.mjs +17 -0
  211. package/dist/rules/eslint-prefer-arrow-functions-rules.mjs.map +1 -0
  212. package/dist/rules/eslint-promise-rules.d.mts +3 -0
  213. package/dist/rules/eslint-promise-rules.d.mts.map +1 -0
  214. package/dist/rules/eslint-promise-rules.mjs +25 -0
  215. package/dist/rules/eslint-promise-rules.mjs.map +1 -0
  216. package/dist/rules/eslint-react-hooks-rules.d.mts +3 -0
  217. package/dist/rules/eslint-react-hooks-rules.d.mts.map +1 -0
  218. package/dist/rules/eslint-react-hooks-rules.mjs +7 -0
  219. package/dist/rules/eslint-react-hooks-rules.mjs.map +1 -0
  220. package/dist/rules/eslint-react-perf-rules.d.mts +3 -0
  221. package/dist/rules/eslint-react-perf-rules.d.mts.map +1 -0
  222. package/dist/rules/eslint-react-perf-rules.mjs +9 -0
  223. package/dist/rules/eslint-react-perf-rules.mjs.map +1 -0
  224. package/dist/rules/eslint-react-refresh-rules.d.mts +3 -0
  225. package/dist/rules/eslint-react-refresh-rules.d.mts.map +1 -0
  226. package/dist/rules/eslint-react-refresh-rules.mjs +6 -0
  227. package/dist/rules/eslint-react-refresh-rules.mjs.map +1 -0
  228. package/dist/rules/eslint-react-rules.d.mts +3 -0
  229. package/dist/rules/eslint-react-rules.d.mts.map +1 -0
  230. package/dist/rules/eslint-react-rules.mjs +141 -0
  231. package/dist/rules/eslint-react-rules.mjs.map +1 -0
  232. package/dist/rules/eslint-rules.d.mts +55 -0
  233. package/dist/rules/eslint-rules.d.mts.map +1 -0
  234. package/dist/rules/eslint-rules.mjs +441 -0
  235. package/dist/rules/eslint-rules.mjs.map +1 -0
  236. package/dist/rules/eslint-security-rules.d.mts +3 -0
  237. package/dist/rules/eslint-security-rules.d.mts.map +1 -0
  238. package/dist/rules/eslint-security-rules.mjs +19 -0
  239. package/dist/rules/eslint-security-rules.mjs.map +1 -0
  240. package/dist/rules/eslint-testing-library-rules.d.mts +3 -0
  241. package/dist/rules/eslint-testing-library-rules.d.mts.map +1 -0
  242. package/dist/rules/eslint-testing-library-rules.mjs +35 -0
  243. package/dist/rules/eslint-testing-library-rules.mjs.map +1 -0
  244. package/dist/rules/eslint-total-functions-rules.d.mts +3 -0
  245. package/dist/rules/eslint-total-functions-rules.d.mts.map +1 -0
  246. package/dist/rules/eslint-total-functions-rules.mjs +19 -0
  247. package/dist/rules/eslint-total-functions-rules.mjs.map +1 -0
  248. package/dist/rules/eslint-tree-shakable-rules.d.mts +3 -0
  249. package/dist/rules/eslint-tree-shakable-rules.d.mts.map +1 -0
  250. package/dist/rules/eslint-tree-shakable-rules.mjs +6 -0
  251. package/dist/rules/eslint-tree-shakable-rules.mjs.map +1 -0
  252. package/dist/rules/eslint-unicorn-rules.d.mts +3 -0
  253. package/dist/rules/eslint-unicorn-rules.d.mts.map +1 -0
  254. package/dist/rules/eslint-unicorn-rules.mjs +202 -0
  255. package/dist/rules/eslint-unicorn-rules.mjs.map +1 -0
  256. package/dist/rules/eslint-vitest-rules.d.mts +3 -0
  257. package/dist/rules/eslint-vitest-rules.d.mts.map +1 -0
  258. package/dist/rules/eslint-vitest-rules.mjs +75 -0
  259. package/dist/rules/eslint-vitest-rules.mjs.map +1 -0
  260. package/dist/rules/index.d.mts +23 -0
  261. package/dist/rules/index.d.mts.map +1 -0
  262. package/dist/rules/index.mjs +23 -0
  263. package/dist/rules/index.mjs.map +1 -0
  264. package/dist/rules/typescript-eslint-rules.d.mts +5 -0
  265. package/dist/rules/typescript-eslint-rules.d.mts.map +1 -0
  266. package/dist/rules/typescript-eslint-rules.mjs +379 -0
  267. package/dist/rules/typescript-eslint-rules.mjs.map +1 -0
  268. package/dist/tsconfig.json +1 -0
  269. package/dist/types/flat-config.d.mts +7 -0
  270. package/dist/types/flat-config.d.mts.map +1 -0
  271. package/dist/types/flat-config.mjs +2 -0
  272. package/dist/types/flat-config.mjs.map +1 -0
  273. package/dist/types/index.d.mts +4 -0
  274. package/dist/types/index.d.mts.map +1 -0
  275. package/dist/types/index.mjs +2 -0
  276. package/dist/types/index.mjs.map +1 -0
  277. package/dist/types/rules/eslint-array-func-rules.d.mts +103 -0
  278. package/dist/types/rules/eslint-array-func-rules.d.mts.map +1 -0
  279. package/dist/types/rules/eslint-array-func-rules.mjs +2 -0
  280. package/dist/types/rules/eslint-array-func-rules.mjs.map +1 -0
  281. package/dist/types/rules/eslint-cypress-rules.d.mts +205 -0
  282. package/dist/types/rules/eslint-cypress-rules.d.mts.map +1 -0
  283. package/dist/types/rules/eslint-cypress-rules.mjs +2 -0
  284. package/dist/types/rules/eslint-cypress-rules.mjs.map +1 -0
  285. package/dist/types/rules/eslint-deprecation-rules.d.mts +21 -0
  286. package/dist/types/rules/eslint-deprecation-rules.d.mts.map +1 -0
  287. package/dist/types/rules/eslint-deprecation-rules.mjs +2 -0
  288. package/dist/types/rules/eslint-deprecation-rules.mjs.map +1 -0
  289. package/dist/types/rules/eslint-functional-rules.d.mts +3767 -0
  290. package/dist/types/rules/eslint-functional-rules.d.mts.map +1 -0
  291. package/dist/types/rules/eslint-functional-rules.mjs +2 -0
  292. package/dist/types/rules/eslint-functional-rules.mjs.map +1 -0
  293. package/dist/types/rules/eslint-import-rules.d.mts +2082 -0
  294. package/dist/types/rules/eslint-import-rules.d.mts.map +1 -0
  295. package/dist/types/rules/eslint-import-rules.mjs +2 -0
  296. package/dist/types/rules/eslint-import-rules.mjs.map +1 -0
  297. package/dist/types/rules/eslint-jest-rules.d.mts +1576 -0
  298. package/dist/types/rules/eslint-jest-rules.d.mts.map +1 -0
  299. package/dist/types/rules/eslint-jest-rules.mjs +2 -0
  300. package/dist/types/rules/eslint-jest-rules.mjs.map +1 -0
  301. package/dist/types/rules/eslint-jsx-a11y-rules.d.mts +1679 -0
  302. package/dist/types/rules/eslint-jsx-a11y-rules.d.mts.map +1 -0
  303. package/dist/types/rules/eslint-jsx-a11y-rules.mjs +2 -0
  304. package/dist/types/rules/eslint-jsx-a11y-rules.mjs.map +1 -0
  305. package/dist/types/rules/eslint-playwright-rules.d.mts +1302 -0
  306. package/dist/types/rules/eslint-playwright-rules.d.mts.map +1 -0
  307. package/dist/types/rules/eslint-playwright-rules.mjs +2 -0
  308. package/dist/types/rules/eslint-playwright-rules.mjs.map +1 -0
  309. package/dist/types/rules/eslint-plugin-rules.d.mts +814 -0
  310. package/dist/types/rules/eslint-plugin-rules.d.mts.map +1 -0
  311. package/dist/types/rules/eslint-plugin-rules.mjs +2 -0
  312. package/dist/types/rules/eslint-plugin-rules.mjs.map +1 -0
  313. package/dist/types/rules/eslint-prefer-arrow-functions-rules.d.mts +82 -0
  314. package/dist/types/rules/eslint-prefer-arrow-functions-rules.d.mts.map +1 -0
  315. package/dist/types/rules/eslint-prefer-arrow-functions-rules.mjs +2 -0
  316. package/dist/types/rules/eslint-prefer-arrow-functions-rules.mjs.map +1 -0
  317. package/dist/types/rules/eslint-promise-rules.d.mts +503 -0
  318. package/dist/types/rules/eslint-promise-rules.d.mts.map +1 -0
  319. package/dist/types/rules/eslint-promise-rules.mjs +2 -0
  320. package/dist/types/rules/eslint-promise-rules.mjs.map +1 -0
  321. package/dist/types/rules/eslint-react-hooks-rules.d.mts +70 -0
  322. package/dist/types/rules/eslint-react-hooks-rules.d.mts.map +1 -0
  323. package/dist/types/rules/eslint-react-hooks-rules.mjs +2 -0
  324. package/dist/types/rules/eslint-react-hooks-rules.mjs.map +1 -0
  325. package/dist/types/rules/eslint-react-perf-rules.d.mts +196 -0
  326. package/dist/types/rules/eslint-react-perf-rules.d.mts.map +1 -0
  327. package/dist/types/rules/eslint-react-perf-rules.mjs +2 -0
  328. package/dist/types/rules/eslint-react-perf-rules.mjs.map +1 -0
  329. package/dist/types/rules/eslint-react-refresh-rules.d.mts +51 -0
  330. package/dist/types/rules/eslint-react-refresh-rules.d.mts.map +1 -0
  331. package/dist/types/rules/eslint-react-refresh-rules.mjs +2 -0
  332. package/dist/types/rules/eslint-react-refresh-rules.mjs.map +1 -0
  333. package/dist/types/rules/eslint-react-rules.d.mts +4592 -0
  334. package/dist/types/rules/eslint-react-rules.d.mts.map +1 -0
  335. package/dist/types/rules/eslint-react-rules.mjs +2 -0
  336. package/dist/types/rules/eslint-react-rules.mjs.map +1 -0
  337. package/dist/types/rules/eslint-rules.d.mts +12863 -0
  338. package/dist/types/rules/eslint-rules.d.mts.map +1 -0
  339. package/dist/types/rules/eslint-rules.mjs +2 -0
  340. package/dist/types/rules/eslint-rules.mjs.map +1 -0
  341. package/dist/types/rules/eslint-security-rules.d.mts +253 -0
  342. package/dist/types/rules/eslint-security-rules.d.mts.map +1 -0
  343. package/dist/types/rules/eslint-security-rules.mjs +2 -0
  344. package/dist/types/rules/eslint-security-rules.mjs.map +1 -0
  345. package/dist/types/rules/eslint-strict-dependencies-rules.d.mts +75 -0
  346. package/dist/types/rules/eslint-strict-dependencies-rules.d.mts.map +1 -0
  347. package/dist/types/rules/eslint-strict-dependencies-rules.mjs +2 -0
  348. package/dist/types/rules/eslint-strict-dependencies-rules.mjs.map +1 -0
  349. package/dist/types/rules/eslint-testing-library-rules.d.mts +814 -0
  350. package/dist/types/rules/eslint-testing-library-rules.d.mts.map +1 -0
  351. package/dist/types/rules/eslint-testing-library-rules.mjs +2 -0
  352. package/dist/types/rules/eslint-testing-library-rules.mjs.map +1 -0
  353. package/dist/types/rules/eslint-total-functions-rules.d.mts +197 -0
  354. package/dist/types/rules/eslint-total-functions-rules.d.mts.map +1 -0
  355. package/dist/types/rules/eslint-total-functions-rules.mjs +2 -0
  356. package/dist/types/rules/eslint-total-functions-rules.mjs.map +1 -0
  357. package/dist/types/rules/eslint-tree-shakable-rules.d.mts +19 -0
  358. package/dist/types/rules/eslint-tree-shakable-rules.d.mts.map +1 -0
  359. package/dist/types/rules/eslint-tree-shakable-rules.mjs +2 -0
  360. package/dist/types/rules/eslint-tree-shakable-rules.mjs.map +1 -0
  361. package/dist/types/rules/eslint-unicorn-rules.d.mts +3544 -0
  362. package/dist/types/rules/eslint-unicorn-rules.d.mts.map +1 -0
  363. package/dist/types/rules/eslint-unicorn-rules.mjs +2 -0
  364. package/dist/types/rules/eslint-unicorn-rules.mjs.map +1 -0
  365. package/dist/types/rules/eslint-vitest-rules.d.mts +1461 -0
  366. package/dist/types/rules/eslint-vitest-rules.d.mts.map +1 -0
  367. package/dist/types/rules/eslint-vitest-rules.mjs +2 -0
  368. package/dist/types/rules/eslint-vitest-rules.mjs.map +1 -0
  369. package/dist/types/rules/index.d.mts +25 -0
  370. package/dist/types/rules/index.d.mts.map +1 -0
  371. package/dist/types/rules/index.mjs +2 -0
  372. package/dist/types/rules/index.mjs.map +1 -0
  373. package/dist/types/rules/typescript-eslint-rules.d.mts +9150 -0
  374. package/dist/types/rules/typescript-eslint-rules.d.mts.map +1 -0
  375. package/dist/types/rules/typescript-eslint-rules.mjs +2 -0
  376. package/dist/types/rules/typescript-eslint-rules.mjs.map +1 -0
  377. package/dist/types/types.d.mts +8 -0
  378. package/dist/types/types.d.mts.map +1 -0
  379. package/dist/types/types.mjs +2 -0
  380. package/dist/types/types.mjs.map +1 -0
  381. package/dist/types.d.mts +2 -0
  382. package/package.json +129 -0
  383. package/src/configs/cypress.mts +27 -0
  384. package/src/configs/index.mts +11 -0
  385. package/src/configs/jest.mts +23 -0
  386. package/src/configs/playwright.mts +28 -0
  387. package/src/configs/plugins.mts +123 -0
  388. package/src/configs/preact.mts +17 -0
  389. package/src/configs/react-base.mts +41 -0
  390. package/src/configs/react.mts +17 -0
  391. package/src/configs/testing-library.mts +21 -0
  392. package/src/configs/typescript-without-rules.mts +94 -0
  393. package/src/configs/typescript.mts +91 -0
  394. package/src/configs/vitest.mts +19 -0
  395. package/src/custom-rules/custom.mts +8 -0
  396. package/src/custom-rules/index.mts +2 -0
  397. package/src/custom-rules/no-restricted-syntax2.mts +79 -0
  398. package/src/globals.d.mts +3 -0
  399. package/src/index.mts +5 -0
  400. package/src/plugins/index.mts +2 -0
  401. package/src/plugins/total-functions/index.mts +2 -0
  402. package/src/plugins/total-functions/plugin.mts +8 -0
  403. package/src/plugins/total-functions/rules/common.mts +81 -0
  404. package/src/plugins/total-functions/rules/fp-ts.mts +57 -0
  405. package/src/plugins/total-functions/rules/index.mts +18 -0
  406. package/src/plugins/total-functions/rules/no-enums.mts +26 -0
  407. package/src/plugins/total-functions/rules/no-enums.test.mts +65 -0
  408. package/src/plugins/total-functions/rules/no-hidden-type-assertions.mts +207 -0
  409. package/src/plugins/total-functions/rules/no-hidden-type-assertions.test.mts +287 -0
  410. package/src/plugins/total-functions/rules/no-nested-fp-ts-effects.mts +67 -0
  411. package/src/plugins/total-functions/rules/no-nested-fp-ts-effects.test.mts +150 -0
  412. package/src/plugins/total-functions/rules/no-partial-array-reduce.mts +126 -0
  413. package/src/plugins/total-functions/rules/no-partial-array-reduce.test.mts +270 -0
  414. package/src/plugins/total-functions/rules/no-partial-division.mts +107 -0
  415. package/src/plugins/total-functions/rules/no-partial-division.test.mts +233 -0
  416. package/src/plugins/total-functions/rules/no-partial-string-normalize.mts +133 -0
  417. package/src/plugins/total-functions/rules/no-partial-string-normalize.test.mts +146 -0
  418. package/src/plugins/total-functions/rules/no-partial-url-constructor.mts +100 -0
  419. package/src/plugins/total-functions/rules/no-partial-url-constructor.test.mts +152 -0
  420. package/src/plugins/total-functions/rules/no-premature-fp-ts-effects.mts +51 -0
  421. package/src/plugins/total-functions/rules/no-premature-fp-ts-effects.test.mts +108 -0
  422. package/src/plugins/total-functions/rules/no-unsafe-enum-assignment.mts +19 -0
  423. package/src/plugins/total-functions/rules/no-unsafe-mutable-readonly-assignment.mts +99 -0
  424. package/src/plugins/total-functions/rules/no-unsafe-mutable-readonly-assignment.test.mts +830 -0
  425. package/src/plugins/total-functions/rules/no-unsafe-optional-property-assignment.mts +19 -0
  426. package/src/plugins/total-functions/rules/no-unsafe-readonly-mutable-assignment.mts +99 -0
  427. package/src/plugins/total-functions/rules/no-unsafe-readonly-mutable-assignment.test.mts +626 -0
  428. package/src/plugins/total-functions/rules/no-unsafe-type-assertion.mts +65 -0
  429. package/src/plugins/total-functions/rules/no-unsafe-type-assertion.test.mts +269 -0
  430. package/src/plugins/total-functions/rules/require-strict-mode.mts +65 -0
  431. package/src/plugins/total-functions/rules/require-strict-mode.test.mts +92 -0
  432. package/src/plugins/total-functions/rules/rules.mts +28 -0
  433. package/src/plugins/total-functions/rules/unsafe-assignment-rule.mts +401 -0
  434. package/src/plugins/tree-shakable/index.mts +2 -0
  435. package/src/plugins/tree-shakable/plugin.mts +8 -0
  436. package/src/plugins/tree-shakable/rules/import-star.mts +266 -0
  437. package/src/plugins/tree-shakable/rules/import-star.test.mts +174 -0
  438. package/src/plugins/tree-shakable/rules/index.mts +2 -0
  439. package/src/plugins/tree-shakable/rules/rules.mts +6 -0
  440. package/src/rules/eslint-array-func-rules.mts +10 -0
  441. package/src/rules/eslint-cypress-rules.mts +14 -0
  442. package/src/rules/eslint-functional-rules.mts +148 -0
  443. package/src/rules/eslint-import-rules.mts +124 -0
  444. package/src/rules/eslint-jest-rules.mts +84 -0
  445. package/src/rules/eslint-jsx-a11y-rules.mts +178 -0
  446. package/src/rules/eslint-playwright-rules.mts +63 -0
  447. package/src/rules/eslint-plugin-rules.mts +35 -0
  448. package/src/rules/eslint-prefer-arrow-functions-rules.mts +16 -0
  449. package/src/rules/eslint-promise-rules.mts +26 -0
  450. package/src/rules/eslint-react-hooks-rules.mts +6 -0
  451. package/src/rules/eslint-react-perf-rules.mts +8 -0
  452. package/src/rules/eslint-react-refresh-rules.mts +5 -0
  453. package/src/rules/eslint-react-rules.mts +159 -0
  454. package/src/rules/eslint-rules.mts +462 -0
  455. package/src/rules/eslint-security-rules.mts +18 -0
  456. package/src/rules/eslint-testing-library-rules.mts +35 -0
  457. package/src/rules/eslint-total-functions-rules.mts +22 -0
  458. package/src/rules/eslint-tree-shakable-rules.mts +5 -0
  459. package/src/rules/eslint-unicorn-rules.mts +209 -0
  460. package/src/rules/eslint-vitest-rules.mts +82 -0
  461. package/src/rules/index.mts +22 -0
  462. package/src/rules/typescript-eslint-rules.mts +413 -0
  463. package/src/types/flat-config.mts +13 -0
  464. package/src/types/index.mts +3 -0
  465. package/src/types/rules/eslint-array-func-rules.mts +109 -0
  466. package/src/types/rules/eslint-cypress-rules.mts +221 -0
  467. package/src/types/rules/eslint-deprecation-rules.mts +22 -0
  468. package/src/types/rules/eslint-functional-rules.mts +4071 -0
  469. package/src/types/rules/eslint-import-rules.mts +2251 -0
  470. package/src/types/rules/eslint-jest-rules.mts +1705 -0
  471. package/src/types/rules/eslint-jsx-a11y-rules.mts +1866 -0
  472. package/src/types/rules/eslint-playwright-rules.mts +1402 -0
  473. package/src/types/rules/eslint-plugin-rules.mts +885 -0
  474. package/src/types/rules/eslint-prefer-arrow-functions-rules.mts +89 -0
  475. package/src/types/rules/eslint-promise-rules.mts +547 -0
  476. package/src/types/rules/eslint-react-hooks-rules.mts +78 -0
  477. package/src/types/rules/eslint-react-perf-rules.mts +215 -0
  478. package/src/types/rules/eslint-react-refresh-rules.mts +58 -0
  479. package/src/types/rules/eslint-react-rules.mts +5075 -0
  480. package/src/types/rules/eslint-rules.mts +13614 -0
  481. package/src/types/rules/eslint-security-rules.mts +267 -0
  482. package/src/types/rules/eslint-strict-dependencies-rules.mts +84 -0
  483. package/src/types/rules/eslint-testing-library-rules.mts +887 -0
  484. package/src/types/rules/eslint-total-functions-rules.mts +209 -0
  485. package/src/types/rules/eslint-tree-shakable-rules.mts +20 -0
  486. package/src/types/rules/eslint-unicorn-rules.mts +3796 -0
  487. package/src/types/rules/eslint-vitest-rules.mts +1575 -0
  488. package/src/types/rules/index.mts +24 -0
  489. package/src/types/rules/typescript-eslint-rules.mts +9992 -0
  490. package/src/types/types.mts +7 -0
@@ -0,0 +1,207 @@
1
+ import {
2
+ isTypeNeverType,
3
+ isTypeUnknownType,
4
+ } from '@typescript-eslint/type-utils';
5
+ import { ESLintUtils } from '@typescript-eslint/utils';
6
+ import {
7
+ isArrayTypeNode,
8
+ isConditionalTypeNode,
9
+ isFunctionTypeNode,
10
+ isIndexedAccessTypeNode,
11
+ isIntersectionTypeNode,
12
+ isNamedTupleMember,
13
+ isTupleTypeNode,
14
+ isTypeLiteralNode,
15
+ isTypeNode,
16
+ isTypeOperatorNode,
17
+ isTypeReferenceNode,
18
+ isUnionTypeNode,
19
+ type NodeArray,
20
+ type ParameterDeclaration,
21
+ SyntaxKind,
22
+ type TypeElement,
23
+ type TypeNode,
24
+ } from 'typescript';
25
+ import { createRule } from './common.mjs';
26
+
27
+ /** An ESLint rule to ban hidden type assertions. */
28
+
29
+ export const noHiddenTypeAssertions = createRule({
30
+ name: 'no-hidden-type-assertions',
31
+ meta: {
32
+ type: 'problem',
33
+ docs: {
34
+ description: 'Bans hidden type assertions.',
35
+ },
36
+ messages: {
37
+ errorStringGeneric:
38
+ 'Do not use hidden type assertions. Specify `unknown` or `never` instead of an arbitrary type argument.',
39
+ },
40
+ schema: [],
41
+ },
42
+ create: (context) => {
43
+ const parserServices = ESLintUtils.getParserServices(context);
44
+ const checker = parserServices.program.getTypeChecker();
45
+
46
+ const explodeTypeNode = (
47
+ type: TypeNode,
48
+ depth: number,
49
+ ): readonly TypeNode[] => {
50
+ // TODO write a test that exercises this
51
+
52
+ if (depth >= 100) {
53
+ return [] as const;
54
+ }
55
+
56
+ const next = isTypeReferenceNode(type)
57
+ ? (type.typeArguments ?? [])
58
+ : isConditionalTypeNode(type)
59
+ ? [type.checkType, type.trueType, type.falseType]
60
+ : isIndexedAccessTypeNode(type)
61
+ ? [type.objectType, type.indexType]
62
+ : isFunctionTypeNode(type)
63
+ ? [type.type, ...parametersToTypeNodes(type.parameters, depth)]
64
+ : isTupleTypeNode(type)
65
+ ? type.elements
66
+ : isNamedTupleMember(type)
67
+ ? [type.type]
68
+ : isTypeLiteralNode(type)
69
+ ? type.members.flatMap((m) =>
70
+ hasTypeNode(m) ? [m.type] : [],
71
+ )
72
+ : isArrayTypeNode(type)
73
+ ? [type.elementType]
74
+ : isTypeOperatorNode(type)
75
+ ? [type.type]
76
+ : isUnionTypeNode(type)
77
+ ? type.types
78
+ : isIntersectionTypeNode(type)
79
+ ? type.types
80
+ : [];
81
+
82
+ return [type, ...next.flatMap(explodeTypeNode)] as const;
83
+ };
84
+
85
+ const parametersToTypeNodes = (
86
+ parameters: NodeArray<ParameterDeclaration>,
87
+ depth: number,
88
+ ): readonly TypeNode[] =>
89
+ parameters
90
+ .flatMap((parameter) =>
91
+ parameter.type !== undefined ? [parameter.type] : [],
92
+ )
93
+ .flatMap((parameter) => explodeTypeNode(parameter, depth));
94
+
95
+ return {
96
+ CallExpression: (node) => {
97
+ const tsExpressionNode = parserServices.esTreeNodeToTSNodeMap.get(node);
98
+ const callSignature = checker.getResolvedSignature(tsExpressionNode);
99
+
100
+ if (callSignature?.declaration === undefined) {
101
+ return;
102
+ }
103
+
104
+ if (callSignature.declaration.kind === SyntaxKind.JSDocSignature) {
105
+ // TODO support JSDoc
106
+ return;
107
+ }
108
+
109
+ const typeParameters = callSignature.declaration.typeParameters;
110
+ const parameters = parametersToTypeNodes(
111
+ callSignature.declaration.parameters,
112
+ 0,
113
+ );
114
+
115
+ const returnType = callSignature.declaration.type;
116
+
117
+ if (
118
+ returnType === undefined ||
119
+ typeParameters === undefined ||
120
+ typeParameters.length === 0
121
+ ) {
122
+ return;
123
+ }
124
+
125
+ const returnTypes = explodeTypeNode(returnType, 0);
126
+
127
+ // Of all the type parameters, these are the ones that are used in the
128
+ // return type (alongside their positional index, which we use next to
129
+ // look up corresponding type arguments)
130
+ const typeParamsUsedInReturnType = typeParameters
131
+ .map((typeParameter, index) => ({ typeParameter, index }))
132
+ .filter((typeParameter) =>
133
+ returnTypes.some(
134
+ (retType) =>
135
+ isTypeReferenceNode(retType) &&
136
+ retType.typeName.kind === SyntaxKind.Identifier &&
137
+ retType.typeName.text === typeParameter.typeParameter.name.text,
138
+ ),
139
+ );
140
+
141
+ // Of all the type parameters that appear in the return type,
142
+ // are they all set to `unknown` type arguments in this specific call?
143
+ // If so, this is safe even if the function being called is a hidden type assertion.
144
+ const allCorrespondingTypeArgumentsAreUnknownType =
145
+ typeParamsUsedInReturnType.every(({ typeParameter, index }) => {
146
+ const typeArgument = (tsExpressionNode.typeArguments ?? [])[index];
147
+ const typeArgumentType =
148
+ typeArgument !== undefined
149
+ ? checker.getTypeAtLocation(typeArgument)
150
+ : undefined;
151
+
152
+ const typeParamDefaultType =
153
+ typeParameter.default !== undefined
154
+ ? checker.getTypeAtLocation(typeParameter.default)
155
+ : undefined;
156
+
157
+ const typeToCheck = typeArgumentType ?? typeParamDefaultType;
158
+
159
+ return (
160
+ typeToCheck !== undefined &&
161
+ (isTypeUnknownType(typeToCheck) || isTypeNeverType(typeToCheck))
162
+ );
163
+ });
164
+
165
+ if (allCorrespondingTypeArgumentsAreUnknownType) {
166
+ return;
167
+ }
168
+
169
+ // Confirms that all the type parameters that appear in the return type ALSO
170
+ // appear in at least one (value) parameter. If they do, this probably isn't
171
+ // a hidden type assertion.
172
+ const allTypeParamsUsedInReturnTypeAlsoAppearInValueParams =
173
+ typeParamsUsedInReturnType
174
+ .map(({ typeParameter }) => typeParameter)
175
+ .every((typeParameter) =>
176
+ parameters.some(
177
+ (parameter) =>
178
+ isTypeReferenceNode(parameter) &&
179
+ parameter.typeName.kind === SyntaxKind.Identifier &&
180
+ typeParameter.name.text === parameter.typeName.text,
181
+ ),
182
+ );
183
+
184
+ if (!allTypeParamsUsedInReturnTypeAlsoAppearInValueParams) {
185
+ context.report({
186
+ node,
187
+ messageId: 'errorStringGeneric',
188
+ } as const);
189
+ }
190
+ },
191
+ };
192
+ },
193
+ defaultOptions: [],
194
+ } as const);
195
+
196
+ const hasTypeNode = (
197
+ typeElement: TypeElement,
198
+ ): typeElement is TypeElement & Readonly<{ type: TypeNode }> => {
199
+ try {
200
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
201
+ const typeAttr = (typeElement as Partial<Readonly<{ type: TypeNode }>>)
202
+ .type;
203
+ return typeAttr !== undefined && isTypeNode(typeAttr);
204
+ } catch {
205
+ return false;
206
+ }
207
+ };
@@ -0,0 +1,287 @@
1
+ import parser from '@typescript-eslint/parser';
2
+ import { RuleTester } from '@typescript-eslint/rule-tester';
3
+ import { AST_NODE_TYPES } from '@typescript-eslint/utils';
4
+ import { noHiddenTypeAssertions } from './no-hidden-type-assertions.mjs';
5
+
6
+ const ruleTester = new RuleTester({
7
+ languageOptions: {
8
+ parserOptions: {
9
+ sourceType: 'module',
10
+ project: './tsconfig.tests.json',
11
+ },
12
+ parser,
13
+ },
14
+ });
15
+
16
+ ruleTester.run('no-hidden-type-assertions', noHiddenTypeAssertions, {
17
+ valid: [
18
+ // No call signature
19
+ {
20
+ filename: 'file.ts',
21
+ code: `
22
+ foo()
23
+ `,
24
+ },
25
+ // Hidden type assertion but set to `unknown`
26
+ {
27
+ filename: 'file.ts',
28
+ code: `
29
+ declare class Axios {
30
+ readonly request: <T = any>(url: string) => Promise<T>;
31
+ }
32
+ declare const axios: Axios;
33
+ export const result: Promise<unknown> = axios.request<unknown>("hello");
34
+ `,
35
+ },
36
+ // Hidden type assertion but set to `never`
37
+ {
38
+ filename: 'file.ts',
39
+ code: `
40
+ declare class Axios {
41
+ readonly request: <T>() => Promise<T>;
42
+ }
43
+ declare const axios: Axios;
44
+ export const result = axios.request<never>();
45
+ `,
46
+ },
47
+ // Generic used in input value, explicitly provided
48
+ {
49
+ filename: 'file.ts',
50
+ code: `
51
+ declare class Axios {
52
+ readonly request: <T = any>(url: T) => T;
53
+ }
54
+ declare const axios: Axios;
55
+ export const result: string = axios.request<string>("hello");
56
+ `,
57
+ },
58
+ // Generic used in input value, not explicitly provided
59
+ {
60
+ filename: 'file.ts',
61
+ code: `
62
+ declare class Axios {
63
+ readonly request: <T = any>(url: T) => Promise<T>;
64
+ }
65
+ declare const axios: Axios;
66
+ export const result = axios.request("hello");
67
+ `,
68
+ },
69
+ // Generic used in input value, not explicitly provided, no default
70
+ {
71
+ filename: 'file.ts',
72
+ code: `
73
+ declare class Axios {
74
+ readonly request: <T>(url: T) => Promise<T>;
75
+ }
76
+ declare const axios: Axios;
77
+ export const result = axios.request("hello");
78
+ `,
79
+ },
80
+ // No generic
81
+ {
82
+ filename: 'file.ts',
83
+ code: `
84
+ declare class Axios {
85
+ readonly request: (url: string) => Promise<string>;
86
+ }
87
+ declare const axios: Axios;
88
+ export const result: Promise<string> = axios.request("hello");
89
+ `,
90
+ },
91
+ // Reused generic name
92
+ {
93
+ filename: 'file.ts',
94
+ code: `
95
+ declare const foo: <T = any>(
96
+ a: string,
97
+ b: T
98
+ ) => typeof a extends (infer T)[] ? T : typeof a;
99
+ export const result = foo("hello", "world");
100
+ `,
101
+ },
102
+ // function type parameter
103
+ {
104
+ filename: 'file.ts',
105
+ code: `
106
+ declare class Axios {
107
+ readonly request: <T = any>(url: () => T) => Promise<T>;
108
+ }
109
+ declare const axios: Axios;
110
+ export const result = axios.request(() => "hello");
111
+ `,
112
+ },
113
+ // chainFirstIOK
114
+ {
115
+ filename: 'file.ts',
116
+ code: `
117
+ declare const chainFirstIOK: <A, B>(
118
+ f: (a: A) => Promise<B>
119
+ ) => (first: Promise<A>) => Promise<A>;
120
+
121
+ export const result = chainFirstIOK<string, boolean>(() =>
122
+ Promise.resolve(true)
123
+ );
124
+ `,
125
+ },
126
+ // object literal type hidden type assertion but set to unknown
127
+ {
128
+ filename: 'file.ts',
129
+ code: `
130
+ declare class Axios {
131
+ readonly request: <T = any>(url: string) => { t: T };
132
+ }
133
+ declare const axios: Axios;
134
+ export const result = axios.request<unknown>("hello");
135
+ `,
136
+ },
137
+ // type param has default set to never
138
+ {
139
+ filename: 'file.ts',
140
+ code: `
141
+ declare const right: <E = never, A = never>(a: A) => E | A;
142
+ export const result = right("hello");
143
+ `,
144
+ },
145
+ // toArray
146
+ {
147
+ filename: 'file.ts',
148
+ code: `
149
+ export declare const toArray: <A>(val: readonly A[]) => A[];
150
+ const ra = [""] as const;
151
+ export const result = toArray(ra);
152
+ `,
153
+ },
154
+ ],
155
+ invalid: [
156
+ // Hidden type assertion set to arbitrary type
157
+ {
158
+ filename: 'file.ts',
159
+ code: `
160
+ declare class Axios {
161
+ readonly request: <T = any>(url: string) => Promise<T>;
162
+ }
163
+
164
+ declare const axios: Axios;
165
+
166
+ export const result: Promise<boolean> = axios.request<boolean>("hello");
167
+ `,
168
+ errors: [
169
+ {
170
+ messageId: 'errorStringGeneric',
171
+ type: AST_NODE_TYPES.CallExpression,
172
+ },
173
+ ],
174
+ },
175
+ // Hidden type assertion set to parameter type coincidentally
176
+ {
177
+ filename: 'file.ts',
178
+ code: `
179
+ declare class Axios {
180
+ readonly request: <T = any>(url: string) => Promise<T>;
181
+ }
182
+
183
+ declare const axios: Axios;
184
+
185
+ export const result: Promise<string> = axios.request<string>("hello");
186
+ `,
187
+ errors: [
188
+ {
189
+ messageId: 'errorStringGeneric',
190
+ type: AST_NODE_TYPES.CallExpression,
191
+ },
192
+ ],
193
+ },
194
+ {
195
+ filename: 'file.ts',
196
+ code: `
197
+ declare class Axios {
198
+ readonly request: <T = any>(url: string) => T;
199
+ }
200
+
201
+ declare const axios: Axios;
202
+
203
+ export const result: boolean = axios.request<boolean>("hello");
204
+ `,
205
+ errors: [
206
+ {
207
+ messageId: 'errorStringGeneric',
208
+ type: AST_NODE_TYPES.CallExpression,
209
+ },
210
+ ],
211
+ },
212
+ // index into type
213
+ {
214
+ filename: 'file.ts',
215
+ code: `
216
+ declare class Axios {
217
+ readonly request: <T extends { a: U }, U>(url: string) => Promise<T["a"]>;
218
+ }
219
+
220
+ declare const axios: Axios;
221
+
222
+ export const result = axios.request("hello");
223
+ `,
224
+ errors: [
225
+ {
226
+ messageId: 'errorStringGeneric',
227
+ type: AST_NODE_TYPES.CallExpression,
228
+ },
229
+ ],
230
+ },
231
+ // conditional type
232
+ {
233
+ filename: 'file.ts',
234
+ code: `
235
+ declare class Axios {
236
+ readonly request: <T>(
237
+ url: string
238
+ ) => T extends 42 ? 43 : 45;
239
+ }
240
+
241
+ declare const axios: Axios;
242
+
243
+ export const result = axios.request<"asdf">("hello");
244
+ `,
245
+ errors: [
246
+ {
247
+ messageId: 'errorStringGeneric',
248
+ type: AST_NODE_TYPES.CallExpression,
249
+ },
250
+ ],
251
+ },
252
+ // object literal type
253
+ {
254
+ filename: 'file.ts',
255
+ code: `
256
+ declare class Axios {
257
+ readonly request: <T = any>(url: string) => { t: { t2: T } };
258
+ }
259
+ declare const axios: Axios;
260
+ export const result = axios.request<boolean>("hello");
261
+ `,
262
+ errors: [
263
+ {
264
+ messageId: 'errorStringGeneric',
265
+ type: AST_NODE_TYPES.CallExpression,
266
+ },
267
+ ],
268
+ },
269
+ // tuple
270
+ {
271
+ filename: 'file.ts',
272
+ code: `
273
+ declare class Axios {
274
+ readonly request: <T = any>(url: string) => { t: [T] };
275
+ }
276
+ declare const axios: Axios;
277
+ export const result = axios.request<boolean>("hello");
278
+ `,
279
+ errors: [
280
+ {
281
+ messageId: 'errorStringGeneric',
282
+ type: AST_NODE_TYPES.CallExpression,
283
+ },
284
+ ],
285
+ },
286
+ ],
287
+ } as const);
@@ -0,0 +1,67 @@
1
+ import { ESLintUtils } from '@typescript-eslint/utils';
2
+ import { isThenableType } from 'tsutils';
3
+ import { createRule, typeSymbolName } from './common.mjs';
4
+ import { effects, fpTsEffectType } from './fp-ts.mjs';
5
+
6
+ /** An ESLint rule to ban problematic nested fp-ts effects. */
7
+
8
+ export const noNestedFpTsEffects = createRule({
9
+ name: 'no-nested-fp-ts-effects',
10
+ meta: {
11
+ type: 'problem',
12
+ docs: {
13
+ description: 'Bans problematic nested fp-ts effects.',
14
+ },
15
+ messages: {
16
+ errorStringGeneric: 'Do not nest these fp-ts effects.',
17
+ },
18
+ schema: [],
19
+ },
20
+ create: (context) => {
21
+ const parserServices = ESLintUtils.getParserServices(context);
22
+ const checker = parserServices.program.getTypeChecker();
23
+
24
+ return {
25
+ CallExpression: (node) => {
26
+ const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);
27
+ const expressionType = checker.getTypeAtLocation(tsNode);
28
+
29
+ const effectType = fpTsEffectType(expressionType);
30
+
31
+ if (effectType === undefined) {
32
+ return;
33
+ }
34
+
35
+ // TODO report other types of problematic nesting besides Tasks within IOs.
36
+
37
+ if (
38
+ effectType.effectName === 'IO' &&
39
+ effectType.effectTypeParameter !== undefined
40
+ ) {
41
+ const effectTypeParameterName = typeSymbolName(
42
+ effectType.effectTypeParameter,
43
+ );
44
+
45
+ if (effectTypeParameterName === undefined) {
46
+ return;
47
+ }
48
+ const isNestedEffect = effects.includes(effectTypeParameterName);
49
+
50
+ const isNestedPromise = isThenableType(
51
+ checker,
52
+ tsNode,
53
+ effectType.effectTypeParameter,
54
+ );
55
+
56
+ if (isNestedEffect || isNestedPromise) {
57
+ context.report({
58
+ node,
59
+ messageId: 'errorStringGeneric',
60
+ } as const);
61
+ }
62
+ }
63
+ },
64
+ };
65
+ },
66
+ defaultOptions: [],
67
+ } as const);
@@ -0,0 +1,150 @@
1
+ import parser from '@typescript-eslint/parser';
2
+ import { RuleTester } from '@typescript-eslint/rule-tester';
3
+ import { AST_NODE_TYPES } from '@typescript-eslint/utils';
4
+ import { noNestedFpTsEffects } from './no-nested-fp-ts-effects.mjs';
5
+
6
+ const ruleTester = new RuleTester({
7
+ languageOptions: {
8
+ parserOptions: {
9
+ sourceType: 'module',
10
+ project: './tsconfig.tests.json',
11
+ },
12
+ parser,
13
+ },
14
+ });
15
+
16
+ ruleTester.run('no-async-effect-within-io', noNestedFpTsEffects, {
17
+ valid: [
18
+ // CallExpression with no symbol is okay
19
+ {
20
+ filename: 'file.ts',
21
+ code: `
22
+ (() => undefined)();
23
+ `,
24
+ },
25
+ // Some other type with coincidentally the same name is okay (zero call signatures)
26
+ {
27
+ filename: 'file.ts',
28
+ code: `
29
+ export interface IO<A> {
30
+ a: A;
31
+ }
32
+
33
+ export interface Task<A> {
34
+ a: A;
35
+ }
36
+
37
+ const liftIO = <A>(val: A): IO<A> => ({ a: val });
38
+
39
+ const liftTask = <A>(val: A): Task<A> => ({ a: val });
40
+
41
+ const foo = liftIO(liftTask("a"));
42
+ `,
43
+ },
44
+ // Some other type with coincidentally the same name is okay (multiple call signatures)
45
+ {
46
+ filename: 'file.ts',
47
+ code: `
48
+ export interface IO<A> {
49
+ (): A;
50
+ (a: string): void;
51
+ }
52
+
53
+ export interface Task<A> {
54
+ (): Promise<A>;
55
+ (a: string): void;
56
+ }
57
+
58
+ declare const liftIO: <A>(val: A) => IO<A>;
59
+
60
+ declare const liftTask: <A>(val: A) => Task<A>;
61
+
62
+ const foo = liftIO(liftTask("a"));
63
+ `,
64
+ },
65
+ // IO<string> is okay
66
+ {
67
+ filename: 'file.ts',
68
+ code: `
69
+ export interface IO<A> {
70
+ (): A;
71
+ }
72
+
73
+ declare const liftIO: <A>(val: A) => IO<A>;
74
+
75
+ const bar = liftIO("a");
76
+ `,
77
+ },
78
+ ],
79
+ invalid: [
80
+ // IO<Task<A>> is invalid
81
+ {
82
+ filename: 'file.ts',
83
+ code: `
84
+ export interface IO<A> {
85
+ (): A;
86
+ }
87
+
88
+ export interface Task<A> {
89
+ (): Promise<A>;
90
+ }
91
+
92
+ declare const liftIO: <A>(val: A) => IO<A>;
93
+
94
+ declare const liftTask: <A>(val: A) => Task<A>;
95
+
96
+ const foo = liftIO(liftTask("a"));
97
+ `,
98
+ errors: [
99
+ {
100
+ messageId: 'errorStringGeneric',
101
+ type: AST_NODE_TYPES.CallExpression,
102
+ },
103
+ ],
104
+ },
105
+ // IO<TaskEither<A>> is invalid
106
+ {
107
+ filename: 'file.ts',
108
+ code: `
109
+ export interface IO<A> {
110
+ (): A;
111
+ }
112
+
113
+ export interface TaskEither<A> {
114
+ (): Promise<A>;
115
+ }
116
+
117
+ declare const liftIO: <A>(val: A) => IO<A>;
118
+
119
+ declare const liftTaskEither: <A>(val: A) => TaskEither<A>;
120
+
121
+ const foo = liftIO(liftTaskEither("a"));
122
+ `,
123
+ errors: [
124
+ {
125
+ messageId: 'errorStringGeneric',
126
+ type: AST_NODE_TYPES.CallExpression,
127
+ },
128
+ ],
129
+ },
130
+ // IO<Promise<A>> is invalid
131
+ {
132
+ filename: 'file.ts',
133
+ code: `
134
+ export interface IO<A> {
135
+ (): A;
136
+ }
137
+
138
+ declare const liftIO: <A>(val: A) => IO<A>;
139
+
140
+ const foo = liftIO(Promise.resolve("a"));
141
+ `,
142
+ errors: [
143
+ {
144
+ messageId: 'errorStringGeneric',
145
+ type: AST_NODE_TYPES.CallExpression,
146
+ },
147
+ ],
148
+ },
149
+ ],
150
+ } as const);