xojs/xo

Recommended way to disable eslint rules

mmkal opened this issue · 2 comments

mmkal commented

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?

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 commented

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