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 false positives on JSX strings

See original GitHub issue

This is a JSX issue, but since it’s in eslint/no-useless-escape I thought it would be appropriate to file here.

What version of ESLint are you using? 2.8.0

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

Please show your full configuration: It’s super long but these should be enough,

module.exports = {

  // base off Airbnb Javascript Style Guide
  // https://github.com/airbnb/javascript
  'extends': [
    'eslint-config-airbnb',
  ],

  'parser': 'babel-eslint',
}

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

<input
  autoComplete="cc-cvc cc-csc"
  maxLength="4"
  pattern="[\d]{3,4}"
  placeholder="CVC"
/>

What did you expect to happen?

The pattern "[\d]{3,4}" would not be flagged as the backslash is not an escape character in this context. (It’s a literal backslash, like in HTML.)

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

  135:21  error  Unnecessary escape character: \d  no-useless-escape

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
platinumazurecommented, Apr 18, 2016

Ah well, worth a shot. Thanks for trying those out. I’ll dig in further when I get home. On Apr 18, 2016 4:44 PM, “Turadg Aleahmad” notifications@github.com wrote:

Very handy! I changed the parser from “acorn” to “babel-eslint” and the value literal is still “[\d]{3,4}”. (Fwiw, same for Espree, but Typescript parses as “[d]{3,4}”.)

I also commented out babel-eslint in my eslintrc and it made no difference.

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/eslint/eslint/issues/5882#issuecomment-211595196

0reactions
mysticateacommented, Apr 18, 2016

I saw the spec: https://facebook.github.io/jsx/ JSXText seems to not have any escape sequence.

And I confirmed this with espree, too. I will fix this.

C:\Users\t-nagashima.AD\Documents\GitHub\eslint [master]> cat test.js
<foo attr="\d"/>;
C:\Users\t-nagashima.AD\Documents\GitHub\eslint [master]> eslint -v
v2.8.0
C:\Users\t-nagashima.AD\Documents\GitHub\eslint [master]> eslint test.js --rule no-useless-escape:2 --parser-options "ecmaFeatures:{jsx:true}" --no-ignore --no-eslintrc

C:\Users\t-nagashima.AD\Documents\GitHub\eslint\test.js
  2:12  error  Unnecessary escape character: \d  no-useless-escape

✖ 1 problem (1 error, 0 warnings)
Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
type="number" react typescript false positive in onChange?
I got error in line 24. Argument of type 'string' is not assignable to parameter of type ' ...
Read more >
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 >
The Better Way to Type React Components | by Mikael Brevik
Using props directly on parameters allow you to more correctly type components and avoid false positives while also being more flexible.
Read more >
Cross-site Scripting in React Web Applications - Invicti
React is a popular JavaScript framework for building user interfaces. ... Let's take a look at the User-Agent string the Chrome browser uses ......
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