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

Suggested fix for no-div-regex trips no-useless-escape #11355

Closed
coreyfarrell opened this issue Feb 4, 2019 · 7 comments · Fixed by #11744 · May be fixed by Omrisnyk/npm-lockfiles#130
Closed

Suggested fix for no-div-regex trips no-useless-escape #11355

coreyfarrell opened this issue Feb 4, 2019 · 7 comments · Fixed by #11744 · May be fixed by Omrisnyk/npm-lockfiles#130
Assignees
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 good first issue Good for people who haven't worked on ESLint before rule Relates to ESLint's core rules

Comments

@coreyfarrell
Copy link

Tell us about your environment

  • ESLint Version: 5.13
  • Node Version: 10.15.0
  • npm Version: 6.4.1

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

Please show your full configuration:

Configuration
{
	"rules": {
		"no-div-regex": "error",
		"no-useless-escape": "error"
	}
}

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

console.log('test=='.replace(/=*$/, '')); // no-div-regex error
console.log('test=='.replace(/\=*$/, '')); // no-useless-escape error
console.log('test=='.replace(/[=]*$/, '')); // accepted by both rules
eslint script.js

What did you expect to happen?
no-div-regex should suggest replacing /=foo/ with /[=]foo/ to avoid no-useless-escape error. Alternatively no-useless-escape could accept an ignoreDivRegex boolean option to allow /\=foo/.

Are you willing to submit a pull request to fix this bug?
I'm sure I can handle the documentation approach of suggesting /[=]foo/. I'm not confident I can create the no-useless-escape option to ignore div regex.

@coreyfarrell coreyfarrell added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Feb 4, 2019
@xianghongai
Copy link

xianghongai commented Feb 21, 2019

no-useless-escape, Unnecessary escape character: [.

name = name.replace(/[\[\]]/g, "\\$&");

@eslint-deprecated eslint-deprecated bot added the auto closed The bot closed this issue label Mar 24, 2019
@eslint-deprecated
Copy link

Unfortunately, it looks like there wasn't enough interest from the team
or community to implement this change. While we wish we'd be able to
accommodate everyone's requests, we do need to prioritize. We've found
that issues failing to reach accepted status after 21 days tend to
never be accepted, and as such, we close those issues.
This doesn't mean the idea isn't interesting or useful, just that it's
not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

@platinumazure
Copy link
Member

Oops, this slipped through the cracks. Sorry about that.

I think this is a bug and I think the best option is to have no-div-regex use [=] in its autofix. I'll reopen this and mark as accepted.

@coreyfarrell Would you be willing to submit a PR? If not, no worries, just wanted to see if you were still interested!

@platinumazure platinumazure reopened this Mar 24, 2019
@platinumazure platinumazure added rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion and removed auto closed The bot closed this issue triage An ESLint team member will look at this issue soon labels Mar 24, 2019
@platinumazure platinumazure self-assigned this Mar 24, 2019
@coreyfarrell
Copy link
Author

@platinumazure thanks for responding. Unfortunately I don't currently have time to work on this and since xo has removed the no-div-regex this is no longer as issue for me.

@platinumazure
Copy link
Member

No worries, thanks for getting back to me so fast!

@platinumazure platinumazure added the good first issue Good for people who haven't worked on ESLint before label Mar 24, 2019
@SalsabeelQandeel
Copy link

I can work on this one, Is it available?

@platinumazure
Copy link
Member

Hi @SalsabeelQandeel, feel free to work on this. Thanks!

kaicataldo pushed a commit that referenced this issue May 25, 2019
Adding fixer for no-div-regex-rule and use [=] instead of \= as suggestion to avoid conflicting with no-useless-escape error.
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Nov 22, 2019
@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 Nov 22, 2019
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 good first issue Good for people who haven't worked on ESLint before rule Relates to ESLint's core rules
Projects
None yet
4 participants