@innovixx/eslint-config 3.0.14 → 4.0.0-alpha.1

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 (32) hide show
  1. package/README.md +370 -20
  2. package/config/configs/base/index.mjs +40 -40
  3. package/config/configs/base/rules/best-practices.mjs +331 -333
  4. package/config/configs/base/rules/errors.mjs +115 -115
  5. package/config/configs/base/rules/es6.mjs +176 -176
  6. package/config/configs/base/rules/imports.mjs +238 -238
  7. package/config/configs/base/rules/variables.mjs +31 -31
  8. package/config/configs/graphql/index.mjs +62 -0
  9. package/config/configs/jest/index.mjs +19 -19
  10. package/config/configs/jest/rules/jest-dom.mjs +8 -8
  11. package/config/configs/jest/rules/jest.mjs +33 -33
  12. package/config/configs/react/index.mjs +31 -42
  13. package/config/configs/react/rules/custom-rules.mjs +332 -0
  14. package/config/configs/react/rules/react-a11y.mjs +227 -227
  15. package/config/configs/react/rules/react-hooks.mjs +6 -6
  16. package/config/configs/react/rules/react.mjs +49 -452
  17. package/config/configs/typescript/index.mjs +24 -24
  18. package/config/configs/typescript/rules/all.mjs +14 -14
  19. package/config/configs/typescript/settings/typescript.mjs +8 -11
  20. package/config/deepMerge.mjs +47 -47
  21. package/config/index.mjs +117 -117
  22. package/demo/src/components/ComponentTest/index.tsx +3 -0
  23. package/demo/{components → src/components}/ComponentTestWithProps/index.tsx +2 -2
  24. package/demo/src/graphql/generated/schema.graphql +7 -0
  25. package/demo/src/graphql/query/index.graphql +5 -0
  26. package/eslint.config.mjs +20 -4
  27. package/graphql.config.ts +11 -0
  28. package/package.json +21 -18
  29. package/tsconfig.json +1 -1
  30. package/demo/components/ComponentTest/index.tsx +0 -3
  31. package/demo/index.ts +0 -1
  32. /package/demo/{components → src/components}/index.ts +0 -0
package/README.md CHANGED
@@ -1,51 +1,401 @@
1
1
  # ESLint Config Guide
2
2
 
3
+ An opinionated, extensible ESLint flat configuration library with configurations for JavaScript, TypeScript, React, accessibility, and Jest.
4
+
3
5
  ## Highlights
4
6
 
5
- An extensible config library for JavaScript developers which utilizes the [flat config](https://eslint.org/docs/latest/use/migrate-to-9.0.0#flat-linter) now default in ESlint v9.x.
7
+ - ESLint flat configuration.
8
+ - TypeScript linting and type-aware rules.
9
+ - Modern React 19 configuration using the automatic JSX runtime.
10
+ - React correctness checks from `@eslint-react/eslint-plugin`.
11
+ - Custom React policies implemented with `@eslint-react/kit`.
12
+ - JSX formatting from `@stylistic/eslint-plugin`.
13
+ - Accessibility checks from `eslint-plugin-jsx-a11y`.
14
+ - Official Hooks and React Compiler diagnostics from `eslint-plugin-react-hooks`.
15
+
16
+ The React configuration no longer depends on `eslint-plugin-react`.
17
+
18
+ ## Compatibility
19
+
20
+ The current package declares ESLint `^10.14.0` and TypeScript `6.0.3`.
21
+
22
+ Known compatibility considerations:
23
+
24
+ - `@typescript-eslint/parser@8.72.1` supports TypeScript `>=4.8.4 <6.1.0`, which includes TypeScript `6.0.3`.
25
+ - `eslint-plugin-jsx-a11y@6.10.2` declares ESLint support through version 9, not version 10. Its compatibility with ESLint 10 remains to be verified.
26
+ - `eslint-plugin-react-hooks@7.1.1` declares ESLint 10 support.
27
+ - `@eslint-react/kit` is beta and is pinned to `5.28.8` to limit unexpected API changes.
28
+ - ESLint 10 requires a supported Node.js release: `^20.19.0`, `^22.13.0`, or `>=24`.
29
+
30
+ Using TypeScript `6.0.3` is within the declared support range of the configured TypeScript ESLint parser. This does not by itself confirm that the full dependency combination passes linting; validate it with the commands below.
31
+
32
+ See the [package manifest](./package.json) for the complete dependency list.
6
33
 
7
34
  ## Quick Start
8
35
 
9
36
  ### Installation
10
37
 
38
+ ```sh
39
+ npm install --save-dev @innovixx/eslint-config
11
40
  ```
12
- npm i --save-dev @innovixx/eslint-config
13
- ```
14
- ```
41
+
42
+ ```sh
15
43
  yarn add --dev @innovixx/eslint-config
16
44
  ```
45
+
46
+ ```sh
47
+ pnpm add -D @innovixx/eslint-config
17
48
  ```
18
- pnpm i -D @innovixx/eslint-config
19
- ```
20
49
 
21
- ### Usage
50
+ Ensure the peer dependencies required by the configurations you load are installed. Package managers differ in how they install peer dependencies.
51
+
52
+ ### Base configuration
22
53
 
23
- There are a number of configurations for consumption. For an example of a minimal base configuration:
54
+ Create an `eslint.config.mjs` file:
24
55
 
25
- ```javascript
56
+ ```js
26
57
  import baseConfig from '@innovixx/eslint-config/config/configs/base/index.mjs';
27
58
 
28
59
  export default [
29
- baseConfig,
30
- {
31
- files: ['**/*.{js}'],
32
- },
60
+ {
61
+ ...baseConfig,
62
+ files: ['**/*.js'],
63
+ },
33
64
  ];
34
65
  ```
35
- This can then be extended to provide the React, TypeScript and Jest Configs also available in the library, as well as custom rules, plugins, and settings. For more information see the [ESLint config guide](https://eslint.org/docs/latest/use/configure/configuration-files)
36
66
 
37
- For working examples, see the [demo app](./demo).
67
+ The `files` pattern belongs on the configuration it scopes. A separate trailing object containing only `files` does not scope earlier configuration objects.
68
+
69
+ ### Available configurations
70
+
71
+ | Configuration | Module |
72
+ | --- | --- |
73
+ | Base JavaScript | `@innovixx/eslint-config/config/configs/base/index.mjs` |
74
+ | React | `@innovixx/eslint-config/config/configs/react/index.mjs` |
75
+ | TypeScript | `@innovixx/eslint-config/config/configs/typescript/index.mjs` |
76
+ | Jest | `@innovixx/eslint-config/config/configs/jest/index.mjs` |
77
+
78
+ These modules export individual configuration objects. Consumers compose and scope them using flat configuration.
79
+
80
+ The [root configuration module](./config/index.mjs) exports a separate configuration array with additional overrides. It is not identical to the [repository ESLint configuration](./eslint.config.mjs).
81
+
82
+ See the [ESLint configuration guide](https://eslint.org/docs/latest/use/configure/configuration-files) and [demo components](./demo) for further context.
83
+
84
+ ## React Configuration
85
+
86
+ ### Plugin responsibilities
87
+
88
+ | Package | Responsibility |
89
+ | --- | --- |
90
+ | `@eslint-react/eslint-plugin` | React correctness and selected deprecated API checks |
91
+ | `@eslint-react/kit` | Registration and utilities for locally implemented React rules |
92
+ | `@stylistic/eslint-plugin` | JSX formatting, indentation, and spacing |
93
+ | `eslint-plugin-jsx-a11y` | Accessibility |
94
+ | `eslint-plugin-react-hooks` | Official Hooks and React Compiler diagnostics |
95
+
96
+ The configuration uses explicit rules rather than adopting the new React plugin's recommended preset. This avoids unintentionally enabling additional policies.
97
+
98
+ ### Automatic JSX runtime
99
+
100
+ The repository uses:
101
+
102
+ ```json
103
+ {
104
+ "compilerOptions": {
105
+ "jsx": "react-jsx"
106
+ }
107
+ }
108
+ ```
109
+
110
+ Consumer projects must configure their own compiler or build tool consistently. Loading an ESLint configuration does not change JSX compilation.
38
111
 
39
- ## Demo
112
+ A default React import is not required solely to render JSX with the automatic runtime. Keep imports used by explicit React APIs or types.
40
113
 
114
+ Explicit fragments remain required:
115
+
116
+ ```tsx
117
+ import { Fragment } from 'react';
118
+
119
+ export function Example() {
120
+ return (
121
+ <Fragment>
122
+ <div>Example</div>
123
+ </Fragment>
124
+ );
125
+ }
126
+ ```
127
+
128
+ Shorthand fragments are reported:
129
+
130
+ ```tsx
131
+ <>
132
+ <div>Example</div>
133
+ </>
134
+ ```
135
+
136
+ ## Migration from eslint-plugin-react
137
+
138
+ This migration targets modern React 19 and TypeScript. It is not a behavior-identical replacement for every legacy React lint rule.
139
+
140
+ The old plugin import, plugin registration, rule entries, and legacy settings have been removed from the React configuration.
141
+
142
+ ### React correctness replacements
143
+
144
+ The following rules now use `@eslint-react/eslint-plugin`.
145
+
146
+ | Previous rule | Replacement |
147
+ | --- | --- |
148
+ | `react/no-will-update-set-state` | `@eslint-react/no-set-state-in-component-will-update` |
149
+ | `react/no-unknown-property` | `@eslint-react/dom-no-unknown-property` |
150
+ | `react/jsx-no-target-blank` | `@eslint-react/dom-no-unsafe-target-blank` |
151
+ | `react/jsx-no-comment-textnodes` | `@eslint-react/jsx-no-comment-textnodes` |
152
+ | `react/no-render-return-value` | `@eslint-react/dom-no-render-return-value` |
153
+ | `react/no-find-dom-node` | `@eslint-react/dom-no-find-dom-node` |
154
+ | `react/no-danger-with-children` | `@eslint-react/dom-no-dangerously-set-innerhtml-with-children` |
155
+ | `react/style-prop-object` | `@eslint-react/dom-no-string-style-prop` |
156
+ | `react/no-children-prop` | `@eslint-react/jsx-no-children-prop` |
157
+ | `react/void-dom-elements-no-children` | `@eslint-react/dom-no-void-elements-with-children` |
158
+ | `react/no-access-state-in-setstate` | `@eslint-react/no-access-state-in-setstate` |
159
+ | `react/button-has-type` | `@eslint-react/dom-no-missing-button-type` |
160
+
161
+ Important differences:
162
+
163
+ - The style rule prohibits string styles; it does not reproduce every check from `style-prop-object`.
164
+ - The blank-target rule has different options and behavior. The old `enforceDynamicLinks` option is not carried across.
165
+ - The button rule requires an explicit type but does not preserve the previous prohibition on `type="reset"`.
166
+
167
+ The old `react/no-deprecated` umbrella rule is partially replaced by:
168
+
169
+ ```text
170
+ @eslint-react/no-component-will-mount
171
+ @eslint-react/no-component-will-receive-props
172
+ @eslint-react/no-component-will-update
173
+ @eslint-react/dom-no-render
174
+ @eslint-react/dom-no-hydrate
175
+ ```
176
+
177
+ Together with the existing DOM checks, these cover selected deprecated APIs, not every case reported by the old rule.
178
+
179
+ ### Formatting replacements
180
+
181
+ These rules move from `react/` to `@stylistic/`, retaining their configured options:
182
+
183
+ ```text
184
+ jsx-closing-bracket-location
185
+ jsx-closing-tag-location
186
+ jsx-curly-spacing
187
+ jsx-indent-props
188
+ jsx-max-props-per-line
189
+ jsx-pascal-case
190
+ jsx-wrap-multilines
191
+ jsx-first-prop-new-line
192
+ jsx-equals-spacing
193
+ jsx-tag-spacing
194
+ jsx-curly-brace-presence
195
+ jsx-one-expression-per-line
196
+ jsx-curly-newline
41
197
  ```
42
- git clone git@github.com:innovixx/eslint-config.git
43
- pnpm i
198
+
199
+ Additional replacements:
200
+
201
+ | Previous rule | Replacement |
202
+ | --- | --- |
203
+ | Core `jsx-quotes` | `@stylistic/jsx-quotes` |
204
+ | `react/self-closing-comp` | `@stylistic/jsx-self-closing-comp` |
205
+ | `react/jsx-indent` | `@stylistic/indent` |
206
+ | `react/jsx-props-no-multi-spaces` | `@stylistic/no-multi-spaces` |
207
+
208
+ The general indentation and spacing replacements apply throughout matching files, not only JSX.
209
+
210
+ The JSX-only indentation options `checkAttributes` and `indentLogicalExpressions` were removed because the general `indent` rule does not accept them.
211
+
212
+ Core `no-multi-spaces` is disabled to avoid duplicate reporting where the Stylistic replacement applies.
213
+
214
+ The React-specific `class-methods-use-this` exception list was removed. The base configuration and any later consumer overrides control that core rule.
215
+
216
+ ### Custom React rules
217
+
218
+ The implementations live in [custom-rules.mjs](./config/configs/react/rules/custom-rules.mjs).
219
+
220
+ Kit registers these locally implemented rules at `error` severity. They are not built-in rule implementations supplied by installing kit.
221
+
222
+ | Previous rule | Local replacement |
223
+ | --- | --- |
224
+ | `react/jsx-boolean-value` | `@eslint-react/kit/jsx-boolean-value` |
225
+ | `react/jsx-no-bind` | `@eslint-react/kit/jsx-no-bind` |
226
+ | `react/jsx-no-duplicate-props` | `@eslint-react/kit/jsx-no-duplicate-props` |
227
+ | `react/jsx-filename-extension` | `@eslint-react/kit/jsx-filename-extension` |
228
+ | `react/no-unescaped-entities` | `@eslint-react/kit/no-unescaped-entities` |
229
+ | `react/jsx-fragments` | `@eslint-react/kit/jsx-fragments` |
230
+ | `react/no-string-refs` | `@eslint-react/kit/no-string-refs` |
231
+ | `react/destructuring-assignment` | `@eslint-react/kit/destructuring-assignment` |
232
+ | `react/no-this-in-sfc` | `@eslint-react/kit/no-this-in-sfc` |
233
+
234
+ #### Behavior and limitations
235
+
236
+ - **Boolean values:** requires shorthand for literal `true` attributes and provides an autofix.
237
+ - **Binding:** rejects direct function expressions and direct `.bind()` calls in component props. Arrow functions are allowed; refs and lowercase DOM elements are ignored. Variables and aliases are not resolved.
238
+ - **Duplicate props:** checks explicit attributes case-insensitively. It does not inspect properties hidden inside spreads.
239
+ - **Filename extensions:** permits JSX only in `.js`, `.jsx`, `.ts`, and `.tsx` files that ESLint actually parses. Parser errors can occur before this rule runs.
240
+ - **Unescaped entities:** inspects raw JSX text for literal `>`, `"`, `'`, and `}` characters. Escaped entities and JSX expressions are not treated as raw text.
241
+ - **Fragments:** requires explicit fragment elements. No autofix is supplied because choosing or adding an import requires additional context.
242
+ - **String refs:** rejects string literals and static template strings in `ref` attributes. It does not perform dynamic value or legacy refs-access analysis.
243
+ - **Destructuring:** checks direct member access on an identifier props parameter in function components detected by kit. It does not track aliases or check class props, state, or context.
244
+ - **Function-component `this`:** checks detected function components, including lexical arrow-function usage, while excluding separate ordinary-function and class contexts.
245
+
246
+ These focused implementations intentionally do not reproduce all analysis performed by the old plugin.
247
+
248
+ ### JSX scope rules
249
+
250
+ | Removed rule | Modern handling |
251
+ | --- | --- |
252
+ | `react/jsx-no-undef` | TypeScript compiler diagnostics for TypeScript; core `no-undef` for JavaScript with ESLint 10 |
253
+ | `react/jsx-uses-vars` | JSX reference tracking in ESLint 10 and compatible parser scope analysis |
254
+ | `react/jsx-uses-react` | No implicit React factory import needed with the automatic runtime |
255
+ | `react/react-in-jsx-scope` | Unnecessary with the automatic runtime |
256
+
257
+ Compiler diagnostics require a TypeScript checking workflow. Running ESLint does not run every TypeScript compiler diagnostic.
258
+
259
+ Classic-runtime consumers need a separate configuration review.
260
+
261
+ ### Retired PropTypes policies
262
+
263
+ The following legacy checks are intentionally retired:
264
+
265
+ ```text
266
+ react/forbid-prop-types
267
+ react/prop-types
268
+ react/no-unused-prop-types
269
+ react/forbid-foreign-prop-types
270
+ react/default-props-match-prop-types
271
+ ```
272
+
273
+ Use TypeScript props contracts for typed components. TypeScript does not reproduce every retired policy or provide runtime validation.
274
+
275
+ The experimental, type-aware `@eslint-react/no-unused-props` rule is not enabled as a replacement.
276
+
277
+ ### Retired class-component policies
278
+
279
+ The following specialized legacy checks are intentionally retired:
280
+
281
+ ```text
282
+ react/no-is-mounted
283
+ react/prefer-es6-class
284
+ react/prefer-stateless-function
285
+ react/require-render-return
286
+ react/sort-comp
287
+ react/no-redundant-should-component-update
288
+ react/no-unused-state
289
+ react/no-typos
290
+ react/state-in-constructor
291
+ react/static-property-placement
292
+ ```
293
+
294
+ Class components are not banned. This modern configuration simply no longer promises those specialized checks.
295
+
296
+ Maintained class-related rules already provided by the new React plugin remain enabled where configured.
297
+
298
+ ### Hooks and accessibility
299
+
300
+ Accessibility rules continue to use `eslint-plugin-jsx-a11y`, including the existing custom options.
301
+
302
+ The official Hooks plugin remains enabled. Its recommended rules are merged before explicit Hooks overrides, ensuring these severities win:
303
+
304
+ ```js
305
+ 'react-hooks/rules-of-hooks': 'error',
306
+ 'react-hooks/exhaustive-deps': 'error',
307
+ ```
308
+
309
+ Although the new React plugin includes counterparts for the two classic Hooks rules, it is not an identical replacement for all official React Compiler diagnostics.
310
+
311
+ ## Customizing Rules
312
+
313
+ Place overrides after the configurations they modify.
314
+
315
+ For example, after loading the React configuration:
316
+
317
+ ```js
318
+ {
319
+ files: ['**/*.tsx'],
320
+ rules: {
321
+ '@eslint-react/kit/jsx-fragments': 'off',
322
+ '@eslint-react/dom-no-unknown-property': 'warn',
323
+ },
324
+ }
325
+ ```
326
+
327
+ This permits shorthand fragments and changes unknown DOM properties to warnings for matching files.
328
+
329
+ ## Demo and Validation
330
+
331
+ Clone and install:
332
+
333
+ ```sh
334
+ git clone https://github.com/innovixx/eslint-config.git
335
+ cd eslint-config
336
+ pnpm install
337
+ ```
338
+
339
+ Inspect the repository configuration:
340
+
341
+ ```sh
342
+ pnpm exec eslint --print-config demo/components/ComponentTest/index.tsx
343
+ ```
344
+
345
+ Inspect the separately exported root configuration:
346
+
347
+ ```sh
348
+ pnpm exec eslint \
349
+ --config config/index.mjs \
350
+ --print-config demo/components/ComponentTest/index.tsx
351
+ ```
352
+
353
+ Run linting and compiler checking:
354
+
355
+ ```sh
44
356
  pnpm lint
357
+ pnpm exec tsc --noEmit
45
358
  ```
46
359
 
47
- The demo directory uses the eslint config file in the [root](https://github.com/innovixx/eslint-config/blob/master/eslint.config.mjs) of the project.
360
+ These are validation instructions, not a claim that the current dependency combination has passed them.
361
+
362
+ Before publishing changes to custom rules, verify both accepted and rejected examples, including:
363
+
364
+ - Boolean shorthand and its autofix.
365
+ - Allowed arrows and ignored DOM/ref binding cases.
366
+ - Case-insensitive duplicate attributes.
367
+ - Escaped versus literal JSX text.
368
+ - Explicit versus shorthand fragments.
369
+ - Literal string refs versus object/callback refs.
370
+ - Component props access versus unrelated functions.
371
+ - Lexical `this` versus nested function/class contexts.
372
+ - Filename restrictions for files included in linting.
373
+
374
+ Configuration resolution alone does not establish behavioral correctness.
375
+
376
+ ## Upgrade Notes
377
+
378
+ This migration changes enforcement and dependency requirements:
379
+
380
+ - `eslint-plugin-react` is removed.
381
+ - Stylistic owns JSX formatting.
382
+ - Kit registers locally maintained replacement rules.
383
+ - General spacing and indentation checks replace deprecated JSX-only checks.
384
+ - The automatic JSX runtime is assumed.
385
+ - Legacy PropTypes and selected class-component policies are retired.
386
+ - Some replacement rules intentionally have narrower or different coverage.
387
+
388
+ Consumers should review these as potentially breaking changes rather than a dependency-only upgrade.
389
+
390
+ ## References
391
+
392
+ - [ESLint flat configuration](https://eslint.org/docs/latest/use/configure/configuration-files)
393
+ - [ESLint 10 migration guide](https://eslint.org/docs/latest/use/migrate-to-10.0.0)
394
+ - [ESLint React migration guide](https://eslint-react.xyz/docs/migrating-from-eslint-plugin-react)
395
+ - [ESLint React kit](https://eslint-react.xyz/docs/packages/kit)
396
+ - [Stylistic rules](https://eslint.style/rules)
397
+ - [TypeScript ESLint dependency support](https://typescript-eslint.io/users/dependency-versions/)
48
398
 
49
399
  ## License
50
400
 
51
- [MIT](https://github.com/innovixx/eslint-config/blob/master/LICENSE) Copyright (c) Innovixx Digital Limited
401
+ [MIT](./LICENSE) Copyright (c) Innovixx Digital Limited
@@ -13,46 +13,46 @@ import variableRules from './rules/variables.mjs';
13
13
  /** @type {import('eslint').Linter.Config} */
14
14
 
15
15
  export const index = deepMerge(
16
- {
17
- languageOptions: {
18
- globals: {
19
- ...globals.node,
20
- },
21
- },
22
- },
23
- {
24
- rules: bestPracticesRules.rules,
25
- },
26
- {
27
- rules: errorRules.rules,
28
- },
29
- {
30
- rules: es6Rules.rules,
31
- },
32
- {
33
- rules: importRules.rules,
34
- },
35
- {
36
- rules: {
37
- ...nodePlugin.configs['flat/mixed-esm-and-cjs'].rules,
38
- },
39
- },
40
- {
41
- rules: styleRules.rules,
42
- },
43
- {
44
- rules: variableRules.rules,
45
- },
46
- {
47
- plugins: {
48
- import: esPluginImport,
49
- 'sort-export-all': sortExportAllPlugin,
50
- ...nodePlugin.configs['flat/recommended'].plugins,
51
- },
52
- },
53
- {
54
- settings: importRules.settings,
55
- },
16
+ {
17
+ languageOptions: {
18
+ globals: {
19
+ ...globals.node,
20
+ },
21
+ },
22
+ },
23
+ {
24
+ rules: bestPracticesRules.rules,
25
+ },
26
+ {
27
+ rules: errorRules.rules,
28
+ },
29
+ {
30
+ rules: es6Rules.rules,
31
+ },
32
+ {
33
+ rules: importRules.rules,
34
+ },
35
+ {
36
+ rules: {
37
+ ...nodePlugin.configs['flat/mixed-esm-and-cjs'].rules,
38
+ },
39
+ },
40
+ {
41
+ rules: styleRules.rules,
42
+ },
43
+ {
44
+ rules: variableRules.rules,
45
+ },
46
+ {
47
+ plugins: {
48
+ import: esPluginImport,
49
+ 'sort-export-all': sortExportAllPlugin,
50
+ ...nodePlugin.configs['flat/recommended'].plugins,
51
+ },
52
+ },
53
+ {
54
+ settings: importRules.settings,
55
+ },
56
56
  );
57
57
 
58
58
  export default index;