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

Recommended way to disable eslint rules #658

Closed
mmkal opened this issue Apr 7, 2022 · 2 comments · Fixed by #659
Closed

Recommended way to disable eslint rules #658

mmkal opened this issue Apr 7, 2022 · 2 comments · Fixed by #659

Comments

@mmkal
Copy link
Contributor

mmkal commented Apr 7, 2022

Hi there - I'm trying to set up a small simple project with xo, but there are a few rules that I'd like to disable. The docs say:

Globals and rules can be configured inline in files.

Is that the only way they can be configured? If so, does that mean that every file needs to have /* eslint-disable unicorn/no-array-for-each */ at the top of it? There's a stackoverflow answer that suggests there's a workaround, but can something be added to the docs to indicate whether this is a legit way to disable rules, and should be respected by the various tools like vscode plugins?

@spence-s
Copy link
Contributor

spence-s commented Apr 7, 2022

disable the rule in your xo configuration to turn it off globally in your project.
package.json

{
    "xo": {
        "rules": {
            "unicorn/no-array-for-each": "off"
        }
    }
}

You could also use .xo-config.json or one of the other config file formats supported by xo.


it's the same rule configuration for eslint - "off" is valid, [0] is valid, false is not.

@mmkal
Copy link
Contributor Author

mmkal commented Apr 8, 2022

Thank you @spence-s - I created a PR (#659) so that people/a forgetful me in the future don't need to guess this.

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

Successfully merging a pull request may close this issue.

2 participants