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

An array is unexpectedly regarded as a valid ESLint severity #5499

Closed
shinnn opened this issue Mar 7, 2016 · 5 comments · Fixed by #5527
Closed

An array is unexpectedly regarded as a valid ESLint severity #5499

shinnn opened this issue Mar 7, 2016 · 5 comments · Fixed by #5527
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

@shinnn
Copy link
Contributor

shinnn commented Mar 7, 2016

What version of ESLint are you using?

v2.3.0

What configuration and parser (Espree, Babel-ESLint, etc.) are you using?

Default parser

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

This is an extremely rare case, but a user may carelessly fill an ESLint severity value with an array of the string like below:

const CLIEngine = require('eslint').CLIEngine;

new CLIEngine({
  useEslintrc: false,
  rules: {
    'comma-dangle': [['error'], 'never']
  }
});

What did you expect to happen?

new CLIEngine(...) should throw an error because ['error'] is, of course, not a valid severity according to the doc.

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

new CLIEngine(...) doesn't throw any errors, because,

  1. /^(?:off|warn|error)$/i.test(severity) always stringify non-string severity before testing.
  2. String(['error']) returns 'error'. Unfortunately, that also matches /^(?:off|warn|error)$/i.

We should do stricter type checking for severity to fix this unexpected behavior. I can create a pull request for this issue.

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Mar 7, 2016
@ilyavolodin ilyavolodin 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 and removed triage An ESLint team member will look at this issue soon labels Mar 7, 2016
@ilyavolodin
Copy link
Member

Looks like an oversight to me.

@BYK
Copy link
Member

BYK commented Mar 7, 2016

👍 for being more strict and throwing an error for this case.

@nzakas nzakas added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Mar 7, 2016
@nzakas
Copy link
Member

nzakas commented Mar 7, 2016

I suspect this code path isn't being run through the validator.

@shinnn
Copy link
Contributor Author

shinnn commented Mar 9, 2016

I've just started to implement strict severity checking.

shinnn added a commit to shinnn/is-eslint-severity that referenced this issue Mar 9, 2016
@shinnn
Copy link
Contributor Author

shinnn commented Mar 9, 2016

Submitted a PR. #5527

nzakas added a commit that referenced this issue Mar 11, 2016
Fix: validate the type of severity level (fixes: #5499)
@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

Successfully merging a pull request may close this issue.

5 participants