Skip to content

Commit a095388

Browse files
authoredMay 28, 2024
chore: add graphql linter (#1205)
And fix up the reported issues, including removing references to deprecated fields. Closes #1204
1 parent 9aeee1b commit a095388

24 files changed

+16682
-181
lines changed
 

‎.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ src/locales/*.js
44

55
# these files are code generated
66
src/graphql-client/*.ts
7+
src/graphql/ads-serve.graphql.schema.json
78

89
# npm and prettier fight over a EOF on these files, let npm win:
910
package.json

‎codegen.ts

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ const config: CodegenConfig = {
1212
fragmentMasking: false,
1313
},
1414
},
15+
"src/graphql/ads-serve.graphql.schema.json": {
16+
plugins: ["introspection"],
17+
},
1518
},
1619
config: {
1720
strictScalars: true,

‎eslint.config.js

+26-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,18 @@ import jsxRuntime from "eslint-plugin-react/configs/jsx-runtime.js";
55
import prettier from "eslint-config-prettier";
66
import reactHooks from "eslint-plugin-react-hooks";
77
import lingui from "eslint-plugin-lingui";
8+
import * as graphql from "@graphql-eslint/eslint-plugin";
89

910
export default tseslint.config(
1011
eslint.configs.recommended,
1112
...tseslint.configs.recommended,
13+
{
14+
plugins: {
15+
prettier,
16+
"react-hooks": reactHooks,
17+
lingui,
18+
},
19+
},
1220
{
1321
files: ["**/*.{js,cjs,jsx,mjsx,ts,tsx,mtsx}"],
1422
...reactRecommended,
@@ -18,10 +26,24 @@ export default tseslint.config(
1826
version: "detect",
1927
},
2028
},
29+
},
30+
{
31+
name: "apply graphql processor to all typescript files",
32+
files: ["**/*.{ts,tsx}"],
33+
processor: graphql.processors.graphql,
34+
},
35+
{
36+
name: "configure graphql linter",
37+
files: ["**/*.graphql"],
2138
plugins: {
22-
prettier,
23-
"react-hooks": reactHooks,
24-
lingui,
39+
"@graphql-eslint": graphql,
40+
},
41+
languageOptions: {
42+
parser: graphql,
43+
},
44+
rules: {
45+
...graphql.configs["operations-recommended"].rules,
46+
"@graphql-eslint/no-deprecated": "warn",
2547
},
2648
},
2749
{
@@ -91,6 +113,7 @@ export default tseslint.config(
91113
ignores: [
92114
"**/*.test.ts",
93115
"src/components/TimeZonePicker/useTimeZoneList.ts",
116+
"codegen.ts",
94117
],
95118
},
96119
{

‎graphql.config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
schema: "../ads-serve/src/graphql/schema.graphql"
1+
schema: "src/graphql/ads-serve.graphql.schema.json"
22
documents: "src/**/*.{ts,tsx,graphql}"

0 commit comments

Comments
 (0)