-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Angular Control Syntax issues #15833
Comments
Can't reproduce Prettier 3.1.1 --parser angular Input: @if (mealType !== 'lodging' && !package) {
<span class="mx-0.5 text-base font-normal sm:text-lg"> + </span>
@switch (mealType.toLowerCase()) { @case ('breakfast') {
<svg-icon
class="h-6 w-6 grow-0 text-dark-primary"
data-test-id="breakfast-icon"
src="assets/icons/icon-coffee-cup.svg"
/>
} @case ('halfboard') {
<svg-icon
class="h-6 w-6 grow-0 text-dark-primary"
data-test-id="halfboard-icon"
src="assets/icons/icon-fork-knife.svg"
/>
} @default {
<svg-icon
class="h-6 w-6 grow-0 text-dark-primary"
data-test-id="fullboard-allin-icon"
src="assets/icons/icon-checklist.svg"
/>
} } } Output: @if (mealType !== "lodging" && !package) {
<span class="mx-0.5 text-base font-normal sm:text-lg"> + </span>
@switch (mealType.toLowerCase()) {
@case ("breakfast") {
<svg-icon
class="h-6 w-6 grow-0 text-dark-primary"
data-test-id="breakfast-icon"
src="assets/icons/icon-coffee-cup.svg"
/>
}
@case ("halfboard") {
<svg-icon
class="h-6 w-6 grow-0 text-dark-primary"
data-test-id="halfboard-icon"
src="assets/icons/icon-fork-knife.svg"
/>
}
@default {
<svg-icon
class="h-6 w-6 grow-0 text-dark-primary"
data-test-id="fullboard-allin-icon"
src="assets/icons/icon-checklist.svg"
/>
}
}
} Next time please follow the issue template. |
thanks, i have to use parser angular instead of the default html when using the control syntax. will close the issue |
Thanks @fisker. If someone has this issue, in your .prettierrc add this to use the angular parser:
|
I use prettier inside eslint, so i tried this : {
"files": ["*.component.html"],
"extends": ["plugin:@angular-eslint/template/recommended", "plugin:prettier/recommended"],
"rules": {
"@angular-eslint/template/prefer-control-flow": "warn",
"prettier/prettier": ["error", { "overrides": [{ "options": { "parser": "angular" } }] }]
}
} which doesn't work "overrides": [
{
"files": "*.component.html",
"options": {
"parser": "angular"
}
}
] Can someone help ? |
I have the same issue. I'm on prettier 3.2.5 and I've added that overrides in the .prettierrc, however the tab format for Angular 17 flow controls still doesn't work. Here's my .prettierrc file:
Can somebody help? |
I'm also on prettier 3.2.5 and no success with .prettierrc in project root:
|
@mvermand22 I was able to figure it out. When I ran: |
Hi, i'm already on v3.2.5, so that won't fix it for me. Thanks for the reply though. |
After using the new Angular Control Syntax, prettier does not always indent correctly.
sometimes it works, sometimes it doesnt, but i cannot pinpoint why.
i think it has something to do when control statements are on a single line, then indentation doesnt work anymore
} @for (mealType of mealTypeKeys; track mealType) { @if (mealType) {
The text was updated successfully, but these errors were encountered: