Files
test-repo/changelog_unreleased/css/7933.md
T

1.2 KiB

[BREAKING] Add the pure css parser (#7933, #9092, #9093 by @fisker)

Previously, when --parser=css was passed, Prettier tried to parse the content using postcss-scss and postcss-less. This caused confusion, and made syntax errors difficult to spot. Now --parser=css works only with the vanilla CSS syntax.

If you use parser="css" for your .less/.scss files, update it to the correct parser or remove the parser option to let Prettier auto-detect the parser by the file extension.

/* Input */
/* Less Syntax with `--parser=css` */
a {.bordered();}

/* Prettier stable */
/* Less Syntax with `--parser=css` */
a {
  .bordered();
}

/* Prettier main */
SyntaxError: (postcss) CssSyntaxError Unknown word (2:4)
  1 | /* Less Syntax with `--parser=css` */
> 2 | a {.bordered();}
/* Input */
/* Scss Syntax with `--parser=css` */
::before {content: #{$foo}}

/* Prettier stable */
/* Scss Syntax with `--parser=css` */
::before {
  content: #{$foo};
}

/* Prettier main */
SyntaxError: (postcss) CssSyntaxError Unknown word (2:22)
  1 | /* Scss Syntax with `--parser=css` */
> 2 | ::before {content: #{$foo}}