diff --git a/apps/frontend/.eslintignore b/apps/frontend/.eslintignore deleted file mode 100644 index 68aacde..0000000 --- a/apps/frontend/.eslintignore +++ /dev/null @@ -1,13 +0,0 @@ -dist -node_modules -public -.vscode -.idea -*.sh -*.md - -src/assets - -.eslintrc.cjs -.prettierrc.cjs -.stylelintrc.cjs diff --git a/apps/frontend/.eslintrc.cjs b/apps/frontend/.eslintrc.cjs deleted file mode 100644 index 097d04d..0000000 --- a/apps/frontend/.eslintrc.cjs +++ /dev/null @@ -1,31 +0,0 @@ -module.exports = { - env: { - browser: true, - es2021: true, - node: true, - }, - parser: "vue-eslint-parser", // https://eslint.vuejs.org/user-guide/#bundle-configurations - extends: [ - "eslint:recommended", - "plugin:vue/vue3-essential", - "plugin:@typescript-eslint/recommended", - "./.eslintrc-auto-import.json", - ], - parserOptions: { - ecmaVersion: "latest", - sourceType: "module", - parser: "@typescript-eslint/parser", - }, - plugins: ["vue", "@typescript-eslint"], - rules: { - "vue/multi-word-component-names": "off", // Disable multi-word component name requirement: https://eslint.vuejs.org/rules/multi-word-component-names.html - "@typescript-eslint/no-empty-function": "off", // Disable empty function checks - "@typescript-eslint/no-explicit-any": "off", // Disable warnings for any - "vue/no-v-model-argument": "off", - "@typescript-eslint/no-non-null-assertion": "off", - }, // https://eslint.org/docs/latest/use/configure/language-options#specifying-globals - globals: { - DialogType: "readonly", - OptionType: "readonly", - }, -}; diff --git a/apps/frontend/eslint.config.mjs b/apps/frontend/eslint.config.mjs new file mode 100644 index 0000000..c726089 --- /dev/null +++ b/apps/frontend/eslint.config.mjs @@ -0,0 +1,96 @@ +import { createRequire } from "node:module"; + +import js from "@eslint/js"; +import globals from "globals"; +import tseslint from "typescript-eslint"; +import pluginVue from "eslint-plugin-vue"; +import prettier from "eslint-config-prettier"; +import vueParser from "vue-eslint-parser"; + +/** + * Конфигурация ESLint во flat-формате. + * + * Заменяет `.eslintrc.cjs`. Причина не в моде на формат: eslint 8 объявлен + * EOL, перестал получать исправления и оставался последним источником десятка + * предупреждений `pnpm audit` в проекте (minimatch, brace-expansion, js-yaml, + * flatted — всё в его собственном графе). Eslintrc-формат в eslint 9 работает + * только через переменную окружения, а в 10 удалён вовсе, поэтому обновление + * версии без перехода на flat-config было бы отсрочкой на один релиз. + * + * Набор правил сохранён ровно тем же, что был в `.eslintrc.cjs`: перевод + * формата не место для изменения политики линтинга. + */ + +// Глобальные имена авто-импорта генерирует unplugin-auto-import в +// eslintrc-формате (`{ globals: { ref: true, ... } }`). Flat-config такой файл +// через `extends` не подключает, поэтому список читается напрямую — источник +// истины остаётся один, и он по-прежнему пересоздаётся сборкой. +const require = createRequire(import.meta.url); +const autoImportGlobals = require("./.eslintrc-auto-import.json").globals; + +export default tseslint.config( + { + // Перенесено из .eslintignore: eslint 9 этот файл больше не читает, и + // список исключений обязан жить в самой конфигурации. + // + // src/assets — SVG и изображения; src/types/*.d.ts — объявления, которые + // генерируют unplugin-auto-import и unplugin-vue-components, править их + // вручную нельзя, а замечания линтера по ним только шумят. + ignores: [ + "dist/**", + "node_modules/**", + "public/**", + "src/assets/**", + "src/types/*.d.ts", + ], + }, + + js.configs.recommended, + ...tseslint.configs.recommended, + ...pluginVue.configs["flat/essential"], + + { + languageOptions: { + ecmaVersion: "latest", + sourceType: "module", + globals: { + ...globals.browser, + ...globals.node, + ...autoImportGlobals, + // Объявлены в src/types/global.d.ts и используются как глобальные типы. + DialogType: "readonly", + OptionType: "readonly", + }, + }, + rules: { + // Имя компонента из одного слова — устоявшееся соглашение этого проекта. + "vue/multi-word-component-names": "off", + "vue/no-v-model-argument": "off", + "@typescript-eslint/no-empty-function": "off", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-non-null-assertion": "off", + }, + }, + + { + // .vue разбирает vue-eslint-parser, а