Skip to content

Commit a1dba45

Browse files
committed
lint ci
1 parent 8dd0ef7 commit a1dba45

File tree

6 files changed

+172
-7
lines changed

6 files changed

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

.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)