Files
TeyvatGuide/eslint/vueEslint.js
目棃 f802ee9a68 🔧 Eslint v9
2024-04-23 18:49:44 +08:00

87 lines
2.0 KiB
JavaScript

import eslint_js from "@eslint/js";
import eslint_ts from "typescript-eslint";
import eslint_vue from "eslint-plugin-vue";
import eslint_prettier from "eslint-plugin-prettier";
import eslint_import from "eslint-plugin-import";
import vue_parser from "vue-eslint-parser";
import pluginVue from "eslint-plugin-vue";
import globals from "globals";
const tsConfigRules = {
"@typescript-eslint/consistent-type-assertions": [
"error",
{
assertionStyle: "angle-bracket",
},
],
"@typescript-eslint/no-import-type-side-effects": "error",
"@typescript-eslint/strict-boolean-expressions": "error",
"import/order": [
"error",
{
groups: ["builtin", "external", "internal", "parent", "sibling", "index", "unknown"],
"newlines-between": "always",
alphabetize: {
order: "asc",
caseInsensitive: true,
},
},
],
"prettier/prettier": "error",
};
const tsConfig = {
files: ["*.ts"],
plugins: {
typescript: eslint_ts,
import: eslint_import,
prettier: eslint_prettier,
},
languageOptions: {
parser: eslint_ts.parser,
parserOptions: {
project: "tsconfig.json",
tsconfigRootDir: ".",
},
},
rules: tsConfigRules,
};
const vueConfig = {
plugins: {
vue: eslint_vue,
import: eslint_import,
prettier: eslint_prettier,
},
languageOptions: {
globals: {
...globals.browser,
...globals.es2021,
TGApp: "readonly",
window: "readonly",
},
ecmaVersion: "latest",
sourceType: "module",
parser: vue_parser,
parserOptions: {
project: "tsconfig.json",
parser: eslint_ts.parser,
extraFileExtensions: [".vue"],
tsconfigRootDir: ".",
},
},
rules: {
...tsConfigRules,
"vue/multi-word-component-names": "off",
},
};
export const vueEslintConfig = [
eslint_js.configs.recommended,
...eslint_ts.configs.recommended,
...eslint_vue.configs["flat/essential"],
...pluginVue.configs["flat/essential"],
tsConfig,
vueConfig,
];