Search code examples
typescriptsassprettier

Run prettier on ts and scss files


I am trying to configurate my prettier for typescript and scss files

I have have the following .pretterrc file:

{
    "printWidth": 100,
    "parser": "typescript",
    "tabWidth": 2,
    "semi": true,
    "singleQuote": true,
    "trailingComma": "all",
    "bracketSpacing": true,
    "jsxBracketSameLine": true,
    "arrowParens": "avoid"
}

When running my prettier it errors on the scss files:

SyntaxError: Expression expected. (1:2)
[error] > 1 | @import 

When I change the parser to "parser": "scss" then prettier errors on my ts files.

How can I run Prettier on all my files?


Solution

  • You need to remove the parser option.

    If you use VSCode, you need to install the extension.

    Prettier will automatically detect which language you are using.