-
Notifications
You must be signed in to change notification settings - Fork 12k
fix(@schematics/angular): add missing prettier config #30590
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
The current style guide no longer enforces the use of the template file extension `.component.html`. This means that prettier won't auto-detect the proper parser for these files anymore. To ensure template formatting works out-of-the-box, we're adding a prettier config to newly created projects. Fixes angular#30548
@@ -8,6 +8,16 @@ | |||
"watch": "ng build --watch --configuration development"<% if (!minimal) { %>, | |||
"test": "ng test"<% } %> | |||
}, | |||
"prettier": { |
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.
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.
My thinking here was that creating a dedicated file may be more confusing for people who don't actively use prettier
. It feels a bit less boilerplate-y. But I don't have super strong opinions either way.
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.
That’s a valid point.
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.
actually this will be super confusing for anyone using prettier since creating a prettierrc file will have zero affect (prettier doesn't merge configurations but only take one; and the one inside the package.json has the highest order)
and I'm talking from experience because I faced it before myself as in one repo someone configured prettier in the package.json and I was trying to add one plugin and it wasn't working and it took me forever to figure out why
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.
Is there an issue in prettier about that behavior? That seems worth fixing independent of this change.
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.
it's how it works
I can open an issue there and see where it goes, but I don't think they will change this behavior since it can lead to many repos being broken
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.
Sorry, I wasn't talking about changing the behavior. I was talking about silently ignoring a config file that's clearly "meant" to be used (it's called prettierrc after all) and not warning the user about it. Printing a warning should hopefully not break anything and would remove this confusion?
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.
okay I will create an issue now
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 changes were merged into the following branches: main, 20.0.x |
The current style guide no longer enforces the use of the template file extension
.component.html
. This means that prettier won't auto-detect the proper parser for these files anymore.To ensure template formatting works out-of-the-box, we're adding a prettier config to newly created projects.
Fixes #30548