|
| 1 | +import js from '@eslint/js' |
| 2 | +import react from 'eslint-plugin-react' |
| 3 | +import reactHooks from 'eslint-plugin-react-hooks' |
| 4 | +import reactRefresh from 'eslint-plugin-react-refresh' |
| 5 | +import globals from 'globals' |
| 6 | +import tseslint from 'typescript-eslint' |
| 7 | + |
| 8 | +// Copy from https://github.com/hyparam/hyperparam-cli/blob/87b516bbcaadc0ffacb9914c4ba7a8d827e65469/shared.eslint.config.js |
| 9 | +const sharedJsRules = { |
| 10 | + 'arrow-spacing': 'error', |
| 11 | + camelcase: 'off', |
| 12 | + 'comma-spacing': 'error', |
| 13 | + 'comma-dangle': ['error', 'always-multiline'], |
| 14 | + 'eol-last': 'error', |
| 15 | + eqeqeq: 'error', |
| 16 | + 'func-style': ['error', 'declaration'], |
| 17 | + indent: ['error', 2], |
| 18 | + 'no-constant-condition': 'off', |
| 19 | + 'no-extra-parens': 'error', |
| 20 | + 'no-multi-spaces': 'error', |
| 21 | + 'no-trailing-spaces': 'error', |
| 22 | + 'no-unused-vars': 'off', |
| 23 | + 'no-useless-concat': 'error', |
| 24 | + 'no-useless-rename': 'error', |
| 25 | + 'no-useless-return': 'error', |
| 26 | + 'no-var': 'error', |
| 27 | + 'object-curly-spacing': ['error', 'always'], |
| 28 | + 'prefer-const': 'warn', |
| 29 | + 'prefer-destructuring': ['warn', { |
| 30 | + object: true, |
| 31 | + array: false, |
| 32 | + }], |
| 33 | + 'prefer-promise-reject-errors': 'error', |
| 34 | + quotes: ['error', 'single'], |
| 35 | + 'require-await': 'warn', |
| 36 | + semi: ['error', 'never'], |
| 37 | + |
| 38 | + 'sort-imports': ['error', { |
| 39 | + ignoreDeclarationSort: true, |
| 40 | + ignoreMemberSort: false, |
| 41 | + memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'], |
| 42 | + }], |
| 43 | + |
| 44 | + 'space-infix-ops': 'error', |
| 45 | +} |
| 46 | +const sharedTsRules = { |
| 47 | + '@typescript-eslint/restrict-template-expressions': 'off', |
| 48 | + '@typescript-eslint/no-unused-vars': 'warn', |
| 49 | +} |
| 50 | + |
| 51 | +export default tseslint.config( |
| 52 | + { ignores: ['dist', 'coverage'] }, |
| 53 | + { |
| 54 | + extends: [js.configs.recommended, ...tseslint.configs.strictTypeChecked, ...tseslint.configs.stylisticTypeChecked], |
| 55 | + // Set the react version |
| 56 | + settings: { react: { version: '18.3' } }, |
| 57 | + files: ['{test,src}/**/*.{ts,tsx}'], |
| 58 | + languageOptions: { |
| 59 | + ecmaVersion: 2023, |
| 60 | + globals: globals.browser, |
| 61 | + parserOptions: { |
| 62 | + project: './tsconfig.json', |
| 63 | + tsconfigRootDir: import.meta.dirname, |
| 64 | + }, |
| 65 | + }, |
| 66 | + plugins: { |
| 67 | + react, |
| 68 | + 'react-hooks': reactHooks, |
| 69 | + 'react-refresh': reactRefresh, |
| 70 | + }, |
| 71 | + rules: { |
| 72 | + ...react.configs.recommended.rules, |
| 73 | + ...react.configs['jsx-runtime'].rules, |
| 74 | + ...reactHooks.configs.recommended.rules, |
| 75 | + 'react-refresh/only-export-components': [ |
| 76 | + 'warn', |
| 77 | + { allowConstantExport: true }, |
| 78 | + ], |
| 79 | + ...js.configs.recommended.rules, |
| 80 | + ...tseslint.configs.recommended.rules, |
| 81 | + ...sharedJsRules, |
| 82 | + ...sharedTsRules, |
| 83 | + }, |
| 84 | + }, |
| 85 | +) |
0 commit comments