Skip to content

escape-case and no-hex-escape false positives – need to handle backslashes #85

@lydell

Description

@lydell

package.json:

{
  "private": true,
  "eslintConfig": {
    "env": {
      "es6": true
    },
    "parserOptions": {
      "ecmaVersion": 2017,
      "sourceType": "module"
    },
    "plugins": [
      "unicorn"
    ],
    "rules": {
      "unicorn/escape-case": "error",
      "unicorn/no-hex-escape": "error"
    }
  },
  "scripts": {
    "test": "eslint test.js"
  },
  "devDependencies": {
    "eslint": "^3.15.0",
    "eslint-plugin-unicorn": "^2.0.1"
  }
}

test.js:

"\\ufeff"
"\\\\xa0"

Output:

$ npm test

> @ test /home/lydell/bugs/eslint-plugin-unicorn-bugs
> eslint test.js


/home/lydell/bugs/eslint-plugin-unicorn-bugs/test.js
  1:1  error  Use uppercase characters for the value of the escape sequence  unicorn/escape-case
  2:1  error  Use uppercase characters for the value of the escape sequence  unicorn/escape-case
  2:1  error  Use unicode escapes instead of hexadecimal escapes             unicorn/no-hex-escape

✖ 3 problems (3 errors, 0 warnings)

npm ERR! Test failed.  See above for more details.

Expected: No errors.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions