|
| 1 | +/* eslint-env node */ |
| 2 | +const SCHEMA_PATH = 'server/**/*.gql'; |
| 3 | +const OPERATIONS_PATH = 'client/**/*.{tsx,gql}'; |
| 4 | + |
| 5 | +module.exports = { |
| 6 | + root: true, |
| 7 | + // ❗️ It's very important that you don't have any rules configured at the top-level config, |
| 8 | + // and to move all configurations into the overrides section. Since JavaScript rules |
| 9 | + // can't run on GraphQL files and vice versa, if you have rules configured at the top level, |
| 10 | + // they will try to also execute for all overrides, as ESLint's configs cascade |
| 11 | + overrides: [ |
| 12 | + { |
| 13 | + files: '*.{cjs,tsx}', |
| 14 | + extends: 'eslint:recommended', |
| 15 | + env: { |
| 16 | + es2022: true, |
| 17 | + }, |
| 18 | + }, |
| 19 | + { |
| 20 | + files: 'client/**/*.tsx', |
| 21 | + parserOptions: { |
| 22 | + sourceType: 'module', |
| 23 | + ecmaFeatures: { |
| 24 | + jsx: true, |
| 25 | + }, |
| 26 | + }, |
| 27 | + }, |
| 28 | + { |
| 29 | + // Setup GraphQL Parser |
| 30 | + files: '*.{graphql,gql}', |
| 31 | + parser: '@graphql-eslint/eslint-plugin', |
| 32 | + plugins: ['@graphql-eslint'], |
| 33 | + parserOptions: { |
| 34 | + schema: SCHEMA_PATH, |
| 35 | + operations: OPERATIONS_PATH, |
| 36 | + }, |
| 37 | + }, |
| 38 | + { |
| 39 | + // Setup processor for operations/fragments definitions on code-files |
| 40 | + files: 'client/**/*.tsx', |
| 41 | + processor: '@graphql-eslint/graphql', |
| 42 | + }, |
| 43 | + { |
| 44 | + // Setup recommended config for schema files |
| 45 | + files: SCHEMA_PATH, |
| 46 | + extends: 'plugin:@graphql-eslint/schema-recommended', |
| 47 | + rules: { |
| 48 | + // Override graphql-eslint rules for schema files |
| 49 | + }, |
| 50 | + }, |
| 51 | + { |
| 52 | + // Setup recommended config for operations files |
| 53 | + files: 'client/**/*.{graphql,gql}', |
| 54 | + extends: 'plugin:@graphql-eslint/operations-recommended', |
| 55 | + rules: { |
| 56 | + // Override graphql-eslint rules for operations files |
| 57 | + }, |
| 58 | + }, |
| 59 | + ], |
| 60 | +}; |
0 commit comments