diff --git a/crates/oxc_linter/src/rules/eslint/no_octal_escape.rs b/crates/oxc_linter/src/rules/eslint/no_octal_escape.rs index a9afe2a9e442e1..4f7b6cc0084607 100644 --- a/crates/oxc_linter/src/rules/eslint/no_octal_escape.rs +++ b/crates/oxc_linter/src/rules/eslint/no_octal_escape.rs @@ -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] @@ -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'", @@ -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'", diff --git a/crates/oxc_linter/src/snapshots/eslint_no_octal_escape.snap b/crates/oxc_linter/src/snapshots/eslint_no_octal_escape.snap index 43b2a83fa53285..9d51594937c1e3 100644 --- a/crates/oxc_linter/src/snapshots/eslint_no_octal_escape.snap +++ b/crates/oxc_linter/src/snapshots/eslint_no_octal_escape.snap @@ -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' @@ -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.