Stylelint输出不显示发生警告的文件的名称 设置

运行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
  }
}
guxiaoke0510 回答:Stylelint输出不显示发生警告的文件的名称 设置

您需要add a reporter to your PostCSS pipeline

stylelint插件通过PostCSS注册警告。因此,您需要将其与用于打印警告的PostCSS运行程序或另一个用于格式化和打印警告的PostCSS插件一起使用(例如postcss-reporter)。

例如:

module.exports = {
  plugins: {
    autoprefixer: {},stylelint: {},'postcss-reporter': { clearReportedMessages: true }
  },}

或者,您可以使用official webpack plugin for stylelint

本文链接:https://www.f2er.com/2702083.html

大家都在问