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

linter.verify does not validate rule configs #8325

Closed
not-an-aardvark opened this issue Mar 26, 2017 · 3 comments
Closed

linter.verify does not validate rule configs #8325

not-an-aardvark opened this issue Mar 26, 2017 · 3 comments
Labels
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 evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion

Comments

@not-an-aardvark
Copy link
Member

Tell us about your environment

  • ESLint Version: master
  • Node Version: 7.7.4
  • npm Version: 4.1.2

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

require("eslint").linter.verify("foo", {
    rules: {
        "no-restricted-properties": ["error", "foo"]
    }
});

What did you expect to happen?

I expected core to throw a config validation error. Note that ["foo"] is not a valid config for the no-restricted-properties rule, which accepts a list of objects.

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

ESLint returns an empty array (i.e. reports no problems). The no-restricted-properties rule gets run with a string option, violating its schema invariant. (no-restricted-properties happens to handle this gracefully and report no errors, but some other rules crash when this happens.)

I'm pretty sure this is a bug -- although linter doesn't get configs from the filesystem, it seems like it should still preserve invariants for rules by throwing an error rather than having undefined behavior when a config is invalid.

@not-an-aardvark not-an-aardvark added bug ESLint is working incorrectly core Relates to ESLint's core APIs and features evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Mar 26, 2017
@ilyavolodin
Copy link
Member

I'm not sure it would be a good idea to validate config in linter. Doing that would validate config for every single file that you lint, vs. validating actual config. I think this could affect performance in a significant way.

@platinumazure
Copy link
Member

In addition to @ilyavolodin's comments, I also feel that config validation would violate single responsibility principle for the linter object and so it wouldn't make sense architecturally.

@not-an-aardvark
Copy link
Member Author

It seems like this is working as intended, so I'll close it. I had opened it because I thought it was unintended behavior (seems like we shouldn't expose an API that allows rules to be passed an invalid schema).

@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
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 evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion
Projects
None yet
Development

No branches or pull requests

3 participants