Skip to content

Commit

Permalink
Fix: Allow \u2028 and \u2029 as string escapes in no-useless-escape (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
not-an-aardvark authored and vitorbal committed Nov 30, 2016
1 parent 76c33a9 commit 0a2a7fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/rules/no-useless-escape.js
Expand Up @@ -24,7 +24,7 @@ function union(setA, setB) {
}());
}

const VALID_STRING_ESCAPES = new Set("\\nrvtbfux\n\r");
const VALID_STRING_ESCAPES = new Set("\\nrvtbfux\n\r\u2028\u2029");
const REGEX_GENERAL_ESCAPES = new Set("\\bcdDfnrsStvwWxu0123456789");
const REGEX_CHARCLASS_ESCAPES = union(REGEX_GENERAL_ESCAPES, new Set("]"));
const REGEX_NON_CHARCLASS_ESCAPES = union(REGEX_GENERAL_ESCAPES, new Set("^/.$*+?[{}|()B"));
Expand Down
5 changes: 4 additions & 1 deletion tests/lib/rules/no-useless-escape.js
Expand Up @@ -102,7 +102,10 @@ ruleTester.run("no-useless-escape", rule, {
"var foo = /\\1/", // \x01 character (octal literal)
"var foo = /(a)\\1/", // backreference
"var foo = /(a)\\12/", // backreference
"var foo = /[\\0]/" // null character in character class
"var foo = /[\\0]/", // null character in character class

"var foo = 'foo \\\u2028 bar'",
"var foo = 'foo \\\u2029 bar'"
],

invalid: [
Expand Down

0 comments on commit 0a2a7fd

Please sign in to comment.