Skip to content

prefer-regex-literals: should report regex literals passed to RegExp constructor #12840

@lo1tuma

Description

@lo1tuma

What rule do you want to change?

prefer-regex-literals

Does this change cause the rule to produce more or fewer warnings?

It will produce more warnings.

How will the change be implemented? (New option, new default behavior, etc.)?

I think this makes sense as default behavior.

Please provide some example code that this change will affect:

const foo = new RegExp(/foo/);

What does the rule currently do for this code?

It is not recognized as a problem.

What will the rule do after it's changed?

The rule should report this as problem and suggest the following autofix:

-const foo = new RegExp(/foo/);
+const foo = /foo/;

Are you willing to submit a pull request to implement this change?

Yes

Metadata

Metadata

Assignees

Labels

acceptedThere 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 discussionenhancementThis change enhances an existing feature of ESLintruleRelates to ESLint's core rules

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy