Skip to content

Commit 7006e2f

Browse files
committed
lint ci
1 parent 8dd0ef7 commit 7006e2f

File tree

6 files changed

+180
-7
lines changed

6 files changed

+180
-7
lines changed

.clang-format

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BasedOnStyle: LLVM
2+
IndentWidth: 4

.github/workflows/lint.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Lint & Format
2+
3+
permissions:
4+
contents: write
5+
6+
on:
7+
push:
8+
branches: [main]
9+
10+
workflow_dispatch:
11+
12+
concurrency:
13+
group: lint
14+
cancel-in-progress: false
15+
16+
jobs:
17+
lint:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
- name: Setup Git
25+
run: |
26+
echo '${{ github.token }}' | gh auth login --with-token
27+
gh auth status
28+
gh auth setup-git
29+
git config --global user.name 'github-actions[bot]'
30+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
31+
32+
- name: Setup Node
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version-file: package.json
36+
check-latest: true
37+
#cache: yarn
38+
39+
- name: Setup yarn
40+
run: |
41+
corepack enable
42+
yarn set version stable
43+
44+
- name: Get yarn cachedir
45+
id: yarn-cachedir
46+
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
47+
48+
- name: Cache yarn
49+
uses: actions/cache@v4
50+
with:
51+
path: ${{ steps.yarn-cachedir.outputs.dir }}
52+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
53+
restore-keys: |
54+
${{ runner.os }}-yarn-
55+
56+
- name: Install dependencies
57+
run: yarn install
58+
59+
- name: Cpp Lint (clang-format & clang-tidy)
60+
uses: cpp-linter/cpp-linter-action@v2
61+
env:
62+
GITHUB_TOKEN: ${{ github.token }}
63+
with:
64+
style: file
65+
thread-comments: update
66+
continue-on-error: true
67+
68+
- name: ESLint (+vue +prettier)
69+
run: yarn run eslint --fix --ignore-pattern .gitignore
70+
continue-on-error: true
71+
72+
- name: Prettier
73+
run: yarn run prettier --write .
74+
continue-on-error: true
75+
76+
- name: Markdown Lint
77+
uses: DavidAnson/markdownlint-cli2-action@v19
78+
with:
79+
globs: "**/*.{md,markdown} !node_modules"
80+
fix: true
81+
continue-on-error: true
82+
83+
- name: Autocorrect Lint
84+
id: autocorrect-lint
85+
uses: huacnlee/autocorrect-action@v2
86+
env:
87+
REVIEWDOG_GITHUB_API_TOKEN: ${{ github.token }}
88+
with:
89+
use_npm: true
90+
args: --lint --config 'https://raw.githubusercontent.com/huacnlee/autocorrect/main/.autocorrectrc.template'
91+
reviewdog: true
92+
continue-on-error: true
93+
- name: Autocorrect Fix
94+
if: steps.autocorrect-lint.outcome == 'failure'
95+
uses: huacnlee/autocorrect-action@v2
96+
with:
97+
use_npm: true
98+
args: --fix --config 'https://raw.githubusercontent.com/huacnlee/autocorrect/main/.autocorrectrc.template'
99+
continue-on-error: true
100+
- name: Create PullRequest
101+
run: |
102+
git branch -f lint
103+
git switch lint
104+
git add .
105+
git commit -m "lint:${{ github.ref }}"
106+
git push -f origin lint
107+
gh pr create --fill
108+
continue-on-error: true

.markdownlint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ MD013: false
66

77
# 内联HTML
88
MD033:
9-
allowed_elements:
9+
allowed_elements:
1010
- table # 灵活表格
1111
- tl # table
1212
- tr # table

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ int main(int argc, char* argv[]){
3939
2. 标题层级不应过多,如果出现该情况,可以拆分成多篇文章;
4040
一般地,标题层级不应超过**四**级;
4141
3. `/教程` 和 `/杂项/工具和环境` 文件夹里的文档,除一级标题之外的标题应有**编号**:
42-
1. 二级标题前应有 `1.` `2.` 等编号,数字后加小数点;
43-
2. 三级标题前应有 `1.1` `1.2` 等编号,末尾不要加小数点;
44-
3. 四级标题前应有 `1.1.1` `1.1.2` 等编号,末尾不要加小数点;
42+
1. 二级标题前应有 `1.` `2.` 等编号,数字后加小数点;
43+
2. 三级标题前应有 `1.1` `1.2` 等编号,末尾不要加小数点;
44+
3. 四级标题前应有 `1.1.1` `1.1.2` 等编号,末尾不要加小数点;
4545
4. **代码块**和**列表**前后各有一个空行;文件结尾要有一个空行;文件任何位置不得存在连续两个空行;
4646
5. 段落和段落之间有一个空行;只换行不换段落,无空行,在前一行结尾加两个空格;
4747
6. **强调**用 `** **` 标识,_次强调_ 用 `_ _` 标识,`代码块` 用 `` ` ` `` 标识;
@@ -88,9 +88,9 @@ int main(int argc, char* argv[]){
8888
```
8989

9090
5. 标识符的命名:
91-
1. 使用惯例,尤其禁止使用拼音;
92-
2. 宏名所有字母均大写,单词之间以下划线分割;
93-
3. 其余标识符所有字母均小写,单词之间以下划线分割;
91+
1. 使用惯例,尤其禁止使用拼音;
92+
2. 宏名所有字母均大写,单词之间以下划线分割;
93+
3. 其余标识符所有字母均小写,单词之间以下划线分割;
9494
6. `if` `else` `for` `while` 必须跟随**复合语句**
9595

9696
## 对预期读者的要求

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
},
99
"devDependencies": {
1010
"@eslint/js": "^9.19.0",
11+
"autocorrect-node": "^2.13.0",
1112
"eslint": "^9.19.0",
1213
"eslint-config-prettier": "^10.0.1",
1314
"eslint-plugin-prettier": "^5.2.3",

yarn.lock

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,6 +1822,67 @@ __metadata:
18221822
languageName: node
18231823
linkType: hard
18241824

1825+
"autocorrect-node-darwin-arm64@npm:2.13.0":
1826+
version: 2.13.0
1827+
resolution: "autocorrect-node-darwin-arm64@npm:2.13.0"
1828+
conditions: os=darwin & cpu=arm64
1829+
languageName: node
1830+
linkType: hard
1831+
1832+
"autocorrect-node-darwin-x64@npm:2.13.0":
1833+
version: 2.13.0
1834+
resolution: "autocorrect-node-darwin-x64@npm:2.13.0"
1835+
conditions: os=darwin & cpu=x64
1836+
languageName: node
1837+
linkType: hard
1838+
1839+
"autocorrect-node-linux-x64-gnu@npm:2.13.0":
1840+
version: 2.13.0
1841+
resolution: "autocorrect-node-linux-x64-gnu@npm:2.13.0"
1842+
conditions: os=linux & cpu=x64 & libc=glibc
1843+
languageName: node
1844+
linkType: hard
1845+
1846+
"autocorrect-node-linux-x64-musl@npm:2.13.0":
1847+
version: 2.13.0
1848+
resolution: "autocorrect-node-linux-x64-musl@npm:2.13.0"
1849+
conditions: os=linux & cpu=x64 & libc=musl
1850+
languageName: node
1851+
linkType: hard
1852+
1853+
"autocorrect-node-win32-x64-msvc@npm:2.13.0":
1854+
version: 2.13.0
1855+
resolution: "autocorrect-node-win32-x64-msvc@npm:2.13.0"
1856+
conditions: os=win32 & cpu=x64
1857+
languageName: node
1858+
linkType: hard
1859+
1860+
"autocorrect-node@npm:^2.13.0":
1861+
version: 2.13.0
1862+
resolution: "autocorrect-node@npm:2.13.0"
1863+
dependencies:
1864+
autocorrect-node-darwin-arm64: "npm:2.13.0"
1865+
autocorrect-node-darwin-x64: "npm:2.13.0"
1866+
autocorrect-node-linux-x64-gnu: "npm:2.13.0"
1867+
autocorrect-node-linux-x64-musl: "npm:2.13.0"
1868+
autocorrect-node-win32-x64-msvc: "npm:2.13.0"
1869+
dependenciesMeta:
1870+
autocorrect-node-darwin-arm64:
1871+
optional: true
1872+
autocorrect-node-darwin-x64:
1873+
optional: true
1874+
autocorrect-node-linux-x64-gnu:
1875+
optional: true
1876+
autocorrect-node-linux-x64-musl:
1877+
optional: true
1878+
autocorrect-node-win32-x64-msvc:
1879+
optional: true
1880+
bin:
1881+
autocorrect: cli.js
1882+
checksum: 10c0/18da306651f207243b2d0268c877270a8438fdc7a36710e5f83bf71d7c66999fab9faa44b44d23358086ae45f4015be429808d8e83a20379a78ce68a2d16d5ee
1883+
languageName: node
1884+
linkType: hard
1885+
18251886
"balanced-match@npm:^1.0.0":
18261887
version: 1.0.2
18271888
resolution: "balanced-match@npm:1.0.2"
@@ -5500,6 +5561,7 @@ __metadata:
55005561
resolution: "vitepress@workspace:."
55015562
dependencies:
55025563
"@eslint/js": "npm:^9.19.0"
5564+
autocorrect-node: "npm:^2.13.0"
55035565
eslint: "npm:^9.19.0"
55045566
eslint-config-prettier: "npm:^10.0.1"
55055567
eslint-plugin-prettier: "npm:^5.2.3"

0 commit comments

Comments
 (0)