Skip to content

Commit 0ed9931

Browse files
authored
Refactoring and cleanup (#3835)
* Refactoring and cleanup * switch to lefthook instead of husky * updated lefthook config * Updated eslint * merge cleanup * approve lefthook * increased test timeout * ignore tests in codeql * Fix typo * Fix instructions * updated lefhook
1 parent 00eaa41 commit 0ed9931

38 files changed

+707
-749
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/codeql/codeql-config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name: "CodeQL Config"
2+
3+
paths-ignore:
4+
- test-fixtures

.github/copilot-instructions.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This is the official Prettier VS Code extension (`prettier.prettier-vscode`). It
66

77
- Use `pnpm` as the package manager
88
- Run `pnpm install` to install dependencies
9-
- Run `pnpm webpack` to build for development
9+
- Run `pnpm compile` to build for development
1010
- Run `pnpm test` to run tests (no VS Code instance can be running)
1111
- Run `pnpm lint` to check linting
1212
- Run `pnpm prettier` to format code
@@ -23,10 +23,9 @@ Core components:
2323
- `src/extension.ts` - Extension activation, creates ModuleResolver, PrettierEditService, and StatusBar
2424
- `src/PrettierEditService.ts` - Registers VS Code document formatting providers, handles format requests
2525
- `src/ModuleResolver.ts` - Resolves local/global Prettier installations, falls back to bundled Prettier
26-
- `src/PrettierWorkerInstance.ts` - Runs Prettier v3+ in a worker thread for async formatting
27-
- `src/PrettierMainThreadInstance.ts` - Runs Prettier v2 synchronously on main thread
26+
- `src/PrettierInstance.ts` - Interface for Prettier loading, with `PrettierMainThreadInstance` and `PrettierWorkerInstance` implementations
2827

29-
Webpack produces two bundles:
28+
esbuild produces two bundles:
3029

3130
- Node bundle (`dist/extension.js`) for desktop VS Code
3231
- Web bundle (`dist/web-extension.js`) for vscode.dev/browser
@@ -70,7 +69,7 @@ When reviewing pull requests, focus on:
7069
### Performance
7170

7271
- Avoid blocking the extension host main thread
73-
- Prettier v3+ should use worker threads via `PrettierWorkerInstance`
72+
- `PrettierWorkerInstance` runs Prettier in a worker thread to avoid blocking
7473
- Module and config resolution results are cached appropriately
7574

7675
### Browser Compatibility

.github/instructions/typescript.instructions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ This is a VS Code extension. Follow these patterns:
2727

2828
## Prettier Integration
2929

30-
- Support both Prettier v2 (sync, main thread) and v3+ (async, worker thread)
31-
- `PrettierMainThreadInstance` for v2, `PrettierWorkerInstance` for v3+
30+
- Support both Prettier v2 and v3+ via `PrettierInstance` interface
31+
- `PrettierMainThreadInstance` loads directly, `PrettierWorkerInstance` uses worker thread
3232
- Module resolution: local install → global install → bundled Prettier
3333
- Handle `.prettierrc`, `.prettierignore`, and `package.json` prettier config
3434

.husky/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.husky/pre-commit

Lines changed: 0 additions & 1 deletion
This file was deleted.

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"editor.codeActionsOnSave": {
44
"source.fixAll.eslint": "explicit"
55
},
6+
"eslint.useFlatConfig": true,
67
"editor.formatOnSave": true,
78
"editor.defaultFormatter": "prettier.prettier-vscode",
89
"editor.formatOnType": false,

.vscodeignore

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.github/
2-
.husky/
32
.vscode/
43
.vscode-test/
54
.vscode-test-web/
@@ -14,10 +13,12 @@ test-fixtures/
1413
.prettierrc
1514
CODE_OF_CONDUCT.md
1615
CONTRIBUTING.md
17-
CONTRIBUTORS.md
1816
tsconfig.json
19-
webpack.config.js
20-
yarn.lock
17+
tsconfig.scripts.json
18+
eslint.config.mjs
19+
lefthook.yml
20+
esbuild.mjs
21+
pnpm-lock.yaml
2122
dist/*.map
2223

2324
node_modules/

CLAUDE.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,12 @@ Web tests are located in `src/test/web/suite/` and test the extension's browser
8686
- Caches resolved modules and configurations
8787
- Handles Workspace Trust restrictions
8888

89-
**Prettier Instance Wrappers**:
89+
**Prettier Instance** (`PrettierInstance.ts`, `PrettierMainThreadInstance.ts`, `PrettierWorkerInstance.ts`):
9090

91-
- `PrettierWorkerInstance.ts`: Runs Prettier v3+ in a worker thread for async formatting
92-
- `PrettierMainThreadInstance.ts`: Runs Prettier v2 synchronously on main thread
93-
- Worker script lives in `src/worker/prettier-instance-worker.js`
91+
- `PrettierInstance` is an interface with two implementations
92+
- `PrettierMainThreadInstance` loads Prettier directly via `require()`
93+
- `PrettierWorkerInstance` loads Prettier in a worker thread to avoid blocking
94+
- Works with both Prettier v2 and v3+
9495

9596
### Bundling
9697

0 commit comments

Comments
 (0)