|
| 1 | +module.exports = { |
| 2 | + extends: [ |
| 3 | + "eslint:recommended", |
| 4 | + "plugin:@typescript-eslint/recommended", |
| 5 | + "plugin:import/typescript", |
| 6 | + "plugin:prettier/recommended", |
| 7 | + "plugin:react/recommended", |
| 8 | + "plugin:@next/next/recommended", |
| 9 | + ], |
| 10 | + rules: { |
| 11 | + // typescript |
| 12 | + "@typescript-eslint/ban-ts-comment": [ |
| 13 | + "error", |
| 14 | + { |
| 15 | + // future defaults |
| 16 | + "ts-expect-error": "allow-with-description", |
| 17 | + minimumDescriptionLength: 10, |
| 18 | + }, |
| 19 | + ], |
| 20 | + "@typescript-eslint/ban-types": [ |
| 21 | + "error", |
| 22 | + { |
| 23 | + types: { |
| 24 | + "{}": false, |
| 25 | + }, |
| 26 | + }, |
| 27 | + ], |
| 28 | + "@typescript-eslint/explicit-module-boundary-types": "off", |
| 29 | + "@typescript-eslint/no-empty-interface": "off", |
| 30 | + "@typescript-eslint/no-explicit-any": "off", |
| 31 | + "@typescript-eslint/no-non-null-assertion": "error", |
| 32 | + "@typescript-eslint/no-parameter-properties": "error", |
| 33 | + "@typescript-eslint/no-unused-vars": "warn", |
| 34 | + // import |
| 35 | + "import/first": "error", |
| 36 | + "import/newline-after-import": "error", |
| 37 | + "import/no-cycle": "error", |
| 38 | + "import/no-default-export": "off", |
| 39 | + "import/no-useless-path-segments": "error", |
| 40 | + // react |
| 41 | + "react/forbid-dom-props": ["error", { forbid: ["className", "style"] }], |
| 42 | + "react/no-children-prop": "off", |
| 43 | + "react/prop-types": "off", |
| 44 | + // react-hooks |
| 45 | + "react-hooks/rules-of-hooks": "error", |
| 46 | + "react-hooks/exhaustive-deps": "error", |
| 47 | + // eslint |
| 48 | + curly: "error", |
| 49 | + eqeqeq: "error", |
| 50 | + "getter-return": "off", |
| 51 | + "key-spacing": [ |
| 52 | + "error", |
| 53 | + { beforeColon: false, afterColon: true, mode: "strict" }, |
| 54 | + ], |
| 55 | + "keyword-spacing": ["error", { before: true, after: true }], |
| 56 | + "line-comment-position": "error", |
| 57 | + "new-cap": "error", |
| 58 | + "no-alert": "error", |
| 59 | + "no-case-declarations": "off", |
| 60 | + |
| 61 | + "no-duplicate-imports": "error", |
| 62 | + "no-eval": "error", |
| 63 | + "no-floating-decimal": "error", |
| 64 | + "no-implicit-coercion": ["error", { boolean: false }], |
| 65 | + "no-implied-eval": "error", |
| 66 | + "no-irregular-whitespace": "error", |
| 67 | + "no-label-var": "error", |
| 68 | + "no-multiple-empty-lines": "error", |
| 69 | + "no-octal-escape": "error", |
| 70 | + "no-restricted-globals": ["error", "xdescribe", "fit", "fdescribe"], |
| 71 | + // has false positives |
| 72 | + "no-shadow": "off", |
| 73 | + // replaced with this |
| 74 | + "@typescript-eslint/no-shadow": "error", |
| 75 | + "no-tabs": "error", |
| 76 | + "no-template-curly-in-string": "error", |
| 77 | + "no-throw-literal": "error", |
| 78 | + "no-trailing-spaces": "error", |
| 79 | + "no-undef": "off", |
| 80 | + "no-unused-expressions": "error", |
| 81 | + "no-useless-computed-key": "error", |
| 82 | + "no-whitespace-before-property": "error", |
| 83 | + "object-curly-spacing": ["error", "always"], |
| 84 | + "object-shorthand": ["error", "always"], |
| 85 | + "prefer-const": "error", |
| 86 | + "prefer-object-spread": "error", |
| 87 | + "prefer-template": "error", |
| 88 | + "quote-props": ["error", "as-needed"], |
| 89 | + // 'sort-imports': ['warn', { ignoreDeclarationSort: true }], |
| 90 | + // 'sort-keys': ['warn', 'asc', { natural: true }], |
| 91 | + "spaced-comment": ["error", "always", { markers: ["/ <reference"] }], |
| 92 | + "symbol-description": "error", |
| 93 | + "template-curly-spacing": ["error", "never"], |
| 94 | + "use-isnan": "error", |
| 95 | + "valid-typeof": "error", |
| 96 | + semi: ["warn", "always"], |
| 97 | + // Inclusive |
| 98 | + "inclusive-language/use-inclusive-words": "error", |
| 99 | + // turn off deprecated things? |
| 100 | + "react/react-in-jsx-scope": "off", |
| 101 | + }, |
| 102 | + parser: "@typescript-eslint/parser", |
| 103 | + plugins: [ |
| 104 | + "@typescript-eslint", |
| 105 | + "import", |
| 106 | + "inclusive-language", |
| 107 | + "react", |
| 108 | + "react-hooks", |
| 109 | + ], |
| 110 | + parserOptions: { |
| 111 | + ecmaVersion: 2019, |
| 112 | + ecmaFeatures: { |
| 113 | + impliedStrict: true, |
| 114 | + jsx: true, |
| 115 | + }, |
| 116 | + warnOnUnsupportedTypeScriptVersion: true, |
| 117 | + }, |
| 118 | + settings: { |
| 119 | + react: { |
| 120 | + createClass: "createReactClass", |
| 121 | + pragma: "React", |
| 122 | + version: "detect", |
| 123 | + }, |
| 124 | + }, |
| 125 | + overrides: [ |
| 126 | + // enable rule specifically for TypeScript files |
| 127 | + { |
| 128 | + files: ["*.ts", "*.tsx"], |
| 129 | + rules: { |
| 130 | + "@typescript-eslint/explicit-module-boundary-types": ["off"], |
| 131 | + }, |
| 132 | + }, |
| 133 | + // disable mandatory display-names in non-production code |
| 134 | + { |
| 135 | + files: ["package-examples/**", "prototyper/**"], |
| 136 | + rules: { |
| 137 | + "react/display-name": "off", |
| 138 | + }, |
| 139 | + }, |
| 140 | + |
| 141 | + // in test files, allow null assertions and anys and eslint is sometimes weird about the react-scope thing |
| 142 | + { |
| 143 | + files: ["*test.ts?(x)"], |
| 144 | + rules: { |
| 145 | + "@typescript-eslint/no-non-null-assertion": "off", |
| 146 | + "@typescript-eslint/no-explicit-any": "off", |
| 147 | + |
| 148 | + "react/display-name": "off", |
| 149 | + }, |
| 150 | + }, |
| 151 | + // allow requires in non-transpiled JS files and logical key ordering in config files |
| 152 | + { |
| 153 | + files: [ |
| 154 | + "babel-node.js", |
| 155 | + "*babel.config.js", |
| 156 | + "env.config.js", |
| 157 | + "next.config.js", |
| 158 | + "webpack.config.js", |
| 159 | + "packages/mobile-web/package-builder/**", |
| 160 | + ], |
| 161 | + rules: {}, |
| 162 | + }, |
| 163 | + |
| 164 | + // setupTests can have separated imports for logical grouping |
| 165 | + { |
| 166 | + files: ["setupTests.ts"], |
| 167 | + rules: { |
| 168 | + "import/newline-after-import": "off", |
| 169 | + }, |
| 170 | + }, |
| 171 | + ], |
| 172 | + env: { |
| 173 | + browser: true, |
| 174 | + node: true, |
| 175 | + }, |
| 176 | +}; |
0 commit comments