Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

升级 eslint 9 & 菜单搜索结果中展现层级 #465

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions .eslintignore

This file was deleted.

11 changes: 10 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,16 @@ module.exports = {
"vue/v-slot-style": "error", // 强制执行 v-slot 指令样式
"vue/no-mutating-props": "error", // 不允许改变组件 prop
"vue/custom-event-name-casing": "error", // 为自定义事件名称强制使用特定大小写
"vue/html-closing-bracket-newline": "error", // 在标签的右括号之前要求或禁止换行
"vue/singleline-html-element-content-newline": "off", // 在单行元素的内容前后需要换行符
"vue/attributes-order": "off", // 强制执行属性顺序
"vue/require-default-prop": "off", // 此规则要求为每个 prop 为必填时,必须提供默认值
"vue/html-closing-bracket-newline": [
"off",
{
singleline: "never",
multiline: "always"
}
], // 在标签的右括号之前要求或禁止换行
"vue/attribute-hyphenation": "error", // 对模板中的自定义组件强制执行属性命名样式:my-prop="prop"
"vue/attributes-order": "off", // vue api使用顺序,强制执行属性顺序
"vue/no-v-html": "off", // 禁止使用 v-html
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ stats.html
*.njsproj
*.sln
*.sw?
.eslintcache
2 changes: 1 addition & 1 deletion .prettierrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
// 在对象,数组括号与文字之间加空格 "{ foo: bar }" (true:有,false:没有)
bracketSpacing: true,
// 将 > 多行元素放在最后一行的末尾,而不是单独放在下一行 (true:放末尾,false:单独一行)
bracketSameLine: false,
bracketSameLine: true,
// (x) => {} 箭头函数参数只有一个时是否要有小括号 (avoid:省略括号,always:不省略括号)
arrowParens: "avoid",
// 指定要使用的解析器,不需要写文件开头的 @prettier
Expand Down
11 changes: 9 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"Biao",
"brotli",
"cascader",
"columnconstcolumn",
"commitlint",
"contentleft",
"contentright",
Expand All @@ -55,7 +56,6 @@
"geeker",
"Gitee",
"hexs",
"huiche",
"iconfont",
"juejin",
"liquidfill",
Expand Down Expand Up @@ -93,5 +93,12 @@
"yiwen",
"zhongyingwen",
"zhuti"
]
],
"i18n-ally.localesPaths": ["src/languages"],
"vue.format.script.initialIndent": true,
"vue.format.style.initialIndent": true,
"vue.inlayHints.inlineHandlerLeading": false,
"vue.inlayHints.missingProps": true,
"vue.inlayHints.optionsWrapper": true,
"vue.inlayHints.vBindShorthand": true
}
207 changes: 207 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
import js from "@eslint/js";
import pluginVue from "eslint-plugin-vue";
import * as parserVue from "vue-eslint-parser";
import configPrettier from "eslint-config-prettier";
import pluginPrettier from "eslint-plugin-prettier";
import { defineFlatConfig } from "eslint-define-config";
import * as parserTypeScript from "@typescript-eslint/parser";
import pluginTypeScript from "@typescript-eslint/eslint-plugin";

export default defineFlatConfig([
{
...js.configs.recommended,
ignores: ["**/.*", "dist/*", "*.d.ts", "public/*", "src/assets/**", "src/**/iconfont/**"],
languageOptions: {
globals: {
// index.d.ts
RefType: "readonly",
EmitType: "readonly",
TargetContext: "readonly",
ComponentRef: "readonly",
ElRef: "readonly",
ForDataType: "readonly",
AnyFunction: "readonly",
PropType: "readonly",
Writable: "readonly",
Nullable: "readonly",
NonNullable: "readonly",
Recordable: "readonly",
ReadonlyRecordable: "readonly",
Indexable: "readonly",
DeepPartial: "readonly",
Without: "readonly",
Exclusive: "readonly",
TimeoutHandle: "readonly",
IntervalHandle: "readonly",
Effect: "readonly",
ChangeEvent: "readonly",
WheelEvent: "readonly",
ImportMetaEnv: "readonly",
Fn: "readonly",
PromiseFn: "readonly",
ComponentElRef: "readonly",
parseInt: "readonly",
parseFloat: "readonly"
}
},
plugins: {
prettier: pluginPrettier
},
rules: {
...configPrettier.rules,
...pluginPrettier.configs.recommended.rules,
"no-var": "error", // 要求使用 let 或 const 而不是 var
"no-multiple-empty-lines": ["error", { max: 1 }], // 不允许多个空行
"prefer-const": "off", // 使用 let 关键字声明但在初始分配后从未重新分配的变量,要求使用 const
"no-use-before-define": "off" // 禁止在 函数/类/变量 定义之前使用它们
// "no-debugger": "off",
// "no-unused-vars": [
// "error",
// {
// argsIgnorePattern: "^_",
// varsIgnorePattern: "^_"
// }
// ],
// "prettier/prettier": [
// "error",
// {
// endOfLine: "auto"
// }
// ]
}
},
{
files: ["**/*.?([cm])ts", "**/*.?([cm])tsx"],
languageOptions: {
parser: parserTypeScript,
parserOptions: {
sourceType: "module"
}
},
plugins: {
"@typescript-eslint": pluginTypeScript
},
rules: {
...pluginTypeScript.configs.strict.rules,
"@typescript-eslint/no-unused-vars": "error", // 禁止定义未使用的变量
"@typescript-eslint/no-empty-function": "error", // 禁止空函数
"@typescript-eslint/prefer-ts-expect-error": "error", // 禁止使用 @ts-ignore
"@typescript-eslint/ban-ts-comment": "error", // 禁止 @ts-<directive> 使用注释或要求在指令后进行描述
"@typescript-eslint/no-inferrable-types": "off", // 可以轻松推断的显式类型可能会增加不必要的冗长
"@typescript-eslint/no-namespace": "off", // 禁止使用自定义 TypeScript 模块和命名空间
"@typescript-eslint/no-explicit-any": "off", // 禁止使用 any 类型
"@typescript-eslint/ban-types": "off", // 禁止使用特定类型
"@typescript-eslint/no-var-requires": "off", // 允许使用 require() 函数导入模块
"@typescript-eslint/no-non-null-assertion": "off" // 不允许使用后缀运算符的非空断言(!)
// "@typescript-eslint/ban-types": "off",
// "@typescript-eslint/no-redeclare": "error",
// "@typescript-eslint/ban-ts-comment": "off",
// "@typescript-eslint/no-explicit-any": "off",
// "@typescript-eslint/prefer-as-const": "warn",
// "@typescript-eslint/no-empty-function": "off",
// "@typescript-eslint/no-non-null-assertion": "off",
// "@typescript-eslint/no-import-type-side-effects": "error",
// "@typescript-eslint/explicit-module-boundary-types": "off",
// "@typescript-eslint/no-namespace": "off",
// "@typescript-eslint/consistent-type-imports": [
// "error",
// { disallowTypeAnnotations: false, fixStyle: "inline-type-imports" }
// ],
// "@typescript-eslint/prefer-literal-enum-member": ["error", { allowBitwiseExpressions: true }],
// "@typescript-eslint/no-unused-vars": [
// "error",
// {
// argsIgnorePattern: "^_",
// varsIgnorePattern: "^_"
// }
// ]
}
},
{
files: ["**/*.d.ts"],
rules: {
"eslint-comments/no-unlimited-disable": "off",
"import/no-duplicates": "off",
"unused-imports/no-unused-vars": "off"
}
},
// {
// files: ["**/*.?([cm])js"],
// rules: {
// "@typescript-eslint/no-require-imports": "off",
// "@typescript-eslint/no-var-requires": "off"
// }
// },
{
files: ["**/*.vue"],
languageOptions: {
globals: {
$: "readonly",
$$: "readonly",
$computed: "readonly",
$customRef: "readonly",
$ref: "readonly",
$shallowRef: "readonly",
$toRef: "readonly"
},
parser: parserVue,
parserOptions: {
ecmaFeatures: {
jsx: true
},
extraFileExtensions: [".vue"],
parser: "@typescript-eslint/parser",
sourceType: "module"
}
},
plugins: {
vue: pluginVue
},
processor: pluginVue.processors[".vue"],
rules: {
...pluginVue.configs.base.rules,
...pluginVue.configs["vue3-essential"].rules,
...pluginVue.configs["vue3-recommended"].rules,
// vue (https://eslint.vuejs.org/rules)
"vue/script-setup-uses-vars": "error", // 防止<script setup>使用的变量<template>被标记为未使用,此规则仅在启用该 no-unused-vars 规则时有效
"vue/v-slot-style": "error", // 强制执行 v-slot 指令样式
"vue/no-mutating-props": "error", // 不允许改变组件 prop
"vue/custom-event-name-casing": "error", // 为自定义事件名称强制使用特定大小写
"vue/singleline-html-element-content-newline": "off", // 在单行元素的内容前后需要换行符
"vue/attributes-order": "off", // 强制执行属性顺序
"vue/require-default-prop": "off", // 此规则要求为每个 prop 为必填时,必须提供默认值
"vue/html-closing-bracket-newline": [
"off",
{
singleline: "never",
multiline: "always"
}
], // 在标签的右括号之前要求或禁止换行
"vue/attribute-hyphenation": "error", // 对模板中的自定义组件强制执行属性命名样式:my-prop="prop"
"vue/attributes-order": "off", // vue api使用顺序,强制执行属性顺序
"vue/no-v-html": "off", // 禁止使用 v-html
"vue/require-default-prop": "off", // 此规则要求为每个 prop 为必填时,必须提供默认值
"vue/multi-word-component-names": "off", // 要求组件名称始终为 “-” 链接的单词
"vue/no-setup-props-destructure": "off" // 禁止解构 props 传递给 setup
// "no-undef": "off",
// "no-unused-vars": "off",
// "vue/no-v-html": "off",
// "vue/require-default-prop": "off",
// "vue/require-explicit-emits": "off",
// "vue/multi-word-component-names": "off",
// "vue/no-setup-props-reactivity-loss": "off",
// "vue/html-self-closing": [
// "error",
// {
// html: {
// void: "always",
// normal: "always",
// component: "always"
// },
// svg: "always",
// math: "always"
// }
// ]
}
}
]);
40 changes: 21 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@
"build:test": "vue-tsc && vite build --mode test",
"build:pro": "vue-tsc && vite build --mode production",
"type:check": "vue-tsc --noEmit --skipLibCheck",
"preview": "pnpm build:dev && vite preview",
"lint:eslint": "eslint --fix --ext .js,.ts,.vue ./src",
"preview": "npm run build:dev && vite preview",
"lint:eslint": "eslint --cache --max-warnings 0 \"{src,build}/**/*.{vue,js,ts,tsx}\" --fix",
"lint:prettier": "prettier --write \"src/**/*.{js,ts,json,tsx,css,less,scss,vue,html,md}\"",
"lint:stylelint": "stylelint --cache --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/",
"lint:lint-staged": "lint-staged",
"prepare": "husky install",
"release": "standard-version",
"commit": "git add -A && czg && git push"
"commit": "git add -A && czg && git push",
"lint": "pnpm lint:lint-staged && pnpm lint:prettier && pnpm lint:stylelint && pnpm prepare && pnpm type:check && pnpm lint:eslint"
},
"dependencies": {
"@element-plus/icons-vue": "^2.3.1",
Expand All @@ -50,7 +51,7 @@
"nprogress": "^0.2.0",
"pinia": "^2.1.7",
"pinia-plugin-persistedstate": "^3.2.1",
"qs": "^6.12.1",
"qs": "^6.12.2",
"screenfull": "^6.0.2",
"sortablejs": "^1.15.2",
"vue": "^3.4.31",
Expand All @@ -59,26 +60,27 @@
"vuedraggable": "^4.1.0"
},
"devDependencies": {
"@commitlint/cli": "^18.4.3",
"@commitlint/config-conventional": "^18.4.3",
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"@types/md5": "^2.3.5",
"@types/nprogress": "^0.2.3",
"@types/qs": "^6.9.15",
"@types/sortablejs": "^1.15.8",
"@typescript-eslint/eslint-plugin": "^7.14.1",
"@typescript-eslint/parser": "^7.14.1",
"@vitejs/plugin-vue": "^5.0.4",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"@typescript-eslint/eslint-plugin": "^7.15.0",
"@typescript-eslint/parser": "^7.15.0",
"@vitejs/plugin-vue": "^5.0.5",
"@vitejs/plugin-vue-jsx": "^4.0.0",
"autoprefixer": "^10.4.19",
"cz-git": "1.9.2",
"czg": "^1.9.2",
"eslint": "^8.57.0",
"cz-git": "1.9.3",
"czg": "^1.9.3",
"eslint": "^9.6.0",
"eslint-config-prettier": "^9.1.0",
"eslint-define-config": "^2.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-vue": "^9.26.0",
"eslint-plugin-vue": "^9.27.0",
"husky": "^9.0.11",
"lint-staged": "^15.2.5",
"postcss": "^8.4.38",
"lint-staged": "^15.2.7",
"postcss": "^8.4.39",
"postcss-html": "^1.7.0",
"prettier": "^3.3.2",
"rollup-plugin-visualizer": "^5.12.0",
Expand All @@ -89,9 +91,9 @@
"stylelint-config-recess-order": "^5.0.1",
"stylelint-config-recommended-scss": "^14.0.0",
"stylelint-config-recommended-vue": "^1.5.0",
"stylelint-config-standard": "^36.0.0",
"stylelint-config-standard": "^36.0.1",
"stylelint-config-standard-scss": "^13.1.0",
"typescript": "^5.5.2",
"typescript": "^5.5.3",
"unplugin-vue-setup-extend-plus": "^1.0.1",
"vite": "^5.3.2",
"vite-plugin-compression": "^0.5.1",
Expand All @@ -100,7 +102,7 @@
"vite-plugin-pwa": "^0.20.0",
"vite-plugin-svg-icons": "^2.0.1",
"vite-plugin-vue-devtools": "^7.3.5",
"vue-tsc": "^2.0.22"
"vue-tsc": "^2.0.24"
},
"engines": {
"node": ">=16.18.0"
Expand Down
Loading