Search code examples
javascripttypescriptnext.jseslinttypescript-eslint

eslint-disable does not suppress errors for the unicorn/filename-case eslint rule


I have a file called

payment-shipping.tsx

and eslint is throwing an error

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

However, the file needs to be in kebab case since it's a next.js page that shows up in the URL.

Adding the following line to the top of said file:

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

Does not suppress the error, it instead throws another error:

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

How do I suppres the filename-case error?


Solution

  • You can use ignore option of that rule.

    .eslintrc

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