Skip to content

Commit 065cdd2

Browse files
committed
Use pnpm instead of yarn
1 parent abd433b commit 065cdd2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+6972
-5876
lines changed

.claude/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"permissions": {
33
"allow": [
44
"WebFetch(domain:prettier.io)",
5-
"Bash(npm run prettier:*)",
5+
"Bash(pnpm prettier:*)",
6+
"Bash(pnpm lint:*)",
67
"mcp__ide__getDiagnostics"
78
],
89
"deny": [],

.github/copilot-instructions.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Copilot Instructions
2+
3+
This is the official Prettier VS Code extension (`prettier.prettier-vscode`). It provides code formatting using Prettier for Visual Studio Code, supporting JavaScript, TypeScript, CSS, HTML, Vue, and many other languages.
4+
5+
## Development
6+
7+
- Use `pnpm` as the package manager
8+
- Run `pnpm install` to install dependencies
9+
- Run `pnpm webpack` to build for development
10+
- Run `pnpm test` to run tests (no VS Code instance can be running)
11+
- Run `pnpm lint` to check linting
12+
- Run `pnpm prettier` to format code
13+
14+
## Architecture
15+
16+
Entry points:
17+
18+
- Desktop: `src/extension.ts` → bundled to `dist/extension.js`
19+
- Browser: Same entry, bundled to `dist/web-extension.js` (uses `BrowserModuleResolver` instead of `ModuleResolver`)
20+
21+
Core components:
22+
23+
- `src/extension.ts` - Extension activation, creates ModuleResolver, PrettierEditService, and StatusBar
24+
- `src/PrettierEditService.ts` - Registers VS Code document formatting providers, handles format requests
25+
- `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
28+
29+
Webpack produces two bundles:
30+
31+
- Node bundle (`dist/extension.js`) for desktop VS Code
32+
- Web bundle (`dist/web-extension.js`) for vscode.dev/browser
33+
34+
## Code Style
35+
36+
- Use TypeScript for all source code
37+
- Follow existing code patterns in the codebase
38+
- Extension settings are prefixed with `prettier.` and defined in `package.json`
39+
- Use the VS Code extension API patterns already established in the codebase
40+
41+
## Testing
42+
43+
- Test fixtures live in `test-fixtures/` with their own `package.json` and Prettier configurations
44+
- The `.do-not-use-prettier-vscode-root` marker file stops module resolver from searching above test fixtures
45+
- Tests run inside a VS Code instance using the Extension Development Host
46+
47+
## Code Review Guidelines
48+
49+
When reviewing pull requests, focus on:
50+
51+
### Security
52+
53+
- No hardcoded secrets or credentials
54+
- Workspace Trust is respected when resolving modules from untrusted workspaces
55+
- User input is validated before use in file paths or module resolution
56+
57+
### VS Code Extension Best Practices
58+
59+
- Disposables are properly registered with `context.subscriptions` to prevent memory leaks
60+
- Async operations handle errors appropriately
61+
- User-facing messages go through `LoggingService` or VS Code's message APIs
62+
- Settings changes are handled correctly (some require reload)
63+
64+
### Prettier Compatibility
65+
66+
- Changes work with both Prettier v2 (sync) and v3+ (async/worker)
67+
- Module resolution fallback chain is maintained: local → global → bundled
68+
- Config file watching covers all Prettier config formats
69+
70+
### Performance
71+
72+
- Avoid blocking the extension host main thread
73+
- Prettier v3+ should use worker threads via `PrettierWorkerInstance`
74+
- Module and config resolution results are cached appropriately
75+
76+
### Browser Compatibility
77+
78+
- Code in the main bundle should work in both Node.js and browser contexts
79+
- Browser-specific code uses `BrowserModuleResolver`
80+
- No Node.js-only APIs in shared code paths
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
applyTo: "src/test/**/*.ts"
3+
---
4+
5+
# Test File Guidelines
6+
7+
Tests run inside a VS Code Extension Development Host using Mocha.
8+
9+
## Test Structure
10+
11+
- Use Mocha's `suite()` and `test()` functions
12+
- Import assertions from `assert` module
13+
- Tests interact with real VS Code APIs
14+
15+
## Test Fixtures
16+
17+
- Test fixtures are in `test-fixtures/` directory (not `src/test/`)
18+
- Each fixture has its own `package.json` and Prettier configuration
19+
- Use `getWorkspaceFolderUri(workspaceFolderName)` to get fixture paths
20+
- Fixtures are added to `test.code-workspace` for the test runner
21+
22+
## Formatting Tests
23+
24+
- Use the `format()` helper to open and format documents
25+
- Compare results with `getText()` helper for expected output
26+
- Execute formatting via `vscode.commands.executeCommand("editor.action.formatDocument")`
27+
28+
## Async Patterns
29+
30+
- Tests are async - use `async/await`
31+
- Use `wait()` helper when needing delays
32+
- Prettier v3 formatting is async, may need retries for timing
33+
34+
## Test File Naming
35+
36+
- Name test files as `*.test.ts`
37+
- Group related tests in the same file (e.g., `format.test.ts`, `plugins.test.ts`)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
applyTo: "src/**/*.ts"
3+
---
4+
5+
# TypeScript Source Guidelines
6+
7+
This is a VS Code extension. Follow these patterns:
8+
9+
## Imports
10+
11+
- Import VS Code API from `vscode` module: `import { commands, workspace, window } from "vscode"`
12+
- Use named imports, not namespace imports
13+
- Group imports: vscode first, then node modules, then local modules
14+
15+
## VS Code Extension Patterns
16+
17+
- Use `ExtensionContext.subscriptions` to register disposables for cleanup
18+
- Access settings via `workspace.getConfiguration("prettier")`
19+
- Use `LoggingService` for all logging (not console.log)
20+
- Commands are registered via `commands.registerCommand()`
21+
22+
## Class Patterns
23+
24+
- Services follow dependency injection pattern (pass dependencies via constructor)
25+
- Key services: `LoggingService`, `ModuleResolver`, `PrettierEditService`, `StatusBar`
26+
- Use `Disposable` interface for cleanup
27+
28+
## Prettier Integration
29+
30+
- Support both Prettier v2 (sync, main thread) and v3+ (async, worker thread)
31+
- `PrettierMainThreadInstance` for v2, `PrettierWorkerInstance` for v3+
32+
- Module resolution: local install → global install → bundled Prettier
33+
- Handle `.prettierrc`, `.prettierignore`, and `package.json` prettier config
34+
35+
## Error Handling
36+
37+
- Log errors through `LoggingService`
38+
- Show user-facing errors via `window.showErrorMessage()`
39+
- Handle Workspace Trust restrictions appropriately
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
applyTo: ".github/workflows/*.yaml"
3+
---
4+
5+
# GitHub Actions Workflow Guidelines
6+
7+
## Package Manager
8+
9+
- Use `pnpm` as the package manager
10+
- Include `pnpm/action-setup@v4` before running pnpm commands
11+
- Use `actions/setup-node@v6` with `node-version-file: ".nvmrc"`
12+
13+
## Checkout and Setup Pattern
14+
15+
```yaml
16+
- uses: actions/checkout@v6
17+
- uses: actions/setup-node@v6
18+
with:
19+
node-version-file: ".nvmrc"
20+
- uses: pnpm/action-setup@v4
21+
- run: pnpm install
22+
```
23+
24+
## Testing
25+
26+
- Linux tests require Xvfb for display: `/usr/bin/Xvfb :99 -screen 0 1024x768x24`
27+
- Set `DISPLAY: ":99.0"` environment variable for tests on Linux
28+
- Tests run via `pnpm test`
29+
30+
## Permissions
31+
32+
- Use minimal required permissions for each job
33+
- Common permissions: `issues: write`, `pull-requests: write`, `contents: read`
34+
35+
## Scripts in Workflows
36+
37+
- For `actions/github-script@v7`, only use built-in Node.js modules (fs, path, etc.)
38+
- Do not use external npm packages like `js-yaml` in github-script (they are not available)
39+
- Use JSON format for config files that need to be read in workflows

.github/labels.json

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
{
2+
"labels": [
3+
{
4+
"name": "bug",
5+
"color": "#d73a4a",
6+
"description": "Something isn't working"
7+
},
8+
{
9+
"name": "enhancement",
10+
"color": "#a2eeef",
11+
"description": "New feature or request"
12+
},
13+
{
14+
"name": "documentation",
15+
"color": "#0075ca",
16+
"description": "Improvements or additions to documentation"
17+
},
18+
{
19+
"name": "performance",
20+
"color": "#f9d0c4",
21+
"description": "Performance related issues"
22+
},
23+
{
24+
"name": "triage-pending",
25+
"color": "#fbca04",
26+
"description": "Awaiting initial triage"
27+
},
28+
{
29+
"name": "need-more-info",
30+
"color": "#d876e3",
31+
"description": "Further information is requested"
32+
},
33+
{
34+
"name": "stale",
35+
"color": "#ffffff",
36+
"description": "No recent activity"
37+
},
38+
{
39+
"name": "locked",
40+
"color": "#ededed",
41+
"description": "Locked due to inactivity"
42+
},
43+
{
44+
"name": "duplicate",
45+
"color": "#cfd3d7",
46+
"description": "This issue or PR already exists"
47+
},
48+
{
49+
"name": "invalid",
50+
"color": "#e4e669",
51+
"description": "This doesn't seem right"
52+
},
53+
{
54+
"name": "wontfix",
55+
"color": "#ffffff",
56+
"description": "This will not be worked on"
57+
},
58+
{
59+
"name": "help-wanted",
60+
"color": "#008672",
61+
"description": "Extra attention is needed"
62+
},
63+
{
64+
"name": "good-first-issue",
65+
"color": "#7057ff",
66+
"description": "Good for newcomers"
67+
},
68+
{
69+
"name": "pinned",
70+
"color": "#006b75",
71+
"description": "Pinned issue - will not be marked stale"
72+
},
73+
{
74+
"name": "prettier-core",
75+
"color": "#bfdadc",
76+
"description": "Issue is with Prettier core, not the extension"
77+
},
78+
{
79+
"name": "config",
80+
"color": "#c2e0c6",
81+
"description": "Related to configuration"
82+
},
83+
{
84+
"name": "plugin",
85+
"color": "#d4c5f9",
86+
"description": "Related to Prettier plugins"
87+
},
88+
{
89+
"name": "breaking-change",
90+
"color": "#b60205",
91+
"description": "Breaking change"
92+
},
93+
{
94+
"name": "dependencies",
95+
"color": "#0366d6",
96+
"description": "Pull requests that update a dependency"
97+
},
98+
{
99+
"name": "github_actions",
100+
"color": "#000000",
101+
"description": "Pull requests that update GitHub Actions"
102+
}
103+
]
104+
}

0 commit comments

Comments
 (0)