-
-
Notifications
You must be signed in to change notification settings - Fork 501
Document language-overridable scope for Prettier settings in README #3862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@copilot add this to the README.md then |
Co-authored-by: ntotten <282782+ntotten@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds documentation to the README explaining how to use language-specific Prettier formatting overrides in VS Code settings. The feature itself was already implemented in v10.3.0 (with "scope": "language-overridable" on all Prettier options), but was not documented for users. This documentation update helps users discover and utilize this valuable feature for multi-language projects.
Key Changes:
- Added a new "Language-Specific Formatting" section to README.md with examples showing how to configure different Prettier options per language
- Updated version from 12.0.4 to 12.0.5 in package.json and package-lock.json
- Applied automatic code formatting to several TypeScript files (via
npm run prettier) - Added
.vscode-test-web/to .prettierignore
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Added "Language-Specific Formatting" documentation section with JSON examples for HTML, TypeScript, and JSON language overrides |
| package.json, package-lock.json | Version bump from 12.0.4 to 12.0.5 |
| .prettierignore | Added .vscode-test/ and .vscode-test-web/ to ignore list (note: .vscode-test/ is duplicated) |
| src/test/suite/ModuleResolverNode.test.ts | Automatic formatting: multi-line import statement |
| src/PrettierEditService.ts | Automatic formatting: adjusted line breaks in ternary expressions |
| src/PrettierDynamicInstance.ts | Automatic formatting: multi-line function call |
| src/ModuleResolverWeb.ts | Automatic formatting: arrays and objects reformatted to multi-line, removed trailing comma inconsistency |
| scripts/update-browser-languages.mjs | Automatic formatting: multi-line function call |
| #### Language-Specific Formatting | ||
|
|
||
| All Prettier options above support language-specific overrides. This allows you to set different formatting rules for different file types directly in your VS Code settings, which are easily synchronized across machines and environments. | ||
|
|
||
| To configure language-specific settings, use the `[language]` syntax in your VS Code `settings.json`: | ||
|
|
||
| ```json | ||
| { | ||
| "[html]": { | ||
| "prettier.printWidth": 180 | ||
| }, | ||
| "[typescript]": { | ||
| "prettier.printWidth": 120, | ||
| "prettier.tabWidth": 4, | ||
| "prettier.semi": false | ||
| }, | ||
| "[json]": { | ||
| "prettier.printWidth": 80, | ||
| "prettier.tabWidth": 2 | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| This feature is particularly useful when working in multi-language projects or when different languages have different formatting conventions. Language-specific settings will override the global Prettier settings when formatting files of that language type. | ||
|
|
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The PR checklist indicates that CHANGELOG.md was updated, but no changes to CHANGELOG.md appear in this PR. For a documentation update like this, consider adding an entry under the ## [unreleased] section, such as:
## [unreleased]
- Added documentation for language-specific formatting overrides to README.mdThis helps maintain a clear history of changes even for documentation-only updates.
| node_modules/ | ||
| package-lock.json | ||
| package-lock.json | ||
| .vscode-test/ |
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The .vscode-test/ entry is duplicated (it appears on both line 1 and line 7). Remove this duplicate entry to keep the ignore file clean.
| .vscode-test/ |
Description
The requested feature—language-overridable scope for
prettier.printWidthand other Prettier settings—was already implemented in v10.3.0 (commit e2e606f, PR #3327, March 21, 2024). All Prettier formatting options inpackage.jsonalready have"scope": "language-overridable"configured.This PR adds documentation to the README.md explaining how to use language-specific overrides in VS Code settings:
{ "[html]": { "prettier.printWidth": 180 }, "[typescript]": { "prettier.printWidth": 120, "prettier.tabWidth": 4, "prettier.semi": false }, "[json]": { "prettier.printWidth": 80, "prettier.tabWidth": 2 } }Changes Made:
Current State:
printWidth,tabWidth,singleQuote, etc.) have"scope": "language-overridable"in package.jsonworkspace.getConfiguration("prettier", scope)for language-aware configurationsrc/test/suite/config.test.tstest-fixtures/test.code-workspaceRelated Issue
Fixes #3093
Type of Change
Checklist
npm run lintpasses)npm run prettierto format my codenpm test)Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.