-
-
Notifications
You must be signed in to change notification settings - Fork 487
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(graphql_analyze): add suppression action for the GraphQL linter (#…
…4312) Co-authored-by: Emanuele Stoppa <[email protected]>
- Loading branch information
1 parent
bc206bb
commit 1c60340
Showing
7 changed files
with
335 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...e_graphql_analyze/tests/suppression/nursery/noDuplicatedFields/noDuplicatedFields.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
query test($v: String, $t: String, $v: String) { | ||
id | ||
} | ||
|
||
query test { | ||
users(first: 100, after: 10, filter: "test", first: 50) { | ||
id | ||
} | ||
} | ||
|
||
query test { | ||
users { | ||
id | ||
name | ||
name | ||
} | ||
} | ||
|
||
query test { | ||
users { | ||
id | ||
name | ||
# biome-ignore lint/nursery/noDuplicatedFields: testing | ||
email: somethingElse | ||
} | ||
} |
113 changes: 113 additions & 0 deletions
113
...phql_analyze/tests/suppression/nursery/noDuplicatedFields/noDuplicatedFields.graphql.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
--- | ||
source: crates/biome_graphql_analyze/tests/spec_tests.rs | ||
expression: noDuplicatedFields.graphql | ||
--- | ||
# Input | ||
```graphql | ||
query test($v: String, $t: String, $v: String) { | ||
id | ||
} | ||
query test { | ||
users(first: 100, after: 10, filter: "test", first: 50) { | ||
id | ||
} | ||
} | ||
query test { | ||
users { | ||
id | ||
name | ||
name | ||
} | ||
} | ||
query test { | ||
users { | ||
id | ||
name | ||
# biome-ignore lint/nursery/noDuplicatedFields: testing | ||
email: somethingElse | ||
} | ||
} | ||
``` | ||
|
||
# Diagnostics | ||
``` | ||
noDuplicatedFields.graphql:1:36 lint/nursery/noDuplicatedFields FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! Variable `v` defined multiple times. | ||
> 1 │ query test($v: String, $t: String, $v: String) { | ||
│ ^^^^^^^^^^ | ||
2 │ id | ||
3 │ } | ||
i Remove the duplicated variable. | ||
i Safe fix: Suppress rule lint/nursery/noDuplicatedFields | ||
1 │ - query·test($v:·String,·$t:·String,·$v:·String)·{ | ||
1 │ + #·biome-ignore·lint/nursery/noDuplicatedFields:·<explanation> | ||
2 │ + query··test($v:·String,·$t:·String,·$v:·String)·{ | ||
2 3 │ id | ||
3 4 │ } | ||
``` | ||
``` | ||
noDuplicatedFields.graphql:6:48 lint/nursery/noDuplicatedFields FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! Argument `first` defined multiple times. | ||
5 │ query test { | ||
> 6 │ users(first: 100, after: 10, filter: "test", first: 50) { | ||
│ ^^^^^^^^^ | ||
7 │ id | ||
8 │ } | ||
i Remove the duplicated argument. | ||
i Safe fix: Suppress rule lint/nursery/noDuplicatedFields | ||
4 4 │ | ||
5 5 │ query test { | ||
6 │ - ··users(first:·100,·after:·10,·filter:·"test",·first:·50)·{ | ||
6 │ + ··#·biome-ignore·lint/nursery/noDuplicatedFields:·<explanation> | ||
7 │ + ··users(first:·100,·after:·10,·filter:·"test",·first:·50)·{ | ||
7 8 │ id | ||
8 9 │ } | ||
``` | ||
``` | ||
noDuplicatedFields.graphql:16:5 lint/nursery/noDuplicatedFields FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! Field `name` defined multiple times. | ||
14 │ name | ||
15 │ email | ||
> 16 │ name | ||
│ ^^^^ | ||
17 │ } | ||
18 │ } | ||
i Remove the duplicated field. | ||
i Safe fix: Suppress rule lint/nursery/noDuplicatedFields | ||
14 14 │ name | ||
15 15 │ email | ||
16 │ - ····name | ||
16 │ + ····#·biome-ignore·lint/nursery/noDuplicatedFields:·<explanation> | ||
17 │ + ····name | ||
17 18 │ } | ||
18 19 │ } | ||
``` |
20 changes: 20 additions & 0 deletions
20
...graphql_analyze/tests/suppression/nursery/useDeprecatedReason/useDeprecatedReason.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
query { | ||
member @deprecated { | ||
id | ||
} | ||
} | ||
|
||
query { | ||
member @deprecated() | ||
} | ||
|
||
query { | ||
member | ||
@deprecated(abc: 123) | ||
} | ||
|
||
query { | ||
# biome-ignore lint/nursery/useDeprecatedReason: testing | ||
member @deprecated() | ||
} | ||
|
107 changes: 107 additions & 0 deletions
107
...ql_analyze/tests/suppression/nursery/useDeprecatedReason/useDeprecatedReason.graphql.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
--- | ||
source: crates/biome_graphql_analyze/tests/spec_tests.rs | ||
expression: useDeprecatedReason.graphql | ||
--- | ||
# Input | ||
```graphql | ||
query { | ||
member @deprecated { | ||
id | ||
} | ||
} | ||
query { | ||
member @deprecated() | ||
} | ||
query { | ||
member | ||
@deprecated(abc: 123) | ||
} | ||
query { | ||
# biome-ignore lint/nursery/useDeprecatedReason: testing | ||
member @deprecated() | ||
} | ||
``` | ||
|
||
# Diagnostics | ||
``` | ||
useDeprecatedReason.graphql:2:10 lint/nursery/useDeprecatedReason FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! The directive `@deprecated` should have a `reason` argument. | ||
1 │ query { | ||
> 2 │ member @deprecated { | ||
│ ^^^^^^^^^^^ | ||
3 │ id | ||
4 │ } | ||
i Add a `reason` argument to the directive. | ||
i Safe fix: Suppress rule lint/nursery/useDeprecatedReason | ||
1 1 │ query { | ||
2 │ - ··member·@deprecated·{ | ||
2 │ + ··#·biome-ignore·lint/nursery/useDeprecatedReason:·<explanation> | ||
3 │ + ··member··@deprecated·{ | ||
3 4 │ id | ||
4 5 │ } | ||
``` | ||
``` | ||
useDeprecatedReason.graphql:8:10 lint/nursery/useDeprecatedReason FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! The directive `@deprecated` should have a `reason` argument. | ||
7 │ query { | ||
> 8 │ member @deprecated() | ||
│ ^^^^^^^^^^^^^ | ||
9 │ } | ||
10 │ | ||
i Add a `reason` argument to the directive. | ||
i Safe fix: Suppress rule lint/nursery/useDeprecatedReason | ||
6 6 │ | ||
7 7 │ query { | ||
8 │ - ··member·@deprecated() | ||
8 │ + ··#·biome-ignore·lint/nursery/useDeprecatedReason:·<explanation> | ||
9 │ + ··member··@deprecated() | ||
9 10 │ } | ||
10 11 │ | ||
``` | ||
``` | ||
useDeprecatedReason.graphql:13:3 lint/nursery/useDeprecatedReason FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! The directive `@deprecated` should have a `reason` argument. | ||
11 │ query { | ||
12 │ member | ||
> 13 │ @deprecated(abc: 123) | ||
│ ^^^^^^^^^^^^^^^^^^^^^ | ||
14 │ } | ||
15 │ | ||
i Add a `reason` argument to the directive. | ||
i Safe fix: Suppress rule lint/nursery/useDeprecatedReason | ||
11 11 │ query { | ||
12 12 │ member | ||
13 │ - ··@deprecated(abc:·123) | ||
13 │ + ··#·biome-ignore·lint/nursery/useDeprecatedReason:·<explanation> | ||
14 │ + ··@deprecated(abc:·123) | ||
14 15 │ } | ||
15 16 │ | ||
``` |