Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HELP] rules in stylelintrc conflict with prettierrc #9

Closed
max8hine opened this issue Oct 31, 2018 · 2 comments
Closed

[HELP] rules in stylelintrc conflict with prettierrc #9

max8hine opened this issue Oct 31, 2018 · 2 comments

Comments

@max8hine
Copy link

max8hine commented Oct 31, 2018

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
Copy link
Member

j-f1 commented Nov 1, 2018

You can add an overrides section to your Prettier config.

@BPScott
Copy link
Member

BPScott commented Nov 1, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants