fix: 格式化代码

This commit is contained in:
戴业伟 2024-02-05 10:47:59 +08:00
parent 815f46af31
commit ef8c31fa29
23 changed files with 188 additions and 187 deletions

View File

@ -5,123 +5,123 @@ module.exports = {
es2021: true,
node: true,
},
parser: "vue-eslint-parser",
parser: 'vue-eslint-parser',
extends: [
// https://eslint.vuejs.org/user-guide/#usage
"plugin:vue/vue3-recommended",
"./.eslintrc-auto-import.json",
"prettier",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
'plugin:vue/vue3-recommended',
'./.eslintrc-auto-import.json',
'prettier',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
parser: "@typescript-eslint/parser",
project: "./tsconfig.*?.json",
ecmaVersion: 'latest',
sourceType: 'module',
parser: '@typescript-eslint/parser',
project: './tsconfig.*?.json',
createDefaultProgram: false,
extraFileExtensions: [".vue"],
extraFileExtensions: ['.vue'],
},
plugins: ["vue", "@typescript-eslint"],
plugins: ['vue', '@typescript-eslint'],
rules: {
// 禁止使用 var用 let 和 const 代替
"no-var": "error",
'no-var': 'error',
// 在 Vue 的 v-for 循环中要求使用 :key
"vue/require-v-for-key": "error", // vue的for循环是否必须有key
'vue/require-v-for-key': 'error', // vue的for循环是否必须有key
// 关闭 Vue 组件名必须多字的规则
"vue/multi-word-component-names": "off",
'vue/multi-word-component-names': 'off',
// 关闭 Vue 的 v-model 中的参数规则
"vue/no-v-model-argument": "off",
'vue/no-v-model-argument': 'off',
// Vue 的 setup() 函数必须使用的变量规则
"vue/script-setup-uses-vars": "error",
'vue/script-setup-uses-vars': 'error',
// 关闭 Vue 组件名的保留规则
"vue/no-reserved-component-names": "off",
'vue/no-reserved-component-names': 'off',
// 关闭 Vue 事件名的命名规则
"vue/custom-event-name-casing": "off",
'vue/custom-event-name-casing': 'off',
// 关闭 Vue 属性的顺序规则
"vue/attributes-order": "off",
'vue/attributes-order': 'off',
// 关闭一个文件只能有一个组件规则
"vue/one-component-per-file": "off",
'vue/one-component-per-file': 'off',
// 关闭 HTML 标签闭合换行规则
"vue/html-closing-bracket-newline": "off",
'vue/html-closing-bracket-newline': 'off',
// 关闭 HTML 属性每行最大数量规则
"vue/max-attributes-per-line": "off",
'vue/max-attributes-per-line': 'off',
// 关闭多行 HTML 元素内容的规则
"vue/multiline-html-element-content-newline": "off",
'vue/multiline-html-element-content-newline': 'off',
// 关闭单行 HTML 元素内容的规则
"vue/singleline-html-element-content-newline": "off",
'vue/singleline-html-element-content-newline': 'off',
// 关闭 HTML 属性连字符的规则
"vue/attribute-hyphenation": "off",
'vue/attribute-hyphenation': 'off',
// 关闭要求 Vue 默认属性的规则
"vue/require-default-prop": "off",
'vue/require-default-prop': 'off',
// 关闭要求 Vue 显式触发事件的规则
"vue/require-explicit-emits": "off",
'vue/require-explicit-emits': 'off',
// HTML 标签自闭合规则
"vue/html-self-closing": [
"error",
'vue/html-self-closing': [
'error',
{
html: {
void: "always", // 自闭合标签必须自闭合
normal: "never", // 普通标签不得自闭合
component: "always", // 组件标签必须自闭合
void: 'always', // 自闭合标签必须自闭合
normal: 'never', // 普通标签不得自闭合
component: 'always', // 组件标签必须自闭合
},
svg: "always",
math: "always",
svg: 'always',
math: 'always',
},
],
// 警告空方法检查
"@typescript-eslint/no-empty-function": "warn",
'@typescript-eslint/no-empty-function': 'warn',
// 关闭 any 类型的警告
"@typescript-eslint/no-explicit-any": "off",
'@typescript-eslint/no-explicit-any': 'off',
// 关闭使用 @ts-ignore 的警告
"@typescript-eslint/ban-ts-ignore": "off",
'@typescript-eslint/ban-ts-ignore': 'off',
// 关闭使用 @ts-comment 的警告
"@typescript-eslint/ban-ts-comment": "off",
'@typescript-eslint/ban-ts-comment': 'off',
// 关闭一些特定类型的警告
"@typescript-eslint/ban-types": "off",
'@typescript-eslint/ban-types': 'off',
// 关闭函数返回类型的警告
"@typescript-eslint/explicit-function-return-type": "off",
'@typescript-eslint/explicit-function-return-type': 'off',
// 关闭 any 类型的警告
"@typescript-eslint/no-explicit-any": "off",
'@typescript-eslint/no-explicit-any': 'off',
// 关闭使用 require 的警告
"@typescript-eslint/no-var-requires": "off",
'@typescript-eslint/no-var-requires': 'off',
// 关闭使用尚未定义的变量的警告
"@typescript-eslint/no-use-before-define": "off",
'@typescript-eslint/no-use-before-define': 'off',
// 关闭模块导出类型的警告
"@typescript-eslint/explicit-module-boundary-types": "off",
'@typescript-eslint/explicit-module-boundary-types': 'off',
// 未使用的变量的警告
"@typescript-eslint/no-unused-vars": "warn",
'@typescript-eslint/no-unused-vars': 'warn',
// Prettier 配置
"prettier/prettier": [
"error",
'prettier/prettier': [
'error',
{
useTabs: false, // 不使用制表符
},
@ -130,12 +130,12 @@ module.exports = {
// eslint不能对html文件生效
overrides: [
{
files: ["*.html"],
processor: "vue/.vue",
files: ['*.html'],
processor: 'vue/.vue',
},
],
// https://eslint.org/docs/latest/use/configure/language-options#specifying-globals
globals: {
OptionType: "readonly",
OptionType: 'readonly',
},
};

View File

@ -24,7 +24,7 @@ module.exports = {
// 结尾添加分号
semi: true,
// 使用单引号 (true:单引号;false:双引号)
singleQuote: false,
singleQuote: true,
// 缩进空格数默认2个空格
tabWidth: 2,
// 元素末尾是否加逗号默认es5: ES5中的 objects, arrays 等会添加逗号TypeScript 中的 type 后不加逗号

View File

@ -1,45 +1,45 @@
module.exports = {
// 继承的规则
extends: ["@commitlint/config-conventional"],
extends: ['@commitlint/config-conventional'],
// 自定义规则
rules: {
// @see https://commitlint.js.org/#/reference-rules
// 提交类型枚举git提交type必须是以下类型
"type-enum": [
'type-enum': [
2,
"always",
'always',
[
"feat", // 新增功能
"fix", // 修复缺陷
"docs", // 文档变更
"style", // 代码格式(不影响功能,例如空格、分号等格式修正)
"refactor", // 代码重构(不包括 bug 修复、功能新增)
"perf", // 性能优化
"test", // 添加疏漏测试或已有测试改动
"build", // 构建流程、外部依赖变更(如升级 npm 包、修改 webpack 配置等)
"ci", // 修改 CI 配置、脚本
"revert", // 回滚 commit
"chore", // 对构建过程或辅助工具和库的更改(不影响源文件、测试用例)
'feat', // 新增功能
'fix', // 修复缺陷
'docs', // 文档变更
'style', // 代码格式(不影响功能,例如空格、分号等格式修正)
'refactor', // 代码重构(不包括 bug 修复、功能新增)
'perf', // 性能优化
'test', // 添加疏漏测试或已有测试改动
'build', // 构建流程、外部依赖变更(如升级 npm 包、修改 webpack 配置等)
'ci', // 修改 CI 配置、脚本
'revert', // 回滚 commit
'chore', // 对构建过程或辅助工具和库的更改(不影响源文件、测试用例)
],
],
"subject-case": [0], // subject大小写不做校验
'subject-case': [0], // subject大小写不做校验
},
prompt: {
messages: {
type: "选择你要提交的类型 :",
scope: "选择一个提交范围(可选):",
customScope: "请输入自定义的提交范围 :",
subject: "填写简短精炼的变更描述 :\n",
type: '选择你要提交的类型 :',
scope: '选择一个提交范围(可选):',
customScope: '请输入自定义的提交范围 :',
subject: '填写简短精炼的变更描述 :\n',
body: '填写更加详细的变更描述(可选)。使用 "|" 换行 :\n',
breaking: '列举非兼容性重大的变更(可选)。使用 "|" 换行 :\n',
footerPrefixesSelect: "选择关联issue前缀可选:",
customFooterPrefix: "输入自定义issue前缀 :",
footer: "列举关联issue (可选) 例如: #31, #I3244 :\n",
generatingByAI: "正在通过 AI 生成你的提交简短描述...",
generatedSelectByAI: "选择一个 AI 生成的简短描述:",
confirmCommit: "是否提交或修改commit ?",
footerPrefixesSelect: '选择关联issue前缀可选:',
customFooterPrefix: '输入自定义issue前缀 :',
footer: '列举关联issue (可选) 例如: #31, #I3244 :\n',
generatingByAI: '正在通过 AI 生成你的提交简短描述...',
generatedSelectByAI: '选择一个 AI 生成的简短描述:',
confirmCommit: '是否提交或修改commit ?',
},
// prettier-ignore
types: [
@ -56,28 +56,28 @@ module.exports = {
{ value: "chore", name: "其他: 🛠️ 对构建过程或辅助工具和库的更改(不影响源文件、测试用例)", emoji: ":hammer:"},
],
useEmoji: true,
emojiAlign: "center",
emojiAlign: 'center',
useAI: false,
aiNumber: 1,
themeColorCode: "",
themeColorCode: '',
scopes: [],
allowCustomScopes: true,
allowEmptyScopes: true,
customScopesAlign: "bottom",
customScopesAlias: "custom",
emptyScopesAlias: "empty",
customScopesAlign: 'bottom',
customScopesAlias: 'custom',
emptyScopesAlias: 'empty',
upperCaseSubject: false,
markBreakingChangeMode: false,
allowBreakingChanges: ["feat", "fix"],
allowBreakingChanges: ['feat', 'fix'],
breaklineNumber: 100,
breaklineChar: "|",
breaklineChar: '|',
skipQuestions: [],
issuePrefixes: [
{ value: "closed", name: "closed: ISSUES has been processed" },
{ value: 'closed', name: 'closed: ISSUES has been processed' },
],
customIssuePrefixAlign: "top",
emptyIssuePrefixAlias: "skip",
customIssuePrefixAlias: "custom",
customIssuePrefixAlign: 'top',
emptyIssuePrefixAlias: 'skip',
customIssuePrefixAlias: 'custom',
allowCustomIssuePrefix: true,
allowEmptyIssuePrefix: true,
confirmColorize: true,
@ -85,9 +85,9 @@ module.exports = {
maxSubjectLength: Infinity,
minSubjectLength: 0,
scopeOverrides: undefined,
defaultBody: "",
defaultIssues: "",
defaultScope: "",
defaultSubject: "",
defaultBody: '',
defaultIssues: '',
defaultScope: '',
defaultSubject: '',
},
};

View File

@ -95,7 +95,7 @@
"stylelint-config-recommended-vue": "^1.5.0",
"stylelint-config-standard": "^34.0.0",
"stylelint-config-standard-scss": "^11.1.0",
"tailwindcss": "^3.3.3",
"tailwindcss": "^3.4.1",
"typescript": "^5.3.2",
"unplugin-auto-import": "^0.15.3",
"unplugin-icons": "^0.16.6",
@ -107,4 +107,4 @@
"engines": {
"node": ">=16.0.0"
}
}
}

View File

@ -17,14 +17,14 @@
</template>
<script lang="ts" setup>
import { computed, onMounted, onUnmounted } from "vue";
import { zhCN, dateZhCN, darkTheme } from "naive-ui";
import { LockScreen } from "@/components/Lockscreen";
import { AppProvider } from "@/components/Application";
import { useScreenLockStore } from "@/store/modules/screenLock.js";
import { useRoute } from "vue-router";
import { useDesignSettingStore } from "@/store/modules/designSetting";
import { lighten } from "@/utils";
import { computed, onMounted, onUnmounted } from 'vue';
import { zhCN, dateZhCN, darkTheme } from 'naive-ui';
import { LockScreen } from '@/components/Lockscreen';
import { AppProvider } from '@/components/Application';
import { useScreenLockStore } from '@/store/modules/screenLock.js';
import { useRoute } from 'vue-router';
import { useDesignSettingStore } from '@/store/modules/designSetting';
import { lighten } from '@/utils';
const route = useRoute();
const useScreenLock = useScreenLockStore();
@ -59,7 +59,7 @@ let timer: any;
const timekeeping = () => {
clearInterval(timer);
if (route.name == "login" || isLock.value) return;
if (route.name == 'login' || isLock.value) return;
//
useScreenLock.setLock(false);
//
@ -76,14 +76,14 @@ const timekeeping = () => {
};
onMounted(() => {
document.addEventListener("mousedown", timekeeping);
document.addEventListener('mousedown', timekeeping);
});
onUnmounted(() => {
document.removeEventListener("mousedown", timekeeping);
document.removeEventListener('mousedown', timekeeping);
});
</script>
<style lang="scss">
@import "styles/index";
@import 'styles/index';
</style>

View File

@ -347,9 +347,9 @@ export default defineComponent({
}
if (props.record) {
initCbs("submitCbs", handleSubmit);
initCbs("validCbs", handleSubmiRule);
initCbs("cancelCbs", handleCancel);
initCbs('submitCbs', handleSubmit);
initCbs('validCbs', handleSubmiRule);
initCbs('cancelCbs', handleCancel);
if (props.column.key) {
if (!props.record.editValueRefs) props.record.editValueRefs = {};
@ -372,7 +372,7 @@ export default defineComponent({
if (!pass) return;
const submitFns = props.record?.submitCbs || [];
submitFns.forEach((fn) => fn(false, false));
table.emit?.("edit-row-end");
table.emit?.('edit-row-end');
return true;
}
};

View File

@ -1,6 +1,6 @@
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, YouSheBiaoTiHei,
"sans-serif ";
'sans-serif ';
font-weight: 400;
line-height: 1.5;
color: rgb(255 255 255 / 87%);

View File

@ -1 +1 @@
@import 'transition/index';
@import 'transition/index';

View File

@ -1,3 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@tailwind utilities;

View File

@ -15,4 +15,4 @@
.expand-x-transition {
@include transition-default;
}
}

View File

@ -78,4 +78,4 @@
.fade-top-leave-to {
opacity: 0;
transform: translateY(-8%);
}
}

View File

@ -6,5 +6,6 @@
@import './zoom';
.collapse-transition {
transition: 0.2s height ease-in-out, 0.2s padding-top ease-in-out, 0.2s padding-bottom ease-in-out;
}
transition: 0.2s height ease-in-out, 0.2s padding-top ease-in-out,
0.2s padding-bottom ease-in-out;
}

View File

@ -18,4 +18,4 @@
opacity: 0;
transform: scale(0) rotate(-45deg);
}
}
}

View File

@ -64,4 +64,4 @@
&-leave-to {
transform: translateX(-15px);
}
}
}

View File

@ -36,4 +36,4 @@
opacity: 0;
transform: translateX(15px);
}
}
}

View File

@ -24,4 +24,4 @@
.zoom-fade-leave-to {
opacity: 0;
transform: scale(1.06);
}
}

View File

@ -1,10 +1,10 @@
<script lang="tsx">
import { defineComponent, onBeforeMount } from "vue";
import { useRoute, useRouter } from "vue-router";
import { NEmpty } from "naive-ui";
import { defineComponent, onBeforeMount } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { NEmpty } from 'naive-ui';
export default defineComponent({
name: "Redirect",
name: 'Redirect',
setup() {
const route = useRoute();
const router = useRouter();
@ -12,7 +12,7 @@ export default defineComponent({
const { params, query } = route;
const { path } = params;
router.replace({
path: "/" + (Array.isArray(path) ? path.join("/") : path),
path: '/' + (Array.isArray(path) ? path.join('/') : path),
query,
});
});

View File

@ -1,58 +1,58 @@
module.exports = {
// 继承推荐规范配置
extends: [
"stylelint-config-standard",
"stylelint-config-recommended-scss",
"stylelint-config-recommended-vue/scss",
"stylelint-config-html/vue",
"stylelint-config-recess-order",
'stylelint-config-standard',
'stylelint-config-recommended-scss',
'stylelint-config-recommended-vue/scss',
'stylelint-config-html/vue',
'stylelint-config-recess-order',
],
// 指定不同文件对应的解析器
overrides: [
{
files: ["**/*.{vue,html}"],
customSyntax: "postcss-html",
files: ['**/*.{vue,html}'],
customSyntax: 'postcss-html',
},
{
files: ["**/*.{css,scss}"],
customSyntax: "postcss-scss",
files: ['**/*.{css,scss}'],
customSyntax: 'postcss-scss',
},
],
// 自定义规则
rules: {
"import-notation": "string", // 指定导入CSS文件的方式("string"|"url")
"selector-class-pattern": null, // 选择器类名命名规则
"custom-property-pattern": null, // 自定义属性命名规则
"keyframes-name-pattern": null, // 动画帧节点样式命名规则
"no-descending-specificity": null, // 允许无降序特异性
'import-notation': 'string', // 指定导入CSS文件的方式("string"|"url")
'selector-class-pattern': null, // 选择器类名命名规则
'custom-property-pattern': null, // 自定义属性命名规则
'keyframes-name-pattern': null, // 动画帧节点样式命名规则
'no-descending-specificity': null, // 允许无降序特异性
// 允许 global 、export 、deep伪类
"selector-pseudo-class-no-unknown": [
'selector-pseudo-class-no-unknown': [
true,
{
ignorePseudoClasses: ["global", "export", "deep"],
ignorePseudoClasses: ['global', 'export', 'deep'],
},
],
// 允许未知属性
"property-no-unknown": [
'property-no-unknown': [
true,
{
// ignoreProperties: ["menuBg", "menuText", "menuActiveText"],
},
],
"at-rule-no-unknown": [
'at-rule-no-unknown': [
true,
{
ignoreAtRules: [
"tailwind",
"apply",
"variants",
"responsive",
"screen",
"function",
"if",
"each",
"include",
"mixin",
'tailwind',
'apply',
'variants',
'responsive',
'screen',
'function',
'if',
'each',
'include',
'mixin',
],
},
],

View File

@ -1,5 +1,5 @@
module.exports = {
content: ["./index.html", "./src/**/*.{vue,ts,tsx}"],
content: ['./index.html', './src/**/*.{vue,ts,tsx}'],
important: true,
theme: {
extend: {},

4
types/env.d.ts vendored
View File

@ -1,7 +1,7 @@
/// <reference types="vite/client" />
declare module "*.vue" {
import { DefineComponent } from "vue";
declare module '*.vue' {
import { DefineComponent } from 'vue';
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
const component: DefineComponent<{}, {}, any>;
export default component;

4
types/router.d.ts vendored
View File

@ -1,6 +1,6 @@
import "vue-router";
import 'vue-router';
declare module "vue-router" {
declare module 'vue-router' {
// https://router.vuejs.org/zh/guide/advanced/meta.html#typescript
// 可以通过扩展 RouteMeta 接口来输入 meta 字段
interface RouteMeta {

View File

@ -1 +1 @@
declare module "xlsx/xlsx.mjs";
declare module 'xlsx/xlsx.mjs';

View File

@ -1,25 +1,25 @@
import vue from "@vitejs/plugin-vue";
import { UserConfig, ConfigEnv, loadEnv, defineConfig } from "vite";
import vue from '@vitejs/plugin-vue';
import { UserConfig, ConfigEnv, loadEnv, defineConfig } from 'vite';
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import Icons from "unplugin-icons/vite";
import Icons from 'unplugin-icons/vite';
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
import vueJsx from "@vitejs/plugin-vue-jsx";
import vueJsx from '@vitejs/plugin-vue-jsx';
import { resolve } from "path";
import { resolve } from 'path';
const pathSrc = resolve(__dirname, "src");
const pathSrc = resolve(__dirname, 'src');
// https://cn.vitejs.dev/config
export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
const env = loadEnv(mode, process.cwd());
return {
resolve: {
alias: {
"@": pathSrc,
'@': pathSrc,
},
},
css: {
@ -36,7 +36,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
},
server: {
// 允许IP访问
host: "0.0.0.0",
host: '0.0.0.0',
// 应用端口 (默认:3000)
port: Number(env.VITE_APP_PORT),
// 运行是否自动打开浏览器
@ -53,7 +53,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
changeOrigin: true,
target: env.VITE_APP_API_URL,
rewrite: (path) =>
path.replace(new RegExp("^" + env.VITE_APP_BASE_API), ""),
path.replace(new RegExp('^' + env.VITE_APP_BASE_API), ''),
},
},
},
@ -64,24 +64,24 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
// 自动导入参考: https://github.com/sxzz/element-plus-best-practices/blob/main/vite.config.ts
AutoImport({
// 自动导入 Vue 相关函数ref, reactive, toRef 等
imports: ["vue", "@vueuse/core"],
imports: ['vue', '@vueuse/core'],
eslintrc: {
enabled: false,
filepath: "./.eslintrc-auto-import.json",
filepath: './.eslintrc-auto-import.json',
globalsPropValue: true,
},
vueTemplate: true,
// 配置文件生成位置(false:关闭自动生成)
dts: "types/auto-imports.d.ts",
dts: 'types/auto-imports.d.ts',
}),
Components({
resolvers: [],
// 指定自定义组件位置(默认:src/components)
dirs: ["src/components", "src/**/components"],
dirs: ['src/components', 'src/**/components'],
// 配置文件位置 (false:关闭自动生成)
dts: "types/components.d.ts",
dts: 'types/components.d.ts',
}),
Icons({
@ -89,27 +89,27 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
}),
createSvgIconsPlugin({
// 指定需要缓存的图标文件夹
iconDirs: [resolve(pathSrc, "assets/svgs")],
iconDirs: [resolve(pathSrc, 'assets/svgs')],
// 指定symbolId格式
symbolId: "icon-[dir]-[name]",
symbolId: 'icon-[dir]-[name]',
}),
],
// 预加载项目必需的组件
optimizeDeps: {
include: [
"vue",
"vue-router",
"pinia",
"axios",
"@vueuse/core",
"path-to-regexp",
"echarts",
'vue',
'vue-router',
'pinia',
'axios',
'@vueuse/core',
'path-to-regexp',
'echarts',
],
},
// 构建配置
build: {
chunkSizeWarningLimit: 2000, // 消除打包大小超过500kb警告
minify: "terser", // Vite 2.6.x 以上需要配置 minify: "terser", terserOptions 才能生效
minify: 'terser', // Vite 2.6.x 以上需要配置 minify: "terser", terserOptions 才能生效
terserOptions: {
compress: {
keep_infinity: true, // 防止 Infinity 被压缩成 1/0这可能会导致 Chrome 上的性能问题