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

no-regex-spaces false positive in character class #12226

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 rule Relates to ESLint's core rules

Comments

@mdjermanovic
Copy link
Member

Tell us about your environment

  • ESLint Version: 6.3.0
  • Node Version: 10.16.0
  • npm Version: 6.9.0

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

default

Please show your full configuration:

Configuration
module.exports = {
  parserOptions: {
    ecmaVersion: 2015,
  }
};

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

Demo link

/*eslint no-regex-spaces: "error"*/

/[  ]/.test("2"); // false
eslint index.js

What did you expect to happen?

No errors from the no-regex-spaces rule.

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

Error and invalid auto-fix to:

/*eslint no-regex-spaces: "error"*/

/[ {2}]/.test("2"); // true

Are you willing to submit a pull request to fix this bug?

Yes, I would love to try.

I guess this can't be solved properly without regexpp?

@mdjermanovic mdjermanovic added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Sep 5, 2019
@aladdin-add aladdin-add added accepted There is consensus among the team that this change meets the criteria for inclusion rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Sep 5, 2019
@mdjermanovic
Copy link
Member Author

I'm working on this

@platinumazure
Copy link
Member

Should this instead collapse down to one space and still report an error?

@mdjermanovic
Copy link
Member Author

Should this instead collapse down to one space and still report an error?

That would be a correct fix indeed :)

Though I don't think that's the intention of this rule, looks to me more like a case for a rule that would target duplicate characters in [], and also report [ a ], [11], maybe even [\d1].

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Mar 29, 2020
@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 Mar 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.