Skip to content

Commit 2bac047

Browse files
author
微信公众号:储凡
authored
perf(scripts): 修改lint脚本,优化markdown文档格式化配置 (#85)
1 parent 29c5745 commit 2bac047

File tree

8 files changed

+27
-71
lines changed

8 files changed

+27
-71
lines changed

.dockerignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
node_modules
1+
node_modules
2+
.idea
3+
.github
4+
.husky

.github/workflows/CI.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
6666
- name: Code LintFix
6767
run: |
68-
./scripts/lint --fix
68+
bash ./scripts/lint
6969
7070
- name: Build Site
7171
run: |

.gitignore

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,76 +7,33 @@ logs
77
.DS_Store
88
*/.vscode
99
.idea
10-
# Diagnostic reports (https://nodejs.org/api/report.html)
11-
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
12-
13-
# docs/.vuepress
14-
pids
15-
*.pid
16-
*.seed
17-
*.pid.lock
18-
1910
# Coverage directory used by tools like istanbul
2011
coverage
2112
*.lcov
22-
2313
# nyc test coverage
2414
.nyc_output
25-
26-
2715
# Dependency directories
2816
node_modules/
2917
jspm_packages/
30-
3118
# TypeScript v1 declaration files
3219
typings/
33-
34-
# TypeScript cache
35-
*.tsbuildinfo
36-
3720
# Optional npm cache directory
3821
.npm
39-
40-
# Optional eslint cache
41-
.eslintcache
42-
43-
# Microbundle cache
44-
.rpt2_cache/
45-
.rts2_cache_cjs/
46-
.rts2_cache_es/
47-
.rts2_cache_umd/
48-
4922
# Output of 'npm pack'
5023
*.tgz
51-
52-
53-
# dotenv environment variables file
54-
.env
55-
.env.test
56-
5724
# parcel-bundler cache (https://parceljs.org/)
5825
.cache
59-
6026
# Next.js build output
6127
.next
62-
6328
.nuxt
6429
dist
65-
6630
# Gatsby files
6731
.cache/
68-
69-
7032
# vuepress build output
7133
# .vuepress/dist
72-
73-
## static resource
7434
docs/.vuepress/.cache/
7535
docs/.vuepress/.temp/
7636
docs/.vuepress/dist/
77-
78-
7937
# TernJS port file
8038
.tern-port
81-
/docs/.vuepress/.temp/
8239
/.husky/

.markdownlint.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// 参考:https://github.com/updownpress/markdown-lint/tree/master/rules
1+
// 参考:<https://github.com/updownpress/markdown-lint/tree/master/rules>
22
module.exports = {
33
"default": true,
44
"MD001": false,
@@ -69,4 +69,4 @@ module.exports = {
6969
"MD042": false,
7070
"MD046": false,
7171
"MD049": false
72-
}
72+
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
**/node_modules/**
2-
CHANGELOG.md
32
LICENSE
3+
.idea
4+
.husky
5+
.github

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
},
1010
"scripts": {
1111
"preinstall": "chmod +x ./scripts/*",
12-
"prepare": "rm -f .husky/pre-commit && husky install && npx husky add .husky/pre-commit \"./scripts/lint --fix\" && chmod +x .husky/pre-commit",
1312
"dev": "vuepress dev docs",
1413
"build": "vuepress build docs",
1514
"build:proxy": "./scripts/bundle build_proxy",

scripts/ci

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,3 @@ fi
3737

3838
# 安装项目依赖
3939
pnpm i --frozen-lockfile --registry https://registry.npmmirror.com
40-

scripts/lint

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
1-
#!/usr/bin/env node
1+
#!/bin/bash
22

3-
/**
4-
*
5-
* 格式化代码
6-
* 例如:
7-
* - ./scripts/lint
8-
* - ./scripts/lint --fix
9-
*/
3+
##
4+
## 自动格式化
5+
## - 代码
6+
## - markdown文档
7+
## 使用:
8+
# - ./scripts/lint
9+
## 参考链接:
10+
## - https://eslint.org/docs/latest/use/getting-started
11+
## - https://github.com/igorshubovych/markdownlint-cli
12+
##
1013

11-
const { execShell } = require('./.exec')
12-
const scriptName = process.argv[2]
13-
const fixed = scriptName != null ? '--fix' : '';
14+
# 设置 PATH 环境变量,避免command not found问题
15+
export PATH="$(pnpm bin):$PATH"
1416

15-
// 格式化代码
16-
const lintCode = `eslint ${fixed} --ext .js,.ts,.vue --ignore-path .gitignore .`;
17+
# ESLint格式化代码
18+
eslint --fix --ext .js,.ts,.vue --ignore-path .gitignore .
1719

18-
// 遍历格式化docs目录下的markdown 文档
19-
const lintMd = 'find docs -type f -name \"*.md\" -print0 | xargs -0 -I {} markdownlint -c .markdownlint.js --fix {}';
20-
21-
// 可以在--fix后指定目录
22-
(async () => await execShell([
23-
lintCode,
24-
lintMd
25-
]))()
20+
# markdown-cli格式化markdown 文档
21+
markdownlint '**/*.md' -c .markdownlint.js -p .markdownlintignore --fix
2622

0 commit comments

Comments
 (0)