eslint-config-typed 1.8.1 → 2.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 (270) hide show
  1. package/README.md +349 -202
  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 +2 -2
  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 +35 -2
  125. package/dist/rules/eslint-plugin-rules.d.mts.map +1 -1
  126. package/dist/rules/eslint-plugin-rules.mjs.map +1 -1
  127. package/dist/rules/eslint-plugin-sort-destructure-keys-rules.d.mts +3 -2
  128. package/dist/rules/eslint-plugin-sort-destructure-keys-rules.d.mts.map +1 -1
  129. package/dist/rules/eslint-plugin-sort-destructure-keys-rules.mjs.map +1 -1
  130. package/dist/rules/eslint-prefer-arrow-functions-rules.d.mts +11 -2
  131. package/dist/rules/eslint-prefer-arrow-functions-rules.d.mts.map +1 -1
  132. package/dist/rules/eslint-prefer-arrow-functions-rules.mjs.map +1 -1
  133. package/dist/rules/eslint-promise-rules.d.mts +21 -2
  134. package/dist/rules/eslint-promise-rules.d.mts.map +1 -1
  135. package/dist/rules/eslint-promise-rules.mjs.map +1 -1
  136. package/dist/rules/eslint-react-hooks-rules.d.mts +31 -2
  137. package/dist/rules/eslint-react-hooks-rules.d.mts.map +1 -1
  138. package/dist/rules/eslint-react-hooks-rules.mjs.map +1 -1
  139. package/dist/rules/eslint-react-perf-rules.d.mts +6 -2
  140. package/dist/rules/eslint-react-perf-rules.d.mts.map +1 -1
  141. package/dist/rules/eslint-react-perf-rules.mjs.map +1 -1
  142. package/dist/rules/eslint-react-refresh-rules.d.mts +3 -2
  143. package/dist/rules/eslint-react-refresh-rules.d.mts.map +1 -1
  144. package/dist/rules/eslint-react-refresh-rules.mjs.map +1 -1
  145. package/dist/rules/eslint-react-rules.d.mts +142 -2
  146. package/dist/rules/eslint-react-rules.d.mts.map +1 -1
  147. package/dist/rules/eslint-react-rules.mjs.map +1 -1
  148. package/dist/rules/eslint-rules.d.mts +442 -31
  149. package/dist/rules/eslint-rules.d.mts.map +1 -1
  150. package/dist/rules/eslint-rules.mjs +114 -74
  151. package/dist/rules/eslint-rules.mjs.map +1 -1
  152. package/dist/rules/eslint-security-rules.d.mts +16 -2
  153. package/dist/rules/eslint-security-rules.d.mts.map +1 -1
  154. package/dist/rules/eslint-security-rules.mjs.map +1 -1
  155. package/dist/rules/eslint-testing-library-rules.d.mts +34 -2
  156. package/dist/rules/eslint-testing-library-rules.d.mts.map +1 -1
  157. package/dist/rules/eslint-testing-library-rules.mjs.map +1 -1
  158. package/dist/rules/eslint-total-functions-rules.d.mts +16 -2
  159. package/dist/rules/eslint-total-functions-rules.d.mts.map +1 -1
  160. package/dist/rules/eslint-total-functions-rules.mjs +2 -0
  161. package/dist/rules/eslint-total-functions-rules.mjs.map +1 -1
  162. package/dist/rules/eslint-tree-shakable-rules.d.mts +3 -2
  163. package/dist/rules/eslint-tree-shakable-rules.d.mts.map +1 -1
  164. package/dist/rules/eslint-tree-shakable-rules.mjs.map +1 -1
  165. package/dist/rules/eslint-unicorn-rules.d.mts +186 -2
  166. package/dist/rules/eslint-unicorn-rules.d.mts.map +1 -1
  167. package/dist/rules/eslint-unicorn-rules.mjs +29 -31
  168. package/dist/rules/eslint-unicorn-rules.mjs.map +1 -1
  169. package/dist/rules/eslint-vitest-rules.d.mts +62 -2
  170. package/dist/rules/eslint-vitest-rules.d.mts.map +1 -1
  171. package/dist/rules/eslint-vitest-rules.mjs.map +1 -1
  172. package/dist/rules/index.mjs +3 -3
  173. package/dist/rules/typescript-eslint-rules.d.mts +316 -4
  174. package/dist/rules/typescript-eslint-rules.d.mts.map +1 -1
  175. package/dist/rules/typescript-eslint-rules.mjs +111 -57
  176. package/dist/rules/typescript-eslint-rules.mjs.map +1 -1
  177. package/dist/types/define-config.d.mts +3 -0
  178. package/dist/types/define-config.d.mts.map +1 -0
  179. package/dist/types/define-config.mjs +4 -0
  180. package/dist/types/define-config.mjs.map +1 -0
  181. package/dist/types/define-known-rules.d.mts +2 -2
  182. package/dist/types/define-known-rules.d.mts.map +1 -1
  183. package/dist/types/define-known-rules.mjs.map +1 -1
  184. package/dist/types/flat-config.d.mts +1 -1
  185. package/dist/types/flat-config.d.mts.map +1 -1
  186. package/dist/types/index.d.mts +1 -1
  187. package/dist/types/index.d.mts.map +1 -1
  188. package/dist/types/index.mjs +1 -0
  189. package/dist/types/index.mjs.map +1 -1
  190. package/dist/types/rules/eslint-custom-rules.d.mts +62 -0
  191. package/dist/types/rules/eslint-custom-rules.d.mts.map +1 -0
  192. package/dist/types/rules/eslint-custom-rules.mjs +2 -0
  193. package/dist/types/rules/eslint-custom-rules.mjs.map +1 -0
  194. package/dist/types/rules/eslint-total-functions-rules.d.mts +64 -32
  195. package/dist/types/rules/eslint-total-functions-rules.d.mts.map +1 -1
  196. package/dist/types/rules/index.d.mts +1 -0
  197. package/dist/types/rules/index.d.mts.map +1 -1
  198. package/package.json +10 -3
  199. package/src/configs/browser.mts +24 -0
  200. package/src/configs/cypress.mts +1 -3
  201. package/src/configs/index.mts +2 -0
  202. package/src/configs/jest.mts +1 -3
  203. package/src/configs/nodejs.mts +34 -0
  204. package/src/configs/playwright.mts +1 -1
  205. package/src/configs/plugins.mts +1 -2
  206. package/src/configs/preact.mts +29 -4
  207. package/src/configs/react-base.mts +20 -24
  208. package/src/configs/react.mts +3 -3
  209. package/src/configs/testing-library.mts +1 -1
  210. package/src/configs/typescript-without-rules.mts +1 -1
  211. package/src/configs/typescript.mts +31 -19
  212. package/src/configs/vitest.mts +1 -3
  213. package/src/entry-point.mts +109 -1
  214. package/src/index.mts +0 -1
  215. package/src/plugins/custom/custom.mts +6 -0
  216. package/src/plugins/custom/index.mts +1 -0
  217. package/src/plugins/custom/rules/index.mts +1 -0
  218. package/src/{custom-rules → plugins/custom/rules}/no-restricted-syntax2.mts +1 -1
  219. package/src/plugins/custom/rules/rules.mts +6 -0
  220. package/src/plugins/index.mts +1 -0
  221. package/src/plugins/total-functions/index.mts +0 -1
  222. package/src/plugins/total-functions/rules/no-unsafe-optional-property-assignment.mts +1 -1
  223. package/src/plugins/total-functions/rules/rules.mts +12 -8
  224. package/src/plugins/tree-shakable/index.mts +0 -1
  225. package/src/rules/eslint-array-func-rules.mts +2 -2
  226. package/src/rules/eslint-cypress-rules.mts +2 -2
  227. package/src/rules/eslint-functional-rules.mts +52 -47
  228. package/src/rules/eslint-import-rules.mts +2 -2
  229. package/src/rules/eslint-jest-rules.mts +2 -2
  230. package/src/rules/eslint-jsx-a11y-rules.mts +2 -2
  231. package/src/rules/eslint-playwright-rules.mts +2 -2
  232. package/src/rules/eslint-plugin-rules.mts +2 -2
  233. package/src/rules/eslint-plugin-sort-destructure-keys-rules.mts +3 -4
  234. package/src/rules/eslint-prefer-arrow-functions-rules.mts +2 -2
  235. package/src/rules/eslint-promise-rules.mts +2 -2
  236. package/src/rules/eslint-react-hooks-rules.mts +2 -2
  237. package/src/rules/eslint-react-perf-rules.mts +2 -2
  238. package/src/rules/eslint-react-refresh-rules.mts +2 -2
  239. package/src/rules/eslint-react-rules.mts +2 -2
  240. package/src/rules/eslint-rules.mts +126 -79
  241. package/src/rules/eslint-security-rules.mts +2 -2
  242. package/src/rules/eslint-testing-library-rules.mts +2 -2
  243. package/src/rules/eslint-total-functions-rules.mts +5 -2
  244. package/src/rules/eslint-tree-shakable-rules.mts +2 -2
  245. package/src/rules/eslint-unicorn-rules.mts +35 -33
  246. package/src/rules/eslint-vitest-rules.mts +2 -2
  247. package/src/rules/typescript-eslint-rules.mts +120 -65
  248. package/src/types/define-config.mts +5 -0
  249. package/src/types/define-known-rules.mts +4 -0
  250. package/src/types/flat-config.mts +1 -3
  251. package/src/types/index.mts +1 -1
  252. package/src/types/rules/eslint-custom-rules.mts +76 -0
  253. package/src/types/rules/eslint-total-functions-rules.mts +68 -32
  254. package/src/types/rules/index.mts +1 -0
  255. package/dist/custom-rules/custom.d.mts +0 -3
  256. package/dist/custom-rules/custom.d.mts.map +0 -1
  257. package/dist/custom-rules/custom.mjs +0 -10
  258. package/dist/custom-rules/custom.mjs.map +0 -1
  259. package/dist/custom-rules/index.d.mts +0 -3
  260. package/dist/custom-rules/index.d.mts.map +0 -1
  261. package/dist/custom-rules/no-restricted-syntax2.d.mts.map +0 -1
  262. package/dist/custom-rules/no-restricted-syntax2.mjs.map +0 -1
  263. package/dist/types/types.d.mts +0 -8
  264. package/dist/types/types.d.mts.map +0 -1
  265. package/dist/types/types.mjs +0 -2
  266. package/dist/types/types.mjs.map +0 -1
  267. package/src/custom-rules/custom.mts +0 -8
  268. package/src/custom-rules/index.mts +0 -2
  269. package/src/types/types.mts +0 -7
  270. /package/dist/{custom-rules → plugins/custom/rules}/no-restricted-syntax2.d.mts +0 -0
package/README.md CHANGED
@@ -13,6 +13,9 @@ 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)
@@ -20,27 +23,36 @@ A comprehensive ESLint configuration package with strongly-typed rule definition
20
23
  - [VS Code Integration](#vs-code-integration)
21
24
  - [API Reference](#api-reference)
22
25
  - [Configuration Functions](#configuration-functions)
26
+ - [Base Configurations](#base-configurations)
27
+ - [Framework Configurations](#framework-configurations)
28
+ - [Utility Configurations](#utility-configurations)
23
29
  - [Rule Collections](#rule-collections)
24
- - [Utility Exports](#utility-exports)
30
+ - [Exported Pre-configured Rule Options](#exported-pre-configured-rule-options)
25
31
  - [Custom Plugins](#custom-plugins)
26
- - [Custom Rules](#custom-rules)
27
32
  - [Type Definitions](#type-definitions)
33
+ - [Core Types](#core-types)
34
+ - [Rule Types](#rule-types)
28
35
  - [Customization](#customization)
29
36
  - [Override Specific Rules](#override-specific-rules)
30
37
  - [Use Type-Safe Rule Options](#use-type-safe-rule-options)
31
38
  - [Target Specific Files](#target-specific-files)
32
39
  - [Troubleshooting](#troubleshooting)
40
+ - [Common Issues](#common-issues)
41
+ - [1. ESLint can't find tsconfig.json](#1-eslint-cant-find-tsconfigjson)
42
+ - [2. Import resolution errors](#2-import-resolution-errors)
43
+ - [3. Performance issues](#3-performance-issues)
44
+ - [Known Limitations](#known-limitations)
33
45
  - [Contributing](#contributing)
34
46
  - [License](#license)
47
+ - [Future Updates](#future-updates)
35
48
 
36
49
  ## Features
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,7 +63,7 @@ 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-config-typed
55
67
  # or
56
68
  yarn add -D eslint-config-typed
57
69
  # or
@@ -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
287
 
198
- const thisDir = import.meta.dirname;
199
-
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
@@ -234,92 +322,112 @@ Add the following to `.vscode/settings.json` for proper ESLint integration:
234
322
 
235
323
  These functions return arrays of ESLint flat configurations:
236
324
 
237
- #### Framework Configurations
325
+ #### Base Configurations
238
326
 
239
- - **`eslintFlatConfigForTypeScript(options)`** - TypeScript configuration with strict type checking rules
327
+ - **`eslintConfigForTypeScript(options)`** - TypeScript configuration with strict type checking rules
240
328
  - `options.tsconfigRootDir`: Root directory containing tsconfig.json
241
329
  - `options.tsconfigFileName`: Path to tsconfig.json file
242
330
  - `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
331
+ - **`eslintConfigForBrowser`** - Browser configuration (Turn off Node.js-specific rules)
332
+ - **`eslintConfigForNodeJs`** - Node.js configuration (Turn off browser-specific rules)
246
333
 
247
- #### Testing Framework Configurations
334
+ #### Framework Configurations
248
335
 
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
336
+ - **`eslintConfigForReact(options?)`** - React configuration with hooks and JSX rules
337
+ - `eslintConfigForBrowser` is included in this configuration
338
+ - **`eslintConfigForPreact(options?)`** - Preact configuration (lighter React alternative)
339
+ - `eslintConfigForBrowser` is included in this configuration
340
+ - **`eslintConfigForVitest(options?)`** - Vitest testing framework configuration
341
+ - **`eslintConfigForJest(options?)`** - Jest testing framework configuration
342
+ - **`eslintConfigForTestingLibrary(options?)`** - Testing Library configuration
343
+ - **`eslintConfigForPlaywright(options?)`** - Playwright E2E testing configuration
344
+ - **`eslintConfigForCypress(options?)`** - Cypress E2E testing configuration
254
345
 
255
346
  #### Utility Configurations
256
347
 
257
- - **`eslintFlatConfigForTypeScriptWithoutRules(options)`** - TypeScript parser setup without any rules
348
+ - **`eslintConfigForTypeScriptWithoutRules(options)`** - TypeScript parser & plugins setup without any rules
258
349
 
259
350
  ### Rule Collections
260
351
 
261
352
  Pre-configured rule sets that can be imported and customized:
262
353
 
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
354
+ | Rule set | Plugin name | Description |
355
+ | :----------------------------------------- | :------------------------------------- | :----------------------------------- |
356
+ | **`eslintRules`** | (eslint) | Core ESLint rules |
357
+ | **`typescriptEslintRules`** | `@typescript-eslint/eslint-plugin` | TypeScript-specific ESLint rules |
358
+ | **`eslintFunctionalRules`** | `eslint-plugin-functional` | Functional programming style rules |
359
+ | **`eslintTotalFunctionsRules`** | `eslint-plugin-total-functions` | Functional programming style rules |
360
+ | **`eslintUnicornRules`** | `eslint-plugin-unicorn` | Unicorn plugin rules for better code |
361
+ | **`eslintArrayFuncRules`** | `eslint-plugin-array-func` | Array function preference rules |
362
+ | **`eslintPreferArrowFunctionRules`** | `eslint-plugin-prefer-arrow-functions` | Arrow function preference rules |
363
+ | **`eslintPluginSortDestructureKeysRules`** | `eslint-plugin-sort-destructure-keys` | Object destructuring rules |
364
+ | **`eslintPromiseRules`** | `eslint-plugin-promise` | Promise handling rules |
365
+ | **`eslintImportsRules`** | `eslint-plugin-import` | Import/export rules |
366
+ | **`eslintSecurityRules`** | `eslint-plugin-security` | Security best practices |
367
+ | **`eslintTreeShakableRules`** | `eslint-plugin-tree-shakable` | Tree-shaking optimization rules |
368
+ | **`eslintReactRules`** | `eslint-plugin-react` | React-specific rules |
369
+ | **`eslintReactHooksRules`** | `eslint-plugin-react-hooks` | React Hooks rules |
370
+ | **`eslintReactPerfRules`** | `eslint-plugin-react-perf` | React performance optimization rules |
371
+ | **`eslintReactRefreshRules`** | `eslint-plugin-react-refresh` | React Refresh (HMR) rules |
372
+ | **`eslintJsxA11yRules`** | `eslint-plugin-jsx-a11y` | Accessibility rules for JSX |
373
+ | **`eslintVitestRules`** | `eslint-plugin-vitest` | Vitest-specific rules |
374
+ | **`eslintJestRules`** | `eslint-plugin-jest` | Jest-specific rules |
375
+ | **`eslintTestingLibraryRules`** | `eslint-plugin-testing-library` | Testing Library rules |
376
+ | **`eslintPlaywrightRules`** | `eslint-plugin-playwright` | Playwright-specific rules |
377
+ | **`eslintCypressRules`** | `eslint-plugin-cypress` | Cypress-specific rules |
378
+ | **`eslintPluginRules`** | `eslint-plugin-eslint-plugin` | eslint-plugin development rules |
379
+
380
+ ### Exported Pre-configured Rule Options
381
+
382
+ | Pre-configured rule option | Rule | Description |
383
+ | :-------------------------------- | :---------------------- | :---------------------------------------------- |
384
+ | **`restrictedGlobals`** | `no-restricted-globals` | Array of restricted global variables |
385
+ | **`restrictedGlobalsForBrowser`** | `no-restricted-globals` | Browser-environment-specific restricted globals |
386
+
387
+ You can find other pre-configured rule options by traversing the pre-defined rules object like this:
388
+
389
+ - `typescriptEslintRules['@typescript-eslint/no-restricted-types'][1].types`
390
+ - `eslintRules['no-restricted-syntax'].slice(1)`
391
+
392
+ 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
393
 
298
394
  ### Custom Plugins
299
395
 
396
+ - **`eslintPluginTotalFunctions`**
397
+ - `eslint-plugin-total-functions` with support for Flat Config
398
+ - **`eslintPluginTreeShakable`**
399
+ - `eslint-plugin-tree-shakable` with support for Flat Config
300
400
  - **`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
401
+ - Currently, this plugin only provides the `custom/no-restricted-syntax` rule (which duplicates ESLint's `no-restricted-syntax` rule).
402
+ - Can be used to set the error level to `error` or `warn` as needed.
403
+
404
+ Example:
405
+
406
+ ```js
407
+ import { eslintRules } from 'eslint-config-typed';
408
+
409
+ export default defineConfig([
410
+ // ...
411
+ {
412
+ rules: defineKnownRules({
413
+ 'no-restricted-syntax': [
414
+ 'warn',
415
+ ...eslintRules['no-restricted-syntax'].slice(1),
416
+ ],
417
+ 'custom/no-restricted-syntax': [
418
+ 'error',
419
+ {
420
+ // Restrict import style of React
421
+ selector:
422
+ "ImportDeclaration[source.value='react'][specifiers.0.type!='ImportNamespaceSpecifier']",
423
+ message:
424
+ "React should be imported as `import * as React from 'react'.",
425
+ },
426
+ ],
427
+ }),
428
+ },
429
+ ]);
430
+ ```
323
431
 
324
432
  ### Type Definitions
325
433
 
@@ -331,49 +439,56 @@ All rules and configurations come with complete TypeScript type definitions:
331
439
  - **`ESLintPlugin`** - ESLint plugin type
332
440
  - **`Rule`** - ESLint rule definition type
333
441
  - **`Rules`** - Collection of rules type
334
- - **`RestrictedImportsOption`** - Type for restricted imports configuration
335
442
 
336
443
  #### Rule Types
337
444
 
338
445
  Each plugin provides typed rule definitions:
339
446
 
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)
447
+ - General rules
448
+ - **`EslintRules`** & **`EslintRulesOption`**
449
+ - **`TypeScriptEslintRules`** & **`TypeScriptEslintRulesOption`**
450
+ - **`EslintFunctionalRules`** & **`EslintFunctionalRulesOption`**
451
+ - **`EslintTotalFunctionsRules`** (no options)
452
+ - **`EslintUnicornRules`** & **`EslintUnicornRulesOption`**
453
+ - **`EslintArrayFuncRules`** (no options)
454
+ - **`EslintPreferArrowFunctionRules`** & **`EslintPreferArrowFunctionRulesOption`**
455
+ - **`EslintPluginSortDestructureKeysRules`** & **`EslintPluginSortDestructureKeysRulesOption`**
456
+ - **`EslintPromiseRules`** & **`EslintPromiseRulesOption`**
457
+ - **`EslintImportsRules`** & **`EslintImportsRulesOption`**
458
+ - **`EslintStrictDependenciesRules`** & **`EslintStrictDependenciesRulesOption`**
459
+ - **`EslintSecurityRules`** (no options)
460
+ - **`EslintTreeShakableRules`** (no options)
461
+ - React & JSX
462
+ - **`EslintReactRules`** & **`EslintReactRulesOption`**
463
+ - **`EslintReactHooksRules`** & **`EslintReactHooksRulesOption`**
464
+ - **`EslintReactPerfRules`** & **`EslintReactPerfRulesOption`**
465
+ - **`EslintReactRefreshRules`** & **`EslintReactRefreshRulesOption`**
466
+ - **`EslintJsxA11yRules`** & **`EslintJsxA11yRulesOption`**
467
+ - Testing
468
+ - **`EslintVitestRules`** & **`EslintVitestRulesOption`**
469
+ - **`EslintJestRules`** & **`EslintJestRulesOption`**
470
+ - **`EslintPlaywrightRules`** & **`EslintPlaywrightRulesOption`**
471
+ - **`EslintCypressRules`** & **`EslintCypressRulesOption`**
472
+ - **`EslintTestingLibraryRules`** & **`EslintTestingLibraryRulesOption`**
473
+ - Others
474
+ - **`EslintPluginRules`** & **`EslintPluginRulesOption`**
364
475
 
365
476
  ## Customization
366
477
 
478
+ 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.
479
+
367
480
  ### Override Specific Rules
368
481
 
369
482
  You can override any rule by adding a configuration object after the preset configurations:
370
483
 
371
484
  ```js
372
- export default [
373
- ...eslintFlatConfigForTypeScript(options),
485
+ import { typescriptEslintRules } from 'eslint-config-typed';
486
+
487
+ export default defineConfig([
488
+ ...eslintConfigForTypeScript(options),
374
489
  {
375
- rules: {
376
- // Downgrade to warning
490
+ rules: defineKnownRules({
491
+ // Downgrade to warning (Option settings are inherited)
377
492
  '@typescript-eslint/no-explicit-any': 'warn',
378
493
  // Disable a rule
379
494
  '@typescript-eslint/prefer-readonly-parameter-types': 'off',
@@ -385,57 +500,86 @@ export default [
385
500
  allowInFunctions: false,
386
501
  },
387
502
  ],
388
- },
503
+
504
+ // Update rule options
505
+ '@typescript-eslint/no-restricted-types': [
506
+ 'error',
507
+ {
508
+ types: {
509
+ ...typescriptEslintRules[
510
+ '@typescript-eslint/no-restricted-types'
511
+ ][1].types,
512
+ Function: "Don't use Function type",
513
+ },
514
+ },
515
+ ],
516
+ }),
389
517
  },
390
- ];
518
+ ]);
391
519
  ```
392
520
 
393
521
  ### Use Type-Safe Rule Options
394
522
 
395
523
  Leverage TypeScript for type-safe rule configuration:
396
524
 
397
- ```js
398
- /** @type {import('eslint-config-typed').EslintFunctionalRulesOption['functional/no-let']} */
399
- const noLetOptions = {
400
- allowInForLoopInit: false,
401
- allowInFunctions: false,
402
- };
525
+ ```ts
526
+ // configs/restricted-syntax-defs.mjs
403
527
 
404
- export default [
405
- ...eslintFlatConfigForTypeScript(options),
528
+ import { eslintRules } from 'eslint-config-typed';
529
+
530
+ /** @type {import("eslint-config-typed").EslintRulesOption["no-restricted-syntax"]} */
531
+ export const restrictedSyntax = [
532
+ ...eslintRules['no-restricted-syntax'].slice(1),
406
533
  {
407
- rules: {
408
- 'functional/no-let': ['error', noLetOptions],
409
- },
534
+ // Restrict type annotation style for React.useMemo
535
+ selector:
536
+ "TSTypeAnnotation[parent.parent.type='CallExpression'][parent.parent.callee.object.name='React'][parent.parent.callee.property.name='useMemo']",
537
+ message:
538
+ 'The variable type T should be annotated as `React.useMemo<T>` or `const v: T = React.useMemo(...)`.',
410
539
  },
411
540
  ];
412
541
  ```
413
542
 
543
+ ```ts
544
+ // eslint.config.js
545
+
546
+ import { restrictedSyntax } from './configs/restricted-syntax-defs.mjs';
547
+
548
+ export default defineConfig([
549
+ ...eslintConfigForTypeScript(options),
550
+ {
551
+ rules: defineKnownRules({
552
+ 'no-restricted-syntax': ['error', restrictedSyntax],
553
+ }),
554
+ },
555
+ ]);
556
+ ```
557
+
414
558
  ### Target Specific Files
415
559
 
416
560
  Apply different rules to different file patterns:
417
561
 
418
562
  ```js
419
- export default [
420
- ...eslintFlatConfigForTypeScript(options),
563
+ export default defineConfig([
564
+ ...eslintConfigForTypeScript(options),
421
565
  {
422
566
  files: ['**/*.test.ts', '**/*.spec.ts'],
423
- rules: {
567
+ rules: defineKnownRules({
424
568
  // Allow any in tests
425
569
  '@typescript-eslint/no-explicit-any': 'off',
426
570
  // Allow console in tests
427
571
  'no-console': 'off',
428
- },
572
+ }),
429
573
  },
430
574
  {
431
- files: ['**/scripts/**/*.ts'],
432
- rules: {
575
+ files: ['scripts/**/*.ts'],
576
+ rules: defineKnownRules({
433
577
  // Allow console in scripts
434
- 'no-console': 'off',
435
- 'no-process-exit': 'off',
436
- },
578
+ 'no-await-in-loop': 'off',
579
+ 'import/no-unassigned-import': 'off',
580
+ }),
437
581
  },
438
- ];
582
+ ]);
439
583
  ```
440
584
 
441
585
  ## Troubleshooting
@@ -449,11 +593,13 @@ Ensure the paths are correct:
449
593
  ```js
450
594
  const thisDir = import.meta.dirname;
451
595
 
452
- ...eslintFlatConfigForTypeScript({
453
- tsconfigRootDir: thisDir, // Must be absolute path
454
- tsconfigFileName: './tsconfig.json', // Relative to tsconfigRootDir
455
- packageDirs: [thisDir],
456
- })
596
+ export default defineConfig([
597
+ ...eslintConfigForTypeScript({
598
+ tsconfigRootDir: thisDir, // Must be absolute path
599
+ tsconfigFileName: './tsconfig.json', // Relative to tsconfigRootDir
600
+ packageDirs: [thisDir],
601
+ }),
602
+ ]);
457
603
  ```
458
604
 
459
605
  #### 2. Import resolution errors
@@ -461,24 +607,25 @@ const thisDir = import.meta.dirname;
461
607
  The `packageDirs` option helps ESLint resolve imports correctly in monorepos:
462
608
 
463
609
  ```js
464
- ...eslintFlatConfigForTypeScript({
465
- tsconfigRootDir: thisDir,
466
- tsconfigFileName: './tsconfig.json',
467
- packageDirs: [
468
- path.resolve(thisDir, '../../..'), // Monorepo root
469
- thisDir, // Current package
470
- ],
471
- })
610
+ export default defineConfig([
611
+ ...eslintConfigForTypeScript({
612
+ tsconfigRootDir: thisDir,
613
+ tsconfigFileName: './tsconfig.json',
614
+ packageDirs: [
615
+ path.resolve(thisDir, '../../..'), // Monorepo root
616
+ thisDir, // Current package
617
+ ],
618
+ }),
619
+ ]);
472
620
  ```
473
621
 
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
622
+ #### 3. Performance issues
479
623
 
480
624
  For large projects, consider:
481
625
 
626
+ - Using `TIMING=1 eslint` to identify heavy rules
627
+ - Using `NODE_OPTIONS='--max-old-space-size=<memory-size-MB>' eslint` to increase the maximum memory available
628
+ - Separate heavy rules into a separate config and prepare a dedicated command
482
629
  - Using `.eslintignore` or `ignores` patterns to skip generated files
483
630
  - Running ESLint with `--cache` flag
484
631
  - Limiting the scope of type-aware rules