stylelint: Unknown word CssSyntaxError in import inside script tag in vue file
Clearly describe the bug
CssSyntaxError unknown word in import inside script tag in vue file

Which rule, if any, is the bug related to?
What code is needed to reproduce the bug?
<script>
import {ref, nextTick, onBeforeUnmount, watch, inject} from 'vue';
</script>
What Stylelint configuration is needed to reproduce the bug?
Which version of Stylelint are you using?
e.g. 14.0.0
How are you running stylelint: CLI, PostCSS plugin, Node.js API?
VSCode via stylelint plugin
Does the bug relate to non-standard syntax (e.g. SCSS, Less etc.)?
What did you expect to happen?
“No warnings to be flagged.”
What actually happened (e.g. what warnings or errors did you get)?
CssSyntaxError unknown word in import inside script tag in vue file
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 19 (8 by maintainers)
Maybe, you may need to configure
customSyntax: "postcss-html"in your Stylelint config files. (see also the v14 migration guide)If you want to check Vue files, stylelint-config-recommended-vue may help you.
You’ll need to remove this line. You’re setting an empty Stylelint configuration object for VSCode. The default is
null, not{}.I was struggling with this after upgrading, and @ybiquitous is correct. Also, if you need to use multiple syntaxes (e.g. if you have both SCSS and HTML-like files), you can use the
overridesproperty as well.In my
.stylelintrc.jsfile I have the following:From what I understand,
postcss-syntaxmight be able to handle this, but I’ve already wasted enough time getting this to work so this is good enough for me lol.Oh my god. You are a literal angel. Thank you thank you thank you!
Same thing happens with commented lines Not sure if it’s the same issue 😕
We surface an error already for CLI, e.g.
Gives:
It seems the VS Code extension doesn’t surface the error, though. One for that issue tracker, I think.
No worries.
hello bro, What theme do u use? it is so nice.
Still having this issue in our year of the lord 2022. Having spent almost three hours looking through the docs for every extension and plugin, I’m not really sure what to do.
In vue3, I’m using vite-plugin-stylelint, which is included in vite.config. My stylelint config is as follows:
I’ve added ‘vue’ to stylelint.validate in the extension settings.
Unfortunately my components are still flagging vue syntax as unrecognised AND stylelint-order is picking up errors but not fixing them unless I run
npx stylelint --fix src/file/path, which is something that’s always been handled on save.If anyone can shed light on what I’m doing wrong, I will owe you my undying loyalty and my soul
Huh, I didn’t even see the migration guide, but still @ybiquitous without your comment I wouldn’t even find the vue config. Adding vue config fixed the issue in vue files and adding scss config fixed commented lines in scss files.