Skip to content

Commit 8cfac6b

Browse files
committed
feat(eslint-config-graphql)!: migrate to ESLint v9 and flat config format
BREAKING CHANGES: * ESLint v9 is now required * package type is change to module * config format is changed to flat
1 parent 3204e2c commit 8cfac6b

4 files changed

Lines changed: 79 additions & 106 deletions

File tree

packages/eslint-config-graphql/README.md

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# @alma-oss/eslint-config-graphql
22

3+
> Alma’s ESLint config for projects using GraphQL.
4+
5+
Validates GraphQL schema definitions and embedded GraphQL in JavaScript/TypeScript files.
6+
37
## Install
48

59
```bash
@@ -8,34 +12,59 @@ npm install @alma-oss/eslint-config-graphql -D
812

913
## Usage
1014

11-
Create a _.eslintrc.js_ file with the following contents:
15+
Create a _eslint.config.js_ file with the following contents:
1216

1317
```js
14-
module.exports = {
15-
extends: [
16-
// ... (base eslint config)
17-
'@alma-oss/eslint-config-graphql',
18-
],
19-
};
18+
// eslint.config.js
19+
20+
import graphqlConfig from ‘@alma-oss/eslint-config-graphql’;
21+
22+
export default [
23+
// ... your other configs
24+
...graphqlConfig,
25+
];
2026
```
2127

22-
The shareable config can be customized in your [**eslint** configuration file](https://eslint.org/docs/user-guide/configuring).
28+
## Processing
29+
30+
### Embedded GraphQL
2331

24-
Additionally don’t forget to have `.graphqlconfig` file:
32+
The config includes a processor that validates GraphQL code embedded in JavaScript/TypeScript template literals. Tag your GraphQL with `gql` or `graphql` to enable processing:
2533

26-
```json
27-
{
28-
// ...
29-
"schemaPath": "schema.json"
30-
// ...
31-
}
34+
```js
35+
// ✅ Valid - will be linted
36+
const query = gql`
37+
query GetUser($id: ID!) {
38+
user(id: $id) {
39+
id
40+
name
41+
}
42+
}
43+
`;
44+
45+
// ✅ Valid - graphql tag also works
46+
const mutation = graphql`
47+
mutation CreateUser($name: String!) {
48+
createUser(name: $name) {
49+
id
50+
}
51+
}
52+
`;
3253
```
3354

55+
### `.graphql` Files
56+
57+
The config also validates standalone `.graphql` schema and query files.
58+
3459
## Plugins
3560

3661
This configuration uses the following plugins:
3762

38-
- [`@graphql-eslint/eslint-plugin`](https://the-guild.dev/graphql/eslint/docs/getting-started)
63+
- [`@graphql-eslint/eslint-plugin`](https://the-guild.dev/graphql/eslint/docs/getting-started) — GraphQL validation and code style rules
64+
65+
## Rules
66+
67+
For available rules see [ESLint plugin GraphQL](https://the-guild.dev/graphql/eslint/rules).
3968

4069
## 📝 License
4170

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
1-
const globs = require('@lmc-eu/eslint-config-base/globs');
1+
import globs from '@alma-oss/eslint-config-base/globs';
2+
// eslint-disable-next-line import/no-unresolved
3+
import graphqlPlugin from '@graphql-eslint/eslint-plugin';
24

3-
module.exports = {
4-
overrides: [
5-
{
6-
files: [...globs.configs, ...globs, globs.typescripts],
7-
processor: '@graphql-eslint/graphql',
5+
export default [
6+
{
7+
name: '@alma-oss/eslint-config-graphql',
8+
files: [...globs.configs, ...globs, globs.typescripts],
9+
processor: graphqlPlugin.processor,
10+
},
11+
{
12+
files: ['*.graphql'],
13+
languageOptions: {
14+
parser: graphqlPlugin.parser,
815
},
9-
{
10-
files: ['*.graphql'],
11-
12-
parser: '@graphql-eslint/eslint-plugin',
13-
14-
plugins: ['@graphql-eslint'],
15-
16-
rules: {
17-
'@graphql-eslint/known-type-names': 'error',
18-
},
16+
plugins: {
17+
'@graphql-eslint': graphqlPlugin,
18+
},
19+
rules: {
20+
/**
21+
* Enforce that all GraphQL types referenced in your schema or queries are actually defined.
22+
*
23+
* @see { @link https://the-guild.dev/graphql/eslint/rules/known-type-names }
24+
*/
25+
'@graphql-eslint/known-type-names': 'error',
1926
},
20-
],
21-
};
27+
},
28+
];

packages/eslint-config-graphql/package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"description": "Alma's ESLint config for javascript applications that use GraphQL and Apollo client.",
44
"version": "3.0.6",
55
"author": "Tomas Litera <tomas.litera@almacareer.com>",
6+
"type": "module",
67
"keywords": [
78
"config",
89
"eslint",
@@ -25,13 +26,15 @@
2526
"publishConfig": {
2627
"access": "public"
2728
},
28-
"main": "index.js",
29+
"exports": {
30+
".": "./index.js"
31+
},
2932
"dependencies": {
33+
"@alma-oss/eslint-config-base": "^4.0.0-alpha.2",
3034
"@graphql-eslint/eslint-plugin": "^4.0.0",
31-
"@lmc-eu/eslint-config-base": "^3.1.3",
3235
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
3336
},
3437
"peerDependencies": {
35-
"eslint": "^8"
38+
"eslint": "^9"
3639
}
3740
}

yarn.lock

Lines changed: 3 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ __metadata:
3434
version: 0.0.0-use.local
3535
resolution: "@alma-oss/eslint-config-graphql@workspace:packages/eslint-config-graphql"
3636
dependencies:
37+
"@alma-oss/eslint-config-base": "npm:^4.0.0-alpha.2"
3738
"@graphql-eslint/eslint-plugin": "npm:^4.0.0"
38-
"@lmc-eu/eslint-config-base": "npm:^3.1.3"
3939
graphql: "npm:^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
4040
peerDependencies:
41-
eslint: ^8
41+
eslint: ^9
4242
languageName: unknown
4343
linkType: soft
4444

@@ -1036,17 +1036,6 @@ __metadata:
10361036
languageName: node
10371037
linkType: hard
10381038

1039-
"@es-joy/jsdoccomment@npm:~0.41.0":
1040-
version: 0.41.0
1041-
resolution: "@es-joy/jsdoccomment@npm:0.41.0"
1042-
dependencies:
1043-
comment-parser: "npm:1.4.1"
1044-
esquery: "npm:^1.5.0"
1045-
jsdoc-type-pratt-parser: "npm:~4.0.0"
1046-
checksum: 10c0/1fa27531eba32e4699664da53a0865aeeda1f7e83ac156fe53b7a6b09d2f3816baa94a34845ff019c10289b09572bda5519ec917e3e241088975477fa880f72d
1047-
languageName: node
1048-
linkType: hard
1049-
10501039
"@es-joy/jsdoccomment@npm:~0.52.0":
10511040
version: 0.52.0
10521041
resolution: "@es-joy/jsdoccomment@npm:0.52.0"
@@ -2215,19 +2204,6 @@ __metadata:
22152204
languageName: unknown
22162205
linkType: soft
22172206

2218-
"@lmc-eu/eslint-config-base@npm:^3.1.3":
2219-
version: 3.1.3
2220-
resolution: "@lmc-eu/eslint-config-base@npm:3.1.3"
2221-
dependencies:
2222-
eslint-config-airbnb-base: "npm:^15.0.0"
2223-
eslint-plugin-import: "npm:^2.25.2"
2224-
eslint-plugin-jsdoc: "npm:^46.0.0"
2225-
peerDependencies:
2226-
eslint: ^8.1.0
2227-
checksum: 10c0/edc467f629695366e7d67b71840ea1ea2517d649af5567477f26b7791381cf3d7fc9768f623e2e12124f0efcc19d4108d65a36f7c1e7588331eadffb0fc4c909
2228-
languageName: node
2229-
linkType: hard
2230-
22312207
"@lmc-eu/textlint-rule-preset-lmc@workspace:packages/textlint-rule-preset-lmc":
22322208
version: 0.0.0-use.local
22332209
resolution: "@lmc-eu/textlint-rule-preset-lmc@workspace:packages/textlint-rule-preset-lmc"
@@ -4902,13 +4878,6 @@ __metadata:
49024878
languageName: node
49034879
linkType: hard
49044880

4905-
"builtin-modules@npm:^3.3.0":
4906-
version: 3.3.0
4907-
resolution: "builtin-modules@npm:3.3.0"
4908-
checksum: 10c0/2cb3448b4f7306dc853632a4fcddc95e8d4e4b9868c139400027b71938fc6806d4ff44007deffb362ac85724bd40c2c6452fb6a0aa4531650eeddb98d8e5ee8a
4909-
languageName: node
4910-
linkType: hard
4911-
49124881
"byte-size@npm:8.1.1":
49134882
version: 8.1.1
49144883
resolution: "byte-size@npm:8.1.1"
@@ -6497,7 +6466,7 @@ __metadata:
64976466
languageName: node
64986467
linkType: hard
64996468

6500-
"eslint-plugin-import@npm:^2.25.2, eslint-plugin-import@npm:^2.32.0":
6469+
"eslint-plugin-import@npm:^2.32.0":
65016470
version: 2.32.0
65026471
resolution: "eslint-plugin-import@npm:2.32.0"
65036472
dependencies:
@@ -6553,25 +6522,6 @@ __metadata:
65536522
languageName: node
65546523
linkType: hard
65556524

6556-
"eslint-plugin-jsdoc@npm:^46.0.0":
6557-
version: 46.10.1
6558-
resolution: "eslint-plugin-jsdoc@npm:46.10.1"
6559-
dependencies:
6560-
"@es-joy/jsdoccomment": "npm:~0.41.0"
6561-
are-docs-informative: "npm:^0.0.2"
6562-
comment-parser: "npm:1.4.1"
6563-
debug: "npm:^4.3.4"
6564-
escape-string-regexp: "npm:^4.0.0"
6565-
esquery: "npm:^1.5.0"
6566-
is-builtin-module: "npm:^3.2.1"
6567-
semver: "npm:^7.5.4"
6568-
spdx-expression-parse: "npm:^4.0.0"
6569-
peerDependencies:
6570-
eslint: ^7.0.0 || ^8.0.0 || ^9.0.0
6571-
checksum: 10c0/2c9db7e621e6393c4e22c312e8d729a1c5698a31a62b0985421bb64741eb737d95b65ea0523ea87df3456ff4b3452ed015e463cc5a3b98646f2e7a3f68dd6e1a
6572-
languageName: node
6573-
linkType: hard
6574-
65756525
"eslint-plugin-jsdoc@npm:^51.4.1":
65766526
version: 51.4.1
65776527
resolution: "eslint-plugin-jsdoc@npm:51.4.1"
@@ -8443,15 +8393,6 @@ __metadata:
84438393
languageName: node
84448394
linkType: hard
84458395

8446-
"is-builtin-module@npm:^3.2.1":
8447-
version: 3.2.1
8448-
resolution: "is-builtin-module@npm:3.2.1"
8449-
dependencies:
8450-
builtin-modules: "npm:^3.3.0"
8451-
checksum: 10c0/5a66937a03f3b18803381518f0ef679752ac18cdb7dd53b5e23ee8df8d440558737bd8dcc04d2aae555909d2ecb4a81b5c0d334d119402584b61e6a003e31af1
8452-
languageName: node
8453-
linkType: hard
8454-
84558396
"is-bun-module@npm:^2.0.0":
84568397
version: 2.0.0
84578398
resolution: "is-bun-module@npm:2.0.0"
@@ -9534,13 +9475,6 @@ __metadata:
95349475
languageName: node
95359476
linkType: hard
95369477

9537-
"jsdoc-type-pratt-parser@npm:~4.0.0":
9538-
version: 4.0.0
9539-
resolution: "jsdoc-type-pratt-parser@npm:4.0.0"
9540-
checksum: 10c0/b23ef7bbbe2f56d72630d1c5a233dc9fecaff399063d373c57bef136908c1b05e723dac107177303c03ccf8d75aa51507510b282aa567600477479c5ea0c36d1
9541-
languageName: node
9542-
linkType: hard
9543-
95449478
"jsdoc-type-pratt-parser@npm:~4.1.0":
95459479
version: 4.1.0
95469480
resolution: "jsdoc-type-pratt-parser@npm:4.1.0"

0 commit comments

Comments
 (0)