-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Closed
Labels
acceptedThere is consensus among the team that this change meets the criteria for inclusionThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionThis issue has been archived; please open a new issue for any further discussionenhancementThis change enhances an existing feature of ESLintThis change enhances an existing feature of ESLintruleRelates to ESLint's core rulesRelates to ESLint's core rules
Description
What rule do you want to change?
prefer-regex-literals
What change to do you want to make?
Implement suggestions
How do you think the change should be implemented?
Other
Example code
/* eslint prefer-regex-literals: ["error", {"disallowRedundantWrapping": true}] */
const reg0 = new RegExp('a');
const reg1 = new RegExp(/a/); // no suggestion
const reg2 = new RegExp(/a/, 'g'); // no suggestion
What does the rule currently do for this code?
The rule didn't suggest for unnecessarily wrapped patterns which disallowed by "disallowRedundantWrapping": true
. demo
What will the rule do after it's changed?
It will make suggestions for the patterns also.
/* eslint prefer-regex-literals: ["error", {"disallowRedundantWrapping": true}] */
const reg1 = new RegExp(/a/); // => /a/
const reg2 = new RegExp(/a/, 'g'); // => /a/g
const reg3 = new RegExp(/a/g, 'i') // => /a/i
Participation
- I am willing to submit a pull request to implement this change.
Additional comments
No response
Metadata
Metadata
Assignees
Labels
acceptedThere is consensus among the team that this change meets the criteria for inclusionThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionThis issue has been archived; please open a new issue for any further discussionenhancementThis change enhances an existing feature of ESLintThis change enhances an existing feature of ESLintruleRelates to ESLint's core rulesRelates to ESLint's core rules
Type
Projects
Status
Complete