|
| 1 | +import js from '@eslint/js' |
| 2 | +import parser from '@typescript-eslint/parser' |
| 3 | +import plugin from '@typescript-eslint/eslint-plugin' |
| 4 | +import react from 'eslint-plugin-react' |
| 5 | +import reactRedux from 'eslint-plugin-react-redux' |
| 6 | +import prettier from 'eslint-plugin-prettier' |
| 7 | + |
| 8 | +export default [ |
| 9 | + js.configs.recommended, |
| 10 | + { |
| 11 | + ignores: [ |
| 12 | + 'node_modules', |
| 13 | + 'build', |
| 14 | + 'tmp' |
| 15 | + ], |
| 16 | + files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'], |
| 17 | + languageOptions: { |
| 18 | + parser, |
| 19 | + parserOptions: { |
| 20 | + ecmaVersion: 'latest', |
| 21 | + sourceType: 'module', |
| 22 | + ecmaFeatures: { |
| 23 | + jsx: true, |
| 24 | + }, |
| 25 | + }, |
| 26 | + globals: { |
| 27 | + jest: true |
| 28 | + }, |
| 29 | + }, |
| 30 | + plugins: { |
| 31 | + react, |
| 32 | + 'react-redux': reactRedux, |
| 33 | + '@typescript-eslint': plugin, |
| 34 | + prettier, |
| 35 | + }, |
| 36 | + rules: { |
| 37 | + // ESLint core |
| 38 | + 'object-shorthand': ['error', 'always'], |
| 39 | + 'no-array-constructor': 'off', |
| 40 | + 'no-redeclare': 'off', |
| 41 | + 'no-use-before-define': 'off', |
| 42 | + 'no-unused-expressions': 'off', |
| 43 | + 'no-unused-vars': 'off', |
| 44 | + 'no-useless-constructor': 'off', |
| 45 | + semi: ['warn', 'never'], |
| 46 | + |
| 47 | + // React |
| 48 | + 'react/prop-types': 'off', |
| 49 | + 'react/no-unused-prop-types': 'off', |
| 50 | + |
| 51 | + // React Redux |
| 52 | + 'react-redux/useSelector-prefer-selectors': 'off', |
| 53 | + 'react-redux/no-unused-prop-types': 'warn', |
| 54 | + 'react-redux/prefer-separate-component-file': 'off', |
| 55 | + |
| 56 | + // TypeScript overrides |
| 57 | + ...plugin.configs.recommended.rules, |
| 58 | + ...prettier.configs.recommended.rules, |
| 59 | + '@typescript-eslint/consistent-type-assertions': 'warn', |
| 60 | + '@typescript-eslint/no-array-constructor': 'warn', |
| 61 | + '@typescript-eslint/no-redeclare': 'warn', |
| 62 | + '@typescript-eslint/no-use-before-define': [ |
| 63 | + 'warn', |
| 64 | + { |
| 65 | + functions: false, |
| 66 | + classes: false, |
| 67 | + variables: false, |
| 68 | + typedefs: false, |
| 69 | + }, |
| 70 | + ], |
| 71 | + '@typescript-eslint/no-unused-expressions': [ |
| 72 | + 'error', |
| 73 | + { |
| 74 | + allowShortCircuit: true, |
| 75 | + allowTernary: true, |
| 76 | + allowTaggedTemplates: true, |
| 77 | + }, |
| 78 | + ], |
| 79 | + '@typescript-eslint/no-unused-vars': [ |
| 80 | + 'warn', |
| 81 | + { |
| 82 | + args: 'none', |
| 83 | + ignoreRestSiblings: true, |
| 84 | + }, |
| 85 | + ], |
| 86 | + '@typescript-eslint/no-useless-constructor': 'warn', |
| 87 | + |
| 88 | + // Prettier |
| 89 | + 'prettier/prettier': 'error', |
| 90 | + }, |
| 91 | + settings: { |
| 92 | + react: { |
| 93 | + createClass: 'createReactClass', |
| 94 | + pragma: 'React', |
| 95 | + fragment: 'Fragment', |
| 96 | + version: 'detect', |
| 97 | + flowVersion: '0.53', |
| 98 | + }, |
| 99 | + propWrapperFunctions: [ |
| 100 | + 'forbidExtraProps', |
| 101 | + { property: 'freeze', object: 'Object' }, |
| 102 | + { property: 'myFavoriteWrapper' }, |
| 103 | + { property: 'forbidExtraProps', exact: true }, |
| 104 | + ], |
| 105 | + componentWrapperFunctions: [ |
| 106 | + 'observer', |
| 107 | + { property: 'styled' }, |
| 108 | + { property: 'observer', object: 'Mobx' }, |
| 109 | + { property: 'observer', object: '<pragma>' }, |
| 110 | + ], |
| 111 | + formComponents: ['CustomForm', { name: 'Form', formAttribute: 'endpoint' }], |
| 112 | + linkComponents: ['Hyperlink', { name: 'Link', linkAttribute: 'to' }], |
| 113 | + }, |
| 114 | + }, |
| 115 | + { |
| 116 | + // Test files |
| 117 | + files: ['**/*.spec.js', '**/*.spec.ts', '**/*.test.ts', '**/*.spec.tsx', '**/*.test.tsx'], |
| 118 | + languageOptions: { |
| 119 | + globals: { |
| 120 | + describe: true, |
| 121 | + it: true, |
| 122 | + test: true, |
| 123 | + expect: true, |
| 124 | + beforeEach: true, |
| 125 | + afterEach: true, |
| 126 | + beforeAll: true, |
| 127 | + afterAll: true, |
| 128 | + jest: true, |
| 129 | + }, |
| 130 | + }, |
| 131 | + }, |
| 132 | +] |
0 commit comments