From b70b4ba4b17d02d9744bd72494549f5cf7d980f8 Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Tue, 11 Feb 2020 22:11:08 +0100 Subject: [PATCH] webui: lint graphql files --- webui/{.eslintrc => .eslintrc.js} | 15 ++++++--- webui/Makefile | 1 + webui/codegen.yaml | 9 +++-- webui/package-lock.json | 55 +++++++++++++++++++++++++++++++ webui/package.json | 4 ++- webui/src/.gitignore | 1 + 6 files changed, 77 insertions(+), 8 deletions(-) rename webui/{.eslintrc => .eslintrc.js} (73%) diff --git a/webui/.eslintrc b/webui/.eslintrc.js similarity index 73% rename from webui/.eslintrc rename to webui/.eslintrc.js index 3c6e976f1861a35c901426be2b9c2cb8248b6a86..2b4a60de7009892abb3403edd2d2f5967587184d 100644 --- a/webui/.eslintrc +++ b/webui/.eslintrc.js @@ -1,10 +1,17 @@ -{ - "extends": [ +module.exports = { + extends: [ "react-app", "prettier/@typescript-eslint", "plugin:prettier/recommended" ], - "rules": { + plugins: [ + "graphql" + ], + rules: { + "graphql/template-strings": ["error", { + "schemaJson": require("./src/schema.json"), + "env": "literal" + }], "import/order": [ "error", { "alphabetize": {"order": "asc"}, @@ -22,4 +29,4 @@ } ] } -} +}; diff --git a/webui/Makefile b/webui/Makefile index 8c028e10300c01be80346472d069b609e98f53c8..4ba7fa2975e5c0157e82d8449e89a6d3338ae54f 100644 --- a/webui/Makefile +++ b/webui/Makefile @@ -5,6 +5,7 @@ install: npm install test: + npm run generate npm run lint CI=true npm run test diff --git a/webui/codegen.yaml b/webui/codegen.yaml index 30b67e45ced118ea38f97e6da86338266ebf4fe7..1580632ea85256b9123ba91346d158692b9c7633 100644 --- a/webui/codegen.yaml +++ b/webui/codegen.yaml @@ -10,9 +10,12 @@ generates: ./src/gqlTypes.ts: plugins: - typescript + ./src/schema.json: + plugins: + - introspection ./src/: plugins: - - add: '/* eslint-disable @typescript-eslint/no-unused-vars */' + - add: '/* eslint-disable @typescript-eslint/no-unused-vars, import/order */' - typescript-operations - typescript-react-apollo preset: near-operation-file @@ -25,5 +28,5 @@ generates: withHooks: true hooks: - afterOneFileWrite: - - eslint --fix + afterAllFileWrite: + - prettier --write diff --git a/webui/package-lock.json b/webui/package-lock.json index 78551d9868d235beddde0dc89b83ec36ab24ccb0..9bc9576c136098914a844fae987e922253055d32 100644 --- a/webui/package-lock.json +++ b/webui/package-lock.json @@ -1340,6 +1340,36 @@ "@graphql-codegen/plugin-helpers": "1.12.1" } }, + "@graphql-codegen/introspection": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@graphql-codegen/introspection/-/introspection-1.12.2.tgz", + "integrity": "sha512-YMQIn1R2CxYZLkxkW6fUxqfTBr2WC3Cimp6/0oEcSyLA/W1scVuDw/IUeU5Iu4CEmz8IaqPSjSMEN+8l95wKlA==", + "dev": true, + "requires": { + "@graphql-codegen/plugin-helpers": "1.12.2", + "tslib": "1.10.0" + }, + "dependencies": { + "@graphql-codegen/plugin-helpers": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@graphql-codegen/plugin-helpers/-/plugin-helpers-1.12.2.tgz", + "integrity": "sha512-N294rqdBh+mCi4HWHbhPV9wE0XLCVKx524pYL4yp8qWiSdAs3Iz9+q9C9QNsLBvHypZdqml44M8kBMG41A9I/Q==", + "dev": true, + "requires": { + "@graphql-toolkit/common": "0.9.7", + "camel-case": "4.1.1", + "common-tags": "1.8.0", + "constant-case": "3.0.3", + "import-from": "3.0.0", + "lower-case": "2.0.1", + "param-case": "3.0.3", + "pascal-case": "3.1.1", + "tslib": "1.10.0", + "upper-case": "2.0.1" + } + } + } + }, "@graphql-codegen/near-operation-file-preset": { "version": "1.12.2-alpha-ea7264f9.15", "resolved": "https://registry.npmjs.org/@graphql-codegen/near-operation-file-preset/-/near-operation-file-preset-1.12.2-alpha-ea7264f9.15.tgz", @@ -6300,6 +6330,31 @@ "lodash": "^4.17.15" } }, + "eslint-plugin-graphql": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-graphql/-/eslint-plugin-graphql-3.1.1.tgz", + "integrity": "sha512-VNu2AipS8P1BAnE/tcJ2EmBWjFlCnG+1jKdUlFNDQjocWZlFiPpMu9xYNXePoEXK+q+jG51M/6PdhOjEgJZEaQ==", + "dev": true, + "requires": { + "graphql-config": "^2.0.1", + "lodash": "^4.11.1" + }, + "dependencies": { + "graphql-config": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/graphql-config/-/graphql-config-2.2.1.tgz", + "integrity": "sha512-U8+1IAhw9m6WkZRRcyj8ZarK96R6lQBQ0an4lp76Ps9FyhOXENC5YQOxOFGm5CxPrX2rD0g3Je4zG5xdNJjwzQ==", + "dev": true, + "requires": { + "graphql-import": "^0.7.1", + "graphql-request": "^1.5.0", + "js-yaml": "^3.10.0", + "lodash": "^4.17.4", + "minimatch": "^3.0.4" + } + } + } + }, "eslint-plugin-import": { "version": "2.20.0", "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.20.0.tgz", diff --git a/webui/package.json b/webui/package.json index ed143e68edf7100a3e8f7efe30519212eb960643..cf61b883a9596aac10a7345cfc48cce71e665c51 100644 --- a/webui/package.json +++ b/webui/package.json @@ -36,7 +36,9 @@ "@graphql-codegen/near-operation-file-preset": "^1.12.2-alpha-ea7264f9.15", "@graphql-codegen/typescript-operations": "^1.12.1", "@graphql-codegen/typescript-react-apollo": "^1.12.1", + "@graphql-codegen/introspection": "^1.12.2", "eslint-config-prettier": "^6.10.0", + "eslint-plugin-graphql": "^3.1.1", "eslint-plugin-prettier": "^3.1.2", "prettier": "^1.19.1" }, @@ -46,7 +48,7 @@ "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject", "generate": "graphql-codegen", - "lint": "eslint 'src/**/*.{js,jsx,ts,tsx}'" + "lint": "eslint src --ext .ts --ext .tsx --ext .js --ext .jsx --ext .graphql" }, "proxy": "http://localhost:3001", "browserslist": [ diff --git a/webui/src/.gitignore b/webui/src/.gitignore index 52b71a1542e00f5a2c0ec6d878b84f2938cf4225..640de4f9b9015e774c6cea2bc960f1e21c95afd3 100644 --- a/webui/src/.gitignore +++ b/webui/src/.gitignore @@ -1,3 +1,4 @@ fragmentTypes.js gqlTypes.ts *.generated.* +schema.json