|
| 1 | +module.exports = { |
| 2 | + env: { |
| 3 | + browser: true, |
| 4 | + es6: true, |
| 5 | + node: true, |
| 6 | + jest: true, |
| 7 | + }, |
| 8 | + ignorePatterns: ['setupTests.tsx','*.test.ts*', '*.stories.tsx'], |
| 9 | + extends: [ |
| 10 | + // non-ts recommended rules |
| 11 | + 'eslint:recommended', |
| 12 | + // remove non-ts rules covered by typescript-eslint |
| 13 | + 'plugin:@typescript-eslint/eslint-recommended', |
| 14 | + // ts recommended rules |
| 15 | + // can be slow |
| 16 | + 'plugin:@typescript-eslint/recommended', |
| 17 | + // ts recommended rules that require tsconfig.json to be specified in parserOptions.project |
| 18 | + // can be slow |
| 19 | + 'plugin:@typescript-eslint/recommended-requiring-type-checking', |
| 20 | + 'prettier/@typescript-eslint', |
| 21 | + |
| 22 | + 'plugin:react/recommended', |
| 23 | + 'plugin:security/recommended', |
| 24 | + // remove rules covered by prettier |
| 25 | + 'prettier/@typescript-eslint', |
| 26 | + 'plugin:prettier/recommended', |
| 27 | + ], |
| 28 | + globals: { |
| 29 | + Atomics: 'readonly', |
| 30 | + SharedArrayBuffer: 'readonly', |
| 31 | + }, |
| 32 | + parser: '@typescript-eslint/parser', |
| 33 | + parserOptions: { |
| 34 | + ecmaFeatures: { |
| 35 | + jsx: true, |
| 36 | + modules: true, |
| 37 | + }, |
| 38 | + ecmaVersion: 2018, |
| 39 | + sourceType: 'module', |
| 40 | + project: ['./tsconfig.json'], |
| 41 | + }, |
| 42 | + plugins: ['react', '@typescript-eslint'], |
| 43 | + rules: { |
| 44 | + '@typescript-eslint/ban-ts-ignore': 'off', |
| 45 | + '@typescript-eslint/ban-types': 'warn', |
| 46 | + '@typescript-eslint/interface-name-prefix': 'off', |
| 47 | + '@typescript-eslint/naming-convention': [ |
| 48 | + 'warn', |
| 49 | + { |
| 50 | + selector: 'function', |
| 51 | + format: ['camelCase', 'PascalCase'], |
| 52 | + }, |
| 53 | + ], |
| 54 | + '@typescript-eslint/no-base-to-string': 'warn', |
| 55 | + '@typescript-eslint/no-empty-function': 'warn', |
| 56 | + '@typescript-eslint/no-explicit-any': 'warn', |
| 57 | + '@typescript-eslint/no-floating-promises': 'error', |
| 58 | + '@typescript-eslint/no-implied-eval': 'warn', |
| 59 | + '@typescript-eslint/no-inferrable-types': 'warn', |
| 60 | + '@typescript-eslint/no-misused-promises': 'error', |
| 61 | + '@typescript-eslint/no-non-null-assertion': 'warn', |
| 62 | + '@typescript-eslint/no-throw-literal': 'warn', |
| 63 | + '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'warn', |
| 64 | + '@typescript-eslint/no-unnecessary-condition': 'warn', |
| 65 | + '@typescript-eslint/no-unnecessary-qualifier': 'warn', |
| 66 | + '@typescript-eslint/no-unnecessary-type-arguments': 'warn', |
| 67 | + '@typescript-eslint/no-unnecessary-type-assertion': 'warn', |
| 68 | + '@typescript-eslint/no-unsafe-assignment': 'warn', |
| 69 | + '@typescript-eslint/no-unsafe-call': 'warn', |
| 70 | + '@typescript-eslint/no-unsafe-member-access': 'warn', |
| 71 | + '@typescript-eslint/no-unsafe-return': 'warn', |
| 72 | + '@typescript-eslint/no-unused-vars-experimental': 'off', |
| 73 | + '@typescript-eslint/prefer-nullish-coalescing': 'warn', |
| 74 | + '@typescript-eslint/prefer-readonly': 'warn', |
| 75 | + // Ideally this would be on, but it has too many false positives. Should apply to arrays but seems to apply to everything, potentially a bug |
| 76 | + '@typescript-eslint/prefer-readonly-parameter-types': 'off', |
| 77 | + '@typescript-eslint/prefer-reduce-type-parameter': 'warn', |
| 78 | + '@typescript-eslint/prefer-regexp-exec': 'warn', |
| 79 | + '@typescript-eslint/promise-function-async': 'error', |
| 80 | + '@typescript-eslint/promise-function-async': 'error', |
| 81 | + '@typescript-eslint/require-array-sort-compare': 'warn', |
| 82 | + // require-await is incompatible with promise-function-async |
| 83 | + '@typescript-eslint/require-await': 'off', |
| 84 | + '@typescript-eslint/restrict-plus-operands': 'warn', |
| 85 | + '@typescript-eslint/restrict-template-expressions': [ |
| 86 | + 'warn', |
| 87 | + { |
| 88 | + allowNumber: true, |
| 89 | + allowBoolean: true, |
| 90 | + allowNullable: false, |
| 91 | + }, |
| 92 | + ], |
| 93 | + '@typescript-eslint/strict-boolean-expressions': 'warn', |
| 94 | + '@typescript-eslint/switch-exhaustiveness-check': 'warn', |
| 95 | + // TODO: We use this in mocks in .spec.ts, perhaps syntax is incorrect? |
| 96 | + '@typescript-eslint/unbound-method': 'off', |
| 97 | + 'react/jsx-pascal-case': [ |
| 98 | + 'warn', |
| 99 | + { |
| 100 | + ignore: [ |
| 101 | + 'h1', |
| 102 | + 'h2', |
| 103 | + 'h3', |
| 104 | + 'h4', |
| 105 | + 'h5', |
| 106 | + 'h6', |
| 107 | + 'd1', |
| 108 | + 'd2', |
| 109 | + 'd3', |
| 110 | + 'd4', |
| 111 | + 'd5', |
| 112 | + 'd6', |
| 113 | + ], |
| 114 | + }, |
| 115 | + ], |
| 116 | + }, |
| 117 | +} |
0 commit comments