Skip to content

Commit 352e1a5

Browse files
author
shown
authored
docs: add eslint check for docs website (vllm-project#114)
* docs: add eslint check for docs website Signed-off-by: yuluo-yx <[email protected]> * feat: add docs lint make target in makefile Signed-off-by: yuluo-yx <[email protected]> * fix: fix pre-commit run failed Signed-off-by: yuluo-yx <[email protected]> --------- Signed-off-by: yuluo-yx <[email protected]>
1 parent eca7b2c commit 352e1a5

File tree

20 files changed

+21710
-370
lines changed

20 files changed

+21710
-370
lines changed

.github/workflows/pre-commit.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
jobs:
1111
pre-commit:
1212
runs-on: ubuntu-latest
13-
name: Run pre-commit hooks on Go, Rust, and Python files
13+
name: Run pre-commit hooks on Go, Rust, JavaScripts and Python files
1414

1515
steps:
1616
- name: Check out the repo
@@ -28,6 +28,11 @@ jobs:
2828
with:
2929
go-version: '1.24'
3030

31+
- name: Set up Node
32+
uses: actions/setup-node@v5
33+
with:
34+
node-version: 23
35+
3136
- name: Set up Rust
3237
uses: dtolnay/rust-toolchain@stable
3338
with:
@@ -60,6 +65,13 @@ jobs:
6065
~/go/pkg/mod
6166
key: ${{ runner.os }}-go-precommit-${{ hashFiles('**/go.sum') }}
6267

68+
- name: Cache Node dependencies
69+
uses: actions/cache@v4
70+
with:
71+
path: |
72+
~/.npm
73+
key: ${{ runner.os }}-node-precommit-${{ hashFiles('website/package-lock.json') }}
74+
6375
- name: Cache pre-commit environments
6476
uses: actions/cache@v4
6577
with:
@@ -69,13 +81,14 @@ jobs:
6981
- name: Install pre-commit
7082
run: pip install pre-commit
7183

72-
- name: Run pre-commit on Go, Rust, and Python files
84+
- name: Run pre-commit on Go, Rust, JavaScript and Python files
7385
run: |
74-
# Find all Go, Rust, and Python files (excluding vendored/generated code)
75-
FILES=$(find . -type f \( -name "*.go" -o -name "*.rs" -o -name "*.py" \) \
86+
# Find all Go, Rust, JavaScripts and Python files (excluding vendored/generated code)
87+
FILES=$(find . -type f \( -name "*.go" -o -name "*.rs" -o -name "*.py" -o -name "*.js" \) \
7688
! -path "./target/*" \
7789
! -path "./candle-binding/target/*" \
7890
! -path "./.git/*" \
91+
! -path "./node_modules/*" \
7992
! -path "./vendor/*" \
8093
! -path "./__pycache__/*" \
8194
! -path "./site/*" \
@@ -86,7 +99,7 @@ jobs:
8699
echo "Running pre-commit on files: $FILES"
87100
pre-commit run --files $FILES
88101
else
89-
echo "No Go, Rust, or Python files found to check"
102+
echo "No Go, Rust, JavaScript or Python files found to check"
90103
fi
91104
92105
- name: Show pre-commit results

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ example_prd.txt
9696
.windsurfrules
9797
scripts/prd.txt
9898
.env.taskmaster
99-
package-lock.json
10099

101100
website/build
102101
.docusaurus

.pre-commit-config.yaml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ repos:
66
rev: v6.0.0
77
hooks:
88
- id: trailing-whitespace
9-
files: \.(go|rs|py)$
9+
files: \.(go|rs|py|js)$
1010
- id: end-of-file-fixer
11-
files: \.(go|rs|py)$
11+
files: \.(go|rs|py|js)$
1212
- id: check-added-large-files
1313
args: ['--maxkb=500']
14-
files: \.(go|rs|py)$
14+
files: \.(go|rs|py|js)$
1515

1616
# Go specific hooks
1717
- repo: local
@@ -22,6 +22,17 @@ repos:
2222
language: system
2323
files: \.go$
2424

25+
# JavaScript specific hooks
26+
- repo: local
27+
hooks:
28+
- id: js-lint
29+
name: js lint
30+
entry: bash -c 'cd website && npm install 2>/dev/null || true && npm run lint'
31+
language: system
32+
files: \.js$
33+
exclude: ^(\node_modules/)
34+
pass_filenames: false
35+
2536
# Rust specific hooks
2637
- repo: local
2738
hooks:

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,3 +335,11 @@ docs-serve: docs-build
335335
docs-clean:
336336
@echo "Cleaning documentation build artifacts..."
337337
cd website && npm run clear
338+
339+
docs-lint:
340+
@echo "Linting documentation..."
341+
cd website && npm run lint
342+
343+
docs-lint-fix:
344+
@echo "Fixing documentation lint issues..."
345+
cd website && npm run lint:fix

website/docusaurus.config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// @ts-check
22
// Note: type annotations allow type checking and IDEs autocompletion
33

4-
const {themes} = require('prism-react-renderer');
5-
const lightCodeTheme = themes.github;
6-
const darkCodeTheme = themes.vsDark;
4+
const { themes } = require('prism-react-renderer')
5+
const lightCodeTheme = themes.github
6+
const darkCodeTheme = themes.vsDark
77

88
/** @type {import('@docusaurus/types').Config} */
99
const config = {
@@ -211,6 +211,6 @@ const config = {
211211
respectPrefersColorScheme: false,
212212
},
213213
}),
214-
};
214+
}
215215

216-
module.exports = config;
216+
module.exports = config

website/eslint.config.mjs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import stylistic from '@stylistic/eslint-plugin'
2+
import react from 'eslint-plugin-react'
3+
4+
export default [
5+
{
6+
ignores: ['.docusaurus', 'build'],
7+
},
8+
stylistic.configs['recommended-flat'],
9+
{
10+
files: ['**/*.js', '**/*.jsx'],
11+
plugins: {
12+
react: react,
13+
},
14+
rules: {
15+
...react.configs['jsx-runtime'].rules,
16+
},
17+
languageOptions: {
18+
parserOptions: {
19+
ecmaFeatures: { jsx: true },
20+
},
21+
},
22+
},
23+
]

0 commit comments

Comments
 (0)