diff --git a/crates/oxc_language_server/src/snapshots/fixtures_linter_regexp_feature@index.ts.snap b/crates/oxc_language_server/src/snapshots/fixtures_linter_regexp_feature@index.ts.snap index ae1905f6443f0..d46ad5cba0688 100644 --- a/crates/oxc_language_server/src/snapshots/fixtures_linter_regexp_feature@index.ts.snap +++ b/crates/oxc_language_server/src/snapshots/fixtures_linter_regexp_feature@index.ts.snap @@ -4,7 +4,7 @@ input_file: crates/oxc_language_server/fixtures/linter/regexp_feature/index.ts --- code: "eslint(no-control-regex)" code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-control-regex.html" -message: "Unexpected control character\nhelp: '\\u0000' is not a valid control character." +message: "Unexpected control character\nhelp: '\\u0000' is a control character." range: Range { start: Position { line: 1, character: 13 }, end: Position { line: 1, character: 32 } } related_information[0].message: "" related_information[0].location.uri: "file:///fixtures/linter/regexp_feature/index.ts" diff --git a/crates/oxc_linter/src/rules/eslint/no_control_regex.rs b/crates/oxc_linter/src/rules/eslint/no_control_regex.rs index fb6e66e60bab2..abd87a066edd5 100644 --- a/crates/oxc_linter/src/rules/eslint/no_control_regex.rs +++ b/crates/oxc_linter/src/rules/eslint/no_control_regex.rs @@ -40,7 +40,7 @@ fn no_control_regex_diagnostic(control_chars: &[Character], span: Span) -> OxcDi let regexes = other_chars.iter().join(", "); writeln!( help, - "'{regexes}' {} not {}valid control character{}.", + "'{regexes}' {} {}control character{}.", if other_chars.len() > 1 { "are" } else { "is" }, if other_chars.len() > 1 { "" } else { "a " }, if other_chars.len() > 1 { "s" } else { "" }, @@ -52,7 +52,7 @@ fn no_control_regex_diagnostic(control_chars: &[Character], span: Span) -> OxcDi let regexes = octal_chars.iter().join(", "); writeln!( help, - "'{regexes}' {} not {}valid control character{}. They look like backreferences, but there {} no corresponding capture group{}. If you are trying to match the octal character, consider using '\\xNN' or '\\u00NN' instead.", + "'{regexes}' {} {}control character{}. They look like backreferences, but there {} no corresponding capture group{}.", if octal_chars.len() > 1 { "are" } else { "is" }, if octal_chars.len() > 1 { "" } else { "a " }, if octal_chars.len() > 1 { "s" } else { "" }, @@ -62,10 +62,8 @@ fn no_control_regex_diagnostic(control_chars: &[Character], span: Span) -> OxcDi } if !null_chars.is_empty() { - writeln!( - help, - "'\\0' matches the null character (U+0000), which is a control character. If you intend to match the null character, consider using '\\x00' or '\\u0000' for clarity." - ).unwrap(); + writeln!(help, "'\\0' matches the null character (U+0000), which is a control character.") + .unwrap(); } debug_assert!(!help.is_empty()); diff --git a/crates/oxc_linter/src/snapshots/eslint_no_control_regex.snap b/crates/oxc_linter/src/snapshots/eslint_no_control_regex.snap index 80654e31f495c..ef50818925d3f 100644 Binary files a/crates/oxc_linter/src/snapshots/eslint_no_control_regex.snap and b/crates/oxc_linter/src/snapshots/eslint_no_control_regex.snap differ diff --git a/crates/oxc_linter/src/snapshots/eslint_no_control_regex@capture-group-indexing.snap b/crates/oxc_linter/src/snapshots/eslint_no_control_regex@capture-group-indexing.snap index be4bc264691a0..9f8452b5ef1bd 100644 --- a/crates/oxc_linter/src/snapshots/eslint_no_control_regex@capture-group-indexing.snap +++ b/crates/oxc_linter/src/snapshots/eslint_no_control_regex@capture-group-indexing.snap @@ -6,25 +6,25 @@ source: crates/oxc_linter/src/tester.rs 1 │ const r = /\0/; · ──── ╰──── - help: '\0' matches the null character (U+0000), which is a control character. If you intend to match the null character, consider using '\x00' or '\u0000' for clarity. + help: '\0' matches the null character (U+0000), which is a control character. ⚠ eslint(no-control-regex): Unexpected control character ╭─[no_control_regex.tsx:1:11] 1 │ const r = /[a-z]\1/; · ───────── ╰──── - help: '\1' is not a valid control character. They look like backreferences, but there is no corresponding capture group. If you are trying to match the octal character, consider using '\xNN' or '\u00NN' instead. + help: '\1' is a control character. They look like backreferences, but there is no corresponding capture group. ⚠ eslint(no-control-regex): Unexpected control character ╭─[no_control_regex.tsx:1:11] 1 │ const r = /([a-z])\2/; · ─────────── ╰──── - help: '\2' is not a valid control character. They look like backreferences, but there is no corresponding capture group. If you are trying to match the octal character, consider using '\xNN' or '\u00NN' instead. + help: '\2' is a control character. They look like backreferences, but there is no corresponding capture group. ⚠ eslint(no-control-regex): Unexpected control character ╭─[no_control_regex.tsx:1:11] 1 │ const r = /([a-z])\0/; · ─────────── ╰──── - help: '\0' matches the null character (U+0000), which is a control character. If you intend to match the null character, consider using '\x00' or '\u0000' for clarity. + help: '\0' matches the null character (U+0000), which is a control character.