@innovixx/eslint-config 4.0.0-alpha.2 → 4.0.0-alpha.4

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.
package/README.md CHANGED
@@ -1,10 +1,11 @@
1
1
  # ESLint Config Guide
2
2
 
3
- An opinionated, extensible ESLint flat configuration library with configurations for JavaScript, TypeScript, React, accessibility, and Jest.
3
+ An opinionated, extensible ESLint flat configuration library with configurations for JavaScript, TypeScript, React, accessibility, Jest, and GraphQL.
4
4
 
5
5
  ## Highlights
6
6
 
7
7
  - ESLint flat configuration.
8
+ - Internally scoped JavaScript, TypeScript, React, and Jest configurations.
8
9
  - TypeScript linting and type-aware rules.
9
10
  - Modern React 19 configuration using the automatic JSX runtime.
10
11
  - React correctness checks from `@eslint-react/eslint-plugin`.
@@ -12,6 +13,8 @@ An opinionated, extensible ESLint flat configuration library with configurations
12
13
  - JSX formatting from `@stylistic/eslint-plugin`.
13
14
  - Accessibility checks from `eslint-plugin-jsx-a11y`.
14
15
  - Official Hooks and React Compiler diagnostics from `eslint-plugin-react-hooks`.
16
+ - GraphQL schema and operations linting through `@graphql-eslint/eslint-plugin`.
17
+ - Directory-based GraphQL rule selection through one shared configuration import.
15
18
 
16
19
  The React configuration no longer depends on `eslint-plugin-react`.
17
20
 
@@ -26,6 +29,9 @@ Known compatibility considerations:
26
29
  - `eslint-plugin-react-hooks@7.1.1` declares ESLint 10 support.
27
30
  - `@eslint-react/kit` is beta and is pinned to `5.28.8` to limit unexpected API changes.
28
31
  - ESLint 10 requires a supported Node.js release: `^20.19.0`, `^22.13.0`, or `>=24`.
32
+ - `@graphql-eslint/eslint-plugin@4.4.2` declares GraphQL `^16` as a peer dependency. GraphQL 17 is not covered by that declared range.
33
+ - The package supplies its plugins and parsers as dependencies. Consuming apps provide compatible ESLint, TypeScript, and GraphQL peer dependencies.
34
+ - ESLint remains the consuming app's lint runner; installing this configuration does not guarantee an exact ESLint version.
29
35
 
30
36
  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
37
 
@@ -35,19 +41,17 @@ See the [package manifest](./package.json) for the complete dependency list.
35
41
 
36
42
  ### Installation
37
43
 
38
- ```sh
39
- npm install --save-dev @innovixx/eslint-config
40
- ```
44
+ For the current alpha:
41
45
 
42
46
  ```sh
43
- yarn add --dev @innovixx/eslint-config
47
+ pnpm add -D @innovixx/eslint-config@alpha eslint@^10.14.0 typescript@6.0.3
44
48
  ```
45
49
 
46
- ```sh
47
- pnpm add -D @innovixx/eslint-config
48
- ```
50
+ This assumes prereleases are published under the `alpha` distribution tag. Alternatively, specify an exact published prerelease version.
49
51
 
50
- Ensure the peer dependencies required by the configurations you load are installed. Package managers differ in how they install peer dependencies.
52
+ Ensure compatible peer dependencies are installed. The package currently declares GraphQL ^16 as a required peer dependency, even for consumers that do not load the GraphQL configuration. Depending on package-manager settings, missing peers may be installed automatically or reported as unmet dependencies.
53
+
54
+ The configuration supplies its ESLint plugins and parsers, so apps do not need to register them individually.
51
55
 
52
56
  ### Base configuration
53
57
 
@@ -56,6 +60,16 @@ Create an `eslint.config.mjs` file:
56
60
  ```js
57
61
  import baseConfig from '@innovixx/eslint-config/config/configs/base/index.mjs';
58
62
 
63
+ export default [
64
+ baseConfig,
65
+ ];
66
+ ```
67
+
68
+ The shared base configuration already scopes itself to JavaScript and TypeScript files.
69
+
70
+ To narrow its scope:
71
+
72
+ ```js
59
73
  export default [
60
74
  {
61
75
  ...baseConfig,
@@ -68,18 +82,229 @@ The `files` pattern belongs on the configuration it scopes. A separate trailing
68
82
 
69
83
  ### Available configurations
70
84
 
71
- | Configuration | Module |
85
+ | Configuration | Module | Default scope |
86
+ | --- | --- | --- |
87
+ | Base JavaScript | `@innovixx/eslint-config/config/configs/base/index.mjs` | `**/*.{js,jsx,ts,tsx}` |
88
+ | React | `@innovixx/eslint-config/config/configs/react/index.mjs` | `**/*.{jsx,tsx}` |
89
+ | TypeScript | `@innovixx/eslint-config/config/configs/typescript/index.mjs` | `**/*.{ts,tsx}` |
90
+ | Jest | `@innovixx/eslint-config/config/configs/jest/index.mjs` | `**/*.test.{js,jsx,ts,tsx}` |
91
+ | GraphQL | `@innovixx/eslint-config/config/configs/graphql/index.mjs` | Schema and operations directories described below |
92
+
93
+ Base, React, TypeScript, and Jest export individual configuration objects. GraphQL exports a configuration array and must be spread into the consuming configuration.
94
+
95
+ React rules are scoped to JSX and TSX files. Extend that scope if the app needs React checks in plain JavaScript or TypeScript files.
96
+
97
+ Jest's default scope covers `.test` files. Override it if the app uses `.spec` files or other test naming conventions.
98
+
99
+ ### Combined configuration
100
+
101
+ ```js
102
+ import baseConfig from '@innovixx/eslint-config/config/configs/base/index.mjs';
103
+ import reactConfig from '@innovixx/eslint-config/config/configs/react/index.mjs';
104
+ import typescriptConfig from '@innovixx/eslint-config/config/configs/typescript/index.mjs';
105
+ import jestConfig from '@innovixx/eslint-config/config/configs/jest/index.mjs';
106
+ import { graphqlConfig } from '@innovixx/eslint-config/config/configs/graphql/index.mjs';
107
+
108
+ export default [
109
+ baseConfig,
110
+ reactConfig,
111
+ typescriptConfig,
112
+ jestConfig,
113
+ ...graphqlConfig,
114
+ {
115
+ files: ['codegen.ts', '*.config.ts'],
116
+ languageOptions: {
117
+ parserOptions: {
118
+ project: null,
119
+ },
120
+ },
121
+ },
122
+ ];
123
+ ```
124
+
125
+ Load only the configurations the app needs. The `project: null` override disables project-based parser analysis for those configuration files; omit it if they are included in the app's TypeScript project.
126
+
127
+ The [root configuration module](./config/index.mjs) exports a separate configuration array with additional overrides. It does not automatically include the modular GraphQL configuration and is not identical to the [repository ESLint configuration](./eslint.config.mjs).
128
+
129
+ See the [ESLint configuration guide](https://eslint.org/docs/latest/use/configure/configuration-files) and [demo fixtures](./demo) for further context.
130
+
131
+ ## GraphQL Configuration
132
+
133
+ The shared GraphQL configuration registers the parser and plugin, then selects schema or operations rules according to file location.
134
+
135
+ ### File conventions
136
+
137
+ | Path | Behavior |
72
138
  | --- | --- |
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` |
139
+ | `src/endpoints/**/*.graphql` | Schema recommended rules |
140
+ | `src/graphql/typeDefs/**/*.graphql` | Schema recommended rules |
141
+ | Other `src/graphql/**/*.graphql` files | Operations recommended rules |
142
+ | `**/schema.graphql` | Globally ignored by ESLint |
143
+ | `**/generated/**` | Globally ignored by ESLint |
144
+
145
+ Both schema definitions and operations can be named `index.graphql`; their directories determine which rules apply.
146
+
147
+ For example:
148
+
149
+ ```text
150
+ src/
151
+ endpoints/
152
+ test/
153
+ index.graphql
154
+ graphql/
155
+ typeDefs/
156
+ where/
157
+ index.graphql
158
+ query/
159
+ test/
160
+ index.graphql
161
+ generated/
162
+ schema.graphql
163
+ ```
164
+
165
+ The operations configuration explicitly excludes `src/graphql/typeDefs/**`. Without this exclusion, schema files would also receive operations rules and could fail while loading rules that require operation documents.
166
+
167
+ The generated-directory ignore applies to all file types, including generated TypeScript, not only GraphQL.
168
+
169
+ These are root-relative conventions. Projects using different layouts must adapt the scopes. For a nested app, ESLint's `basePath` can apply the array relative to that app's directory.
170
+
171
+ ### Included rules
172
+
173
+ Schema files use:
174
+
175
+ ```text
176
+ flat/schema-recommended
177
+ ```
178
+
179
+ Operations use:
180
+
181
+ ```text
182
+ flat/operations-recommended
183
+ ```
184
+
185
+ Shared overrides include:
186
+
187
+ - `eol-last`: warning for schema and operations files.
188
+ - `no-anonymous-operations`: warning for operations.
189
+ - `known-type-names`: error for operations.
190
+ - `no-duplicate-fields`: warning for operations.
191
+ - Operation names: PascalCase.
192
+ - Forbidden operation prefixes: `Query`, `Mutation`, `Subscription`, `Get`.
193
+ - Forbidden operation suffixes: `Query`, `Mutation`, `Subscription`.
194
+
195
+ The explicit operations naming configuration replaces the recommended preset's naming options; it does not retain every naming check from that preset.
77
196
 
78
- These modules export individual configuration objects. Consumers compose and scope them using flat configuration.
197
+ Recommended schema rules introduce additional policies, including descriptions, naming conventions, and ID checks. For example, lowercase enum values can violate the recommended uppercase enum convention.
79
198
 
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).
199
+ Review these policies before enabling them across existing schemas. Override deliberate API conventions rather than changing public API names solely to satisfy lint.
81
200
 
82
- See the [ESLint configuration guide](https://eslint.org/docs/latest/use/configure/configuration-files) and [demo components](./demo) for further context.
201
+ ### Schema discovery
202
+
203
+ Each app owns its GraphQL Config. The shared ESLint configuration does not hard-code schema locations.
204
+
205
+ Generated schemas may be ignored by ESLint while still being loaded as schema references.
206
+
207
+ #### Schema-only server
208
+
209
+ Example `graphql.config.ts`:
210
+
211
+ ```ts
212
+ import type { IGraphQLConfig } from '@graphql-eslint/eslint-plugin';
213
+
214
+ const config: IGraphQLConfig = {
215
+ schema: 'src/graphql/schema.graphql',
216
+ };
217
+
218
+ export default config;
219
+ ```
220
+
221
+ The referenced schema must include the complete merged schema, including shared types, scalars, and directives supplied by packages such as API-kit.
222
+
223
+ A schema-only server does not need a `documents` field.
224
+
225
+ #### Client operations
226
+
227
+ ```ts
228
+ import type { IGraphQLConfig } from '@graphql-eslint/eslint-plugin';
229
+
230
+ const config: IGraphQLConfig = {
231
+ schema: 'src/graphql/generated/schema.graphql',
232
+ documents: [
233
+ 'src/graphql/**/*.graphql',
234
+ '!src/graphql/generated/**',
235
+ '!src/graphql/typeDefs/**',
236
+ ],
237
+ };
238
+
239
+ export default config;
240
+ ```
241
+
242
+ Operations rules can require both the schema and loaded operation documents.
243
+
244
+ ESLint ignores do not automatically apply to GraphQL Config's document discovery. Exclude generated files and schema definitions from `documents` explicitly.
245
+
246
+ If an app directly imports plugin types, declare the plugin as an app development dependency rather than relying on access to a transitive dependency. Alternatively, use an untyped GraphQL Config file.
247
+
248
+ #### Server calling another API
249
+
250
+ When a server also sends operations to another API, use separate GraphQL Config projects so each file group uses the correct schema:
251
+
252
+ ```ts
253
+ import type { IGraphQLConfig } from '@graphql-eslint/eslint-plugin';
254
+
255
+ const config: IGraphQLConfig = {
256
+ projects: {
257
+ server: {
258
+ schema: 'src/graphql/schema.graphql',
259
+ include: [
260
+ 'src/endpoints/**/*.graphql',
261
+ 'src/graphql/typeDefs/**/*.graphql',
262
+ ],
263
+ },
264
+ externalApi: {
265
+ schema: 'src/graphql/generated/external-schema.graphql',
266
+ documents: [
267
+ 'src/graphql/query/**/*.graphql',
268
+ 'src/graphql/mutation/**/*.graphql',
269
+ 'src/graphql/subscription/**/*.graphql',
270
+ 'src/graphql/fragments/**/*.graphql',
271
+ ],
272
+ include: [
273
+ 'src/graphql/query/**/*.graphql',
274
+ 'src/graphql/mutation/**/*.graphql',
275
+ 'src/graphql/subscription/**/*.graphql',
276
+ 'src/graphql/fragments/**/*.graphql',
277
+ ],
278
+ },
279
+ },
280
+ };
281
+
282
+ export default config;
283
+ ```
284
+
285
+ Adjust these paths to the app's layout. Keep project file groups non-overlapping.
286
+
287
+ Each API's operations must be validated against that API's schema, not automatically against the server's own schema.
288
+
289
+ ### Code generation and linting
290
+
291
+ Generate the schema reference before running schema-dependent lint rules. Keep generated schemas current with their APIs.
292
+
293
+ Ensure any server-side schema-loading glob includes only schema definitions, not outgoing operations.
294
+
295
+ This configuration handles standalone `.graphql` files. It does not configure extraction of GraphQL embedded in JavaScript or TypeScript.
296
+
297
+ Include GraphQL in the app's lint command:
298
+
299
+ ```json
300
+ {
301
+ "scripts": {
302
+ "lint": "eslint \"src/**/*.{graphql,js,jsx,ts,tsx}\""
303
+ }
304
+ }
305
+ ```
306
+
307
+ Quoting the glob lets ESLint handle recursive matching rather than the shell.
83
308
 
84
309
  ## React Configuration
85
310
 
@@ -238,7 +463,7 @@ Kit registers these locally implemented rules at `error` severity. They are not
238
463
  - **Duplicate props:** checks explicit attributes case-insensitively. It does not inspect properties hidden inside spreads.
239
464
  - **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
465
  - **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.
466
+ - **Fragments:** requires explicit fragment elements. The fixer replaces shorthand fragments with `<React.Fragment>...</React.Fragment>` but does not add a React import or verify that `React` is in scope. Review fixes in files using the automatic JSX runtime.
242
467
  - **String refs:** rejects string literals and static template strings in `ref` attributes. It does not perform dynamic value or legacy refs-access analysis.
243
468
  - **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
469
  - **Function-component `this`:** checks detected function components, including lexical arrow-function usage, while excluding separate ordinary-function and class contexts.
@@ -339,7 +564,7 @@ pnpm install
339
564
  Inspect the repository configuration:
340
565
 
341
566
  ```sh
342
- pnpm exec eslint --print-config demo/components/ComponentTest/index.tsx
567
+ pnpm exec eslint --print-config demo/src/components/ComponentTest/index.tsx
343
568
  ```
344
569
 
345
570
  Inspect the separately exported root configuration:
@@ -347,7 +572,7 @@ Inspect the separately exported root configuration:
347
572
  ```sh
348
573
  pnpm exec eslint \
349
574
  --config config/index.mjs \
350
- --print-config demo/components/ComponentTest/index.tsx
575
+ --print-config demo/src/components/ComponentTest/index.tsx
351
576
  ```
352
577
 
353
578
  Run linting and compiler checking:
@@ -373,6 +598,43 @@ Before publishing changes to custom rules, verify both accepted and rejected exa
373
598
 
374
599
  Configuration resolution alone does not establish behavioral correctness.
375
600
 
601
+ ### GraphQL validation
602
+
603
+ The repository applies the shared GraphQL configuration relative to `demo`, allowing its normal `src/...` patterns to match `demo/src/...`.
604
+
605
+ Inspect the actual operation fixture:
606
+
607
+ ```sh
608
+ pnpm exec eslint --print-config demo/src/graphql/query/index.graphql
609
+ ```
610
+
611
+ Lint it directly:
612
+
613
+ ```sh
614
+ pnpm exec eslint demo/src/graphql/query/index.graphql
615
+ ```
616
+
617
+ To verify schema-aware field validation, temporarily select a nonexistent field:
618
+
619
+ ```graphql
620
+ query Test {
621
+ test {
622
+ missingField
623
+ }
624
+ }
625
+ ```
626
+
627
+ With the demo schema loaded, this should produce an `@graphql-eslint/fields-on-correct-type` error. Restore the valid selection afterward.
628
+
629
+ For schema fixtures, verify that:
630
+
631
+ - Schema recommended rules are enabled.
632
+ - Operations-only rules such as `require-selections` and `executable-definitions` are absent or disabled.
633
+ - Shared types and directives resolve against the complete schema.
634
+ - Generated schemas are excluded from lint targets but remain available as schema references.
635
+
636
+ `--print-config` calculates configuration for a supplied path; it does not prove that the file exists, that its schema loads, or that validation succeeds.
637
+
376
638
  ## Upgrade Notes
377
639
 
378
640
  This migration changes enforcement and dependency requirements:
@@ -384,6 +646,12 @@ This migration changes enforcement and dependency requirements:
384
646
  - The automatic JSX runtime is assumed.
385
647
  - Legacy PropTypes and selected class-component policies are retired.
386
648
  - Some replacement rules intentionally have narrower or different coverage.
649
+ - GraphQL schema and operations configurations are available through one array export.
650
+ - Recommended GraphQL presets enable more rules than the previous consumer-defined rule list.
651
+ - Directory conventions determine whether GraphQL files receive schema or operations rules.
652
+ - Generated directories and files named `schema.graphql` are globally ignored when the GraphQL configuration is loaded.
653
+ - Apps remain responsible for GraphQL schema/document discovery and generating required schema references.
654
+ - Shared JavaScript, React, TypeScript, and Jest modules now contain their own file scopes.
387
655
 
388
656
  Consumers should review these as potentially breaking changes rather than a dependency-only upgrade.
389
657
 
@@ -395,6 +663,9 @@ Consumers should review these as potentially breaking changes rather than a depe
395
663
  - [ESLint React kit](https://eslint-react.xyz/docs/packages/kit)
396
664
  - [Stylistic rules](https://eslint.style/rules)
397
665
  - [TypeScript ESLint dependency support](https://typescript-eslint.io/users/dependency-versions/)
666
+ - [GraphQL ESLint usage](https://the-guild.dev/graphql/eslint/docs/usage)
667
+ - [GraphQL ESLint shared configurations](https://the-guild.dev/graphql/eslint/docs/configs)
668
+ - [GraphQL Config](https://the-guild.dev/graphql/config)
398
669
 
399
670
  ## License
400
671
 
@@ -54,6 +54,11 @@ export const index = deepMerge(
54
54
  {
55
55
  settings: importRules.settings,
56
56
  },
57
+ {
58
+ rules: {
59
+ 'import/extensions': 'off',
60
+ },
61
+ },
57
62
  );
58
63
 
59
64
  export default index;
@@ -27,7 +27,10 @@ export const graphqlConfig = [
27
27
  },
28
28
  },
29
29
  {
30
- files: ['src/endpoints/**/*.graphql'],
30
+ files: [
31
+ 'src/endpoints/**/*.graphql',
32
+ 'src/graphql/typeDefs/**/*.graphql',
33
+ ],
31
34
 
32
35
  rules: {
33
36
  ...graphqlPlugin.configs['flat/schema-recommended'].rules,
@@ -35,21 +38,16 @@ export const graphqlConfig = [
35
38
  },
36
39
  {
37
40
  files: ['src/graphql/**/*.graphql'],
41
+ ignores: ['src/graphql/typeDefs/**'],
38
42
 
39
43
  rules: {
40
- ...graphqlPlugin.configs['flat/operations-recommended'].rules,
41
- 'eol-last': 'warn',
42
- '@graphql-eslint/no-anonymous-operations': 'warn',
43
- '@graphql-eslint/known-type-names': 'error',
44
- '@graphql-eslint/no-duplicate-fields': 'warn',
44
+ ...graphqlPlugin.configs['flat/schema-recommended'].rules,
45
+ '@graphql-eslint/strict-id-in-types': 'off',
46
+ '@graphql-eslint/require-description': 'off',
47
+ '@graphql-eslint/no-unreachable-types': 'warn',
45
48
  '@graphql-eslint/naming-convention': [
46
49
  'warn',
47
50
  {
48
- OperationDefinition: {
49
- style: 'PascalCase',
50
- forbiddenPrefixes: ['Query', 'Mutation', 'Subscription', 'Get'],
51
- forbiddenSuffixes: ['Query', 'Mutation', 'Subscription'],
52
- },
53
51
  ObjectTypeDefinition: {
54
52
  style: 'PascalCase',
55
53
  },
@@ -59,4 +57,4 @@ export const graphqlConfig = [
59
57
  },
60
58
  ];
61
59
 
62
- export default graphqlConfig;
60
+ export default graphqlConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innovixx/eslint-config",
3
- "version": "4.0.0-alpha.2",
3
+ "version": "4.0.0-alpha.4",
4
4
  "main": "config/index.mjs",
5
5
  "repository": "git@github.com:innovixx/eslint-config.git",
6
6
  "description": "Opinionated ESLint config for JavaScript developers",