运行stylelint时,警告的输出不会显示错误发生所在的文件的名称(如果出现错误,它可以正常工作)。我的文件如下:
app.scss
@import './_file-with-error';
_file-with-error.scss
html body {
color: red;
}
body { // provocate an error ?
color: red;
}
我在构建时将Webpack Encore和stylelint用作PostCSS插件,
michael@machine:~$ yarn encore dev
yarn run v1.21.1
$ /var/www/html/mop/mop/node_modules/.bin/encore dev
Running webpack ...
WARNING Compiled with 1 warnings 11:47:14 PM
warning in ./assets/scss/app.scss
Module Warning (from ./node_modules/postcss-loader/src/index.js):
Warning
(5:1) Expected selector "body" to come before selector "html body" (no-descending-specificity)
Entrypoint app [big] = runtime.js vendors~app.js app.css app.js
Entrypoint home = runtime.js home.js
Entrypoint _tmp_copy = runtime.js
Done in 3.06s.
所以一切都很好,只是我看不到警告的来源,我需要文件名和行。我该如何配置?
设置
webpack.config.js
Encore.enablePostCssLoader();
postcss.config.js
module.exports = {
plugins: {
autoprefixer: {},stylelint: {},},};
.stylelintrc.json
{
"extends": "stylelint-config-standard","rules": {
"no-duplicate-selectors": null
}
}