Skip to content

Commit 14211d6

Browse files
authored
feat: remove prettier rule, add related docs (#397)
* feat: remove `prettier` rule, add related docs * docs: add changeset for the feat change
1 parent 7598f5f commit 14211d6

File tree

19 files changed

+189
-456
lines changed

19 files changed

+189
-456
lines changed

.changeset/chilly-foxes-help.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@graphql-eslint/eslint-plugin": minor
3+
---
4+
5+
feat: remove `prettier` rule, add related docs

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,55 @@ You can find a complete list of [all available rules here](./docs/README.md)
169169

170170
> This repo doesn't exports a "recommended" set of rules - feel free to recommend us!
171171

172+
### `prettier` rule
173+
174+
The original `prettier` rule has been removed because `eslint-plugin-prettier` supports `.graphql` files well actually.
175+
176+
All you need to do is like the following for now:
177+
178+
```js
179+
// .eslintrc.js
180+
module.exports = {
181+
overrides: [
182+
{
183+
files: ['*.tsx', '*.ts', '*.jsx', '*.js'],
184+
processor: '@graphql-eslint/graphql',
185+
},
186+
{
187+
files: ['*.graphql'],
188+
parser: '@graphql-eslint/eslint-plugin',
189+
plugins: ['@graphql-eslint'],
190+
// the following is required for `eslint-plugin-prettier@<=3.4.0` temporarily
191+
// after https://github.com/prettier/eslint-plugin-prettier/pull/413
192+
// been merged and released, it can be deleted safely
193+
rules: {
194+
'prettier/prettier': [
195+
2,
196+
{
197+
parser: 'graphql',
198+
},
199+
],
200+
},
201+
},
202+
// the following is required for `eslint-plugin-prettier@<=3.4.0` temporarily
203+
// after https://github.com/prettier/eslint-plugin-prettier/pull/415
204+
// been merged and released, it can be deleted safely
205+
{
206+
files: ['*.js/*.graphql'],
207+
rules: {
208+
'prettier/prettier': 0
209+
}
210+
},
211+
],
212+
};
213+
```
214+
215+
You can take [`examples/prettier`](examples/prettier/.eslintrc.js) as example.
216+
217+
It could be better to remove the unnecessary parser setting if https://github.com/prettier/eslint-plugin-prettier/pull/413 and https://github.com/prettier/eslint-plugin-prettier/pull/415 been merged and released.
218+
219+
Please help to vote up if you want to speed up the progress.
220+
172221
## Further Reading
173222

174223
If you wish to learn more about this project, how the parser works, how to add custom rules and more, [please refer to the docs directory](./docs/README.md))

docs/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
- [`naming-convention`](./rules/naming-convention.md)
2121
- [`input-name`](./rules/input-name.md)
2222
- [`strict-id-in-types`](./rules/strict-id-in-types.md)
23-
- [`prettier`](./rules/prettier.md)
2423
- [`executable-definitions`](./rules/executable-definitions.md)
2524
- [`fields-on-correct-type`](./rules/fields-on-correct-type.md)
2625
- [`fragments-on-composite-type`](./rules/fragments-on-composite-type.md)

docs/rules/prettier.md

Lines changed: 0 additions & 16 deletions
This file was deleted.

examples/basic/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"lint": "eslint --ext graphql,js ."
1010
},
1111
"dependencies": {
12-
"eslint": "7.14.0",
12+
"eslint": "7.24.0",
1313
"@graphql-eslint/eslint-plugin": "0.9.1",
14-
"graphql": "15.4.0",
15-
"typescript": "4.1.2"
14+
"graphql": "15.5.0",
15+
"typescript": "4.1.5"
1616
}
1717
}

examples/code-file/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"lint": "eslint --ext graphql,js ."
1010
},
1111
"dependencies": {
12-
"eslint": "7.14.0",
12+
"eslint": "7.24.0",
1313
"@graphql-eslint/eslint-plugin": "0.9.1",
14-
"graphql": "15.4.0",
15-
"typescript": "4.1.2"
14+
"graphql": "15.5.0",
15+
"typescript": "4.1.5"
1616
}
1717
}

examples/graphql-config-code-file/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
},
1111
"dependencies": {
1212
"@graphql-eslint/eslint-plugin": "0.9.1",
13-
"eslint": "7.14.0",
14-
"graphql": "15.4.0",
13+
"eslint": "7.24.0",
14+
"graphql": "15.5.0",
1515
"graphql-tag": "^2.11.0",
16-
"typescript": "4.1.2"
16+
"typescript": "4.1.5"
1717
}
1818
}

examples/graphql-config/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
},
1111
"dependencies": {
1212
"graphql-config": "3.2.0",
13-
"eslint": "7.14.0",
13+
"eslint": "7.24.0",
1414
"@graphql-eslint/eslint-plugin": "0.9.1",
15-
"graphql": "15.4.0",
16-
"typescript": "4.1.2"
15+
"graphql": "15.5.0",
16+
"typescript": "4.1.5"
1717
}
1818
}

examples/prettier/.eslintrc.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
module.exports = {
2+
extends: ['plugin:prettier/recommended'],
3+
overrides: [
4+
{
5+
files: ['*.tsx', '*.ts', '*.jsx', '*.js'],
6+
processor: '@graphql-eslint/graphql',
7+
},
8+
{
9+
files: ['*.graphql'],
10+
parser: '@graphql-eslint/eslint-plugin',
11+
plugins: ['@graphql-eslint'],
12+
// the following is required for `eslint-plugin-prettier@<=3.4.0` temporarily
13+
// after https://github.com/prettier/eslint-plugin-prettier/pull/413
14+
// been merged and released, it can be deleted safely
15+
rules: {
16+
'prettier/prettier': [
17+
2,
18+
{
19+
parser: 'graphql',
20+
},
21+
],
22+
},
23+
},
24+
// the following is required for `eslint-plugin-prettier@<=3.4.0` temporarily
25+
// after https://github.com/prettier/eslint-plugin-prettier/pull/415
26+
// been merged and released, it can be deleted safely
27+
{
28+
files: ['*.js/*.graphql'],
29+
rules: {
30+
'prettier/prettier': 0,
31+
},
32+
},
33+
],
34+
};

examples/prettier/invalid.graphql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
query GetUser($userId: ID!) {
2+
user(id: $userId) {
3+
id,
4+
name,
5+
isViewerFriend,
6+
profilePicture(size: 50) {
7+
...PictureFragment
8+
}
9+
}
10+
}
11+
12+
fragment PictureFragment on Picture {
13+
uri,
14+
width,
15+
height
16+
}

0 commit comments

Comments
 (0)