mysticatea / eslint-plugin-eslint-comments

Additional ESLint rules for directive comments of ESLint.
https://mysticatea.github.io/eslint-plugin-eslint-comments/
MIT License
354 stars 44 forks source link

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

Open iliubinskii opened 2 years ago

iliubinskii commented 2 years ago

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)

ota-meshi commented 2 years ago

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

iliubinskii commented 2 years ago

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.

ota-meshi commented 2 years ago

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.

iliubinskii commented 2 years ago

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.

MichaelDeBoey commented 8 months ago

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