stylint loader for webpack
Install the stylint peerDependency
manually (only if you're using npm v3 or earlier)
npm install --save-dev stylint
Install stylint-loader
package
// webpack 1
npm install stylint-loader@1.x
// webpack 3+
npm install stylint-loader@latest
When using with stylus-loader
, make sure they are in correct order
module.exports = {
// ...
module: {
rules: [
{
test: /\.styl$/,
loader: 'stylint-loader'
},
{
test: /\.styl$/,
use: [
'style-loader',
'css-loader',
'stylus-loader'
]
}
]
}
// ...
}
To be safe, you can use preLoaders
section to check source files, not modified by stylus-loader
module.exports = {
// ...
module: {
rules: [
{
enforce: 'pre',
test: /\.styl$/,
loader: 'stylint-loader'
}
]
}
// ...
}
You can pass stylint options directly by
- Adding a query string to the loader for this loader usabe only
{
module: {
rules: [
{
test: /\.js$/,
loader: 'stylint-loader?{brackets: "never"}',
exclude: /node_modules/,
}
],
},
}
- Adding an
stylint
entry in your webpack config for global options:
plugins: [
new webpack.LoaderOptionsPlugin({
options: {
stylint: {
config: 'path/.stylintrc'
}
}
})
]
Note that you can use both method in order to benefit from global & specific options