Skip to content

Commit 7c1df40

Browse files
feat: Add ESLint + ts-prune + depcheck to CI (#32) - Add GitHub Actions workflow, configure linting tools, clean up unused exports, all tools now pass (#54)
1 parent 314784d commit 7c1df40

File tree

8 files changed

+278
-47
lines changed

8 files changed

+278
-47
lines changed

.depcheckrc

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright IBM Corp. 2025
2+
# Assisted by CursorAI
3+
4+
# Ignore these dependencies that are used but not detected by depcheck
5+
ignores:
6+
# VSCode API is imported as 'vscode' but the package is '@types/vscode'
7+
- "vscode"
8+
# React dependencies used in webview libs (external bundles, not npm dependencies)
9+
- "react"
10+
- "@graphiql/react"
11+
# Test runner used by vscode-test command but not directly imported
12+
- "@vscode/test-electron"
13+
# Depcheck itself is used via npx in scripts
14+
- "depcheck"
15+
16+
# Ignore these patterns - webview libs are bundled separately
17+
ignorePatterns:
18+
- "webview/**"
19+
- "dist/**"
20+
- "out/**"
21+
- "*.vsix"
22+
23+
# Skip missing dependencies check for known false positives
24+
skipMissing: false
25+
26+
# Custom parsers for different file types
27+
parsers:
28+
"**/*.ts": "typescript"
29+
"**/*.js": "es6"
30+
"**/*.mjs": "es6"
31+
32+
# Detectors to use
33+
detectors:
34+
- "requireCallExpression"
35+
- "importDeclaration"
36+
- "exportDeclaration"

.github/workflows/lint.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Copyright IBM Corp. 2025
2+
# Assisted by CursorAI
3+
4+
name: Lint
5+
6+
on:
7+
push:
8+
branches: [main, develop]
9+
pull_request:
10+
branches: [main, develop]
11+
12+
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
16+
strategy:
17+
matrix:
18+
node-version: [18.x, 20.x]
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Node.js ${{ matrix.node-version }}
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
cache: "npm"
29+
30+
- name: Install dependencies
31+
run: npm ci
32+
33+
- name: Run ESLint
34+
run: npm run lint
35+
36+
- name: Check for unused exports with ts-prune
37+
run: npm run lint:prune
38+
39+
- name: Check for unused dependencies with depcheck
40+
run: npm run lint:deps
41+
42+
- name: Run type checking
43+
run: npm run check-types

package-lock.json

Lines changed: 160 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,15 @@
125125
"check-types": "tsc --noEmit",
126126
"lint": "eslint src",
127127
"lint:prune": "ts-prune --error",
128+
"lint:deps": "depcheck",
129+
"lint:all": "npm run lint && npm run lint:prune && npm run lint:deps",
130+
"ci:lint": "npm run lint && npm run lint:prune && npm run lint:deps && npm run check-types",
128131
"test": "vscode-test"
129132
},
130133
"devDependencies": {
131134
"@types/mocha": "^10.0.10",
132135
"@types/node": "20.x",
136+
"@types/sinon": "^17.0.3",
133137
"@types/vscode": "^1.100.0",
134138
"@typescript-eslint/eslint-plugin": "^8.31.1",
135139
"@typescript-eslint/parser": "^8.31.1",
@@ -138,7 +142,9 @@
138142
"depcheck": "^1.4.7",
139143
"esbuild": "^0.25.3",
140144
"eslint": "^9.25.1",
145+
"mocha": "^10.8.2",
141146
"npm-run-all": "^4.1.5",
147+
"sinon": "^19.0.2",
142148
"ts-prune": "^0.10.3",
143149
"typescript": "^5.8.3"
144150
},

readme.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,38 @@ npm run compile
135135
npm run watch
136136
```
137137

138+
### Code Quality & Linting
139+
140+
This project uses multiple linting tools to ensure code quality:
141+
142+
```bash
143+
# Run ESLint for code style and best practices
144+
npm run lint
145+
146+
# Check for unused TypeScript exports
147+
npm run lint:prune
148+
149+
# Check for unused dependencies
150+
npm run lint:deps
151+
152+
# Run type checking
153+
npm run check-types
154+
155+
# Run all linting tools (used in CI)
156+
npm run ci:lint
157+
```
158+
159+
**CI Integration**: All linting tools run automatically in GitHub Actions on every push and pull request. The CI will fail if any of these tools report issues:
160+
161+
- **ESLint** - Enforces code style, prevents console statements, ensures proper imports
162+
- **ts-prune** - Finds unused exports to keep the codebase clean
163+
- **depcheck** - Identifies unused dependencies and missing dependencies
164+
165+
Configuration files:
166+
- ESLint: `eslint.config.mjs`
167+
- depcheck: `.depcheckrc`
168+
- TypeScript: `tsconfig.json`
169+
138170
### Testing
139171

140172
The extension uses the standard VS Code testing framework with Mocha. The tests are located in the `src/test` directory. View the README.md file in that directory for more details.

src/extension.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,6 @@ export let EXTENSION_URI: vscode.Uri;
1919
export let runtimeDiag: vscode.DiagnosticCollection;
2020

2121

22-
/**
23-
* Gets or creates a terminal for StepZen operations
24-
* @param name The name to give the terminal if creating a new one
25-
* @returns An existing or newly created terminal instance
26-
*/
27-
export function getOrCreateStepZenTerminal(name: string = UI.TERMINAL_NAME): vscode.Terminal {
28-
if (!stepzenTerminal) {
29-
stepzenTerminal = vscode.window.createTerminal(name);
30-
}
31-
return stepzenTerminal;
32-
}
33-
3422
/**
3523
* Resolve the workspace folder that owns the given URI (or the active editor if none supplied).
3624
*/

0 commit comments

Comments
 (0)