From 02cb45b1785af858d06dd7df3d8467b3dc88b4b6 Mon Sep 17 00:00:00 2001 From: camchenry <1514176+camchenry@users.noreply.github.com> Date: Sat, 8 Feb 2025 19:47:02 +0000 Subject: [PATCH] docs(linter): add prettier-ignore where formatting ruins code (#8978) While running `just website`, I noticed that these docs were causing some issues when running `npm run fmt` subsequently, I think due to the usage of character escapes. Disabling prettier seems to stop this from occurring. Also the code examples in `no-nonoctal-decimal-escape` had weird formatting due to the usage of text which gets parsed as a label, so I updated the example. --- .../eslint/no_nonoctal_decimal_escape.rs | 22 ++++++++++++++----- .../src/rules/unicorn/escape_case.rs | 21 +++++++++++------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/crates/oxc_linter/src/rules/eslint/no_nonoctal_decimal_escape.rs b/crates/oxc_linter/src/rules/eslint/no_nonoctal_decimal_escape.rs index 092a7a30ccfde..d09fe562f0dfb 100644 --- a/crates/oxc_linter/src/rules/eslint/no_nonoctal_decimal_escape.rs +++ b/crates/oxc_linter/src/rules/eslint/no_nonoctal_decimal_escape.rs @@ -30,13 +30,23 @@ declare_oxc_lint!( /// ECMAScript specification treats \8 and \9 in string literals as a legacy feature /// /// ### Example + /// + /// Examples of **incorrect** code for this rule: + /// + /// + /// + /// ```javascript + /// let x = "\8" + /// let y = "\9" + /// ``` + /// + /// + /// + /// Examples of **correct** code for this rule: + /// /// ```javascript - /// incorrect: - /// "\8" - /// "\9" - /// correct: - /// "8" - /// "\\9" + /// let x = "8" + /// let y = "\\9" /// ``` NoNonoctalDecimalEscape, eslint, diff --git a/crates/oxc_linter/src/rules/unicorn/escape_case.rs b/crates/oxc_linter/src/rules/unicorn/escape_case.rs index 9b0828740fd23..b8bcf9854689a 100644 --- a/crates/oxc_linter/src/rules/unicorn/escape_case.rs +++ b/crates/oxc_linter/src/rules/unicorn/escape_case.rs @@ -28,20 +28,25 @@ declare_oxc_lint!( /// ### Examples /// /// Examples of **incorrect** code for this rule: + /// + /// + /// /// ```javascript - /// const foo = '\xa9'; - /// const foo = '\ud834'; - /// const foo = '\u{1d306}'; - /// const foo = '\ca'; + /// const foo = "\xa9"; + /// const foo = "\ud834"; + /// const foo = "\u{1d306}"; + /// const foo = "\ca"; /// ``` /// /// Examples of **correct** code for this rule: /// ```javascript - /// const foo = '\xA9'; - /// const foo = '\uD834'; - /// const foo = '\u{1D306}'; - /// const foo = '\cA'; + /// const foo = "\xA9"; + /// const foo = "\uD834"; + /// const foo = "\u{1D306}"; + /// const foo = "\cA"; /// ``` + /// + /// EscapeCase, unicorn, pedantic,