Skip to content

Commit a9d1eba

Browse files
committed
feat(vue): 优化代码格式化和 lint 配置
- 更新 .prettierignore、biome.jsonc、eslint.config.mjs 等配置文件 - 调整 ignore 文件和目录路径,提高代码格式化效率 - 更新 stylelint 配置,增加对 Vue 文件的支持 - 修改 lefthook.yml 中的 lint 命令,优化提交前检查流程
1 parent 8ca3519 commit a9d1eba

File tree

6 files changed

+49
-49
lines changed

6 files changed

+49
-49
lines changed

templates/vue/.prettierignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,3 @@ yarn.lock
3939

4040
# TypeScript
4141
*.tsbuildinfo
42-
43-

templates/vue/biome.jsonc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,19 @@
99
"files": {
1010
"ignoreUnknown": true,
1111
"ignore": [
12-
".*",
13-
"node_modules",
14-
"/dist/**",
15-
"/public/**",
16-
"/coverage/**",
12+
// node
13+
"**/node_modules/**",
1714
"package.json",
1815
"package-lock.json",
1916
"pnpm-lock.{yml,yaml}",
20-
"yarn.lock"
17+
"yarn.lock",
18+
// vite
19+
"dist/**",
20+
"public/**",
21+
// vitest
22+
"coverage/**",
23+
// dot files
24+
".*"
2125
]
2226
},
2327
"formatter": {

templates/vue/eslint.config.mjs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,22 @@ export default antfu(
1414
yaml: true,
1515
unocss: true,
1616
ignores: [
17-
// Node
18-
"node_modules",
17+
// node
18+
"**/node_modules/**",
1919
"package.json",
2020
"package-lock.json",
2121
"pnpm-lock.{yml,yaml}",
2222
"yarn.lock",
23-
// Dot Files
23+
// vite
24+
"dist/**",
25+
"public/**",
26+
// vitest
27+
"coverage/**",
28+
// dot files
2429
'**/.*',
25-
// Vite
26-
"/dist/**",
27-
"/public/**",
28-
// Testing
29-
"/coverage/**"
30+
// uni-app
31+
'src/uni_modules/**',
32+
'src/static/**',
3033
],
3134
stylistic: {
3235
semi: prettierConfig.semi,
@@ -35,16 +38,15 @@ export default antfu(
3538
},
3639
typescript: {
3740
overrides: {
38-
'ts/explicit-function-return-type': ['off'],
41+
'ts/explicit-function-return-type': 'off',
3942
'ts/no-require-imports': 'off',
4043
},
4144
},
4245
rules: {
43-
'unused-imports/no-unused-imports': 'off',
4446
'unused-imports/no-unused-vars': 'off',
45-
'no-console': 'off',
47+
'no-unused-vars': 'off',
48+
'no-console': 'off', },
4649
},
47-
},
4850
);
4951

5052

templates/vue/lefthook.yml.ejs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ pre-commit:
77
<%_ if (codeLinter === 'biome') { _%>
88
biome:
99
glob: "*"
10-
run: npx biome check --write --no-errors-on-unmatched --files-ignore-unknown=true --colors=off {staged_files}
10+
run: npx biome check --write --no-errors-on-unmatched --files-ignore-unknown=true {staged_files}
1111
stage_fixed: true
1212
<%_ } else if (codeLinter === 'eslint') { _%>
1313
eslint:
1414
glob: "*"
15-
run: npx eslint --no-error-on-unmatched-pattern --no-color --fix {staged_files}
15+
run: npx eslint --no-error-on-unmatched-pattern --no-warn-ignored --fix {staged_files}
1616
stage_fixed: true
1717
<%_ } _%>
1818
stylelint:
1919
glob: "*.{css,scss,html,vue}"
20-
run: npx stylelint {staged_files} --no-color --fix
20+
run: npx stylelint {staged_files} --fix
2121
stage_fixed: true
2222

2323
commit-msg:

templates/vue/package.json.ejs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"stylelint-config-html": "^1.1.0",
5858
"stylelint-config-recommended": "^15.0.0",
5959
"stylelint-config-recommended-scss": "^14.1.0",
60+
"stylelint-config-recommended-vue": "^1.6.0",
6061
"stylelint-config-standard": "^37.0.0",
6162
"typescript": "^5.7.3",
6263
"unocss": "^65.4.0",

templates/vue/stylelint.config.mjs

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
// @ref https://unocss.dev/integrations/postcss
44
const ignoreAtRules = [
55
// Tailwindcss v4
6-
"theme",
7-
"source",
8-
"utility",
9-
"variant",
10-
"custom-variant",
11-
"apply",
12-
"reference",
13-
"config",
14-
"plugin",
6+
'theme',
7+
'source',
8+
'utility',
9+
'variant',
10+
'custom-variant',
11+
'apply',
12+
'reference',
13+
'config',
14+
'plugin',
1515

1616
// Unocss v65
17-
"unocss",
18-
"screen",
17+
'unocss',
18+
'screen',
1919
];
2020

2121
/**
@@ -26,35 +26,32 @@ const ignoreAtRules = [
2626
export default {
2727
ignoreFiles: [
2828
// Node
29-
"node_modules",
29+
'**/node_modules/**',
3030
// Vite
31-
"dist/**",
32-
"public/**",
31+
'dist/**',
32+
'public/**',
3333
// Vitest
34-
"coverage/**",
34+
'coverage/**',
3535
],
3636

3737
extends: [
3838
'stylelint-config-recommended',
3939
'stylelint-config-recommended-scss',
4040
'stylelint-config-css-modules',
4141
'stylelint-config-html',
42-
'stylelint-config-html/vue',
42+
'stylelint-config-recommended-vue',
43+
'stylelint-config-recommended-vue/scss',
4344
],
4445

4546
rules: {
46-
// 源可以为空
47+
// @ref https://stylelint.io/user-guide/rules/no-empty-source/
4748
'no-empty-source': null,
48-
49-
// 样式类名:无规则限制
49+
// @ref https://stylelint.io/user-guide/rules/selector-class-pattern/
5050
'selector-class-pattern': null,
51-
52-
// 不接受无效属性值
53-
'declaration-property-value-no-unknown': true,
54-
55-
// 不需要要求声明倒序
51+
// @ref https://stylelint.io/user-guide/rules/no-descending-specificity/
5652
'no-descending-specificity': null,
5753

54+
// tailwind
5855
// @ref https://stylelint.io/user-guide/rules/at-rule-no-unknown/
5956
'at-rule-no-unknown': [true, { ignoreAtRules }],
6057
// @ref https://stylelint.io/user-guide/rules/at-rule-no-deprecated/
@@ -63,5 +60,3 @@ export default {
6360
};
6461

6562

66-
67-

0 commit comments

Comments
 (0)