no-useless-escape false negative
See original GitHub issueTell us about your environment
- ESLint Version: 3.12.2
- Node Version: 7.2.1
- npm Version: 3.10.10
What parser (default, Babel-ESLint, etc.) are you using?
default
Please show your full configuration: n/a, no configuration file
What did you do? Please include the actual source code causing the issue.
Running eslint --no-eslintrc --rule 'no-useless-escape: 2' test.js
with the contents of `test.js being:
/\{/
Also same results with this more complete example:
console.log(/\{/.test('{')); // true
console.log(/{/.test('{')); // also true
What did you expect to happen?
I expected to be told that {
was being uselessly escaped on line 1.
What actually happened? Please include the actual, raw output from ESLint.
No error reported. This issue also applies to /\}/
.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
no-useless-escape - 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 >eslint: false positive no-useless-escape : r/reactjs - Reddit
But eslint saying that I do not need backslash, but without backslash it will be not "non-space" but S. React version is 16.12.0....
Read more >Disable Unnecessary escape character: \/ no-useless-escape
I have this regex of mine that will check the string if it contains link or url (i.e. https://eslint.org/docs/rules/no-useless-escape) . Using ...
Read more >regexp/no-useless-escape
regexp/no-useless-escape #. disallow unnecessary escape characters in RegExp. ⚙️ This rule is included in "plugin:regexp/recommended" .
Read more >Practices of Science: False Positives and False Negatives
This is a false positive. This can lead to unnecessary medical treatment. On the other hand a false negative is when the test...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Actually, after looking at the spec I’m not sure this is a bug – see this comment for more explanation.
/{/
is only a legal regex for engines that implement Annex B, a part of the spec which is only normative for engines in web browsers. So/\{/
is only a useless escape on engines that implement Annex B, which might not apply to all engines.Closing this issue – as described above,
/\{/
is only a useless escape for engines that implement Annex B, but it’s not useless for JS engines in general.