|
| 1 | +module.exports = { |
| 2 | + extends: ['eslint-config-airbnb-base', 'prettier', 'plugin:@typescript-eslint/recommended'], |
| 3 | + parser: '@typescript-eslint/parser', |
| 4 | + plugins: ['eslint-comments', 'react', 'jest', 'unicorn', 'react-hooks'], |
| 5 | + env: { |
| 6 | + browser: true, |
| 7 | + node: true, |
| 8 | + es6: true, |
| 9 | + mocha: true, |
| 10 | + jest: true, |
| 11 | + jasmine: true, |
| 12 | + }, |
| 13 | + rules: { |
| 14 | + 'react/display-name': 0, |
| 15 | + 'react/jsx-props-no-spreading': 0, |
| 16 | + 'react/state-in-constructor': 0, |
| 17 | + 'react/static-property-placement': 0, |
| 18 | + // Too restrictive: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/destructuring-assignment.md |
| 19 | + 'react/destructuring-assignment': 'off', |
| 20 | + 'react/jsx-filename-extension': 'off', |
| 21 | + 'react/no-array-index-key': 'warn', |
| 22 | + 'react-hooks/rules-of-hooks': 'error', // Checks rules of Hooks |
| 23 | + 'react-hooks/exhaustive-deps': 'warn', // Checks deps of Hooks |
| 24 | + 'react/require-default-props': 0, |
| 25 | + 'react/jsx-fragments': 0, |
| 26 | + 'react/jsx-wrap-multilines': 0, |
| 27 | + 'react/prop-types': 0, |
| 28 | + 'react/forbid-prop-types': 0, |
| 29 | + 'react/sort-comp': 0, |
| 30 | + 'react/react-in-jsx-scope': 0, |
| 31 | + 'react/jsx-one-expression-per-line': 0, |
| 32 | + 'generator-star-spacing': 0, |
| 33 | + 'function-paren-newline': 0, |
| 34 | + 'import/no-unresolved': 0, |
| 35 | + 'import/order': 0, |
| 36 | + 'import/no-named-as-default': 0, |
| 37 | + 'import/no-cycle': 0, |
| 38 | + 'import/prefer-default-export': 0, |
| 39 | + 'import/no-default-export': 0, |
| 40 | + 'import/no-extraneous-dependencies': 0, |
| 41 | + 'import/named': 0, |
| 42 | + 'import/no-named-as-default-member': 0, |
| 43 | + 'import/no-duplicates': 0, |
| 44 | + 'import/no-self-import': 0, |
| 45 | + 'import/extensions': 0, |
| 46 | + 'import/no-useless-path-segments': 0, |
| 47 | + 'jsx-a11y/no-noninteractive-element-interactions': 0, |
| 48 | + 'jsx-a11y/click-events-have-key-events': 0, |
| 49 | + 'jsx-a11y/no-static-element-interactions': 0, |
| 50 | + 'jsx-a11y/anchor-is-valid': 0, |
| 51 | + 'sort-imports': 0, |
| 52 | + 'class-methods-use-this': 0, |
| 53 | + 'no-confusing-arrow': 0, |
| 54 | + 'linebreak-style': 0, |
| 55 | + // Too restrictive, writing ugly code to defend against a very unlikely scenario: https://eslint.org/docs/rules/no-prototype-builtins |
| 56 | + 'no-prototype-builtins': 'off', |
| 57 | + 'unicorn/prevent-abbreviations': 'off', |
| 58 | + // Conflict with prettier |
| 59 | + 'arrow-body-style': 0, |
| 60 | + 'arrow-parens': 0, |
| 61 | + 'object-curly-newline': 0, |
| 62 | + 'implicit-arrow-linebreak': 0, |
| 63 | + 'operator-linebreak': 0, |
| 64 | + 'eslint-comments/no-unlimited-disable': 0, |
| 65 | + 'no-param-reassign': 2, |
| 66 | + 'space-before-function-paren': 0, |
| 67 | + // tsEslintConfig |
| 68 | + 'no-undef': 0, |
| 69 | + '@typescript-eslint/adjacent-overload-signatures': 0, |
| 70 | + '@typescript-eslint/array-type': 'error', |
| 71 | + '@typescript-eslint/await-thenable': 0, |
| 72 | + '@typescript-eslint/ban-ts-comment': 0, |
| 73 | + '@typescript-eslint/ban-tslint-comment': 0, |
| 74 | + 'brace-style': 'off', |
| 75 | + '@typescript-eslint/brace-style': 0, |
| 76 | + '@typescript-eslint/class-literal-property-style': 0, |
| 77 | + 'comma-dangle': 'off', |
| 78 | + '@typescript-eslint/comma-dangle': 0, |
| 79 | + 'comma-spacing': 'off', |
| 80 | + '@typescript-eslint/comma-spacing': 0, |
| 81 | + '@typescript-eslint/consistent-indexed-object-style': 1, |
| 82 | + '@typescript-eslint/consistent-type-assertions': 0, |
| 83 | + '@typescript-eslint/consistent-type-definitions': 0, |
| 84 | + '@typescript-eslint/consistent-type-imports': 1, |
| 85 | + 'default-param-last': 'off', |
| 86 | + '@typescript-eslint/default-param-last': 0, |
| 87 | + 'dot-notation': 'off', |
| 88 | + '@typescript-eslint/dot-notation': 1, |
| 89 | + '@typescript-eslint/explicit-function-return-type': 0, |
| 90 | + 'func-call-spacing': 'off', |
| 91 | + '@typescript-eslint/func-call-spacing': 0, |
| 92 | + indent: 'off', |
| 93 | + 'init-declarations': 'off', |
| 94 | + '@typescript-eslint/init-declarations': 0, |
| 95 | + 'keyword-spacing': 'off', |
| 96 | + '@typescript-eslint/keyword-spacing': 0, |
| 97 | + 'lines-between-class-members': 'off', |
| 98 | + '@typescript-eslint/lines-between-class-members': 0, |
| 99 | + '@typescript-eslint/member-delimiter-style': 0, |
| 100 | + '@typescript-eslint/member-ordering': 0, |
| 101 | + '@typescript-eslint/method-signature-style': 'error', |
| 102 | + 'no-array-constructor': 'off', |
| 103 | + '@typescript-eslint/no-array-constructor': 0, |
| 104 | + '@typescript-eslint/no-base-to-string': 0, |
| 105 | + '@typescript-eslint/no-confusing-non-null-assertion': 'error', |
| 106 | + '@typescript-eslint/no-confusing-void-expression': 0, |
| 107 | + 'no-dupe-class-members': 'off', |
| 108 | + '@typescript-eslint/no-dupe-class-members': 'error', |
| 109 | + 'no-duplicate-imports': 'off', |
| 110 | + '@typescript-eslint/no-duplicate-imports': 0, |
| 111 | + '@typescript-eslint/no-dynamic-delete': 0, |
| 112 | + 'no-empty-function': 'off', |
| 113 | + '@typescript-eslint/no-empty-function': 0, |
| 114 | + '@typescript-eslint/no-empty-interface': 1, |
| 115 | + '@typescript-eslint/no-extra-non-null-assertion': 0, |
| 116 | + 'no-extra-parens': 'off', |
| 117 | + '@typescript-eslint/no-extra-parens': 0, |
| 118 | + 'no-extra-semi': 'off', |
| 119 | + '@typescript-eslint/no-extra-semi': 0, |
| 120 | + '@typescript-eslint/no-extraneous-class': 0, |
| 121 | + '@typescript-eslint/no-floating-promises': 0, |
| 122 | + '@typescript-eslint/no-for-in-array': 'error', |
| 123 | + '@typescript-eslint/no-implicit-any-catch': 0, |
| 124 | + 'no-implied-eval': 'off', |
| 125 | + '@typescript-eslint/no-implied-eval': 0, |
| 126 | + '@typescript-eslint/no-inferrable-types': 0, |
| 127 | + 'no-invalid-this': 'off', |
| 128 | + '@typescript-eslint/no-invalid-this': 'error', |
| 129 | + '@typescript-eslint/no-invalid-void-type': 0, |
| 130 | + 'no-loop-func': 'off', |
| 131 | + '@typescript-eslint/no-loop-func': 'error', |
| 132 | + 'no-loss-of-precision': 'off', |
| 133 | + '@typescript-eslint/no-loss-of-precision': 0, |
| 134 | + 'no-magic-numbers': 'off', |
| 135 | + '@typescript-eslint/no-magic-numbers': 0, |
| 136 | + '@typescript-eslint/no-misused-new': 'error', |
| 137 | + '@typescript-eslint/no-misused-promises': 0, |
| 138 | + '@typescript-eslint/no-namespace': 1, |
| 139 | + '@typescript-eslint/no-non-null-asserted-optional-chain': 'error', |
| 140 | + '@typescript-eslint/no-parameter-properties': 'error', |
| 141 | + 'no-redeclare': 'off', |
| 142 | + '@typescript-eslint/no-redeclare': 'error', |
| 143 | + '@typescript-eslint/no-require-imports': 0, |
| 144 | + 'no-shadow': 'off', |
| 145 | + '@typescript-eslint/no-shadow': 'error', |
| 146 | + '@typescript-eslint/no-this-alias': 'error', |
| 147 | + 'no-throw-literal': 'off', |
| 148 | + '@typescript-eslint/no-throw-literal': 'error', |
| 149 | + '@typescript-eslint/no-type-alias': 0, |
| 150 | + '@typescript-eslint/no-unnecessary-boolean-literal-compare': 0, |
| 151 | + '@typescript-eslint/no-unnecessary-condition': 0, |
| 152 | + '@typescript-eslint/no-unnecessary-qualifier': 0, |
| 153 | + '@typescript-eslint/no-unnecessary-type-arguments': 0, |
| 154 | + '@typescript-eslint/no-unnecessary-type-assertion': 0, |
| 155 | + '@typescript-eslint/no-unnecessary-type-constraint': 0, |
| 156 | + '@typescript-eslint/no-unsafe-assignment': 0, |
| 157 | + '@typescript-eslint/no-unsafe-call': 0, |
| 158 | + '@typescript-eslint/no-unsafe-member-access': 0, |
| 159 | + '@typescript-eslint/no-unsafe-return': 0, |
| 160 | + 'no-unused-expressions': 'off', |
| 161 | + '@typescript-eslint/no-unused-expressions': 'error', |
| 162 | + 'no-unused-vars': 'off', |
| 163 | + 'no-use-before-define': 'off', |
| 164 | + 'no-useless-constructor': 'off', |
| 165 | + '@typescript-eslint/no-useless-constructor': 'error', |
| 166 | + '@typescript-eslint/non-nullable-type-assertion-style': 0, |
| 167 | + '@typescript-eslint/prefer-as-const': 0, |
| 168 | + '@typescript-eslint/prefer-enum-initializers': 0, |
| 169 | + '@typescript-eslint/prefer-for-of': 0, |
| 170 | + '@typescript-eslint/prefer-function-type': 0, |
| 171 | + '@typescript-eslint/prefer-includes': 0, |
| 172 | + '@typescript-eslint/prefer-literal-enum-member': 0, |
| 173 | + '@typescript-eslint/prefer-namespace-keyword': 0, |
| 174 | + '@typescript-eslint/prefer-nullish-coalescing': 0, |
| 175 | + '@typescript-eslint/prefer-optional-chain': 0, |
| 176 | + '@typescript-eslint/prefer-readonly': 0, |
| 177 | + '@typescript-eslint/prefer-readonly-parameter-types': 0, |
| 178 | + '@typescript-eslint/prefer-reduce-type-parameter': 0, |
| 179 | + '@typescript-eslint/prefer-regexp-exec': 0, |
| 180 | + '@typescript-eslint/prefer-string-starts-ends-with': 0, |
| 181 | + '@typescript-eslint/prefer-ts-expect-error': 0, |
| 182 | + '@typescript-eslint/promise-function-async': 0, |
| 183 | + quotes: 'off', |
| 184 | + '@typescript-eslint/quotes': 0, |
| 185 | + '@typescript-eslint/require-array-sort-compare': 0, |
| 186 | + 'require-await': 'off', |
| 187 | + '@typescript-eslint/require-await': 0, |
| 188 | + '@typescript-eslint/restrict-plus-operands': 0, |
| 189 | + '@typescript-eslint/restrict-template-expressions': 0, |
| 190 | + 'no-return-await': 'off', |
| 191 | + '@typescript-eslint/return-await': 0, |
| 192 | + semi: 'off', |
| 193 | + '@typescript-eslint/semi': 0, |
| 194 | + '@typescript-eslint/space-before-function-paren': 0, |
| 195 | + 'space-infix-ops': 'off', |
| 196 | + '@typescript-eslint/space-infix-ops': 0, |
| 197 | + '@typescript-eslint/strict-boolean-expressions': 0, |
| 198 | + '@typescript-eslint/switch-exhaustiveness-check': 'error', |
| 199 | + '@typescript-eslint/triple-slash-reference': 'error', |
| 200 | + '@typescript-eslint/type-annotation-spacing': 'error', |
| 201 | + '@typescript-eslint/typedef': 'error', |
| 202 | + '@typescript-eslint/unbound-method': 0, |
| 203 | + '@typescript-eslint/unified-signatures': 'error', |
| 204 | + '@typescript-eslint/indent': 0, |
| 205 | + // Makes no sense to allow type inferrence for expression parameters, but require typing the response |
| 206 | + '@typescript-eslint/no-use-before-define': [ |
| 207 | + 'error', |
| 208 | + { functions: false, classes: true, variables: true, typedefs: true }, |
| 209 | + ], |
| 210 | + camelcase: 0, |
| 211 | + '@typescript-eslint/camelcase': 0, |
| 212 | + '@typescript-eslint/no-var-requires': 0, |
| 213 | + // Common abbreviations are known and readable |
| 214 | + '@typescript-eslint/explicit-member-accessibility': 0, |
| 215 | + '@typescript-eslint/interface-name-prefix': 0, |
| 216 | + '@typescript-eslint/no-non-null-assertion': 0, |
| 217 | + '@typescript-eslint/no-explicit-any': 0, |
| 218 | + '@typescript-eslint/ban-types': 1, |
| 219 | + '@typescript-eslint/explicit-module-boundary-types': 0, |
| 220 | + '@typescript-eslint/naming-convention': 0, |
| 221 | + '@typescript-eslint/no-unused-vars': [ |
| 222 | + 'error', |
| 223 | + { vars: 'all', args: 'after-used', ignoreRestSiblings: true }, |
| 224 | + ], |
| 225 | + }, |
| 226 | + settings: { |
| 227 | + // support import modules from TypeScript files in JavaScript files |
| 228 | + 'import/resolver': { |
| 229 | + node: { |
| 230 | + extensions: ['.js', '.jsx', '.ts', '.tsx', '.d.ts'], |
| 231 | + }, |
| 232 | + }, |
| 233 | + 'import/parsers': { |
| 234 | + '@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'], |
| 235 | + }, |
| 236 | + 'import/extensions': ['.js', '.mjs', '.jsx', '.ts', '.tsx', '.d.ts'], |
| 237 | + 'import/external-module-folders': ['node_modules', 'node_modules/@types'], |
| 238 | + polyfills: ['fetch', 'Promise', 'URL', 'object-assign'], |
| 239 | + }, |
| 240 | + parserOptions: { |
| 241 | + ecmaFeatures: { |
| 242 | + jsx: true, |
| 243 | + }, |
| 244 | + babelOptions: { |
| 245 | + presets: ['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript'], |
| 246 | + plugins: [ |
| 247 | + ['@babel/plugin-proposal-decorators', { legacy: true }], |
| 248 | + ['@babel/plugin-proposal-class-properties', { loose: true }], |
| 249 | + ], |
| 250 | + }, |
| 251 | + requireConfigFile: false, |
| 252 | + project: './tsconfig.json', |
| 253 | + tsconfigRootDir: __dirname, |
| 254 | + }, |
| 255 | +}; |
0 commit comments