|
| 1 | +const { readFileSync } = require("fs"); |
| 2 | +const schemaString = readFileSync(`${__dirname}/data/schema.graphql`, "utf8"); |
| 3 | + |
| 4 | +module.exports = { |
| 5 | + parser: "@typescript-eslint/parser", |
| 6 | + extends: [ |
| 7 | + "plugin:react/recommended", |
| 8 | + "plugin:import/errors", |
| 9 | + "plugin:import/typescript", |
| 10 | + "prettier", |
| 11 | + "prettier/@typescript-eslint", |
| 12 | + "prettier/react", |
| 13 | + ], |
| 14 | + plugins: [ |
| 15 | + "jest", |
| 16 | + "@typescript-eslint", |
| 17 | + "react-hooks", |
| 18 | + "react", |
| 19 | + "graphql", |
| 20 | + "simple-import-sort", |
| 21 | + "import", |
| 22 | + ], |
| 23 | + overrides: [ |
| 24 | + { |
| 25 | + files: ["@app/e2e/cypress/**"], |
| 26 | + plugins: ["cypress"], |
| 27 | + env: { |
| 28 | + "cypress/globals": true, |
| 29 | + }, |
| 30 | + }, |
| 31 | + ], |
| 32 | + parserOptions: { |
| 33 | + ecmaVersion: 2018, |
| 34 | + sourceType: "module", |
| 35 | + ecmaFeatures: { |
| 36 | + jsx: true, |
| 37 | + }, |
| 38 | + }, |
| 39 | + settings: { |
| 40 | + react: { |
| 41 | + version: "detect", |
| 42 | + }, |
| 43 | + }, |
| 44 | + env: { |
| 45 | + browser: true, |
| 46 | + node: true, |
| 47 | + jest: true, |
| 48 | + es6: true, |
| 49 | + }, |
| 50 | + rules: { |
| 51 | + "react-hooks/rules-of-hooks": "error", |
| 52 | + "react-hooks/exhaustive-deps": "error", |
| 53 | + "@typescript-eslint/no-unused-vars": [ |
| 54 | + "error", |
| 55 | + { |
| 56 | + argsIgnorePattern: "^_", |
| 57 | + varsIgnorePattern: "^_", |
| 58 | + args: "after-used", |
| 59 | + ignoreRestSiblings: true, |
| 60 | + }, |
| 61 | + ], |
| 62 | + "no-unused-expressions": [ |
| 63 | + "error", |
| 64 | + { |
| 65 | + allowTernary: true, |
| 66 | + }, |
| 67 | + ], |
| 68 | + "no-console": 0, |
| 69 | + "no-confusing-arrow": 0, |
| 70 | + "no-else-return": 0, |
| 71 | + "no-return-assign": [2, "except-parens"], |
| 72 | + "no-underscore-dangle": 0, |
| 73 | + "jest/no-focused-tests": 2, |
| 74 | + "jest/no-identical-title": 2, |
| 75 | + camelcase: 0, |
| 76 | + "prefer-arrow-callback": [ |
| 77 | + "error", |
| 78 | + { |
| 79 | + allowNamedFunctions: true, |
| 80 | + }, |
| 81 | + ], |
| 82 | + "class-methods-use-this": 0, |
| 83 | + "no-restricted-syntax": 0, |
| 84 | + "no-param-reassign": [ |
| 85 | + "error", |
| 86 | + { |
| 87 | + props: false, |
| 88 | + }, |
| 89 | + ], |
| 90 | + "react/prop-types": 0, |
| 91 | + "react/no-multi-comp": 0, |
| 92 | + "react/jsx-filename-extension": 0, |
| 93 | + "react/no-unescaped-entities": 0, |
| 94 | + |
| 95 | + "import/no-extraneous-dependencies": 0, |
| 96 | + |
| 97 | + "graphql/template-strings": [ |
| 98 | + "error", |
| 99 | + { |
| 100 | + env: "literal", |
| 101 | + schemaString, |
| 102 | + validators: [ |
| 103 | + "ExecutableDefinitions", |
| 104 | + "FieldsOnCorrectType", |
| 105 | + "FragmentsOnCompositeTypes", |
| 106 | + "KnownArgumentNames", |
| 107 | + "KnownDirectives", // disabled by default in relay |
| 108 | + // 'KnownFragmentNames', // disabled by default in all envs |
| 109 | + "KnownTypeNames", |
| 110 | + "LoneAnonymousOperation", |
| 111 | + "NoFragmentCycles", |
| 112 | + "NoUndefinedVariables", //disabled by default in relay |
| 113 | + // 'NoUnusedFragments' // disabled by default in all envs |
| 114 | + // 'NoUnusedVariables' throws even when fragments use the variable |
| 115 | + "OverlappingFieldsCanBeMerged", |
| 116 | + "PossibleFragmentSpreads", |
| 117 | + "ProvidedRequiredArguments", // disabled by default in relay |
| 118 | + "ScalarLeafs", // disabled by default in relay |
| 119 | + "SingleFieldSubscriptions", |
| 120 | + "UniqueArgumentNames", |
| 121 | + "UniqueDirectivesPerLocation", |
| 122 | + "UniqueFragmentNames", |
| 123 | + "UniqueInputFieldNames", |
| 124 | + "UniqueOperationNames", |
| 125 | + "UniqueVariableNames", |
| 126 | + "ValuesOfCorrectType", |
| 127 | + "VariablesAreInputTypes", |
| 128 | + // "VariablesDefaultValueAllowed", |
| 129 | + "VariablesInAllowedPosition", |
| 130 | + ], |
| 131 | + }, |
| 132 | + ], |
| 133 | + "graphql/named-operations": [ |
| 134 | + "error", |
| 135 | + { |
| 136 | + schemaString, |
| 137 | + }, |
| 138 | + ], |
| 139 | + "graphql/required-fields": [ |
| 140 | + "error", |
| 141 | + { |
| 142 | + env: "literal", |
| 143 | + schemaString, |
| 144 | + requiredFields: ["nodeId", "id"], |
| 145 | + }, |
| 146 | + ], |
| 147 | + "react/destructuring-assignment": 0, |
| 148 | + |
| 149 | + "arrow-body-style": 0, |
| 150 | + "no-nested-ternary": 0, |
| 151 | + |
| 152 | + /* |
| 153 | + * simple-import-sort seems to be the most stable import sorting currently, |
| 154 | + * disable others |
| 155 | + */ |
| 156 | + "simple-import-sort/sort": "error", |
| 157 | + "sort-imports": "off", |
| 158 | + "import/order": "off", |
| 159 | + |
| 160 | + "import/no-deprecated": "warn", |
| 161 | + "import/no-duplicates": "error", |
| 162 | + }, |
| 163 | +}; |
0 commit comments