|
| 1 | +// For more info, see https://github.com/storybookjs/eslint-plugin-storybook#configuration-flat-config-format |
| 2 | +import js from "@eslint/js"; |
| 3 | +import globals from "globals"; |
| 4 | +import reactHooks from "eslint-plugin-react-hooks"; |
| 5 | +import reactRefresh from "eslint-plugin-react-refresh"; |
| 6 | +import tseslint from "typescript-eslint"; |
| 7 | +import { defineConfig } from "eslint/config"; |
| 8 | +import importPlugin from "eslint-plugin-import"; |
| 9 | +import typescriptParser from "@typescript-eslint/parser"; |
| 10 | +import eslintConfigPrettier from "eslint-config-prettier"; |
| 11 | +import react from "eslint-plugin-react"; |
| 12 | + |
| 13 | +export default defineConfig([ |
| 14 | + { |
| 15 | + ignores: [ |
| 16 | + "dist", |
| 17 | + "node_modules", |
| 18 | + "build", |
| 19 | + "*.config.js", |
| 20 | + "*.config.ts", |
| 21 | + "**/*.ejs", |
| 22 | + ], |
| 23 | + }, |
| 24 | + |
| 25 | + importPlugin.flatConfigs.recommended, |
| 26 | + importPlugin.flatConfigs.typescript, |
| 27 | + js.configs.recommended, |
| 28 | + ...tseslint.configs.recommended, |
| 29 | + reactHooks.configs.flat.recommended, |
| 30 | + reactRefresh.configs.vite, |
| 31 | + |
| 32 | + { |
| 33 | + files: ["**/*.{ts,tsx}"], |
| 34 | + plugins: { |
| 35 | + react, |
| 36 | + }, |
| 37 | + settings: { |
| 38 | + react: { |
| 39 | + version: "detect", |
| 40 | + }, |
| 41 | + "import/resolver": { |
| 42 | + typescript: { |
| 43 | + alwaysTryTypes: true, |
| 44 | + project: "./tsconfig.app.json", |
| 45 | + }, |
| 46 | + }, |
| 47 | + }, |
| 48 | + languageOptions: { |
| 49 | + ecmaVersion: 2020, |
| 50 | + globals: globals.browser, |
| 51 | + sourceType: "module", |
| 52 | + parser: typescriptParser, |
| 53 | + parserOptions: { |
| 54 | + ecmaFeatures: { |
| 55 | + jsx: true, |
| 56 | + }, |
| 57 | + }, |
| 58 | + }, |
| 59 | + rules: { |
| 60 | + "no-var": "error", // var 금지 |
| 61 | + "no-console": ["warn", { allow: ["warn", "error"] }], // console.log 경고 |
| 62 | + |
| 63 | + "no-unused-vars": "off", // ts 룰로 대체함 |
| 64 | + "@typescript-eslint/no-unused-vars": [ |
| 65 | + // 사용하지 않는 변수 경고 |
| 66 | + "warn", |
| 67 | + { |
| 68 | + argsIgnorePattern: "^_", |
| 69 | + varsIgnorePattern: "^_", |
| 70 | + caughtErrorsIgnorePattern: "^_", |
| 71 | + }, |
| 72 | + ], |
| 73 | + |
| 74 | + "@typescript-eslint/consistent-type-imports": [ |
| 75 | + // type import 사용 권장 |
| 76 | + "error", |
| 77 | + { prefer: "type-imports" }, |
| 78 | + ], |
| 79 | + "@typescript-eslint/no-explicit-any": "warn", // any 사용 경고 |
| 80 | + "@typescript-eslint/no-non-null-assertion": "warn", // non-null assertion 경고 |
| 81 | + |
| 82 | + "react-hooks/rules-of-hooks": "error", // Hooks 규칙 준수 |
| 83 | + "react-hooks/exhaustive-deps": "warn", // useEffect 의존성 배열 검사 |
| 84 | + |
| 85 | + // 화살표 함수 컴포넌트 사용 권장 |
| 86 | + "react/function-component-definition": [ |
| 87 | + "warn", |
| 88 | + { |
| 89 | + namedComponents: "arrow-function", |
| 90 | + }, |
| 91 | + ], |
| 92 | + // import 정렬 order 설정 |
| 93 | + "import/order": [ |
| 94 | + "warn", |
| 95 | + { |
| 96 | + groups: [ |
| 97 | + "builtin", |
| 98 | + "external", |
| 99 | + "internal", |
| 100 | + "parent", |
| 101 | + "sibling", |
| 102 | + "index", |
| 103 | + "type", |
| 104 | + ], |
| 105 | + "newlines-between": "always", |
| 106 | + alphabetize: { order: "asc", caseInsensitive: true }, |
| 107 | + }, |
| 108 | + ], |
| 109 | + "import/first": "error", // import문 최상단 위치 |
| 110 | + "import/no-duplicates": "error", // 중복 import 금지 |
| 111 | + "import/no-unresolved": "off", // TS resolver가 처리 |
| 112 | + "import/default": "off", // default export 불필요한 경고 제거 |
| 113 | + "import/prefer-default-export": "off", // named export 사용(최적화 관점) |
| 114 | + |
| 115 | + // Prettier와 충돌 방지 |
| 116 | + "arrow-body-style": "off", |
| 117 | + "prefer-arrow-callback": "off", |
| 118 | + }, |
| 119 | + }, |
| 120 | + eslintConfigPrettier, |
| 121 | +]); |
0 commit comments