From c220a75bbc668dfc7f6b3f4d9ff4224b331b9f2d Mon Sep 17 00:00:00 2001 From: LSF <1920392080@qq.com> Date: Thu, 10 Jul 2025 11:58:13 +0800 Subject: [PATCH] feat: add h1 element --- .husky/commit-msg | 4 ++ eslint.config.js | 100 +++++++++++++++++++++++----------------------- pnpm-lock.yaml | 12 +++--- src/App.vue | 11 ++--- src/main.ts | 2 - 5 files changed, 63 insertions(+), 66 deletions(-) create mode 100644 .husky/commit-msg diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100644 index 0000000..1ffb133 --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +pnpm commitlint diff --git a/eslint.config.js b/eslint.config.js index ea49284..3e0587e 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,77 +1,77 @@ -import js from "@eslint/js"; -import globals from "globals"; -import tseslint from "typescript-eslint"; -import pluginVue from "eslint-plugin-vue"; -import { defineConfig } from "eslint/config"; +import js from '@eslint/js' +import globals from 'globals' +import tseslint from 'typescript-eslint' +import pluginVue from 'eslint-plugin-vue' +import { defineConfig } from 'eslint/config' export default defineConfig([ { ignores: [ - "**/dist/**", // 忽略所有 dist 文件夹 - "**/node_modules/**" // 忽略所有 node_modules - ] + '**/dist/**', // 忽略所有 dist 文件夹 + '**/node_modules/**', // 忽略所有 node_modules + ], }, // 1. 使用 ESLint 官方推荐规则 js.configs.recommended, - + // 2. 设置全局变量(浏览器、Node.js、ES2021、Jest) { - files: ["**/*.{js,mjs,cjs,ts,mts,cts,vue}"], + files: ['**/*.{js,mjs,cjs,ts,mts,cts,vue}'], languageOptions: { globals: { - ...globals.browser, // 浏览器全局变量(如 `window`, `document`) - ...globals.es2021, // ES2021 全局变量(如 `Promise`, `Map`) - ...globals.node, // Node.js 全局变量(如 `require`, `process`) - ...{ jest: "readonly" } // Jest 测试框架全局变量(如 `describe`, `test`) - } - } + ...globals.browser, // 浏览器全局变量(如 `window`, `document`) + ...globals.es2021, // ES2021 全局变量(如 `Promise`, `Map`) + ...globals.node, // Node.js 全局变量(如 `require`, `process`) + ...{ jest: 'readonly' }, // Jest 测试框架全局变量(如 `describe`, `test`) + }, + }, }, - + // 3. 添加 TypeScript 支持(使用 `@typescript-eslint` 推荐规则) ...tseslint.configs.recommended, - + // 4. 添加 Vue 3 支持(使用 `eslint-plugin-vue` 基础规则) - ...pluginVue.configs["flat/essential"], - + ...pluginVue.configs['flat/essential'], + // 5. 针对 `.vue` 文件的解析配置 { - files: ["**/*.vue"], + files: ['**/*.vue'], languageOptions: { parserOptions: { - ecmaVersion: "latest", // 使用最新的 ECMAScript 版本 - sourceType: "module", // 使用 ES Module 语法 - jsxPragma: "React", // 如果用了 JSX,指定 React 作为全局变量 + ecmaVersion: 'latest', // 使用最新的 ECMAScript 版本 + sourceType: 'module', // 使用 ES Module 语法 + jsxPragma: 'React', // 如果用了 JSX,指定 React 作为全局变量 ecmaFeatures: { - jsx: true // 启用 JSX 支持 - } - } - } + jsx: true, // 启用 JSX 支持 + }, + }, + }, }, - + // 6. 自定义规则(覆盖或扩展默认规则) { rules: { // ESLint 基础规则 - "no-var": "error", // 禁止使用 `var`,必须用 `let` 或 `const` - "no-multiple-empty-lines": ["warn", { max: 1 }], // 最多允许 1 个空行 - "no-console": process.env.NODE_ENV === "production" ? "error" : "off", // 生产环境禁止 `console` - "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off", // 生产环境禁止 `debugger` - "no-unexpected-multiline": "error", // 禁止意外的多行代码 - "no-useless-escape": "off", // 允许不必要的转义字符(如 `\/`) - + 'no-var': 'error', // 禁止使用 `var`,必须用 `let` 或 `const` + 'no-multiple-empty-lines': ['warn', { max: 1 }], // 最多允许 1 个空行 + 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', // 生产环境禁止 `console` + 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', // 生产环境禁止 `debugger` + 'no-unexpected-multiline': 'error', // 禁止意外的多行代码 + 'no-useless-escape': 'off', // 允许不必要的转义字符(如 `\/`) + // TypeScript 规则 - "@typescript-eslint/no-unused-vars": "error", // 禁止未使用的变量 - "@typescript-eslint/prefer-ts-expect-error": "error", // 禁止 `@ts-ignore`,推荐用 `@ts-expect-error` - "@typescript-eslint/no-explicit-any": "off", // 允许使用 `any` 类型 - "@typescript-eslint/no-non-null-assertion": "off", // 允许 `!` 非空断言 - "@typescript-eslint/no-namespace": "off", // 允许使用 `namespace` - "@typescript-eslint/semi": "off", // 不强制分号 - + '@typescript-eslint/no-unused-vars': 'error', // 禁止未使用的变量 + '@typescript-eslint/prefer-ts-expect-error': 'error', // 禁止 `@ts-ignore`,推荐用 `@ts-expect-error` + '@typescript-eslint/no-explicit-any': 'off', // 允许使用 `any` 类型 + '@typescript-eslint/no-non-null-assertion': 'off', // 允许 `!` 非空断言 + '@typescript-eslint/no-namespace': 'off', // 允许使用 `namespace` + '@typescript-eslint/semi': 'off', // 不强制分号 + // Vue 规则 - "vue/multi-word-component-names": "off", // 允许单单词组件名(如 `Home.vue`) - "vue/script-setup-uses-vars": "error", // 确保 ` - \ No newline at end of file + + diff --git a/src/main.ts b/src/main.ts index e19cb66..d0cac5a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -11,5 +11,3 @@ const app = createApp(App) app.use(ElementPlus) //挂载APP实例到#app元素上 app.mount('#app') - -