diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..09b72bb --- /dev/null +++ b/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "@antfu" +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 13ee2b0..b4fb16f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,14 @@ { - "nuxt.isNuxtApp": false + "nuxt.isNuxtApp": false, + "prettier.enable": false, + "editor.formatOnSave": false, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": true + }, + "stylelint.enable": true, + "stylelint.validate": [ + "css", + "vue", + "html" + ] } \ No newline at end of file diff --git a/components/HelloWorld.vue b/components/HelloWorld.vue index d106ac6..8f928e7 100644 --- a/components/HelloWorld.vue +++ b/components/HelloWorld.vue @@ -1,124 +1,35 @@ - - + + diff --git a/package.json b/package.json index 85bf28c..911d8ef 100644 --- a/package.json +++ b/package.json @@ -6,12 +6,43 @@ "dev": "nuxt dev", "generate": "nuxt generate", "preview": "nuxt preview", - "postinstall": "nuxt prepare" + "postinstall": "nuxt prepare", + "lint-staged": "lint-staged" }, "devDependencies": { + "@antfu/eslint-config": "^0.39.3", + "@commitlint/cli": "^17.6.3", + "@commitlint/config-conventional": "^17.6.3", "@nuxt/devtools": "^0.5.5", "@nuxthq/ui": "^2.2.0", "@types/node": "^18", - "nuxt": "^3.5.1" + "commitizen": "^4.3.0", + "cz-git": "^1.6.1", + "eslint": "^8.41.0", + "lint-staged": "^13.2.2", + "nuxt": "^3.5.1", + "postcss-html": "^1.5.0", + "stylelint": "^15.6.2", + "stylelint-config-html": "^1.1.0", + "stylelint-config-recess-order": "^4.0.0", + "stylelint-config-standard": "^33.0.0", + "typescript": "^5.0.4" + }, + "lint-staged": { + "*.{js,ts,tsx,jsx}": [ + "eslint --fix --ext" + ], + "*.vue": [ + "eslint --fix --ext", + "stylelint --cache --fix" + ], + "*.{css,html}": [ + "stylelint --cache --fix" + ] + }, + "config": { + "commitizen": { + "path": "node_modules/cz-git" + } } } diff --git a/style.config.ts b/style.config.ts new file mode 100644 index 0000000..c3a70fb --- /dev/null +++ b/style.config.ts @@ -0,0 +1,29 @@ +// eslint-disable-next-line antfu/no-cjs-exports +module.exports = { + /* 继承某些已有的规则 */ + extends: [ + 'stylelint-config-standard', // 配置stylelint拓展插件 + 'stylelint-config-html/vue', // 配置 vue 中 template 样式格式化 + 'stylelint-config-recess-order', // 配置stylelint css属性书写顺序插件, + ], + overrides: [ + // 扫描 .vue/html 文件中的