-
Notifications
You must be signed in to change notification settings - Fork 11.9k
feat(@angular/cli): automatic formatting files modified by schematics #32367
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
Open
alan-agius4
wants to merge
5
commits into
angular:main
Choose a base branch
from
alan-agius4:formatter
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+93
−4
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3cc3fdf to
1b984f1
Compare
clydin
approved these changes
Jan 27, 2026
Comment on lines
57
to
64
| await execFileAsync(prettierCliPath, [ | ||
| '--write', | ||
| ...[...files].filter((f) => fileTypes.has(extname(f))).map((f) => relative(cwd, f)), | ||
| ]); |
Member
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.
On Windows, this might need the shell option enabled.
Collaborator
Author
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.
I guess we'll see when this is merged.
packages/angular/cli/src/command-builder/schematics-command-module.ts
Outdated
Show resolved
Hide resolved
f5ca400 to
b8a64b8
Compare
This change introduces automatic formatting of files generated or modified during a schematic execution. When a schematic is executed, the CLI will now attempt to find and use the project's local Prettier installation to format all created or updated files. This ensures that generated code adheres to the project's established coding style without requiring developers to manually run a formatting command. If Prettier is not installed in the user's workspace, the formatting step will be gracefully skipped. This avoids adding a direct dependency on Prettier to the CLI and respects the user's project setup. The implementation leverages the Prettier CLI directly for a more robust and reliable formatting process. Closes angular#10777
a10a6ca to
f6721ed
Compare
f6721ed to
fde5365
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
action: merge
The PR is ready for merge by the caretaker
area: @angular/cli
detected: feature
PR contains a feature commit
target: minor
This PR is targeted for the next minor release
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change introduces automatic formatting of files generated or modified during a schematic execution.
When a schematic is executed, the CLI will now attempt to find and use the project's local Prettier installation to format all created or updated files. This ensures that generated code adheres to the project's established coding style without requiring developers to manually run a formatting command.
If Prettier is not installed in the user's workspace, the formatting step will be gracefully skipped. This avoids adding a direct dependency on Prettier to the CLI and respects the user's project setup. The implementation leverages the Prettier CLI directly for a more robust and reliable formatting process.
Closes #10777