Skip to content

Commit 3d417fc

Browse files
Add eslint to tests (#17)
Co-authored-by: Chengzhong Wu <[email protected]>
1 parent f2605fe commit 3d417fc

File tree

4 files changed

+1103
-3
lines changed

4 files changed

+1103
-3
lines changed

.github/workflows/lint.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Lint
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Harden Runner
13+
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
14+
with:
15+
egress-policy: audit
16+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
17+
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
18+
with:
19+
node-version: 22.x
20+
- run: npm ci
21+
- run: npm run lint

eslint.config.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { defineConfig, globalIgnores } from "eslint/config";
2+
3+
export default defineConfig([
4+
globalIgnores(["node"]),
5+
{
6+
files: ["tests/**/*.js"],
7+
rules: {
8+
// Test files are expected to be self-contained
9+
"no-restricted-imports": ["error", {
10+
patterns: ["*"],
11+
}],
12+
"no-restricted-globals": ["error",
13+
{ name: "require", message: "Test files are expected to be self-contained" }
14+
]
15+
},
16+
},
17+
]);

0 commit comments

Comments
 (0)