Add pure css parser (#7933)

This commit is contained in:
fisker Cheung authored and GitHub committed 2020-08-28 13:07:49 +08:00
1 parent c85ff01ede
commit 589ebf670b
14 files changed
+92 -22

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
#### [BREAKING] Add pure css parser ([#7933](https://github.com/prettier/prettier/pull/7933) by [@fisker](https://github.com/fisker))
Previously when `--parser=css` passed, we try `postcss-scss`/`postcss-less` to parse content, this cause confusion, and hard to check syntax error. Now `--parser=css` only works on css syntax.
_If you're setting `parser="css"` for your `.less`/`.scss` file, you'll need update it to correct parser, or let prettier decide._
<!-- prettier-ignore -->
```less
/* Input */
/* Less Syntax with `--parser=css` */
a {.bordered();}
/* Prettier stable */
/* Less Syntax with `--parser=css` */
a {
.bordered();
}
/* Prettier master */
SyntaxError: (postcss) CssSyntaxError Unknown word (2:4)
1 | /* Less Syntax with `--parser=css` */
> 2 | a {.bordered();}
```
<!-- prettier-ignore -->
```scss
/* Input */
/* Scss Syntax with `--parser=css` */
::before {content: #{$foo}}
/* Prettier stable */
/* Scss Syntax with `--parser=css` */
::before {
content: #{$foo};
}
/* Prettier master */
SyntaxError: (postcss) CssSyntaxError Unknown word (2:22)
1 | /* Scss Syntax with `--parser=css` */
> 2 | ::before {content: #{$foo}}
```