【问题标题】:StyleLint - Ignore specific folders and filesStyleLint - 忽略特定的文件夹和文件
【发布时间】:2019-10-18 06:22:45
【问题描述】:

我在 Webpack 中使用 StyleLint。

我当前的 Webpack 配置是:

module.exports.styleLint = (isProd = false) => {
  const options = {
    configFile: './.stylelintrc.json',
    files: '**/*.less',
    format: 'less',
    failOnError: false,
    quiet: false,
    emitErrors: isProd
  };
  return new StyleLintPlugin(options);
};

如何指定 StyleLint 忽略的一些文件夹或文件(我不想在输出中看到任何错误)?

注意:

我不想添加

/* stylelint-disable */

在这些文件中。

【问题讨论】:

    标签: webpack stylelint


    【解决方案1】:

    我在 stylelint 配置文件中使用了如下配置:

    {
        "extends": "stylelint-config-recommended",
        "ignoreFiles": [
            "app/bootstrap/**/*.less"
        ]
    }
    

    它跳过了指定文件夹中的文件。

    【讨论】:

      【解决方案2】:

      另一种使用 stylelint 排除某些内容的方法是使用 .stylelintignore 文件。


      正如documentation 所说:

      您可以使用 .stylelintignore 文件来忽略特定文件。例如:

      **/*.js
      vendor/**/*.css
      

      .stylelintignore 文件中的模式必须匹配 .gitignore 语法。 (在幕后,node-ignore 会解析您的模式。)您在 .stylelintignore 中的模式总是相对于 process.cwd() 进行分析。

      stylelint 在 process.cwd() 中查找 .stylelintignore 文件。您还可以使用 --ignore-path(在 CLI 中)和 ignorePath(在 JS 中)选项指定忽略模式文件的路径(绝对或相对于 process.cwd())。

      【讨论】:

      • 我对@9​​87654324@ 的配置不满意,但这很有效。
      猜你喜欢
      • 2020-06-19
      • 2018-05-18
      • 2014-02-05
      • 1970-01-01
      • 2019-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-01
      相关资源
      最近更新 更多