eslint-config-typed 1.8.1 → 2.1.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 (281) hide show
  1. package/README.md +377 -209
  2. package/dist/configs/browser.d.mts +3 -0
  3. package/dist/configs/browser.d.mts.map +1 -0
  4. package/dist/configs/browser.mjs +26 -0
  5. package/dist/configs/browser.mjs.map +1 -0
  6. package/dist/configs/cypress.d.mts +1 -1
  7. package/dist/configs/cypress.d.mts.map +1 -1
  8. package/dist/configs/cypress.mjs +2 -3
  9. package/dist/configs/cypress.mjs.map +1 -1
  10. package/dist/configs/index.d.mts +2 -0
  11. package/dist/configs/index.d.mts.map +1 -1
  12. package/dist/configs/index.mjs +12 -10
  13. package/dist/configs/index.mjs.map +1 -1
  14. package/dist/configs/jest.d.mts +1 -1
  15. package/dist/configs/jest.d.mts.map +1 -1
  16. package/dist/configs/jest.mjs +2 -3
  17. package/dist/configs/jest.mjs.map +1 -1
  18. package/dist/configs/nodejs.d.mts +3 -0
  19. package/dist/configs/nodejs.d.mts.map +1 -0
  20. package/dist/configs/nodejs.mjs +36 -0
  21. package/dist/configs/nodejs.mjs.map +1 -0
  22. package/dist/configs/playwright.d.mts +1 -1
  23. package/dist/configs/playwright.d.mts.map +1 -1
  24. package/dist/configs/playwright.mjs +2 -3
  25. package/dist/configs/playwright.mjs.map +1 -1
  26. package/dist/configs/plugins.d.mts.map +1 -1
  27. package/dist/configs/plugins.mjs +1 -19
  28. package/dist/configs/plugins.mjs.map +1 -1
  29. package/dist/configs/preact.d.mts +1 -1
  30. package/dist/configs/preact.d.mts.map +1 -1
  31. package/dist/configs/preact.mjs +30 -4
  32. package/dist/configs/preact.mjs.map +1 -1
  33. package/dist/configs/react-base.d.mts +1 -1
  34. package/dist/configs/react-base.d.mts.map +1 -1
  35. package/dist/configs/react-base.mjs +20 -24
  36. package/dist/configs/react-base.mjs.map +1 -1
  37. package/dist/configs/react.d.mts +1 -1
  38. package/dist/configs/react.d.mts.map +1 -1
  39. package/dist/configs/react.mjs +4 -4
  40. package/dist/configs/react.mjs.map +1 -1
  41. package/dist/configs/testing-library.d.mts +1 -1
  42. package/dist/configs/testing-library.d.mts.map +1 -1
  43. package/dist/configs/testing-library.mjs +2 -3
  44. package/dist/configs/testing-library.mjs.map +1 -1
  45. package/dist/configs/typescript-without-rules.d.mts +1 -1
  46. package/dist/configs/typescript-without-rules.d.mts.map +1 -1
  47. package/dist/configs/typescript-without-rules.mjs +12 -3
  48. package/dist/configs/typescript-without-rules.mjs.map +1 -1
  49. package/dist/configs/typescript.d.mts +2 -1
  50. package/dist/configs/typescript.d.mts.map +1 -1
  51. package/dist/configs/typescript.mjs +27 -20
  52. package/dist/configs/typescript.mjs.map +1 -1
  53. package/dist/configs/vitest.d.mts +1 -1
  54. package/dist/configs/vitest.d.mts.map +1 -1
  55. package/dist/configs/vitest.mjs +2 -3
  56. package/dist/configs/vitest.mjs.map +1 -1
  57. package/dist/entry-point.d.mts +1 -1
  58. package/dist/entry-point.d.mts.map +1 -1
  59. package/dist/entry-point.mjs +18 -37
  60. package/dist/entry-point.mjs.map +1 -1
  61. package/dist/index.d.mts +0 -1
  62. package/dist/index.d.mts.map +1 -1
  63. package/dist/index.mjs +17 -35
  64. package/dist/index.mjs.map +1 -1
  65. package/dist/plugins/custom/custom.d.mts +3 -0
  66. package/dist/plugins/custom/custom.d.mts.map +1 -0
  67. package/dist/plugins/custom/custom.mjs +8 -0
  68. package/dist/plugins/custom/custom.mjs.map +1 -0
  69. package/dist/plugins/custom/index.d.mts +2 -0
  70. package/dist/plugins/custom/index.d.mts.map +1 -0
  71. package/dist/{custom-rules → plugins/custom}/index.mjs +0 -1
  72. package/dist/{custom-rules → plugins/custom}/index.mjs.map +1 -1
  73. package/dist/plugins/custom/rules/index.d.mts +2 -0
  74. package/dist/plugins/custom/rules/index.d.mts.map +1 -0
  75. package/dist/plugins/custom/rules/index.mjs +2 -0
  76. package/dist/plugins/custom/rules/index.mjs.map +1 -0
  77. package/dist/plugins/custom/rules/no-restricted-syntax2.d.mts.map +1 -0
  78. package/dist/{custom-rules → plugins/custom/rules}/no-restricted-syntax2.mjs +1 -1
  79. package/dist/plugins/custom/rules/no-restricted-syntax2.mjs.map +1 -0
  80. package/dist/plugins/custom/rules/rules.d.mts +4 -0
  81. package/dist/plugins/custom/rules/rules.d.mts.map +1 -0
  82. package/dist/plugins/custom/rules/rules.mjs +8 -0
  83. package/dist/plugins/custom/rules/rules.mjs.map +1 -0
  84. package/dist/plugins/index.d.mts +1 -0
  85. package/dist/plugins/index.d.mts.map +1 -1
  86. package/dist/plugins/index.mjs +1 -20
  87. package/dist/plugins/index.mjs.map +1 -1
  88. package/dist/plugins/total-functions/index.d.mts +0 -1
  89. package/dist/plugins/total-functions/index.d.mts.map +1 -1
  90. package/dist/plugins/total-functions/index.mjs +0 -18
  91. package/dist/plugins/total-functions/index.mjs.map +1 -1
  92. package/dist/plugins/total-functions/rules/no-unsafe-optional-property-assignment.mjs +1 -1
  93. package/dist/plugins/total-functions/rules/no-unsafe-optional-property-assignment.mjs.map +1 -1
  94. package/dist/plugins/total-functions/rules/rules.d.mts +10 -8
  95. package/dist/plugins/total-functions/rules/rules.d.mts.map +1 -1
  96. package/dist/plugins/total-functions/rules/rules.mjs +12 -8
  97. package/dist/plugins/total-functions/rules/rules.mjs.map +1 -1
  98. package/dist/plugins/tree-shakable/index.d.mts +0 -1
  99. package/dist/plugins/tree-shakable/index.d.mts.map +1 -1
  100. package/dist/plugins/tree-shakable/index.mjs +0 -2
  101. package/dist/plugins/tree-shakable/index.mjs.map +1 -1
  102. package/dist/rules/eslint-array-func-rules.d.mts +8 -2
  103. package/dist/rules/eslint-array-func-rules.d.mts.map +1 -1
  104. package/dist/rules/eslint-array-func-rules.mjs.map +1 -1
  105. package/dist/rules/eslint-cypress-rules.d.mts +14 -2
  106. package/dist/rules/eslint-cypress-rules.d.mts.map +1 -1
  107. package/dist/rules/eslint-cypress-rules.mjs.map +1 -1
  108. package/dist/rules/eslint-functional-rules.d.mts +32 -5
  109. package/dist/rules/eslint-functional-rules.d.mts.map +1 -1
  110. package/dist/rules/eslint-functional-rules.mjs +47 -40
  111. package/dist/rules/eslint-functional-rules.mjs.map +1 -1
  112. package/dist/rules/eslint-import-rules.d.mts +64 -2
  113. package/dist/rules/eslint-import-rules.d.mts.map +1 -1
  114. package/dist/rules/eslint-import-rules.mjs.map +1 -1
  115. package/dist/rules/eslint-jest-rules.d.mts +73 -2
  116. package/dist/rules/eslint-jest-rules.d.mts.map +1 -1
  117. package/dist/rules/eslint-jest-rules.mjs.map +1 -1
  118. package/dist/rules/eslint-jsx-a11y-rules.d.mts +47 -2
  119. package/dist/rules/eslint-jsx-a11y-rules.d.mts.map +1 -1
  120. package/dist/rules/eslint-jsx-a11y-rules.mjs.map +1 -1
  121. package/dist/rules/eslint-playwright-rules.d.mts +56 -2
  122. package/dist/rules/eslint-playwright-rules.d.mts.map +1 -1
  123. package/dist/rules/eslint-playwright-rules.mjs.map +1 -1
  124. package/dist/rules/eslint-plugin-rules.d.mts +36 -2
  125. package/dist/rules/eslint-plugin-rules.d.mts.map +1 -1
  126. package/dist/rules/eslint-plugin-rules.mjs +1 -0
  127. package/dist/rules/eslint-plugin-rules.mjs.map +1 -1
  128. package/dist/rules/eslint-plugin-sort-destructure-keys-rules.d.mts +3 -2
  129. package/dist/rules/eslint-plugin-sort-destructure-keys-rules.d.mts.map +1 -1
  130. package/dist/rules/eslint-plugin-sort-destructure-keys-rules.mjs.map +1 -1
  131. package/dist/rules/eslint-prefer-arrow-functions-rules.d.mts +11 -2
  132. package/dist/rules/eslint-prefer-arrow-functions-rules.d.mts.map +1 -1
  133. package/dist/rules/eslint-prefer-arrow-functions-rules.mjs.map +1 -1
  134. package/dist/rules/eslint-promise-rules.d.mts +21 -2
  135. package/dist/rules/eslint-promise-rules.d.mts.map +1 -1
  136. package/dist/rules/eslint-promise-rules.mjs.map +1 -1
  137. package/dist/rules/eslint-react-hooks-rules.d.mts +31 -2
  138. package/dist/rules/eslint-react-hooks-rules.d.mts.map +1 -1
  139. package/dist/rules/eslint-react-hooks-rules.mjs.map +1 -1
  140. package/dist/rules/eslint-react-perf-rules.d.mts +6 -2
  141. package/dist/rules/eslint-react-perf-rules.d.mts.map +1 -1
  142. package/dist/rules/eslint-react-perf-rules.mjs.map +1 -1
  143. package/dist/rules/eslint-react-refresh-rules.d.mts +3 -2
  144. package/dist/rules/eslint-react-refresh-rules.d.mts.map +1 -1
  145. package/dist/rules/eslint-react-refresh-rules.mjs.map +1 -1
  146. package/dist/rules/eslint-react-rules.d.mts +142 -2
  147. package/dist/rules/eslint-react-rules.d.mts.map +1 -1
  148. package/dist/rules/eslint-react-rules.mjs +1 -1
  149. package/dist/rules/eslint-react-rules.mjs.map +1 -1
  150. package/dist/rules/eslint-rules.d.mts +442 -31
  151. package/dist/rules/eslint-rules.d.mts.map +1 -1
  152. package/dist/rules/eslint-rules.mjs +114 -74
  153. package/dist/rules/eslint-rules.mjs.map +1 -1
  154. package/dist/rules/eslint-security-rules.d.mts +16 -2
  155. package/dist/rules/eslint-security-rules.d.mts.map +1 -1
  156. package/dist/rules/eslint-security-rules.mjs.map +1 -1
  157. package/dist/rules/eslint-testing-library-rules.d.mts +34 -2
  158. package/dist/rules/eslint-testing-library-rules.d.mts.map +1 -1
  159. package/dist/rules/eslint-testing-library-rules.mjs.map +1 -1
  160. package/dist/rules/eslint-total-functions-rules.d.mts +16 -2
  161. package/dist/rules/eslint-total-functions-rules.d.mts.map +1 -1
  162. package/dist/rules/eslint-total-functions-rules.mjs +2 -0
  163. package/dist/rules/eslint-total-functions-rules.mjs.map +1 -1
  164. package/dist/rules/eslint-tree-shakable-rules.d.mts +3 -2
  165. package/dist/rules/eslint-tree-shakable-rules.d.mts.map +1 -1
  166. package/dist/rules/eslint-tree-shakable-rules.mjs.map +1 -1
  167. package/dist/rules/eslint-unicorn-rules.d.mts +189 -2
  168. package/dist/rules/eslint-unicorn-rules.d.mts.map +1 -1
  169. package/dist/rules/eslint-unicorn-rules.mjs +33 -32
  170. package/dist/rules/eslint-unicorn-rules.mjs.map +1 -1
  171. package/dist/rules/eslint-vitest-rules.d.mts +62 -2
  172. package/dist/rules/eslint-vitest-rules.d.mts.map +1 -1
  173. package/dist/rules/eslint-vitest-rules.mjs.map +1 -1
  174. package/dist/rules/index.mjs +3 -3
  175. package/dist/rules/typescript-eslint-rules.d.mts +316 -4
  176. package/dist/rules/typescript-eslint-rules.d.mts.map +1 -1
  177. package/dist/rules/typescript-eslint-rules.mjs +111 -57
  178. package/dist/rules/typescript-eslint-rules.mjs.map +1 -1
  179. package/dist/types/define-config.d.mts +3 -0
  180. package/dist/types/define-config.d.mts.map +1 -0
  181. package/dist/types/define-config.mjs +4 -0
  182. package/dist/types/define-config.mjs.map +1 -0
  183. package/dist/types/define-known-rules.d.mts +2 -2
  184. package/dist/types/define-known-rules.d.mts.map +1 -1
  185. package/dist/types/define-known-rules.mjs.map +1 -1
  186. package/dist/types/flat-config.d.mts +1 -1
  187. package/dist/types/flat-config.d.mts.map +1 -1
  188. package/dist/types/index.d.mts +1 -1
  189. package/dist/types/index.d.mts.map +1 -1
  190. package/dist/types/index.mjs +1 -0
  191. package/dist/types/index.mjs.map +1 -1
  192. package/dist/types/rules/eslint-custom-rules.d.mts +62 -0
  193. package/dist/types/rules/eslint-custom-rules.d.mts.map +1 -0
  194. package/dist/types/rules/eslint-custom-rules.mjs +2 -0
  195. package/dist/types/rules/eslint-custom-rules.mjs.map +1 -0
  196. package/dist/types/rules/eslint-plugin-rules.d.mts +17 -0
  197. package/dist/types/rules/eslint-plugin-rules.d.mts.map +1 -1
  198. package/dist/types/rules/eslint-react-hooks-rules.d.mts +2 -1
  199. package/dist/types/rules/eslint-react-hooks-rules.d.mts.map +1 -1
  200. package/dist/types/rules/eslint-total-functions-rules.d.mts +64 -32
  201. package/dist/types/rules/eslint-total-functions-rules.d.mts.map +1 -1
  202. package/dist/types/rules/eslint-unicorn-rules.d.mts +219 -142
  203. package/dist/types/rules/eslint-unicorn-rules.d.mts.map +1 -1
  204. package/dist/types/rules/index.d.mts +1 -0
  205. package/dist/types/rules/index.d.mts.map +1 -1
  206. package/package.json +17 -10
  207. package/src/configs/browser.mts +24 -0
  208. package/src/configs/cypress.mts +1 -3
  209. package/src/configs/index.mts +2 -0
  210. package/src/configs/jest.mts +1 -3
  211. package/src/configs/nodejs.mts +34 -0
  212. package/src/configs/playwright.mts +1 -1
  213. package/src/configs/plugins.mts +1 -2
  214. package/src/configs/preact.mts +29 -4
  215. package/src/configs/react-base.mts +20 -24
  216. package/src/configs/react.mts +3 -3
  217. package/src/configs/testing-library.mts +1 -1
  218. package/src/configs/typescript-without-rules.mts +11 -2
  219. package/src/configs/typescript.mts +31 -19
  220. package/src/configs/vitest.mts +1 -3
  221. package/src/entry-point.mts +109 -1
  222. package/src/index.mts +0 -1
  223. package/src/plugins/custom/custom.mts +6 -0
  224. package/src/plugins/custom/index.mts +1 -0
  225. package/src/plugins/custom/rules/index.mts +1 -0
  226. package/src/{custom-rules → plugins/custom/rules}/no-restricted-syntax2.mts +1 -1
  227. package/src/plugins/custom/rules/rules.mts +6 -0
  228. package/src/plugins/index.mts +1 -0
  229. package/src/plugins/total-functions/index.mts +0 -1
  230. package/src/plugins/total-functions/rules/no-unsafe-optional-property-assignment.mts +1 -1
  231. package/src/plugins/total-functions/rules/rules.mts +12 -8
  232. package/src/plugins/tree-shakable/index.mts +0 -1
  233. package/src/rules/eslint-array-func-rules.mts +2 -2
  234. package/src/rules/eslint-cypress-rules.mts +2 -2
  235. package/src/rules/eslint-functional-rules.mts +52 -47
  236. package/src/rules/eslint-import-rules.mts +2 -2
  237. package/src/rules/eslint-jest-rules.mts +2 -2
  238. package/src/rules/eslint-jsx-a11y-rules.mts +2 -2
  239. package/src/rules/eslint-playwright-rules.mts +2 -2
  240. package/src/rules/eslint-plugin-rules.mts +3 -2
  241. package/src/rules/eslint-plugin-sort-destructure-keys-rules.mts +3 -4
  242. package/src/rules/eslint-prefer-arrow-functions-rules.mts +2 -2
  243. package/src/rules/eslint-promise-rules.mts +2 -2
  244. package/src/rules/eslint-react-hooks-rules.mts +2 -2
  245. package/src/rules/eslint-react-perf-rules.mts +2 -2
  246. package/src/rules/eslint-react-refresh-rules.mts +2 -2
  247. package/src/rules/eslint-react-rules.mts +3 -3
  248. package/src/rules/eslint-rules.mts +126 -79
  249. package/src/rules/eslint-security-rules.mts +2 -2
  250. package/src/rules/eslint-testing-library-rules.mts +2 -2
  251. package/src/rules/eslint-total-functions-rules.mts +5 -2
  252. package/src/rules/eslint-tree-shakable-rules.mts +2 -2
  253. package/src/rules/eslint-unicorn-rules.mts +40 -34
  254. package/src/rules/eslint-vitest-rules.mts +2 -2
  255. package/src/rules/typescript-eslint-rules.mts +120 -65
  256. package/src/types/define-config.mts +5 -0
  257. package/src/types/define-known-rules.mts +4 -0
  258. package/src/types/flat-config.mts +1 -3
  259. package/src/types/index.mts +1 -1
  260. package/src/types/rules/eslint-custom-rules.mts +76 -0
  261. package/src/types/rules/eslint-plugin-rules.mts +18 -0
  262. package/src/types/rules/eslint-react-hooks-rules.mts +2 -1
  263. package/src/types/rules/eslint-total-functions-rules.mts +68 -32
  264. package/src/types/rules/eslint-unicorn-rules.mts +226 -142
  265. package/src/types/rules/index.mts +1 -0
  266. package/dist/custom-rules/custom.d.mts +0 -3
  267. package/dist/custom-rules/custom.d.mts.map +0 -1
  268. package/dist/custom-rules/custom.mjs +0 -10
  269. package/dist/custom-rules/custom.mjs.map +0 -1
  270. package/dist/custom-rules/index.d.mts +0 -3
  271. package/dist/custom-rules/index.d.mts.map +0 -1
  272. package/dist/custom-rules/no-restricted-syntax2.d.mts.map +0 -1
  273. package/dist/custom-rules/no-restricted-syntax2.mjs.map +0 -1
  274. package/dist/types/types.d.mts +0 -8
  275. package/dist/types/types.d.mts.map +0 -1
  276. package/dist/types/types.mjs +0 -2
  277. package/dist/types/types.mjs.map +0 -1
  278. package/src/custom-rules/custom.mts +0 -8
  279. package/src/custom-rules/index.mts +0 -2
  280. package/src/types/types.mts +0 -7
  281. /package/dist/{custom-rules → plugins/custom/rules}/no-restricted-syntax2.d.mts +0 -0
package/README.md CHANGED
@@ -13,23 +13,36 @@ A comprehensive ESLint configuration package with strongly-typed rule definition
13
13
  - [Requirements](#requirements)
14
14
  - [Installation](#installation)
15
15
  - [Quick Start](#quick-start)
16
+ - [defineConfig helper](#defineconfig-helper)
17
+ - [defineKnownRules utility](#defineknownrules-utility)
18
+ - [withDefaultOption utility](#withdefaultoption-utility)
16
19
  - [Configuration Examples](#configuration-examples)
17
20
  - [TypeScript + React Project](#typescript--react-project)
18
21
  - [Node.js TypeScript Project](#nodejs-typescript-project)
19
22
  - [React + Testing Libraries](#react--testing-libraries)
20
23
  - [VS Code Integration](#vs-code-integration)
24
+ - [Included plugins](#included-plugins)
21
25
  - [API Reference](#api-reference)
22
26
  - [Configuration Functions](#configuration-functions)
27
+ - [Base Configurations](#base-configurations)
28
+ - [Framework Configurations](#framework-configurations)
29
+ - [Utility Configurations](#utility-configurations)
23
30
  - [Rule Collections](#rule-collections)
24
- - [Utility Exports](#utility-exports)
31
+ - [Exported Pre-configured Rule Options](#exported-pre-configured-rule-options)
25
32
  - [Custom Plugins](#custom-plugins)
26
- - [Custom Rules](#custom-rules)
27
33
  - [Type Definitions](#type-definitions)
34
+ - [Core Types](#core-types)
35
+ - [Rule Types](#rule-types)
28
36
  - [Customization](#customization)
29
37
  - [Override Specific Rules](#override-specific-rules)
30
38
  - [Use Type-Safe Rule Options](#use-type-safe-rule-options)
31
39
  - [Target Specific Files](#target-specific-files)
32
40
  - [Troubleshooting](#troubleshooting)
41
+ - [Common Issues](#common-issues)
42
+ - [1. ESLint can't find tsconfig.json](#1-eslint-cant-find-tsconfigjson)
43
+ - [2. Import resolution errors](#2-import-resolution-errors)
44
+ - [3. Performance issues](#3-performance-issues)
45
+ - [Known Limitations](#known-limitations)
33
46
  - [Contributing](#contributing)
34
47
  - [License](#license)
35
48
 
@@ -37,10 +50,9 @@ A comprehensive ESLint configuration package with strongly-typed rule definition
37
50
 
38
51
  - 🎯 **Type-Safe Configuration**: Fully typed ESLint rules and configurations for better IDE support
39
52
  - 📦 **Pre-configured Setups**: Ready-to-use configurations for TypeScript, React, Preact, and popular testing frameworks
40
- - 🔧 **Custom Rules**: Additional custom ESLint rules for enhanced code quality
41
- - 🚀 **Zero Configuration**: Works out of the box with sensible defaults
42
- - 🔄 **ESLint Flat Config Support**: Built for the modern ESLint flat configuration system
43
53
  - 📝 **Comprehensive Type Definitions**: Complete TypeScript types for all ESLint rules and options
54
+ - 🔄 **ESLint Flat Config Support**: Built for the modern ESLint flat configuration system
55
+ - 🔧 **Custom Rules**: Additional custom ESLint rules for enhanced code quality
44
56
 
45
57
  ## Requirements
46
58
 
@@ -51,11 +63,11 @@ A comprehensive ESLint configuration package with strongly-typed rule definition
51
63
  ## Installation
52
64
 
53
65
  ```sh
54
- npm install --save-dev eslint-config-typed
66
+ npm add -D eslint eslint-config-typed
55
67
  # or
56
- yarn add -D eslint-config-typed
68
+ yarn add -D eslint eslint-config-typed
57
69
  # or
58
- pnpm add -D eslint-config-typed
70
+ pnpm add -D eslint eslint-config-typed
59
71
  ```
60
72
 
61
73
  All required ESLint plugins and dependencies are automatically installed.
@@ -66,50 +78,53 @@ Create an `eslint.config.js` file in your project root:
66
78
 
67
79
  ```js
68
80
  import {
69
- eslintFlatConfigForTypeScript,
70
- eslintFlatConfigForVitest,
81
+ defineConfig,
82
+ eslintConfigForTypeScript,
83
+ eslintConfigForVitest,
84
+ defineKnownRules,
71
85
  } from 'eslint-config-typed';
72
- import * as path from 'node:path';
73
- import * as url from 'node:url';
86
+ // import * as path from 'node:path';
87
+ // import * as url from 'node:url';
74
88
 
75
89
  const thisDir = import.meta.dirname;
76
90
  // or path.dirname(url.fileURLToPath(import.meta.url));
77
91
 
78
- /** @returns {readonly import('eslint-config-typed').FlatConfig[]} */
79
- const defineConfig = () => [
92
+ export default defineConfig([
80
93
  {
81
94
  // config with just ignores is the replacement for `.eslintignore`
82
95
  ignores: ['**/build/**', '**/dist/**', 'src/some/file/to/ignore.ts'],
83
96
  },
84
- ...eslintFlatConfigForTypeScript({
97
+
98
+ // Base config for TypeScript & JavaScript code
99
+ ...eslintConfigForTypeScript({
85
100
  tsconfigRootDir: thisDir,
86
101
  tsconfigFileName: './tsconfig.json',
87
102
  packageDirs: [thisDir],
88
103
 
89
- // If you are using mono repo and the root package.json is in ../../../ :
104
+ // If you are using a monorepo and the root package.json is located at ../../../:
90
105
  // packageDirs: [path.resolve(thisDir, '../../..'), thisDir],
91
106
  }),
92
- eslintFlatConfigForVitest(),
107
+ eslintConfigForVitest(),
93
108
 
94
109
  // You can override per-rule settings if necessary.
95
110
  {
96
- rules: {
111
+ rules: defineKnownRules({
97
112
  '@typescript-eslint/no-explicit-any': 'warn',
98
113
  '@typescript-eslint/prefer-readonly-parameter-types': 'off',
99
114
  'react-hooks/exhaustive-deps': 'warn',
100
- 'functional/no-let': ['error', noLetOptions],
101
- },
115
+ 'functional/no-let': [
116
+ 'error',
117
+ {
118
+ allowInForLoopInit: true,
119
+ allowInFunctions: false,
120
+ ignoreIdentifierPattern: ignorePattern.filter(
121
+ (p) => p !== '^draft',
122
+ ),
123
+ },
124
+ ],
125
+ }),
102
126
  },
103
- ];
104
-
105
- /** @type {import('eslint-config-typed').EslintFunctionalRulesOption['functional/no-let']} */
106
- const noLetOptions = {
107
- allowInForLoopInit: false,
108
- allowInFunctions: false,
109
- ignoreIdentifierPattern: ignorePattern.filter((p) => p !== '^draft'),
110
- };
111
-
112
- export default defineConfig();
127
+ ]);
113
128
  ```
114
129
 
115
130
  Add a lint script to your `package.json`:
@@ -131,83 +146,156 @@ npm run lint
131
146
  npm run lint:fix
132
147
  ```
133
148
 
149
+ ### defineConfig helper
150
+
151
+ `defineConfig` wraps your flat configuration array so JavaScript config files get full IntelliSense without relying on JSDoc casts. It keeps literal types intact while returning the config unchanged at runtime.
152
+
153
+ ```js
154
+ import { defineConfig, eslintConfigForTypeScript } from 'eslint-config-typed';
155
+
156
+ export default defineConfig([
157
+ ...eslintConfigForTypeScript({
158
+ tsconfigRootDir: import.meta.dirname,
159
+ tsconfigFileName: './tsconfig.json',
160
+ packageDirs: [import.meta.dirname],
161
+ }),
162
+ {
163
+ rules: defineKnownRules({
164
+ // ...
165
+ }),
166
+ },
167
+ ]);
168
+ ```
169
+
170
+ This is equivalent to:
171
+
172
+ ```js
173
+ import { eslintConfigForTypeScript } from 'eslint-config-typed';
174
+
175
+ /** @type {import('@typescript-eslint/utils/ts-eslint').FlatConfig[]} */
176
+ export default [
177
+ ...eslintConfigForTypeScript({
178
+ tsconfigRootDir: import.meta.dirname,
179
+ tsconfigFileName: './tsconfig.json',
180
+ packageDirs: [import.meta.dirname],
181
+ }),
182
+ {
183
+ rules: defineKnownRules({
184
+ // ...
185
+ }),
186
+ },
187
+ ];
188
+ ```
189
+
190
+ ### defineKnownRules utility
191
+
192
+ `defineKnownRules` is a helper designed for the `rules` field in ESLint flat configs. It keeps the returned object untouched while giving you type-safe rule names and option inference in editors. When you wrap your overrides with this function you can rely on:
193
+
194
+ - autocomplete and early feedback for rule identifiers, eliminating typo-prone string literals;
195
+ - strongly typed options for every plugin rule that ships with `eslint-config-typed`, so you can discover valid properties without leaving your editor;
196
+ - a zero-cost runtime helper—because the object is returned as-is, it blends seamlessly into any flat config block.
197
+
198
+ ### withDefaultOption utility
199
+
200
+ `withDefaultOption` is a companion helper that highlights rules which ship with option objects. It maps the familiar severity strings to the numeric values ESLint expects: `withDefaultOption('error')` returns `2`, and `withDefaultOption('warn')` returns `1`. Within `defineKnownRules`, rules that provide options require one of these helpers when you want to keep the defaults and only adjust severity. This convention visually distinguishes rules that contain options, reminding users that a rule has configurable options.
201
+
202
+ `defineKnownRules` also reserves `0` for deprecated rules. The resulting severity matrix looks like this:
203
+
204
+ | Rule type | Allowed severity values in `defineKnownRules` |
205
+ | :------------------- | :------------------------------------------------------------- |
206
+ | Deprecated rule | `0` |
207
+ | Rule without options | `"off"`, `"warn"`, `"error"` |
208
+ | Rule with options | `"off"`, `1`, `2`, `["warn", <option>]`, `["error", <option>]` |
209
+
134
210
  ## Configuration Examples
135
211
 
136
212
  ### TypeScript + React Project
137
213
 
138
214
  ```js
139
215
  import {
140
- eslintFlatConfigForTypeScript,
141
- eslintFlatConfigForReact,
216
+ defineConfig,
217
+ eslintConfigForTypeScript,
218
+ eslintConfigForReact,
219
+ eslintConfigForNodeJs,
220
+ defineKnownRules,
142
221
  } from 'eslint-config-typed';
143
- import * as path from 'node:path';
144
- import * as url from 'node:url';
145
222
 
146
223
  const thisDir = import.meta.dirname;
147
224
 
148
- export default [
225
+ export default defineConfig([
149
226
  { ignores: ['**/dist/**', '**/build/**', '**/.next/**'] },
150
- ...eslintFlatConfigForTypeScript({
227
+ ...eslintConfigForTypeScript({
151
228
  tsconfigRootDir: thisDir,
152
229
  tsconfigFileName: './tsconfig.json',
153
230
  packageDirs: [thisDir],
154
231
  }),
155
- ...eslintFlatConfigForReact(),
156
- ];
232
+ eslintConfigForReact(['src/**']),
233
+ eslintConfigForNodeJs(['scripts/**', 'configs/**']),
234
+ {
235
+ files: ['scripts/**', 'configs/**'],
236
+ rules: defineKnownRules({
237
+ '@typescript-eslint/explicit-function-return-type': 'off',
238
+ 'no-await-in-loop': 'off',
239
+ 'import/no-unassigned-import': 'off',
240
+ 'import/no-internal-modules': 'off',
241
+ 'import/no-default-export': 'off',
242
+ 'import/no-extraneous-dependencies': 'off',
243
+ }),
244
+ },
245
+ ]);
157
246
  ```
158
247
 
159
248
  ### Node.js TypeScript Project
160
249
 
161
250
  ```js
162
- import { eslintFlatConfigForTypeScript } from 'eslint-config-typed';
163
- import * as path from 'node:path';
164
- import * as url from 'node:url';
165
-
166
- const thisDir = import.meta.dirname;
251
+ import {
252
+ defineConfig,
253
+ eslintConfigForTypeScript,
254
+ eslintConfigForNodeJs,
255
+ defineKnownRules,
256
+ } from 'eslint-config-typed';
167
257
 
168
- export default [
258
+ export default defineConfig([
169
259
  { ignores: ['**/dist/**', '**/node_modules/**'] },
170
- ...eslintFlatConfigForTypeScript({
171
- tsconfigRootDir: thisDir,
260
+ ...eslintConfigForTypeScript({
261
+ tsconfigRootDir: import.meta.dirname,
172
262
  tsconfigFileName: './tsconfig.json',
173
- packageDirs: [thisDir],
263
+ packageDirs: [import.meta.dirname],
174
264
  }),
265
+ eslintConfigForNodeJs(),
175
266
  {
176
- rules: {
267
+ rules: defineKnownRules({
177
268
  // Allow console in Node.js
178
269
  'no-console': 'off',
179
270
  // Allow process.env access
180
271
  'no-process-env': 'off',
181
- },
272
+ }),
182
273
  },
183
- ];
274
+ ]);
184
275
  ```
185
276
 
186
277
  ### React + Testing Libraries
187
278
 
188
279
  ```js
189
280
  import {
190
- eslintFlatConfigForTypeScript,
191
- eslintFlatConfigForReact,
192
- eslintFlatConfigForVitest,
193
- eslintFlatConfigForTestingLibrary,
281
+ defineConfig,
282
+ eslintConfigForTypeScript,
283
+ eslintConfigForReact,
284
+ eslintConfigForVitest,
285
+ eslintConfigForTestingLibrary,
194
286
  } from 'eslint-config-typed';
195
- import * as path from 'node:path';
196
- import * as url from 'node:url';
197
-
198
- const thisDir = import.meta.dirname;
199
287
 
200
- export default [
288
+ export default defineConfig([
201
289
  { ignores: ['**/dist/**', '**/coverage/**'] },
202
- ...eslintFlatConfigForTypeScript({
203
- tsconfigRootDir: thisDir,
290
+ ...eslintConfigForTypeScript({
291
+ tsconfigRootDir: import.meta.dirname,
204
292
  tsconfigFileName: './tsconfig.json',
205
- packageDirs: [thisDir],
293
+ packageDirs: [import.meta.dirname],
206
294
  }),
207
- ...eslintFlatConfigForReact(),
208
- eslintFlatConfigForVitest(),
209
- eslintFlatConfigForTestingLibrary(),
210
- ];
295
+ ...eslintConfigForReact(),
296
+ eslintConfigForVitest(),
297
+ eslintConfigForTestingLibrary(),
298
+ ]);
211
299
  ```
212
300
 
213
301
  ## VS Code Integration
@@ -228,98 +316,144 @@ Add the following to `.vscode/settings.json` for proper ESLint integration:
228
316
  }
229
317
  ```
230
318
 
319
+ ## Included plugins
320
+
321
+ - "@typescript-eslint/eslint-plugin": "8.46.2"
322
+ - "eslint-plugin-unicorn": "62.0.0"
323
+ - "eslint-plugin-functional": "9.0.2"
324
+ - "eslint-plugin-array-func": "5.1.0"
325
+ - "eslint-plugin-prefer-arrow-functions": "3.9.1"
326
+ - "eslint-plugin-sort-destructure-keys": "^2.0.0"
327
+ - "eslint-plugin-security": "3.0.1"
328
+ - "eslint-plugin-promise": "7.2.1"
329
+ - "eslint-plugin-import": "2.32.0"
330
+ - "eslint-plugin-strict-dependencies": "1.3.27"
331
+ - "eslint-plugin-react": "7.37.5"
332
+ - "eslint-plugin-react-hooks": "7.0.1"
333
+ - "eslint-plugin-react-perf": "3.3.3"
334
+ - "eslint-plugin-react-refresh": "0.4.24"
335
+ - "eslint-plugin-jsx-a11y": "6.10.2"
336
+ - "eslint-plugin-vitest": "0.5.4"
337
+ - "eslint-plugin-jest": "29.0.1"
338
+ - "eslint-plugin-playwright": "2.2.2"
339
+ - "eslint-plugin-cypress": "5.2.0"
340
+ - "eslint-plugin-testing-library": "7.13.3"
341
+ - "eslint-plugin-eslint-plugin": "7.2.0"
342
+ - "eslint-plugin-total-functions" (Reimplemented in this repository to support flat config)
343
+ - "eslint-plugin-tree-shakable" (Reimplemented in this repository to support flat config)
344
+
231
345
  ## API Reference
232
346
 
233
347
  ### Configuration Functions
234
348
 
235
349
  These functions return arrays of ESLint flat configurations:
236
350
 
237
- #### Framework Configurations
351
+ #### Base Configurations
238
352
 
239
- - **`eslintFlatConfigForTypeScript(options)`** - TypeScript configuration with strict type checking rules
353
+ - **`eslintConfigForTypeScript(options)`** - TypeScript configuration with strict type checking rules
240
354
  - `options.tsconfigRootDir`: Root directory containing tsconfig.json
241
355
  - `options.tsconfigFileName`: Path to tsconfig.json file
242
356
  - `options.packageDirs`: Array of package directories for import resolution
243
- - **`eslintFlatConfigForReact(options?)`** - React configuration with hooks and JSX rules
244
- - **`eslintFlatConfigForPreact(options?)`** - Preact configuration (lighter React alternative)
245
- - **`eslintFlatConfigForReactBase(options?)`** - Base React configuration without specific framework rules
357
+ - **`eslintConfigForBrowser`** - Browser configuration (Turn off Node.js-specific rules)
358
+ - **`eslintConfigForNodeJs`** - Node.js configuration (Turn off browser-specific rules)
246
359
 
247
- #### Testing Framework Configurations
360
+ #### Framework Configurations
248
361
 
249
- - **`eslintFlatConfigForVitest(options?)`** - Vitest testing framework configuration
250
- - **`eslintFlatConfigForJest(options?)`** - Jest testing framework configuration
251
- - **`eslintFlatConfigForCypress(options?)`** - Cypress E2E testing configuration
252
- - **`eslintFlatConfigForPlaywright(options?)`** - Playwright E2E testing configuration
253
- - **`eslintFlatConfigForTestingLibrary(options?)`** - Testing Library configuration
362
+ - **`eslintConfigForReact(options?)`** - React configuration with hooks and JSX rules
363
+ - `eslintConfigForBrowser` is included in this configuration
364
+ - **`eslintConfigForPreact(options?)`** - Preact configuration (lighter React alternative)
365
+ - `eslintConfigForBrowser` is included in this configuration
366
+ - **`eslintConfigForVitest(options?)`** - Vitest testing framework configuration
367
+ - **`eslintConfigForJest(options?)`** - Jest testing framework configuration
368
+ - **`eslintConfigForTestingLibrary(options?)`** - Testing Library configuration
369
+ - **`eslintConfigForPlaywright(options?)`** - Playwright E2E testing configuration
370
+ - **`eslintConfigForCypress(options?)`** - Cypress E2E testing configuration
254
371
 
255
372
  #### Utility Configurations
256
373
 
257
- - **`eslintFlatConfigForTypeScriptWithoutRules(options)`** - TypeScript parser setup without any rules
374
+ - **`eslintConfigForTypeScriptWithoutRules(options)`** - TypeScript parser & plugins setup without any rules
258
375
 
259
376
  ### Rule Collections
260
377
 
261
378
  Pre-configured rule sets that can be imported and customized:
262
379
 
263
- - **`eslintRules`** - Core ESLint rules
264
- - **`typescriptEslintRules`** - TypeScript-specific ESLint rules
265
- - **`eslintReactRules`** - React-specific rules
266
- - **`eslintReactHooksRules`** - React Hooks rules
267
- - **`eslintReactPerfRules`** - React performance optimization rules
268
- - **`eslintReactRefreshRules`** - React Refresh (HMR) rules
269
- - **`eslintJsxA11yRules`** - Accessibility rules for JSX
270
- - **`eslintFunctionalRules`** - Functional programming style rules
271
- - **`eslintImportsRules`** - Import/export rules
272
- - **`eslintUnicornRules`** - Unicorn plugin rules for better code
273
- - **`eslintPromiseRules`** - Promise handling rules
274
- - **`eslintSecurityRules`** - Security best practices
275
- - **`eslintArrayFuncRules`** - Array function preference rules
276
- - **`eslintPreferArrowFunctionRules`** - Arrow function preference rules
277
- - **`eslintTotalFunctionsRules`** - Total functions (no partial functions) rules
278
- - **`eslintTreeShakableRules`** - Tree-shaking optimization rules
279
- - **`eslintVitestRules`** - Vitest-specific rules
280
- - **`eslintJestRules`** - Jest-specific rules
281
- - **`eslintCypressRules`** - Cypress-specific rules
282
- - **`eslintPlaywrightRules`** - Playwright-specific rules
283
- - **`eslintTestingLibraryRules`** - Testing Library rules
284
- - **`eslintStrictDependenciesRules`** - Strict dependency checking rules
285
- - **`eslintPluginRules`** - Additional plugin rules
286
-
287
- ### Utility Exports
288
-
289
- - **`restrictedSyntax`** - Array of restricted JavaScript syntax patterns
290
- - **`restrictedGlobals`** - Array of restricted global variables
291
- - **`restrictedGlobalsForFrontend`** - Frontend-specific restricted globals
292
- - **`restrictedImportsOption`** - Configuration for restricted imports
293
- - **`banTypes`** - TypeScript types that should be banned
294
- - **`ignoredMutablePattern`** - Patterns for allowed mutable variables
295
- - **`immutableDataOptions`** - Options for functional/immutable-data rule
296
- - **`noLetOptions`** - Options for functional/no-let rule
380
+ | Rule set | Plugin name | Description |
381
+ | :----------------------------------------- | :------------------------------------- | :----------------------------------- |
382
+ | **`eslintRules`** | (eslint) | Core ESLint rules |
383
+ | **`typescriptEslintRules`** | `@typescript-eslint/eslint-plugin` | TypeScript-specific ESLint rules |
384
+ | **`eslintFunctionalRules`** | `eslint-plugin-functional` | Functional programming style rules |
385
+ | **`eslintTotalFunctionsRules`** | `eslint-plugin-total-functions` | Functional programming style rules |
386
+ | **`eslintUnicornRules`** | `eslint-plugin-unicorn` | Unicorn plugin rules for better code |
387
+ | **`eslintArrayFuncRules`** | `eslint-plugin-array-func` | Array function preference rules |
388
+ | **`eslintPreferArrowFunctionRules`** | `eslint-plugin-prefer-arrow-functions` | Arrow function preference rules |
389
+ | **`eslintPluginSortDestructureKeysRules`** | `eslint-plugin-sort-destructure-keys` | Object destructuring rules |
390
+ | **`eslintPromiseRules`** | `eslint-plugin-promise` | Promise handling rules |
391
+ | **`eslintImportsRules`** | `eslint-plugin-import` | Import/export rules |
392
+ | **`eslintSecurityRules`** | `eslint-plugin-security` | Security best practices |
393
+ | **`eslintTreeShakableRules`** | `eslint-plugin-tree-shakable` | Tree-shaking optimization rules |
394
+ | **`eslintReactRules`** | `eslint-plugin-react` | React-specific rules |
395
+ | **`eslintReactHooksRules`** | `eslint-plugin-react-hooks` | React Hooks rules |
396
+ | **`eslintReactPerfRules`** | `eslint-plugin-react-perf` | React performance optimization rules |
397
+ | **`eslintReactRefreshRules`** | `eslint-plugin-react-refresh` | React Refresh (HMR) rules |
398
+ | **`eslintJsxA11yRules`** | `eslint-plugin-jsx-a11y` | Accessibility rules for JSX |
399
+ | **`eslintVitestRules`** | `eslint-plugin-vitest` | Vitest-specific rules |
400
+ | **`eslintJestRules`** | `eslint-plugin-jest` | Jest-specific rules |
401
+ | **`eslintTestingLibraryRules`** | `eslint-plugin-testing-library` | Testing Library rules |
402
+ | **`eslintPlaywrightRules`** | `eslint-plugin-playwright` | Playwright-specific rules |
403
+ | **`eslintCypressRules`** | `eslint-plugin-cypress` | Cypress-specific rules |
404
+ | **`eslintPluginRules`** | `eslint-plugin-eslint-plugin` | eslint-plugin development rules |
405
+
406
+ ### Exported Pre-configured Rule Options
407
+
408
+ | Pre-configured rule option | Rule | Description |
409
+ | :-------------------------------- | :---------------------- | :---------------------------------------------- |
410
+ | **`restrictedGlobals`** | `no-restricted-globals` | Array of restricted global variables |
411
+ | **`restrictedGlobalsForBrowser`** | `no-restricted-globals` | Browser-environment-specific restricted globals |
412
+
413
+ You can find other pre-configured rule options by traversing the pre-defined rules object like this:
414
+
415
+ - `typescriptEslintRules['@typescript-eslint/no-restricted-types'][1].types`
416
+ - `eslintRules['no-restricted-syntax'].slice(1)`
417
+
418
+ The shape of the rule option varies depending on the rule, so please check the contents by tracing the predefined rules each time and extract it.
297
419
 
298
420
  ### Custom Plugins
299
421
 
422
+ - **`eslintPluginTotalFunctions`**
423
+ - `eslint-plugin-total-functions` with support for Flat Config
424
+ - **`eslintPluginTreeShakable`**
425
+ - `eslint-plugin-tree-shakable` with support for Flat Config
300
426
  - **`eslintPluginCustom`** - Custom ESLint plugin with additional rules
301
- - **`eslintPluginTotalFunctions`** - Plugin for enforcing total functions
302
- - **`eslintPluginTreeShakable`** - Plugin for tree-shaking optimizations
303
- - **`plugins`** - Collection of all available plugins
304
-
305
- ### Custom Rules
306
-
307
- - **`noRestrictedSyntax`** - Enhanced restricted syntax rule
308
- - **`importStarRule`** - Rule for controlling import \* usage
309
- - **`noUnsafeOptionalPropertyAssignment`** - Prevent unsafe optional property assignments
310
- - **`noPrematureFpTsEffects`** - Prevent premature fp-ts effect usage
311
- - **`noPartialStringNormalize`** - Prevent partial string normalization
312
- - **`noUnsafeMutableReadonlyAssignment`** - Prevent unsafe mutable/readonly assignments
313
- - **`noPartialDivision`** - Prevent division by zero possibilities
314
- - **`requireStrictMode`** - Enforce strict mode
315
- - **`noEnums`** - Disallow TypeScript enums
316
- - **`noPartialUrlConstructor`** - Prevent partial URL constructor usage
317
- - **`noUnsafeTypeAssertion`** - Prevent unsafe type assertions
318
- - **`noUnsafeEnumAssignment`** - Prevent unsafe enum assignments
319
- - **`noUnsafeReadonlyMutableAssignment`** - Prevent readonly/mutable mismatches
320
- - **`noNestedFpTsEffects`** - Prevent nested fp-ts effects
321
- - **`noPartialArrayReduce`** - Prevent partial array reduce operations
322
- - **`noHiddenTypeAssertions`** - Prevent hidden type assertions
427
+ - Currently, this plugin only provides the `custom/no-restricted-syntax` rule (which duplicates ESLint's `no-restricted-syntax` rule).
428
+ - Can be used to set the error level to `error` or `warn` as needed.
429
+
430
+ Example:
431
+
432
+ ```js
433
+ import { eslintRules } from 'eslint-config-typed';
434
+
435
+ export default defineConfig([
436
+ // ...
437
+ {
438
+ rules: defineKnownRules({
439
+ 'no-restricted-syntax': [
440
+ 'warn',
441
+ ...eslintRules['no-restricted-syntax'].slice(1),
442
+ ],
443
+ 'custom/no-restricted-syntax': [
444
+ 'error',
445
+ {
446
+ // Restrict import style of React
447
+ selector:
448
+ "ImportDeclaration[source.value='react'][specifiers.0.type!='ImportNamespaceSpecifier']",
449
+ message:
450
+ "React should be imported as `import * as React from 'react'.",
451
+ },
452
+ ],
453
+ }),
454
+ },
455
+ ]);
456
+ ```
323
457
 
324
458
  ### Type Definitions
325
459
 
@@ -331,49 +465,56 @@ All rules and configurations come with complete TypeScript type definitions:
331
465
  - **`ESLintPlugin`** - ESLint plugin type
332
466
  - **`Rule`** - ESLint rule definition type
333
467
  - **`Rules`** - Collection of rules type
334
- - **`RestrictedImportsOption`** - Type for restricted imports configuration
335
468
 
336
469
  #### Rule Types
337
470
 
338
471
  Each plugin provides typed rule definitions:
339
472
 
340
- - **`EslintRules`** & **`EslintRulesOption`**
341
- - **`TypeScriptEslintRules`** & **`TypeScriptEslintRulesOption`**
342
- - **`EslintReactRules`** & **`EslintReactRulesOption`**
343
- - **`EslintReactHooksRules`** & **`EslintReactHooksRulesOption`**
344
- - **`EslintReactPerfRules`** & **`EslintReactPerfRulesOption`**
345
- - **`EslintReactRefreshRules`** & **`EslintReactRefreshRulesOption`**
346
- - **`EslintJsxA11yRules`** & **`EslintJsxA11yRulesOption`**
347
- - **`EslintFunctionalRules`** & **`EslintFunctionalRulesOption`**
348
- - **`EslintImportsRules`** & **`EslintImportsRulesOption`**
349
- - **`EslintUnicornRules`** & **`EslintUnicornRulesOption`**
350
- - **`EslintPromiseRules`** & **`EslintPromiseRulesOption`**
351
- - **`EslintSecurityRules`** (no options)
352
- - **`EslintArrayFuncRules`** (no options)
353
- - **`EslintPreferArrowFunctionRules`** & **`EslintPreferArrowFunctionRulesOption`**
354
- - **`EslintTotalFunctionsRules`** (no options)
355
- - **`EslintTreeShakableRules`** (no options)
356
- - **`EslintVitestRules`** & **`EslintVitestRulesOption`**
357
- - **`EslintJestRules`** & **`EslintJestRulesOption`**
358
- - **`EslintCypressRules`** & **`EslintCypressRulesOption`**
359
- - **`EslintPlaywrightRules`** & **`EslintPlaywrightRulesOption`**
360
- - **`EslintTestingLibraryRules`** & **`EslintTestingLibraryRulesOption`**
361
- - **`EslintStrictDependenciesRules`** & **`EslintStrictDependenciesRulesOption`**
362
- - **`EslintPluginRules`** & **`EslintPluginRulesOption`**
363
- - **`EslintDeprecationRules`** (no options)
473
+ - General rules
474
+ - **`EslintRules`** & **`EslintRulesOption`**
475
+ - **`TypeScriptEslintRules`** & **`TypeScriptEslintRulesOption`**
476
+ - **`EslintFunctionalRules`** & **`EslintFunctionalRulesOption`**
477
+ - **`EslintTotalFunctionsRules`** (no options)
478
+ - **`EslintUnicornRules`** & **`EslintUnicornRulesOption`**
479
+ - **`EslintArrayFuncRules`** (no options)
480
+ - **`EslintPreferArrowFunctionRules`** & **`EslintPreferArrowFunctionRulesOption`**
481
+ - **`EslintPluginSortDestructureKeysRules`** & **`EslintPluginSortDestructureKeysRulesOption`**
482
+ - **`EslintPromiseRules`** & **`EslintPromiseRulesOption`**
483
+ - **`EslintImportsRules`** & **`EslintImportsRulesOption`**
484
+ - **`EslintStrictDependenciesRules`** & **`EslintStrictDependenciesRulesOption`**
485
+ - **`EslintSecurityRules`** (no options)
486
+ - **`EslintTreeShakableRules`** (no options)
487
+ - React & JSX
488
+ - **`EslintReactRules`** & **`EslintReactRulesOption`**
489
+ - **`EslintReactHooksRules`** & **`EslintReactHooksRulesOption`**
490
+ - **`EslintReactPerfRules`** & **`EslintReactPerfRulesOption`**
491
+ - **`EslintReactRefreshRules`** & **`EslintReactRefreshRulesOption`**
492
+ - **`EslintJsxA11yRules`** & **`EslintJsxA11yRulesOption`**
493
+ - Testing
494
+ - **`EslintVitestRules`** & **`EslintVitestRulesOption`**
495
+ - **`EslintJestRules`** & **`EslintJestRulesOption`**
496
+ - **`EslintPlaywrightRules`** & **`EslintPlaywrightRulesOption`**
497
+ - **`EslintCypressRules`** & **`EslintCypressRulesOption`**
498
+ - **`EslintTestingLibraryRules`** & **`EslintTestingLibraryRulesOption`**
499
+ - Others
500
+ - **`EslintPluginRules`** & **`EslintPluginRulesOption`**
364
501
 
365
502
  ## Customization
366
503
 
504
+ The pre-configured rules of `eslint-config-typed` are opinionated settings that prioritize strictness and enable as many non-conflicting rules as possible. Therefore, it is intended to be used by downgrading the severity of unnecessary rules in the config file from `"error"` to `"warn"` or `"off"`, or by overriding option settings.
505
+
367
506
  ### Override Specific Rules
368
507
 
369
508
  You can override any rule by adding a configuration object after the preset configurations:
370
509
 
371
510
  ```js
372
- export default [
373
- ...eslintFlatConfigForTypeScript(options),
511
+ import { typescriptEslintRules } from 'eslint-config-typed';
512
+
513
+ export default defineConfig([
514
+ ...eslintConfigForTypeScript(options),
374
515
  {
375
- rules: {
376
- // Downgrade to warning
516
+ rules: defineKnownRules({
517
+ // Downgrade to warning (Option settings are inherited)
377
518
  '@typescript-eslint/no-explicit-any': 'warn',
378
519
  // Disable a rule
379
520
  '@typescript-eslint/prefer-readonly-parameter-types': 'off',
@@ -385,57 +526,86 @@ export default [
385
526
  allowInFunctions: false,
386
527
  },
387
528
  ],
388
- },
529
+
530
+ // Update rule options
531
+ '@typescript-eslint/no-restricted-types': [
532
+ 'error',
533
+ {
534
+ types: {
535
+ ...typescriptEslintRules[
536
+ '@typescript-eslint/no-restricted-types'
537
+ ][1].types,
538
+ Function: "Don't use Function type",
539
+ },
540
+ },
541
+ ],
542
+ }),
389
543
  },
390
- ];
544
+ ]);
391
545
  ```
392
546
 
393
547
  ### Use Type-Safe Rule Options
394
548
 
395
549
  Leverage TypeScript for type-safe rule configuration:
396
550
 
397
- ```js
398
- /** @type {import('eslint-config-typed').EslintFunctionalRulesOption['functional/no-let']} */
399
- const noLetOptions = {
400
- allowInForLoopInit: false,
401
- allowInFunctions: false,
402
- };
551
+ ```ts
552
+ // configs/restricted-syntax-defs.mjs
403
553
 
404
- export default [
405
- ...eslintFlatConfigForTypeScript(options),
554
+ import { eslintRules } from 'eslint-config-typed';
555
+
556
+ /** @type {import("eslint-config-typed").EslintRulesOption["no-restricted-syntax"]} */
557
+ export const restrictedSyntax = [
558
+ ...eslintRules['no-restricted-syntax'].slice(1),
406
559
  {
407
- rules: {
408
- 'functional/no-let': ['error', noLetOptions],
409
- },
560
+ // Restrict type annotation style for React.useMemo
561
+ selector:
562
+ "TSTypeAnnotation[parent.parent.type='CallExpression'][parent.parent.callee.object.name='React'][parent.parent.callee.property.name='useMemo']",
563
+ message:
564
+ 'The variable type T should be annotated as `React.useMemo<T>` or `const v: T = React.useMemo(...)`.',
410
565
  },
411
566
  ];
412
567
  ```
413
568
 
569
+ ```ts
570
+ // eslint.config.js
571
+
572
+ import { restrictedSyntax } from './configs/restricted-syntax-defs.mjs';
573
+
574
+ export default defineConfig([
575
+ ...eslintConfigForTypeScript(options),
576
+ {
577
+ rules: defineKnownRules({
578
+ 'no-restricted-syntax': ['error', restrictedSyntax],
579
+ }),
580
+ },
581
+ ]);
582
+ ```
583
+
414
584
  ### Target Specific Files
415
585
 
416
586
  Apply different rules to different file patterns:
417
587
 
418
588
  ```js
419
- export default [
420
- ...eslintFlatConfigForTypeScript(options),
589
+ export default defineConfig([
590
+ ...eslintConfigForTypeScript(options),
421
591
  {
422
592
  files: ['**/*.test.ts', '**/*.spec.ts'],
423
- rules: {
593
+ rules: defineKnownRules({
424
594
  // Allow any in tests
425
595
  '@typescript-eslint/no-explicit-any': 'off',
426
596
  // Allow console in tests
427
597
  'no-console': 'off',
428
- },
598
+ }),
429
599
  },
430
600
  {
431
- files: ['**/scripts/**/*.ts'],
432
- rules: {
601
+ files: ['scripts/**/*.ts'],
602
+ rules: defineKnownRules({
433
603
  // Allow console in scripts
434
- 'no-console': 'off',
435
- 'no-process-exit': 'off',
436
- },
604
+ 'no-await-in-loop': 'off',
605
+ 'import/no-unassigned-import': 'off',
606
+ }),
437
607
  },
438
- ];
608
+ ]);
439
609
  ```
440
610
 
441
611
  ## Troubleshooting
@@ -449,11 +619,13 @@ Ensure the paths are correct:
449
619
  ```js
450
620
  const thisDir = import.meta.dirname;
451
621
 
452
- ...eslintFlatConfigForTypeScript({
453
- tsconfigRootDir: thisDir, // Must be absolute path
454
- tsconfigFileName: './tsconfig.json', // Relative to tsconfigRootDir
455
- packageDirs: [thisDir],
456
- })
622
+ export default defineConfig([
623
+ ...eslintConfigForTypeScript({
624
+ tsconfigRootDir: thisDir, // Must be absolute path
625
+ tsconfigFileName: './tsconfig.json', // Relative to tsconfigRootDir
626
+ packageDirs: [thisDir],
627
+ }),
628
+ ]);
457
629
  ```
458
630
 
459
631
  #### 2. Import resolution errors
@@ -461,24 +633,25 @@ const thisDir = import.meta.dirname;
461
633
  The `packageDirs` option helps ESLint resolve imports correctly in monorepos:
462
634
 
463
635
  ```js
464
- ...eslintFlatConfigForTypeScript({
465
- tsconfigRootDir: thisDir,
466
- tsconfigFileName: './tsconfig.json',
467
- packageDirs: [
468
- path.resolve(thisDir, '../../..'), // Monorepo root
469
- thisDir, // Current package
470
- ],
471
- })
636
+ export default defineConfig([
637
+ ...eslintConfigForTypeScript({
638
+ tsconfigRootDir: thisDir,
639
+ tsconfigFileName: './tsconfig.json',
640
+ packageDirs: [
641
+ path.resolve(thisDir, '../../..'), // Monorepo root
642
+ thisDir, // Current package
643
+ ],
644
+ }),
645
+ ]);
472
646
  ```
473
647
 
474
- #### 3. Rule conflicts
475
-
476
- If you encounter rule conflicts, the last configuration wins. Place your overrides after the preset configurations.
477
-
478
- #### 4. Performance issues
648
+ #### 3. Performance issues
479
649
 
480
650
  For large projects, consider:
481
651
 
652
+ - Using `TIMING=1 eslint` to identify heavy rules
653
+ - Using `NODE_OPTIONS='--max-old-space-size=<memory-size-MB>' eslint` to increase the maximum memory available
654
+ - Separate heavy rules into a separate config and prepare a dedicated command
482
655
  - Using `.eslintignore` or `ignores` patterns to skip generated files
483
656
  - Running ESLint with `--cache` flag
484
657
  - Limiting the scope of type-aware rules
@@ -500,8 +673,3 @@ Contributions are welcome! Please check our [GitHub repository](https://github.c
500
673
  ## License
501
674
 
502
675
  This project is licensed under the [Apache License 2.0](./LICENSE).
503
-
504
- ## Future Updates
505
-
506
- - Enhanced support for `eslint-plugin-functional`
507
- - Migration from `functional/prefer-readonly-type` to `functional/prefer-immutable-types` and `functional/type-declaration-immutability`