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 positive

See original GitHub issue

Tell us about your environment

  • ESLint Version: 3.9.0
  • Node Version: node v6.9.1
  • npm Version: 3.3.2

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

Please show your full configuration:

{
  "extends": ["airbnb"],
  "plugins": ["mocha", "no-unused-vars-rest"],
  "env":{
    "meteor": true,
    "es6": true,
    "commonjs": true
  },
  "parserOptions": {
    "ecmaVersion": 6,
    "sourceType": "module"
  },
  "rules": {
    "consistent-return": [0],
    "eol-last": [0],
    "eqeqeq": ["error", "smart"],
    "max-len": ["error", 150, 2],
    "no-console": [0],
    "no-mixed-requires": [0],
    "no-native-reassign": [0],
    "no-param-reassign": [0],
    "no-use-before-define" : ["error", { "functions": false }],
    "no-useless-rename": ["error", {
      "ignoreDestructuring": true
    }],
    "no-undefined": ["error"],
    "no-underscore-dangle": ["error", { "allow": ["_id"], "allowAfterThis": true }],
    "object-curly-spacing": ["error", "always", {
      "objectsInObjects": false,
      "arraysInObjects": false
    }],
    "prefer-template": [0],
    "quotes": [2, "single"],
    "radix": ["error", "always"],
    "require-yield": [0],
    "semi": [2, "always"],
    "no-unused-vars": 0,
    "import/extensions": [0],
    "react/forbid-prop-types": [0],
    "jsx-a11y/no-static-element-interactions": [0],
    "arrow-parens":[2, "as-needed"],
    "react/no-unescaped-entities": [2],
    "react/no-unused-prop-types": [2],
    "no-plusplus":[2, { "allowForLoopAfterthoughts": true }],
    "no-bitwise": [2],
    "import/no-unresolved": [2, { ignore: ['\.sol\.js$'] }],
    "class-methods-use-this": [2],
    "jsx-a11y/anchor-has-content": [2],

    /* Plugins */
    "no-unused-vars-rest/no-unused-vars": [2, { "ignoreDestructuredVarsWithRest": true }],
    "babel/generator-star-spacing": [0],
    "generator-star-spacing": [0],
    "import/no-extraneous-dependencies": [0],
    "mocha/no-exclusive-tests": "error"
  },
  "settings": {
    "import/core-modules": ["meteor"],
    "import/resolver": "meteor"
  }
}

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

const PATTERN_USERNAME = /^[a-z0-9\.\-_]+$/;

What did you expect to happen? No errors

What actually happened? Please include the actual, raw output from ESLint. error Unnecessary escape character: \. no-useless-escape

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
thiagodelgado111commented, Oct 31, 2016

Oh, Ok! Got it! I will close the issue then, thanks a lot for helping! 😃

1reaction
not-an-aardvarkcommented, Oct 31, 2016

Right. They only need to be escaped if they appear outside of character classes (the sections surrounded by []).

var foo = /\./; // needs to be escaped
var foo = /[\.]/; // does not need to be escaped
Read more comments on GitHub >

github_iconTop Results From Across the Web

no-useless-escape false positive on chatacter classes including
The regular expression should be permitted; the closing bracket ] needs to be escaped within a character class, else it signifies the end...
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 >
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 >
regexp/no-useless-escape
This rule reports unnecessary escape characters in RegExp. You may be able to find another mistake by finding unnecessary escapes.
Read more >
ESLint v3.12.0 released - ESLint中文文档
e569225 Update: fix false positive/negative of yoda rule (fixes #7676) (#7695) ... and \u2029 as string escapes in no-useless-escape (#7672) (Teddy Katz) ...
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