【问题标题】:eslint-disable does not suppress errors for the unicorn/filename-case eslint ruleeslint-disable 不会抑制 unicorn/filename-case eslint 规则的错误
【发布时间】:2021-11-14 11:44:40
【问题描述】:

我有一个名为

的文件
payment-shipping.tsx

eslint 报错

Filename is not in camel case. Rename it to `paymentShipping.tsx`  unicorn/filename-case

但是,该文件需要采用 kebab 格式,因为它是显示在 URL 中的 next.js 页面。

将以下行添加到所述文件的顶部:

// eslint-disable-next-line unicorn/filename-case

不抑制错误,而是抛出另一个错误:

'unicorn/filename-case' rule is disabled but never reported        eslint-comments/no-unused-disable

如何抑制文件名大小写错误?

【问题讨论】:

    标签: javascript typescript next.js eslint typescript-eslint


    【解决方案1】:

    您可以使用该规则的ignore 选项。

    .eslintrc

    ...
    rules: {
        ...
        "unicorn/filename-case": [
           "error",
           {
               "case": "kebabCase",
               "ignore": [
                   /pages/.*\.js$/
               ]
           }
        ]
    }
    ...
    

    【讨论】:

    • 感谢我,特别是 "src/pages/**/*.tsx" 工作。双星号捕获所有递归文件夹..
    猜你喜欢
    • 2020-09-26
    • 2020-08-27
    • 2020-10-01
    • 2016-06-20
    • 2020-11-04
    • 2020-08-13
    • 1970-01-01
    • 2019-09-07
    • 1970-01-01
    相关资源
    最近更新 更多