From db63a6445c7a7e6459a5f85015f43e6382802303 Mon Sep 17 00:00:00 2001 From: frankfmy Date: Thu, 5 Feb 2026 19:05:27 +0100 Subject: [PATCH] fix(linter/capitalized-comments): ignore prettier and oxfmt directives Add `prettier-ignore` and `oxfmt-ignore` to the list of directive prefixes that are automatically ignored by the capitalized-comments rule. These are widely used formatter directives that should not trigger capitalization warnings. Closes #17753 --- .../src/rules/eslint/capitalized_comments.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/oxc_linter/src/rules/eslint/capitalized_comments.rs b/crates/oxc_linter/src/rules/eslint/capitalized_comments.rs index 37679dddfbb3e..e1a2420793c09 100644 --- a/crates/oxc_linter/src/rules/eslint/capitalized_comments.rs +++ b/crates/oxc_linter/src/rules/eslint/capitalized_comments.rs @@ -23,6 +23,8 @@ const DIRECTIVES: &[&str] = &[ "global ", "globals ", "exported", + "prettier-ignore", + "oxfmt-ignore", ]; fn capitalized_comments_diagnostic( @@ -455,6 +457,13 @@ fn test() { ("/* globals var1, var2 */", None), ("/* globals var1:true, var2 */", None), ("/* exported myVar */", None), + // Formatter directives should be ignored + ("// prettier-ignore", None), + ("/* prettier-ignore */", None), + ("// prettier-ignore-start", None), + ("// prettier-ignore-end", None), + ("// oxfmt-ignore", None), + ("/* oxfmt-ignore */", None), ("#!foo", None), ("#!foo", Some(serde_json::json!(["always"]))), ("#!Foo", Some(serde_json::json!(["never"]))), @@ -533,6 +542,11 @@ fn test() { ("/* globals var1, var2 */", Some(serde_json::json!(["always"]))), ("/* globals var1:true, var2 */", Some(serde_json::json!(["always"]))), ("/* exported myVar */", Some(serde_json::json!(["always"]))), + // Formatter directives with "always" + ("// prettier-ignore", Some(serde_json::json!(["always"]))), + ("/* prettier-ignore */", Some(serde_json::json!(["always"]))), + ("// oxfmt-ignore", Some(serde_json::json!(["always"]))), + ("/* oxfmt-ignore */", Some(serde_json::json!(["always"]))), ("//lowercase", Some(serde_json::json!(["never"]))), ("// lowercase", Some(serde_json::json!(["never"]))), ("/*lowercase */", Some(serde_json::json!(["never"]))),