prettier/stylelint-prettier

[HELP] rules in stylelintrc conflict with prettierrc

max8hine opened this issue · 2 comments

Version:
prettier: 1.14.2
stylelint: 9.6.0
stylelint-prettier: 1.0.3
stylelint-config-prettier: 4.0.0

.stylelintrc

{
  "extends": [
    "stylelint-config-recommended",
    "stylelint-prettier/recommended"
  ]
}

.prettierrc

{
  "singleQuote": true,
}

What source code are you linting?

.alter:after {
  color: red;
  content: "example"; // <-- want to enable double quotes
}

What did you expect to happen?
should not remove the double quotes in CSS string on editor save.

What actually happened?
removed double quotes in CSS sting on editor save, and added single quotes. I guess that .prettierrc has a rule single quote: true that actually for Javascript files.

questions
Is there a way to add rules for stylelint-prettier that enable double quotes?

j-f1 commented

You can add an overrides section to your Prettier config.

Hi @max8hine,

stylelint-config-prettier disables any stylelint rules that may conflict with prettier's formatting of the files. Prettier shall format your css files based upon the settings in your prettierrc. In this case it is honoring your singleQuotes setting.

If you want to use different prettier settings for different file types then you can use overrides as @j-f1 says. Change your .prettierrc to the following if you want to use single quotes for all files except css files:

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

Please let me know if that resolves your issue so I we can close this issue