|
| 1 | +// @ts-check |
| 2 | + |
| 3 | +import eslint from '@eslint/js'; |
| 4 | +import stylistic from '@stylistic/eslint-plugin'; |
| 5 | +import stylisticTs from '@stylistic/eslint-plugin-ts'; |
| 6 | +import reactHooksPlugin from 'eslint-plugin-react-hooks'; |
| 7 | +import jsxA11yPlugin from 'eslint-plugin-jsx-a11y'; |
| 8 | +// @ts-ignore |
| 9 | +import importPlugin from 'eslint-plugin-import'; |
| 10 | + |
| 11 | +import tseslint from 'typescript-eslint'; |
| 12 | +import { FlatCompat } from '@eslint/eslintrc'; |
| 13 | + |
| 14 | +const compat = new FlatCompat(); |
| 15 | + |
| 16 | +import { includeIgnoreFile } from '@eslint/compat'; |
| 17 | +import path from "node:path"; |
| 18 | +import { fileURLToPath } from "node:url"; |
| 19 | + |
| 20 | +const __filename = fileURLToPath(import.meta.url); |
| 21 | +const __dirname = path.dirname(__filename); |
| 22 | +const gitignorePath = path.resolve(__dirname, ".gitignore"); |
| 23 | + |
| 24 | +export default tseslint.config( |
| 25 | + includeIgnoreFile(gitignorePath), |
| 26 | + { |
| 27 | + ignores: [ |
| 28 | + '**/*.d.ts', |
| 29 | + '*.{js,jsx}', |
| 30 | + 'src/tsconfig.json', |
| 31 | + 'src/stories', |
| 32 | + '**/*.css', |
| 33 | + 'node_modules/**/*', |
| 34 | + './.next/*', |
| 35 | + 'out', |
| 36 | + '.storybook', |
| 37 | + ], |
| 38 | + }, |
| 39 | + { |
| 40 | + files: ['src/**/*.{jsx,ts,tsx}'], |
| 41 | + }, |
| 42 | + eslint.configs.recommended, |
| 43 | + ...tseslint.configs.recommended, |
| 44 | + { |
| 45 | + files: ['src/**/*.{jsx,tsx}'], |
| 46 | + plugins: { |
| 47 | + '@stylistic': stylistic, |
| 48 | + '@stylistic/ts': stylisticTs, |
| 49 | + 'jsx-a11y': jsxA11yPlugin, |
| 50 | + }, |
| 51 | + // @ts-ignore |
| 52 | + extends: [ |
| 53 | + // @ts-ignore |
| 54 | + ...compat.config(reactHooksPlugin.configs.recommended), |
| 55 | + ...compat.config(jsxA11yPlugin.configs.recommended), |
| 56 | + ], |
| 57 | + settings: { |
| 58 | + react: { |
| 59 | + version: 'detect', |
| 60 | + }, |
| 61 | + formComponents: ['Form'], |
| 62 | + linkComponents: [ |
| 63 | + { name: 'Link', linkAttribute: 'to' }, |
| 64 | + { name: 'NavLink', linkAttribute: 'to' }, |
| 65 | + ], |
| 66 | + 'import/resolver': { |
| 67 | + typescript: {}, |
| 68 | + }, |
| 69 | + }, |
| 70 | + }, |
| 71 | + { |
| 72 | + files: ['src/**/*.{ts,tsx}'], |
| 73 | + plugins: { |
| 74 | + import: importPlugin, |
| 75 | + }, |
| 76 | + extends: [ |
| 77 | + ...tseslint.configs.recommended, |
| 78 | + ...compat.config(importPlugin.configs.recommended), |
| 79 | + ...compat.config(importPlugin.configs.typescript), |
| 80 | + ], |
| 81 | + settings: { |
| 82 | + 'import/internal-regex': '^~/', |
| 83 | + 'import/resolver': { |
| 84 | + node: { |
| 85 | + extensions: ['.ts', '.tsx'], |
| 86 | + }, |
| 87 | + typescript: { |
| 88 | + alwaysTryTypes: true, |
| 89 | + }, |
| 90 | + }, |
| 91 | + }, |
| 92 | + }, |
| 93 | + { |
| 94 | + rules: { |
| 95 | + 'react/display-name': 'off', |
| 96 | + 'import/namespace': 'off', |
| 97 | + 'import/no-named-as-default': 'off', |
| 98 | + 'import/no-named-as-default-member': 'off', |
| 99 | + }, |
| 100 | + }, |
| 101 | +); |
0 commit comments