|
| 1 | +// Migration https://eslint.org/docs/latest/use/configure/migration-guide#eslintrc-examples |
| 2 | + |
| 3 | +import process from "process" |
| 4 | +import eslint from "@eslint/js" |
| 5 | +import typescriptEslint from "@typescript-eslint/eslint-plugin" |
| 6 | +import tsParser from "@typescript-eslint/parser" |
| 7 | +import eslintConfigPrettier from "eslint-config-prettier" |
| 8 | +import unusedImports from "eslint-plugin-unused-imports" |
| 9 | +import pluginVue from "eslint-plugin-vue" |
| 10 | +import { defineConfig, globalIgnores } from "eslint/config" |
| 11 | +import globals from "globals" |
| 12 | +import tseslint from "typescript-eslint" |
| 13 | +import vueParser from "vue-eslint-parser" |
| 14 | + |
| 15 | +export default defineConfig( |
| 16 | + globalIgnores([ |
| 17 | + "src/components/ui/**/*.ts", |
| 18 | + "src/components/ui/**/*.vue", |
| 19 | + "public/count.v5.js", |
| 20 | + ]), |
| 21 | + // https://typescript-eslint.io/getting-started/#step-2-configuration |
| 22 | + eslint.configs.recommended, |
| 23 | + ...tseslint.configs.recommended, |
| 24 | + |
| 25 | + //https://eslint.vuejs.org/user-guide/#configuration-eslint-config-js |
| 26 | + ...pluginVue.configs["flat/recommended"], |
| 27 | + |
| 28 | + // Global ignores |
| 29 | + { |
| 30 | + ignores: ["dist/", ".storybook/", "tailwind.config.js", "vite.config.js"], |
| 31 | + }, |
| 32 | + |
| 33 | + // https://www.npmjs.com/package/vue-eslint-parser |
| 34 | + // https://typescript-eslint.io/troubleshooting/#i-am-running-into-errors-when-parsing-typescript-in-my-vue-files |
| 35 | + { |
| 36 | + files: ["src/**/*.vue", "src/**/*.ts", "src/**/*.js"], |
| 37 | + languageOptions: { |
| 38 | + parser: vueParser, |
| 39 | + parserOptions: { |
| 40 | + parser: tsParser, // tseslint.parser, |
| 41 | + project: "tsconfig.json", |
| 42 | + sourceType: "module", |
| 43 | + extraFileExtensions: [".vue"], |
| 44 | + ecmaVersion: 2020, |
| 45 | + ecmaFeatures: { |
| 46 | + globalReturn: false, |
| 47 | + impliedStrict: false, |
| 48 | + jsx: false, |
| 49 | + }, |
| 50 | + }, |
| 51 | + }, |
| 52 | + }, |
| 53 | + |
| 54 | + { |
| 55 | + plugins: { |
| 56 | + "unused-imports": unusedImports, |
| 57 | + }, |
| 58 | + rules: { |
| 59 | + "no-unused-vars": "off", |
| 60 | + "unused-imports/no-unused-imports": "error", |
| 61 | + "unused-imports/no-unused-vars": [ |
| 62 | + "warn", |
| 63 | + { |
| 64 | + vars: "all", |
| 65 | + varsIgnorePattern: "^_", |
| 66 | + args: "after-used", |
| 67 | + argsIgnorePattern: "^_", |
| 68 | + }, |
| 69 | + ], |
| 70 | + }, |
| 71 | + }, |
| 72 | + |
| 73 | + // My rules |
| 74 | + { |
| 75 | + plugins: { typescriptEslint }, |
| 76 | + rules: { |
| 77 | + semi: ["warn", "never"], |
| 78 | + "no-console": "off", // process.env.NODE_ENV === "production" ? "warn" : "off", |
| 79 | + "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off", |
| 80 | + |
| 81 | + //"no-unused-vars": "off", |
| 82 | + "@typescript-eslint/no-explicit-any": "off", |
| 83 | + "@typescript-eslint/no-unused-vars": [ |
| 84 | + "error", |
| 85 | + { varsIgnorePattern: "_*" }, |
| 86 | + ], |
| 87 | + |
| 88 | + "vue/no-v-html": "off", |
| 89 | + "vue/require-default-prop": "off", |
| 90 | + "vue/multi-word-component-names": ["error"], |
| 91 | + "vue/attributes-order": [ |
| 92 | + "error", |
| 93 | + { |
| 94 | + alphabetical: false, |
| 95 | + }, |
| 96 | + ], |
| 97 | + // "sort-imports": [ |
| 98 | + // "error", |
| 99 | + // { |
| 100 | + // ignoreCase: false, |
| 101 | + // ignoreDeclarationSort: false, |
| 102 | + // ignoreMemberSort: false, |
| 103 | + // memberSyntaxSortOrder: ["none", "all", "multiple", "single"], |
| 104 | + // allowSeparatedGroups: false, |
| 105 | + // }, |
| 106 | + // ], |
| 107 | + }, |
| 108 | + }, |
| 109 | + |
| 110 | + { |
| 111 | + // exclude shadcn |
| 112 | + files: ["src/components/ui/**/*.ts", "src/components/ui/**/*.vue"], |
| 113 | + rules: { |
| 114 | + quotes: ["error", "single"], |
| 115 | + "vue/attributes-order": "off", |
| 116 | + "vue/multi-word-component-names": "off", |
| 117 | + "sort-imports": "off", |
| 118 | + "unused-imports/no-unused-vars": "off", |
| 119 | + }, |
| 120 | + }, |
| 121 | + |
| 122 | + { |
| 123 | + files: ["src/**/*.js", "src/**/*.ts", "src/**/*.vue"], |
| 124 | + languageOptions: { |
| 125 | + globals: { |
| 126 | + ...globals.node, |
| 127 | + ...globals.browser, |
| 128 | + //myCustomGlobal: "readonly", |
| 129 | + VITE_TIMESTAMP: "readonly", |
| 130 | + }, |
| 131 | + }, |
| 132 | + }, |
| 133 | + |
| 134 | + // Special config for shadcn |
| 135 | + { |
| 136 | + files: ["src/components/ui/**/*.ts", "src/components/ui/**/*.vue"], |
| 137 | + rules: { |
| 138 | + quotes: ["error", "single"], |
| 139 | + "vue/attributes-order": "off", |
| 140 | + "vue/component-definition-name-casing": "off", |
| 141 | + }, |
| 142 | + }, |
| 143 | + |
| 144 | + // https://github.com/prettier/eslint-config-prettier?tab=readme-ov-file#installation |
| 145 | + // Turns off all rules that are unnecessary or might conflict with Prettier. |
| 146 | + eslintConfigPrettier |
| 147 | +) |
0 commit comments