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

Prettier's parser why not just "css" #2

Closed
yangmingshan opened this issue Aug 30, 2018 · 5 comments
Closed

Prettier's parser why not just "css" #2

yangmingshan opened this issue Aug 30, 2018 · 5 comments

Comments

@yangmingshan
Copy link

Question

This plugin use prettier.getFileInfo to decide which parser to use. But this plugin is work with stylelint, so the parser maybe only need be css?

Problem

In China there is someting called miniProgram. It's style file use css syntax but use wxss as the extension. I want use this plugin in miniProgram, but Prettier don't know *.wxss file. If I told Prettier use css parser, it will work fine.

Or

If the parser can not just be css, maybe use css as default parser when inferredParser is null is a idea.


I'm happy to send a PR :)

@zhaoky
Copy link

zhaoky commented Aug 30, 2018

I met this problem,too

@BPScott
Copy link
Member

BPScott commented Sep 5, 2018

Sorry for the long wait for a reply. I did not realize I was not watching my own repo. That has now been fixed.

Thank you both for your interest in stylelint-prettier.

Prettier and Stylelint both supports multiple css syntaxes - css, scss, sass, less. Each of these syntaxes have their own parser. If I were to tell prettier to always use the css parser then for example, it would never use the scss parser for scss files and thus scss-specific functionality such as formatting maps would not work.


You can teach Prettier to use a particular parser for a file extension it does not already know about by using configuration overrides.

Adding the following to your .prettierrc should tell it to use the css parer for .wxss files

{
  "overrides": [
    {
      "files": "*.wxss",
      "options": { "parser": "css" }
    }
  ]
}

Because stylelint-prettier reads prettier's config I would expect that these files would then be checked using the css parser within prettier.

I'll leave this issue open for now. Could you please let me know if specifying the overrides in your .prettierrc works for you?

@BPScott
Copy link
Member

BPScott commented Sep 5, 2018

I have just released v1.0.1 that works with configuration overrides. Please try it out with the above code and let me know if it solves your issue.

@zhaoky
Copy link

zhaoky commented Sep 6, 2018

thanks!

@yangmingshan
Copy link
Author

Problem solved, thanks

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