Skip to content

Angular inline styles are not formatted if specified as single string (new in v17) #15934

@matthias-dev

Description

@matthias-dev

Prettier 3.2.2
Playground link

--parser babel

Input:

import {Component} from '@angular/core';

@Component({
  selector: 'app-root',
  template: `Hello`,
  styles: `
    :host{
      color:blue;}
  `,
})
export class AppComponent {}

Output:

import { Component } from "@angular/core";

@Component({
  selector: "app-root",
  template: `Hello`,
  styles: `
    :host{
      color:blue;}
  `,
})
export class AppComponent {}

Expected output:

Why?

Since Angular v17 it is possible to specify an inline style with a single string rather than an array of strings. If specified as array prettier formats the css. If specified as string prettier does nothing with the css.

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:angularIssues affecting Angular template (not general JS/TS issues used for Angular)locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions