|
| 1 | +import js from '@eslint/js' |
| 2 | +import tseslint from 'typescript-eslint' |
| 3 | +import reactPlugin from 'eslint-plugin-react' |
| 4 | +import reactHooksPlugin from 'eslint-plugin-react-hooks' |
| 5 | +import globals from 'globals' |
| 6 | + |
| 7 | +// Flat-config base every package in the UI workspace shares. Package configs spread it and |
| 8 | +// append their own overrides; the plugins it imports resolve from the workspace root, so a |
| 9 | +// package only declares the plugins its own overrides use. |
| 10 | +export const baseConfig = tseslint.config( |
| 11 | + js.configs.recommended, |
| 12 | + ...tseslint.configs.recommended, |
| 13 | + { |
| 14 | + files: ['**/*.{ts,tsx}'], |
| 15 | + plugins: { |
| 16 | + react: reactPlugin, |
| 17 | + 'react-hooks': reactHooksPlugin, |
| 18 | + }, |
| 19 | + languageOptions: { |
| 20 | + globals: { |
| 21 | + ...globals.browser, |
| 22 | + ...globals.es2020, |
| 23 | + }, |
| 24 | + parserOptions: { |
| 25 | + ecmaFeatures: { jsx: true }, |
| 26 | + }, |
| 27 | + }, |
| 28 | + settings: { |
| 29 | + react: { version: 'detect' }, |
| 30 | + }, |
| 31 | + rules: { |
| 32 | + ...reactPlugin.configs.recommended.rules, |
| 33 | + ...reactHooksPlugin.configs.recommended.rules, |
| 34 | + 'react/react-in-jsx-scope': 'off', |
| 35 | + 'react/prop-types': 'off', |
| 36 | + '@typescript-eslint/no-explicit-any': 'error', |
| 37 | + // A suppression has to state which error it silences and stop applying once that error |
| 38 | + // is gone, so `@ts-ignore` is never the right form. |
| 39 | + '@typescript-eslint/ban-ts-comment': [ |
| 40 | + 'error', |
| 41 | + { 'ts-ignore': true, 'ts-expect-error': 'allow-with-description' }, |
| 42 | + ], |
| 43 | + '@typescript-eslint/no-unused-vars': [ |
| 44 | + 'error', |
| 45 | + { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }, |
| 46 | + ], |
| 47 | + }, |
| 48 | + }, |
| 49 | + { |
| 50 | + // Triple-slash references are the only way an ambient declaration file can pull in |
| 51 | + // another set of typings. |
| 52 | + files: ['**/*.d.ts'], |
| 53 | + rules: { |
| 54 | + '@typescript-eslint/triple-slash-reference': 'off', |
| 55 | + }, |
| 56 | + }, |
| 57 | + { |
| 58 | + ignores: ['build/', 'dist/', 'node_modules/'], |
| 59 | + }, |
| 60 | +) |
| 61 | + |
| 62 | +export default baseConfig |
0 commit comments