Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
baseballyama committed Dec 28, 2024
1 parent ac4226f commit c868ae4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 33 deletions.
9 changes: 5 additions & 4 deletions crates/oxc_linter/src/rules/eslint/no_octal_escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl Rule for NoOctalEscape {

lazy_static! {
static ref OCTAL_ESCAPE_PATTERN: Regex =
Regex::new(r"^(?:[^\\]|\\.)*?\\([0-3][0-7]{1,2}|[4-7][0-7]|(08|09)|[1-7])").unwrap();
Regex::new(r"(?s)^(?:[^\\]|\\.)*?\\([0-3][0-7]{1,2}|[4-7][0-7]|(08|09)|[1-7])").unwrap();
}

#[test]
Expand Down Expand Up @@ -122,7 +122,9 @@ fn test() {
r#"var foo = "\\\751";"#,
r"'\0\1'",
r"'\0 \1'",
r"#\0\01'",
// oxc itself throws the error below:
// Octal escape sequences are not allowed. Use the syntax '\x01'.
// r"\0\01'",
r"'\0 \01'",
r"'\0a\1'",
r"'\0a\01'",
Expand Down Expand Up @@ -155,8 +157,7 @@ fn test() {
r"'\\\1'",
r"'\\\01'",
r"'\\\08'",
r"'\\
\\1'",
r"'\\n\1'",
r"'\01\02'",
r"'\02\01'",
r"'\01\2'",
Expand Down
32 changes: 3 additions & 29 deletions crates/oxc_linter/src/snapshots/eslint_no_octal_escape.snap
Original file line number Diff line number Diff line change
Expand Up @@ -122,31 +122,6 @@ snapshot_kind: text
· ───────
╰────

× Invalid Unicode escape sequence
╭─[no_octal_escape.tsx:1:3]
1 │ #\0\01'
·
╰────

× Invalid Unicode escape sequence
╭─[no_octal_escape.tsx:1:5]
1 │ #\0\01'
·
╰────

× Unterminated string
╭─[no_octal_escape.tsx:1:7]
1 │ #\0\01'
·
╰────

× Expected `in` but found `Unknown`
╭─[no_octal_escape.tsx:1:7]
1 │ #\0\01'
·
· ╰── `in` expected
╰────

eslint(no-octal-escape): Don't use octal: '\01'. Use '\u....' instead.
╭─[no_octal_escape.tsx:1:1]
1'\0 \01'
Expand Down Expand Up @@ -339,11 +314,10 @@ snapshot_kind: text
· ───────
╰────

× Unterminated string
eslint(no-octal-escape): Don't use octal: '\1'. Use '\u....' instead.
╭─[no_octal_escape.tsx:1:1]
1'\\
· ───
2 │ \\1'
1'\\n\1'
· ───────
╰────

eslint(no-octal-escape): Don't use octal: '\01'. Use '\u....' instead.
Expand Down

0 comments on commit c868ae4

Please sign in to comment.