question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`prefer-regex-literals` suggestions

See original GitHub issue

What rule do you want to change?

prefer-regex-literals

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

No

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

Adds fixer

Please provide some example code that this change will affect:

new RegExp('\\.')

What does the rule currently do for this code?

Reports error

What will the rule do after it’s changed?

Fix it to:

/\./

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:28 (24 by maintainers)

github_iconTop GitHub Comments

2reactions
mdjermanoviccommented, Sep 13, 2021

Should RegExp(1) autofix to /1/? Currently, the prefer-regex-literals rule only detects strings.

No, if it isn’t reported then it shouldn’t be fixed. We could discuss in a separate issue whether or not this should be reported.

1reaction
ljharbcommented, Nov 30, 2021

There’s an open PR: #15077

Read more comments on GitHub >

github_iconTop Results From Across the Web

prefer-regex-literals - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
JavaScript: RegExp constructor vs RegEx literal - Stack Overflow
The literal is the best to use with known regular expressions, while the constructor is better for dynamically constructed regular expressions ...
Read more >
Prefer the usage of regular expression literals ... - DeepSource
When a regular expression is known in advance, it is considered a best practice to avoid the string literal notation on top of...
Read more >
Regular expressions - JavaScript - MDN Web Docs
Regular expression literals provide compilation of the regular expression when the script is loaded. If the regular expression remains constant, ...
Read more >
[Returned for Revision] SE-0354: Regex Literals - Swift Forums
Hi everyone, The review of SE-0354: Regex Literals ran from April 28 to ... implies agreement to the idea that terse syntax ==...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found