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 17fb553c407f3..77ef996669869 100644 --- a/crates/oxc_linter/src/rules/eslint/no_octal_escape.rs +++ b/crates/oxc_linter/src/rules/eslint/no_octal_escape.rs @@ -8,7 +8,7 @@ use std::sync::OnceLock; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_octal_escape_diagnostic(span: Span, sequence: &str) -> OxcDiagnostic { - OxcDiagnostic::warn(format!("Don't use octal: '\\{}'. Use '\\u....' instead.", sequence)) + OxcDiagnostic::warn(format!("Don't use octal: '\\{sequence}'. Use '\\u....' instead.")) .with_label(span) } @@ -70,29 +70,29 @@ fn test() { let pass = vec![ r#"var foo = "\x51";"#, r#"var foo = "foo \\251 bar";"#, - r#"var foo = /([abc]) \1/g;"#, - r#"var foo = '\0';"#, - r#"'\0'"#, - r#"'\8'"#, - r#"'\9'"#, - r#"'\0 '"#, - r#"' \0'"#, - r#"'a\0'"#, - r#"'\0a'"#, - r#"'a\8a'"#, - r#"'\0\8'"#, - r#"'\8\0'"#, - r#"'\80'"#, - r#"'\81'"#, - r#"'\\'"#, - r#"'\\0'"#, - r#"'\\08'"#, - r#"'\\1'"#, - r#"'\\01'"#, - r#"'\\12'"#, - r#"'\\\0'"#, - r#"'\\\8'"#, - r#"'\0\\'"#, + r"var foo = /([abc]) \1/g;", + r"var foo = '\0';", + r"'\0'", + r"'\8'", + r"'\9'", + r"'\0 '", + r"' \0'", + r"'a\0'", + r"'\0a'", + r"'a\8a'", + r"'\0\8'", + r"'\8\0'", + r"'\80'", + r"'\81'", + r"'\\'", + r"'\\0'", + r"'\\08'", + r"'\\1'", + r"'\\01'", + r"'\\12'", + r"'\\\0'", + r"'\\\8'", + r"'\0\\'", "'0'", "'1'", "'8'", @@ -100,8 +100,8 @@ fn test() { "'08'", "'80'", "'12'", - r#"'\a'"#, - r#"'\n'"#, + r"'\a'", + r"'\n'", ]; let fail = vec![ @@ -123,49 +123,49 @@ fn test() { r#"var foo = "foo \400 bar";"#, r#"var foo = "\t\1";"#, r#"var foo = "\\\751";"#, - r#"'\0\1'"#, - r#"'\0 \1'"#, - r#"#\0\01'"#, - r#"'\0 \01'"#, - r#"'\0a\1'"#, - r#"'\0a\01'"#, - r#"'\0\08'"#, - r#"'\1'"#, - r#"'\2'"#, - r#"'\7'"#, - r#"'\00'"#, - r#"'\01'"#, - r#"'\02'"#, - r#"'\07'"#, - r#"'\08'"#, - r#"'\09'"#, - r#"'\10'"#, - r#"'\12'"#, - r#"' \1'"#, - r#"'\1 '"#, - r#"'a\1'"#, - r#"'\1a'"#, - r#"'a\1a'"#, - r#"' \01'"#, - r#"'\01 '"#, - r#"'a\01'"#, - r#"'\01a'"#, - r#"'a\01a'"#, - r#"'a\08a'"#, - r#"'\n\1'"#, - r#"'\n\01'"#, - r#"'\n\08'"#, - r#"'\\\1'"#, - r#"'\\\01'"#, - r#"'\\\08'"#, - r#"'\\ - \\1'"#, - r#"'\01\02'"#, - r#"'\02\01'"#, - r#"'\01\2'"#, - r#"'\2\01'"#, - r#"'\08\1'"#, - r#"'foo \1 bar \2'"#, + r"'\0\1'", + r"'\0 \1'", + r"#\0\01'", + r"'\0 \01'", + r"'\0a\1'", + r"'\0a\01'", + r"'\0\08'", + r"'\1'", + r"'\2'", + r"'\7'", + r"'\00'", + r"'\01'", + r"'\02'", + r"'\07'", + r"'\08'", + r"'\09'", + r"'\10'", + r"'\12'", + r"' \1'", + r"'\1 '", + r"'a\1'", + r"'\1a'", + r"'a\1a'", + r"' \01'", + r"'\01 '", + r"'a\01'", + r"'\01a'", + r"'a\01a'", + r"'a\08a'", + r"'\n\1'", + r"'\n\01'", + r"'\n\08'", + r"'\\\1'", + r"'\\\01'", + r"'\\\08'", + r"'\\ + \\1'", + r"'\01\02'", + r"'\02\01'", + r"'\01\2'", + r"'\2\01'", + r"'\08\1'", + r"'foo \1 bar \2'", ]; Tester::new(NoOctalEscape::NAME, NoOctalEscape::CATEGORY, pass, fail).test_and_snapshot();