|
1 |
| -import js from '@eslint/js' |
2 |
| -import globals from 'globals' |
3 |
| -import reactHooks from 'eslint-plugin-react-hooks' |
4 |
| -import reactRefresh from 'eslint-plugin-react-refresh' |
5 |
| -import tseslint from 'typescript-eslint' |
6 |
| - |
7 |
| -export default tseslint.config( |
8 |
| - { ignores: ['dist'] }, |
| 1 | +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ |
| 2 | +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ |
| 3 | + |
| 4 | +import js from "@eslint/js"; |
| 5 | +import prettier from "eslint-config-prettier"; |
| 6 | +import { flatConfigs as importConfigs } from "eslint-plugin-import"; |
| 7 | +import jsxA11y from "eslint-plugin-jsx-a11y"; |
| 8 | +import react from "eslint-plugin-react"; |
| 9 | +import reactHooks from "eslint-plugin-react-hooks"; |
| 10 | +import reactRefresh from "eslint-plugin-react-refresh"; |
| 11 | +import storybook from "eslint-plugin-storybook"; |
| 12 | +import globals from "globals"; |
| 13 | +import { configs as typescriptConfigs } from "typescript-eslint"; |
| 14 | + |
| 15 | +/** @type {import('eslint').Linter.Config[]} */ |
| 16 | +export default [ |
| 17 | + js.configs.recommended, |
| 18 | + jsxA11y.flatConfigs.recommended, |
| 19 | + prettier, |
| 20 | + { ignores: ["coverage", "dist", "storybook-static"] }, |
| 21 | + |
| 22 | + // import |
| 23 | + importConfigs.recommended, |
| 24 | + importConfigs.typescript, |
9 | 25 | {
|
10 |
| - extends: [js.configs.recommended, ...tseslint.configs.recommended], |
11 |
| - files: ['**/*.{ts,tsx}'], |
12 |
| - languageOptions: { |
13 |
| - ecmaVersion: 2020, |
14 |
| - globals: globals.browser, |
| 26 | + rules: { |
| 27 | + "import/no-extraneous-dependencies": "error", |
| 28 | + "import/order": [ |
| 29 | + "error", |
| 30 | + { |
| 31 | + alphabetize: { order: "asc", orderImportKind: "desc" }, |
| 32 | + "newlines-between": "always", |
| 33 | + warnOnUnassignedImports: true, |
| 34 | + }, |
| 35 | + ], |
15 | 36 | },
|
16 |
| - plugins: { |
17 |
| - 'react-hooks': reactHooks, |
18 |
| - 'react-refresh': reactRefresh, |
| 37 | + settings: { |
| 38 | + "import/internal-regex": "^@/", |
| 39 | + "import/resolver": { node: true, typescript: true }, |
19 | 40 | },
|
| 41 | + }, |
| 42 | + |
| 43 | + // react |
| 44 | + react.configs.flat.recommended, |
| 45 | + react.configs.flat["jsx-runtime"], |
| 46 | + { settings: { react: { version: "detect" } } }, |
| 47 | + |
| 48 | + // react-hooks |
| 49 | + { |
| 50 | + plugins: { "react-hooks": reactHooks }, |
| 51 | + rules: reactHooks.configs.recommended.rules, |
| 52 | + }, |
| 53 | + |
| 54 | + // react-refresh |
| 55 | + { |
| 56 | + plugins: { "react-refresh": reactRefresh }, |
20 | 57 | rules: {
|
21 |
| - ...reactHooks.configs.recommended.rules, |
22 |
| - 'react-refresh/only-export-components': [ |
23 |
| - 'warn', |
| 58 | + "react-refresh/only-export-components": [ |
| 59 | + "warn", |
24 | 60 | { allowConstantExport: true },
|
25 | 61 | ],
|
26 | 62 | },
|
27 | 63 | },
|
28 |
| -) |
| 64 | + |
| 65 | + // storybook |
| 66 | + ...storybook.configs["flat/recommended"], |
| 67 | + { ignores: ["!.storybook"] }, |
| 68 | + |
| 69 | + // typescript |
| 70 | + ...typescriptConfigs.recommendedTypeChecked, |
| 71 | + { |
| 72 | + languageOptions: { |
| 73 | + ecmaVersion: 2020, |
| 74 | + globals: globals.browser, |
| 75 | + parserOptions: { |
| 76 | + projectService: { |
| 77 | + allowDefaultProject: [".storybook/*.js", "*.js"], |
| 78 | + }, |
| 79 | + tsconfigRootDir: import.meta.dirname, |
| 80 | + }, |
| 81 | + }, |
| 82 | + rules: { |
| 83 | + "@typescript-eslint/no-deprecated": "error", |
| 84 | + }, |
| 85 | + }, |
| 86 | +]; |
0 commit comments