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.

no-useless-escape is too aggressive

See original GitHub issue

Tell us about your environment

  • ESLint Version: 3.10.2
  • Node Version: 6.9.1
  • npm Version: 3.10.8

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

Please show your full configuration: eslint-config-standard 6.2.1

Specifically:

{
  "no-useless-escape": 2
}

What did you do? Please include the actual source code causing the issue.

/Expected property "1" of type \[Buffer\], got String "foobar"/

What did you expect to happen?

No error about a useless escape.

What actually happened? Please include the actual, raw output from ESLint.

Unnecessary escape character: \]. (no-useless-escape)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:10
  • Comments:25 (21 by maintainers)

github_iconTop GitHub Comments

3reactions
ferosscommented, Nov 25, 2016

@not-an-aardvark That solution (making the rule configurable to ignore particular useless escapes) would work for standard. Then we could configure it to ignore ) and ].

I still feel that this ought to be the default, because this looks incorrect and unbalanced:

/\[brackets]/
/\(parens)/

But I’ll defer to you and the other contributors on this.

2reactions
not-an-aardvarkcommented, Dec 29, 2016

) only needs to be escaped outside of character classes.

/)/; // syntax error

/\)/; // ok

/[)]/; // ok

/[\)]/; // useless escape
Read more comments on GitHub >

github_iconTop 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 >
Disable Unnecessary escape character: \/ no-useless-escape
Your regex will work fine if you escape the regular metacharacters inside a character class, but doing so significantly reduces readability.
Read more >
Improve Readability with ES6 Template Strings
This makes your string so much more readable, don't you think. If you use the eslint linter in your code, this is under...
Read more >
The Case Against the Death Penalty - ACLU
Capital punishment has been a useless weapon in the so-called "war on drugs." The attempt to reduce murders in the drug trade by...
Read more >
No Useless Mouth - eCommons@Cornell
Title: No useless mouth : waging war and fighting hunger ... have watched for escaped slaves so that they could capture them, black...
Read more >

github_iconTop Related Medium Post

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