prettier/stylelint-prettier

Ignored vue file style block?

ModyQyW opened this issue · 3 comments

What version of stylelint, prettier and stylelint-prettier are you using?

  • stylelint: 15.10.2
  • prettier: 3.0.2
  • stylelint-prettier: 4.0.2
  • node: 18.16.0
  • npm: 9.5.1

Please paste any applicable config files that you're using (e.g. .prettierrc or .stylelintrc files)

No prettier config files.

.stylelintrc.json:

{
  "extends": [
    "stylelint-config-html",
    "stylelint-config-recommended",
    "stylelint-config-recommended-vue",
    "stylelint-prettier/recommended"
  ],
  "rules": {
    "at-rule-no-unknown": null
  }
}

What source code are you linting?

<style>
.insert {
  display: block
}

.alter:after {color: red; content: 'example'}

.delete {
  display: block;;
}
</style>

What did you expect to happen?

Output like README.

What actually happened?

Nothing happened.

Repo

https://github.com/ModyQyW/stylelint-prettier-322

npm install
npm run stylelint

If I run npm run prettier, I can see the output is correct. So I think it is caused by stylelint-prettier.

This appears to be intentional, see

// Stylelint supports languages that may contain multiple types of style
// languages, thus we can't rely on guessing the parser based off the
// filename.
// In all of the following cases stylelint extracts a part of a file to
// be formatted and there exists a prettier parser for the whole file.
// If you're interested in prettier you'll want a fully formatted file so
// you're about to run prettier over the whole file anyway.
// Therefore running prettier over just the style section is wasteful, so
// skip it.
const parserBlockList = [
'babel',
'flow',
'typescript',
'vue',
'markdown',
'html',
'angular', // .component.html files
'svelte',
];

I totally miss that. Thanks for pointing it out!

However, I think it is depressing. I have to run stylelint and prettier separately. Hope we can improve this. 🫡