添加 ESLint 工作流以支持Pull Requests中的代码检查,并在 package.json 中添加 lint 脚本

This commit is contained in:
hi2hi 2024-12-06 09:38:41 +00:00
parent 5f719d5e5a
commit f2fb191b52
2 changed files with 33 additions and 1 deletions

31
.github/workflows/eslint.yml vendored Normal file
View File

@ -0,0 +1,31 @@
name: ESLint Lint for Pull Requests
on:
pull_request:
paths:
- '**/*.js'
- '**/*.ts'
- '**/*.vue'
jobs:
lint:
runs-on: ubuntu-latest
steps:
# 检出代码
- name: Checkout code
uses: actions/checkout@v3
# 设置 Node.js 环境
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
# 安装依赖
- name: Install dependencies
run: npm install
# 运行 ESLint
- name: Run ESLint
run: npm run lint

View File

@ -5,7 +5,8 @@
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "vite build", "build": "vite build",
"preview": "vite preview" "preview": "vite preview",
"lint": "eslint ."
}, },
"dependencies": { "dependencies": {
"axios": "^1.7.7", "axios": "^1.7.7",