【问题标题】:How can I suppress the "No files matching the pattern" message in ESLint?如何抑制 ESLint 中的“没有与模式匹配的文件”消息?
【发布时间】:2019-06-29 18:47:09
【问题描述】:

在我的 CI 设置中,我有一个针对所有 JS 文件运行 eslint 的测试。如果不存在 JS 文件,则当前正在引发错误。如果没有 JS 文件存在,我希望它成功。这可能吗?

$ eslint "./src/assets/scripts/**/*.js"

Oops! Something went wrong! :(

ESLint: 5.7.0.
No files matching the pattern "./src/assets/scripts/**/*.js" were found.
Please check for typing mistakes in the pattern.

ERROR: Job failed: exit code 1

【问题讨论】:

  • 如果所述文件存在,只调用 eslint 怎么样?
  • 我想我可以为此写点东西,我没想到会这样。
  • ESLint: 6.8.0 但错误仍然存​​在。

标签: continuous-integration eslint


【解决方案1】:

对我有用的是changing single quotes to escaped double quotes

所以来自:

"lint": "eslint '**/*.{ts,tsx}'"

收件人:

"lint": "eslint \"**/*.{ts,tsx}\""

原因是因为它取决于您使用的控制台 - 可能是操作系统(这就是为什么它可以为您工作而对其他人不起作用,反之亦然)来源:https://dev.to/gruckion/comment/b65c

【讨论】:

  • 为我工作!谢谢。 @Sebastian Voráč
  • 谢谢哥们,帮了大忙
  • 这在 Windows 中对我有用
【解决方案2】:

--no-error-on-unmatched-pattern 标志被添加到 ESLint 的 v6.8.0 中。

https://eslint.org/docs/user-guide/command-line-interface#no-error-on-unmatched-pattern

【讨论】:

  • 谢谢。完美运行。
  • 这只是在发生不匹配模式时隐藏错误。我在下面建议我的解决方案。
【解决方案3】:

能够挖掘this closed issue on ESLint's GitHub。听起来这是一个常见问题,没有好的解决方法,除了在尝试 lint 之前手动检查文件是否存在,正如@user2864740 所建议的那样

【讨论】:

    猜你喜欢
    • 2022-06-10
    • 2018-12-31
    • 2017-11-26
    • 1970-01-01
    • 2020-06-06
    • 2019-02-19
    • 2023-03-21
    • 2019-10-11
    • 1970-01-01
    相关资源
    最近更新 更多