Skip to content

Commit

Permalink
Merge pull request #5755 from onurtemizkan/no-useless-escape/adding-B…
Browse files Browse the repository at this point in the history
…-escape

Fix: no-useless-escape \B regex escape (fixes #5750)
  • Loading branch information
ilyavolodin committed Apr 1, 2016
2 parents 98523c9 + 5fe6fca commit 0124c87
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/rules/no-useless-escape.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ var VALID_REGEX_ESCAPES = [
"(",
")",
"b",
"B",
"c",
"d",
"D",
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/rules/no-useless-escape.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ ruleTester.run("no-useless-escape", rule, {
"var foo = /\\D/",
"var foo = /\\W/",
"var foo = /\\w/",
"var foo = /\\B/",
"var foo = /\\\\/g",
"var foo = /\\w\\$\\*\\./",
"var foo = /\\^\\+\\./",
Expand All @@ -49,13 +50,12 @@ ruleTester.run("no-useless-escape", rule, {
],

invalid: [
{ code: "var foo = /\\B/;", errors: [{ message: "Unnecessary escape character: \\B", type: "Literal"}] },
{ code: "var foo = /\\#/;", errors: [{ message: "Unnecessary escape character: \\#", type: "Literal"}] },
{ code: "var foo = /\\;/;", errors: [{ message: "Unnecessary escape character: \\;", type: "Literal"}] },
{ code: "var foo = \"\\'\";", errors: [{ message: "Unnecessary escape character: \\'", type: "Literal"}] },
{ code: "var foo = \"\\B\";", errors: [{ message: "Unnecessary escape character: \\B", type: "Literal"}] },
{ code: "var foo = \"\\#/\";", errors: [{ message: "Unnecessary escape character: \\#", type: "Literal"}] },
{ code: "var foo = \"\\a\"", errors: [{ message: "Unnecessary escape character: \\a", type: "Literal"}] },
{ code: "var foo = \"\\B\";", errors: [{ message: "Unnecessary escape character: \\B", type: "Literal"}] },
{ code: "var foo = \"\\@\";", errors: [{ message: "Unnecessary escape character: \\@", type: "Literal"}] },
{ code: "var foo = \"foo \\a bar\";", errors: [{ message: "Unnecessary escape character: \\a", type: "Literal"}] },
{ code: "var foo = '\\\"';", errors: [{ message: "Unnecessary escape character: \\\"", type: "Literal"}] },
Expand Down

0 comments on commit 0124c87

Please sign in to comment.