-
Notifications
You must be signed in to change notification settings - Fork 919
A nice way to lint .vue
files with Stylelint?
#303
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
Comments
I think is possible to do it with htmlhint, but currently only supports jshint and csslint, maybe if someone can make a htmlhint rule for stylelint. |
Actually we could use |
npm i stylelint -D
npm i stylelint-processor-html -D
npm i stylelint-config-standard -D
|
@yisibl that works for me, swear i tried this before! |
I'm wondering if there's a way to get stylelint to report this to sublimelinter, although it works great from the command line, it doesn't work actively while typing in sublime. Have you or anyone else had any luck with that? Also, @yisibl thanks for posting this, helped me get started. |
For the record, this is working configuration for webpack:
npm i --save-dev stylelint stylelint-processor-html stylelint-config-standard stylelint-webpack-plugin
{
"processors": ["stylelint-processor-html"],
"extends": "stylelint-config-standard"
}
//...
var StylelintPlugin = require('stylelint-webpack-plugin')
{
//...
plugins: [
//...
new StylelintPlugin({
files: ['**/*.vue']
})
]
} I published an article which includes both solutions and explains two additional things (configuration rules and errors when starting the dev server). |
@bkzl i follow your config, use the |
@wenkanglin I immediately fix these errors while I code so I didn't even notice that. There is a corresponding issue: ccbikai/stylelint-processor-html/issues/1 |
try |
Can not add single quotation marks in windows. Otherwise it will report the following error.
The following setting worked well in windows 10
|
|
Issue moved to vuejs/011.vuejs.org #6 via ZenHub |
Using the @yisibl solution i can't make it works using postcss. |
@equinusocio The latest version of stylelint can directly support npm i --save postcss postcss-syntax postcss-html postcss(plugins).process(source, {
syntax: require('postcss-syntax')
}).then((result) => {
// An alias for the result.css property. Use it with syntaxes that generate non-CSS output.
result.content
}); |
@gucong3000 Thank you man. This did the trick. There is a documentation somewhere about that? |
Not at the moment. |
@gucong3000 Hi, I cannot get stylelint autofix to work with .vue files? Any idea why? |
@hiendv please update stylelint --fix `src/**/*.vue` |
|
@gucong3000 This solution doesn't works anymore postcss.config.js module.exports = {
syntax: require("postcss-syntax"),
plugins: {
"postcss-preset-env": {
stage: 0,
autoprefixer: {
grid: true
}
}
}
}; Defining the |
@equinusocio |
After trying many things, I got stylelint autofix to work with .vue files in vscode using SaveOnRun extension.
Better solution would be appreciated! |
@mudin good job, saved the day |
Hey guys, can you help me?
|
I noticed this was attempted: vuejs-templates/webpack#154 and closed (For good reason)
But i wondered if anyone has a setup for this currently?
The text was updated successfully, but these errors were encountered: