Skip to content

Commit 6c72e84

Browse files
committed
docs(linter): Use backticks for code elements across more rule diagnostics (#15958)
Improves the consistency of diagnostic formatting in 30ish rules, and improves the diagnostic messages in editors that render markdown, plus makes it clearer which parts refer to code for end-users, even with the raw text. -lso adjust the phrasing of some diagnostics slightly.
1 parent 4f8c414 commit 6c72e84

File tree

62 files changed

+825
-817
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+825
-817
lines changed

apps/oxlint/src/snapshots/_--ignore-path fixtures__linter__.customignore --no-ignore [email protected]

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ working directory:
1313
`----
1414
help: Consider using this expression or removing it
1515
16-
! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/use-isnan.html\eslint(use-isnan)]8;;\: Requires calls to isNaN() when checking for NaN
16+
! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/use-isnan.html\eslint(use-isnan)]8;;\: Requires calls to `isNaN()` when checking for NaN
1717
,-[fixtures/linter/nan.js:1:8]
1818
1 | 123 == NaN;
1919
: ^^^
2020
`----
21-
help: Use the isNaN function to compare with NaN.
21+
help: Use the `isNaN` function to compare with NaN.
2222

2323
Found 2 warnings and 0 errors.
2424
Finished in <variable>ms on 1 file with 89 rules using 1 threads.

apps/oxlint/src/snapshots/[email protected]

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ working directory:
2828
`----
2929
help: Consider using this expression or removing it
3030
31-
! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/use-isnan.html\eslint(use-isnan)]8;;\: Requires calls to isNaN() when checking for NaN
31+
! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/use-isnan.html\eslint(use-isnan)]8;;\: Requires calls to `isNaN()` when checking for NaN
3232
,-[fixtures/linter/nan.js:1:8]
3333
1 | 123 == NaN;
3434
: ^^^
3535
`----
36-
help: Use the isNaN function to compare with NaN.
36+
help: Use the `isNaN` function to compare with NaN.
3737

3838
Found 4 warnings and 0 errors.
3939
Finished in <variable>ms on 3 files with 89 rules using 1 threads.

apps/oxlint/src/snapshots/_fixtures__linter__debugger.js [email protected]

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ working directory:
2020
`----
2121
help: Consider using this expression or removing it
2222

23-
! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/use-isnan.html\eslint(use-isnan)]8;;\: Requires calls to isNaN() when checking for NaN
23+
! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/use-isnan.html\eslint(use-isnan)]8;;\: Requires calls to `isNaN()` when checking for NaN
2424
,-[fixtures/linter/nan.js:1:8]
2525
1 | 123 == NaN;
2626
: ^^^
2727
`----
28-
help: Use the isNaN function to compare with NaN.
28+
help: Use the `isNaN` function to compare with NaN.
2929
3030
Found 3 warnings and 0 errors.
3131
Finished in <variable>ms on 2 files with 89 rules using 1 threads.

crates/oxc_linter/src/rules/eslint/no_self_compare.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::{AstNode, context::LintContext, rule::Rule};
77

88
fn no_self_compare_diagnostic(left_span: Span, right_span: Span) -> OxcDiagnostic {
99
OxcDiagnostic::warn("Both sides of this comparison are exactly the same")
10-
.with_help("If you are testing for NaN, you can use Number.isNaN function.")
10+
.with_help("If you are testing for NaN, you can use the `Number.isNaN()` function.")
1111
.with_labels([left_span, right_span])
1212
}
1313

crates/oxc_linter/src/rules/eslint/no_shadow_restricted_names.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use serde_json::Value;
99
const PRE_DEFINE_VAR: [&str; 5] = ["Infinity", "NaN", "arguments", "eval", "undefined"];
1010

1111
fn no_shadow_restricted_names_diagnostic(shadowed_name: &str, span: Span) -> OxcDiagnostic {
12-
OxcDiagnostic::warn("Shadowing of global properties such as 'undefined' is not allowed.")
12+
OxcDiagnostic::warn("Shadowing of global properties such as `undefined` is not allowed.")
1313
.with_help(format!("Rename '{shadowed_name}' to avoid shadowing the global property."))
1414
.with_label(span)
1515
}

crates/oxc_linter/src/rules/eslint/no_this_before_super.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use rustc_hash::{FxHashMap, FxHashSet};
1515
use crate::{AstNode, context::LintContext, rule::Rule};
1616

1717
fn no_this_before_super_diagnostic(span: Span) -> OxcDiagnostic {
18-
OxcDiagnostic::warn("Expected to always call super() before this/super property access.")
19-
.with_help("Call super() before this/super property access.")
18+
OxcDiagnostic::warn("Expected to always call `super()` before `this`/`super` property access.")
19+
.with_help("Call `super()` before `this`/`super` property access.")
2020
.with_label(span)
2121
}
2222

crates/oxc_linter/src/rules/eslint/no_unsafe_finally.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ use oxc_span::{GetSpan, Span};
99
use crate::{AstNode, context::LintContext, rule::Rule};
1010

1111
fn no_unsafe_finally_diagnostic(span: Span) -> OxcDiagnostic {
12-
OxcDiagnostic::warn("Unsafe finally block")
13-
.with_help("Control flow inside try or catch blocks will be overwritten by this statement")
12+
OxcDiagnostic::warn("Unsafe `finally` block.")
13+
.with_help(
14+
"Control flow inside `try` or `catch` blocks will be overwritten by this statement.",
15+
)
1416
.with_label(span)
1517
}
1618

@@ -20,7 +22,7 @@ pub struct NoUnsafeFinally;
2022
declare_oxc_lint!(
2123
/// ### What it does
2224
///
23-
/// Disallow control flow statements in finally blocks
25+
/// Disallow control flow statements in `finally` blocks.
2426
///
2527
/// ### Why is this bad?
2628
///

crates/oxc_linter/src/rules/eslint/use_isnan.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@ use schemars::JsonSchema;
1111
use crate::{AstNode, context::LintContext, rule::Rule};
1212

1313
fn comparison_with_na_n(span: Span) -> OxcDiagnostic {
14-
OxcDiagnostic::warn("Requires calls to isNaN() when checking for NaN")
15-
.with_help("Use the isNaN function to compare with NaN.")
14+
OxcDiagnostic::warn("Requires calls to `isNaN()` when checking for NaN")
15+
.with_help("Use the `isNaN` function to compare with NaN.")
1616
.with_label(span)
1717
}
1818

1919
fn switch_na_n(span: Span) -> OxcDiagnostic {
20-
OxcDiagnostic::warn("Requires calls to isNaN() when checking for NaN")
20+
OxcDiagnostic::warn("Requires calls to `isNaN()` when checking for NaN.")
2121
.with_help(
22-
"'switch(NaN)' can never match a case clause. Use Number.isNaN instead of the switch.",
22+
"`switch(NaN)` can never match a case clause. Use `Number.isNaN` instead of the switch.",
2323
)
2424
.with_label(span)
2525
}
2626

2727
fn case_na_n(span: Span) -> OxcDiagnostic {
28-
OxcDiagnostic::warn("Requires calls to isNaN() when checking for NaN")
29-
.with_help("'case NaN' can never match. Use Number.isNaN before the switch.")
28+
OxcDiagnostic::warn("Requires calls to `isNaN()` when checking for NaN")
29+
.with_help("`case NaN` can never match. Use `Number.isNaN` before the switch.")
3030
.with_label(span)
3131
}
3232

3333
fn index_of_na_n(method_name: &str, span: Span) -> OxcDiagnostic {
34-
OxcDiagnostic::warn("Requires calls to isNaN() when checking for NaN")
34+
OxcDiagnostic::warn("Requires calls to `isNaN()` when checking for NaN")
3535
.with_help(format!("Array prototype method '{method_name}' cannot find NaN."))
3636
.with_label(span)
3737
}

crates/oxc_linter/src/rules/import/default.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{context::LintContext, module_record::ImportImportName, rule::Rule};
66

77
fn default_diagnostic(imported_name: &str, span: Span) -> OxcDiagnostic {
88
OxcDiagnostic::warn(format!("No default export found in imported module {imported_name:?}"))
9-
.with_help(format!("does {imported_name:?} have the default export?"))
9+
.with_help(format!("Does {imported_name:?} have the default export?"))
1010
.with_label(span)
1111
}
1212

crates/oxc_linter/src/rules/import/named.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{
1010

1111
fn named_diagnostic(imported_name: &str, module_name: &str, span: Span) -> OxcDiagnostic {
1212
OxcDiagnostic::warn(format!("named import {imported_name:?} not found"))
13-
.with_help(format!("does {module_name:?} have the export {imported_name:?}?"))
13+
.with_help(format!("Does {module_name:?} have the export {imported_name:?}?"))
1414
.with_label(span)
1515
}
1616

0 commit comments

Comments
 (0)