diff --git a/.stylelintrc.cjs b/.stylelintrc.cjs index 36b7b18..4501ba1 100644 --- a/.stylelintrc.cjs +++ b/.stylelintrc.cjs @@ -1,63 +1,63 @@ module.exports = { - "extends": [ - "stylelint-config-standard", - "stylelint-config-standard-scss", - "stylelint-config-recommended-vue", - "stylelint-config-recommended-vue/scss" + 'extends': [ + 'stylelint-config-standard', + 'stylelint-config-standard-scss', + 'stylelint-config-recommended-vue', + 'stylelint-config-recommended-vue/scss' ], - "ignoreFiles": ["**/*.js", "**/*.ts"], - "defaultSeverity": "error", - "rules": { - "unit-disallowed-list": [ - "rem", - "pt" + 'ignoreFiles': ['**/*.js', '**/*.ts'], + 'defaultSeverity': 'error', + 'rules': { + 'unit-disallowed-list': [ + 'rem', + 'pt' ], - "no-empty-source": null, - "block-no-empty": null, + 'no-empty-source': null, + 'block-no-empty': null, 'declaration-block-no-duplicate-custom-properties': null, - "font-family-no-missing-generic-family-keyword": null, + 'font-family-no-missing-generic-family-keyword': null, - "selector-class-pattern": "^[a-z]([a-z0-9-]+)?(__([a-z0-9]+-?)+)?(__([a-z0-9]+-?)+)?(--([a-z0-9]+-?)+){0,2}$|^Mui.*$|^([a-z][a-z0-9]*)(_[a-z0-9]+)*$", + 'selector-class-pattern': '^[a-z]([a-z0-9-]+)?(__([a-z0-9]+-?)+)?(__([a-z0-9]+-?)+)?(--([a-z0-9]+-?)+){0,2}$|^Mui.*$|^([a-z][a-z0-9]*)(_[a-z0-9]+)*$', - "scss/at-mixin-pattern": "^[a-z]([a-z0-9-]+)?(__([a-z0-9]+-?)+)?(__([a-z0-9]+-?)+)?(--([a-z0-9]+-?)+){0,2}$|^Mui.*$|^([a-z][a-z0-9]*)(_[a-z0-9]+)*$", - "scss/double-slash-comment-whitespace-inside": "always", - "scss/dollar-variable-pattern": null, + 'scss/at-mixin-pattern': '^[a-z]([a-z0-9-]+)?(__([a-z0-9]+-?)+)?(__([a-z0-9]+-?)+)?(--([a-z0-9]+-?)+){0,2}$|^Mui.*$|^([a-z][a-z0-9]*)(_[a-z0-9]+)*$', + 'scss/double-slash-comment-whitespace-inside': 'always', + 'scss/dollar-variable-pattern': null, - "selector-pseudo-class-no-unknown": [ + 'selector-pseudo-class-no-unknown': [ true, { - "ignorePseudoClasses": [ - "export", - "deep" + 'ignorePseudoClasses': [ + 'export', + 'deep' ] } ], - "property-no-unknown": null, - "at-rule-empty-line-before": [ - "always", + 'property-no-unknown': null, + 'at-rule-empty-line-before': [ + 'always', { - "except": ["first-nested", "blockless-after-same-name-blockless"] + 'except': ['first-nested', 'blockless-after-same-name-blockless'] } ], - "custom-property-empty-line-before": [ - "always", + 'custom-property-empty-line-before': [ + 'always', { - "except": ["after-custom-property", "first-nested"] + 'except': ['after-custom-property', 'first-nested'] } ], - "declaration-empty-line-before": [ - "always", + 'declaration-empty-line-before': [ + 'always', { - "except": ["after-declaration", "first-nested"] + 'except': ['after-declaration', 'first-nested'] } ], - "rule-empty-line-before": ["always-multi-line"], + 'rule-empty-line-before': ['always-multi-line'], // 忽视 -webkit-xxxx 等兼容写法 - "property-no-vendor-prefix": [ + 'property-no-vendor-prefix': [ true, { - ignoreProperties: ["box-shadow"] + ignoreProperties: ['box-shadow'] } ] } diff --git a/README.md b/README.md index 2cb6442..0ed5dd1 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ 🏄‍♂️ A Starter template built on Vite 5.x + TypeScript + Vue 3.4 + Naive UI + Pinia + UnoCSS + Unplugin Auto Import. -一个简洁的 Vite5 + Vue3.4 + TypeScript 的 B 端后台原型 Naive UI 模板框架,内置 Pinia 模块化管理代码、路由鉴权、UnoCSS 暗黑模式、Unplugin 自动导入等, 开箱即用, 注重快速高效搭建实际业务场景, 持续更新最新技术栈 💪 +一个简洁的 Vite5 + Vue3.4 + TypeScript + ESLint(v9) 的 B 端后台原型 Naive UI 模板框架,内置 Pinia 模块化管理代码、路由鉴权、UnoCSS 暗黑模式、Unplugin 自动导入等, 开箱即用, 注重快速高效搭建实际业务场景, 持续更新最新技术栈 🎊 [🔥 Live Demo 在线体验](https://pdsuwwz.github.io/vite-naive-template) diff --git a/eslint.config.js b/eslint.config.js index 2da1af4..d98b428 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,25 +1,27 @@ // import antfu from '@antfu/eslint-config' // export default antfu() -import { defineFlatConfig } from 'eslint-define-config'; +import globals from 'globals' +import { defineFlatConfig } from 'eslint-define-config' -import * as parserTypeScript from '@typescript-eslint/parser'; -import pluginTypeScript from '@typescript-eslint/eslint-plugin'; +import * as parserTypeScript from '@typescript-eslint/parser' +import pluginTypeScript from '@typescript-eslint/eslint-plugin' + +import * as parserVue from 'vue-eslint-parser' +import pluginVue from 'eslint-plugin-vue' +import js from '@eslint/js' -import * as parserVue from 'vue-eslint-parser'; -import pluginVue from 'eslint-plugin-vue'; -import js from '@eslint/js'; function renameRules(rules, map) { return Object.fromEntries( Object.entries(rules).map(([key, value]) => { for (const [from, to] of Object.entries(map)) { if (key.startsWith(`${from}/`)) - return [to + key.slice(from.length), value]; + return [to + key.slice(from.length), value] } - return [key, value]; + return [key, value] }) - ); + ) } export default defineFlatConfig([ @@ -31,7 +33,10 @@ export default defineFlatConfig([ globals: { document: 'readonly', navigator: 'readonly', - window: 'readonly' + window: 'readonly', + ...globals.node, + ...globals.es2021, + ...globals.browser }, parserOptions: { ecmaFeatures: { @@ -50,7 +55,7 @@ export default defineFlatConfig([ 'constructor-super': 'error', 'default-case-last': 'error', 'dot-notation': ['error', { allowKeywords: true }], - 'eqeqeq': ['error', 'smart'], + 'eqeqeq': ['error', 'always'], 'new-cap': ['error', { capIsNew: false, newIsCap: true, properties: true }], 'no-alert': 'error', 'no-array-constructor': 'error', @@ -160,6 +165,9 @@ export default defineFlatConfig([ 'no-useless-return': 'error', 'no-var': 'error', 'no-with': 'error', + 'key-spacing': 'error', + 'space-infix-ops': 'error', + 'object-curly-spacing': ['error', 'always'], 'object-shorthand': [ 'error', 'always', @@ -235,6 +243,11 @@ export default defineFlatConfig([ } } }, + settings: { + 'import/core-modules': [ + 'uno.css' + ] + }, plugins: { '@typescript-eslint': pluginTypeScript }, @@ -321,4 +334,4 @@ export default defineFlatConfig([ }] } } -]); +]) diff --git a/package.json b/package.json index c49f4db..a11556e 100644 --- a/package.json +++ b/package.json @@ -92,6 +92,7 @@ "eslint-plugin-html": "8.0.0", "eslint-plugin-import": "^2.29.1", "eslint-plugin-vue": "^9.24.0", + "globals": "^15.0.0", "identity-obj-proxy": "^3.0.0", "jsdom": "^24.0.0", "postcss": "^8.4.38", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a500ea5..c6818d3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -130,6 +130,9 @@ devDependencies: eslint-plugin-vue: specifier: ^9.24.0 version: 9.24.0(eslint@9.0.0) + globals: + specifier: ^15.0.0 + version: 15.0.0 identity-obj-proxy: specifier: ^3.0.0 version: 3.0.0 @@ -4053,6 +4056,11 @@ packages: engines: {node: '>=18'} dev: true + /globals@15.0.0: + resolution: {integrity: sha512-m/C/yR4mjO6pXDTm9/R/SpYTAIyaUB4EOzcaaMEl7mds7Mshct9GfejiJNQGjHHbdMPey13Kpu4TMbYi9ex1pw==} + engines: {node: '>=18'} + dev: true + /globalthis@1.0.3: resolution: {integrity: sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA==} engines: {node: '>= 0.4'}