Prettier-atom: Different config options for CSS vs JS

Created on 18 Oct 2017  路  9Comments  路  Source: prettier/prettier-atom

I may be completely in the minority here (feel free to close this if I am), but I prefer different config options when using prettier for JS compared to CSS. Specifically, I prefer single quotes in JS, but double quotes in CSS. I would like it if I could somehow configure this option differently for the two file types.

discussion

Most helpful comment

I overrode an scss option like this and it works perfectly:

{
    "singleQuote": true,
    "overrides": [
        {
            "files": "*.scss",
            "options": {
                "singleQuote": false
            }
        }
    ]
}

All 9 comments

@keithjgrant You can add a .prettierrc file to do this using overrides: https://github.com/prettier/prettier#configuration-overrides

Awesome! thanks

I haven鈥檛 been able to get this to work. I鈥檝e added a .prettierrc at the root of my project, with the following content:

{
  "singleQuote": false
}

I鈥檝e also tried adding a prettier key to my package.json:

  "prettier": {
    "overrides": [
      {
        "files": "src/css/**/*.css",
        "options": {
          "singleQuote": false
        }
      }
    ]
  }

In both cases, it still changes quotes to single quotes, according to my configuration in the plugin Settings.

@keithjgrant Are you using the eslint integration as well? If so, can you try turning it off and seeing if it makes a difference? Also, can you make sure you have the latest version of prettier in your node modules?

I overrode an scss option like this and it works perfectly:

{
    "singleQuote": true,
    "overrides": [
        {
            "files": "*.scss",
            "options": {
                "singleQuote": false
            }
        }
    ]
}

@keithjgrant Do know that due to #270, you'll need to reload Atom after adding your prettier configuration. Sorry about that!

Is there a way to use single quotes in Javascript and double quotes in styled components?
They are both in a .js file.

I don鈥檛 think so.

@charlestati Yes, if you're willing to name files with styled components a bit differently, like file.sc.js and agree to put there only SC-related code.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jonyyz picture jonyyz  路  6Comments

Andersos picture Andersos  路  6Comments

jjwyse picture jjwyse  路  5Comments

saadq picture saadq  路  3Comments

iamphill picture iamphill  路  5Comments