eslint-plugin-eslint-comments icon indicating copy to clipboard operation
eslint-plugin-eslint-comments copied to clipboard

[eslint-comments/no-use]: Allow "eslint-disable" only for selected rules (feature request)

Open iliubinskii opened this issue 3 years ago • 5 comments

Thx for the plugin.

Is it possible to add "allowEslintDisable" setting that will accept an array of rule names?

Motivation: Consider "vue/no-bare-strings-in-template" rule that requires that all strings inside template are taken from language file. Imagine that you have a static untranslated page (e.g. privacy, etc). In this case, you want to disable "vue/no-bare-strings-in-template" rule for the entire file. However you may not want to allow global disabling for all other rules. In this case "allowEslintDisable" option may be helpful.

Similar settings may be added for other allowed syntaxes (e.g. eslint-disable-next-line)

iliubinskii avatar Jun 20 '22 06:06 iliubinskii

Hi. I think you can allow /*eslint-disable*/ with no-use and use no-restricted-disable.

{
    "no-restricted-disable": [
        "error",
        "*",
        "!vue/no-bare-strings-in-template"
    ]
}

https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-restricted-disable.html

ota-meshi avatar Jun 20 '22 08:06 ota-meshi

Hi, thx for the hint.

First, I tried to use "no-restricted-disable" and it works for rules without slash:

"eslint-comments/no-restricted-disable": [
      "warn",
      "*",
      "!no-console"
    ],

but does not work for rules with slash (e.g. "vue/no-bare-strings-in-template")

Second, "no-restricted-disable" disallows disabling rule altogether. What I want is to restrict which rule can be disabled for entire file, while allowing any rule to be disabled per line.

iliubinskii avatar Jun 20 '22 09:06 iliubinskii

but does not work for rules with slash (e.g. "vue/no-bare-strings-in-template")

I did not know that 😅

What I want is to restrict which rule can be disabled for entire file, while allowing any rule to be disabled per line.

Does that mean that you want to set the rules that can be used with eslint-disable and the rules that can be used with eslint-disable-next-line separately? If so, that may not be possible now.

ota-meshi avatar Jun 20 '22 10:06 ota-meshi

Does that mean that you want to set the rules that can be used with eslint-disable and the rules that can be used with eslint-disable-next-line separately?

Yes. I prefer eslint-disable to be allowed only for selected rules, while eslint-disable-next-line can be allowed for all rules. I hope this makes sence.

If so, that may not be possible now.

I see that. This is why I am suggesting new feature.

iliubinskii avatar Jun 20 '22 10:06 iliubinskii

Hi @iliubinskii!

Since this repo is unmaintained, you might want to re-open this issue in the @eslint-community fork https://github.com/eslint-community/eslint-plugin-eslint-comments

For more info about why we created this organization, you can read https://eslint.org/blog/2023/03/announcing-eslint-community-org

MichaelDeBoey avatar Oct 14 '23 15:10 MichaelDeBoey