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

Config schemas are enforced for disabled rules #7690

Closed
not-an-aardvark opened this issue Dec 4, 2016 · 0 comments
Closed

Config schemas are enforced for disabled rules #7690

not-an-aardvark opened this issue Dec 4, 2016 · 0 comments
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly core Relates to ESLint's core APIs and features

Comments

@not-an-aardvark
Copy link
Member

not-an-aardvark commented Dec 4, 2016

Tell us about your environment

  • ESLint Version: master
  • Node Version: 7.2.0
  • npm Version: 3.10.9

What parser (default, Babel-ESLint, etc.) are you using?

default

Please show your full configuration:

(n/a)

What did you do? Please include the actual source code causing the issue.

I created a rule with a required schema, like this:

// "example-rule"
module.exports = {
    meta: {
        schema: {
            // At least one option must be provided
            type: "array",
            minItems: 1
        }
    },
    create(context) {}
};

I ran the rule on some code in foo.js with three different sets of options:

eslint foo.js --rule 'example-rule: [error, 4]' # case 1
eslint foo.js --rule 'example-rule: error'      # case 2
eslint foo.js --rule 'example-rule: off'        # case 3

What did you expect to happen?

In Case 1, I expected ESLint to run to completion without reporting an error, because a valid schema was provided.

In Case 2, I expected ESLint to report a schema error, because an invalid schema was provided (it was missing an option).

In Case 3, I expected ESLint to run to completion without reporting an error. The rule is disabled, so I shouldn't have to provide a schema while disabling it (e.g. example-rule: [off, 4])

What actually happened? Please include the actual, raw output from ESLint.

ESLint worked as expected in Case 1 and Case 2, but it reported a schema error in case 3.

eslint foo.js --rule 'example-rule: off'
CLI:
	Configuration for rule "example-rule" is invalid:
	Value "" has less items than allowed.

Error: CLI:
	Configuration for rule "example-rule" is invalid:
	Value "" has less items than allowed.

    at Object.validateRuleOptions (/path/to/eslint/lib/config/config-validator.js:115:15)
    at CLIEngine.Object.keys.forEach.name (/path/to/eslint/lib/cli-engine.js:476:19)
    at Array.forEach (native)
    at new CLIEngine (/path/to/eslint/lib/cli-engine.js:475:43)
    at Object.execute (/path/to/eslint/lib/cli.js:169:28)
    at process.stdin.pipe.text (/path/to/eslint/bin/eslint.js:59:32)
    at ConcatStream.<anonymous> (/path/to/eslint/node_modules/concat-stream/index.js:36:43)
    at emitNone (events.js:91:20)
    at ConcatStream.emit (events.js:185:7)
    at finishMaybe (/path/to/eslint/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js:475:14)

@not-an-aardvark not-an-aardvark added accepted There is consensus among the team that this change meets the criteria for inclusion bug ESLint is working incorrectly core Relates to ESLint's core APIs and features labels Dec 4, 2016
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly core Relates to ESLint's core APIs and features
Projects
None yet
Development

No branches or pull requests

1 participant