Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
iliubinskii opened this issue Jun 20, 2022 · 5 comments

Comments

@iliubinskii
Copy link

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
Copy link
Contributor

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
Copy link
Author

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
Copy link
Contributor

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
Copy link
Author

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 iliubinskii changed the title [eslint-comments/no-use]: Allow "eslint-disable" only for selected rules [eslint-comments/no-use]: Allow "eslint-disable" only for selected rules (feature request) Jun 20, 2022
@MichaelDeBoey
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants