Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ working directory:
`----
help: Consider using this expression or removing it

! ]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
! ]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
,-[fixtures/linter/nan.js:1:8]
1 | 123 == NaN;
: ^^^
`----
help: Use the isNaN function to compare with NaN.
help: Use the `isNaN` function to compare with NaN.

Found 2 warnings and 0 errors.
Finished in <variable>ms on 1 file with 89 rules using 1 threads.
Expand Down
4 changes: 2 additions & 2 deletions apps/oxlint/src/snapshots/_fixtures__linter@oxlint.snap
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ working directory:
`----
help: Consider using this expression or removing it

! ]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
! ]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
,-[fixtures/linter/nan.js:1:8]
1 | 123 == NaN;
: ^^^
`----
help: Use the isNaN function to compare with NaN.
help: Use the `isNaN` function to compare with NaN.

Found 4 warnings and 0 errors.
Finished in <variable>ms on 3 files with 89 rules using 1 threads.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ working directory:
`----
help: Consider using this expression or removing it

! ]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
! ]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
,-[fixtures/linter/nan.js:1:8]
1 | 123 == NaN;
: ^^^
`----
help: Use the isNaN function to compare with NaN.
help: Use the `isNaN` function to compare with NaN.

Found 3 warnings and 0 errors.
Finished in <variable>ms on 2 files with 89 rules using 1 threads.
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_self_compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{AstNode, context::LintContext, rule::Rule};

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use serde_json::Value;
const PRE_DEFINE_VAR: [&str; 5] = ["Infinity", "NaN", "arguments", "eval", "undefined"];

fn no_shadow_restricted_names_diagnostic(shadowed_name: &str, span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Shadowing of global properties such as 'undefined' is not allowed.")
OxcDiagnostic::warn("Shadowing of global properties such as `undefined` is not allowed.")
.with_help(format!("Rename '{shadowed_name}' to avoid shadowing the global property."))
.with_label(span)
}
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_this_before_super.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use rustc_hash::{FxHashMap, FxHashSet};
use crate::{AstNode, context::LintContext, rule::Rule};

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

Expand Down
8 changes: 5 additions & 3 deletions crates/oxc_linter/src/rules/eslint/no_unsafe_finally.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ use oxc_span::{GetSpan, Span};
use crate::{AstNode, context::LintContext, rule::Rule};

fn no_unsafe_finally_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Unsafe finally block")
.with_help("Control flow inside try or catch blocks will be overwritten by this statement")
OxcDiagnostic::warn("Unsafe `finally` block.")
.with_help(
"Control flow inside `try` or `catch` blocks will be overwritten by this statement.",
)
.with_label(span)
}

Expand All @@ -20,7 +22,7 @@ pub struct NoUnsafeFinally;
declare_oxc_lint!(
/// ### What it does
///
/// Disallow control flow statements in finally blocks
/// Disallow control flow statements in `finally` blocks.
///
/// ### Why is this bad?
///
Expand Down
14 changes: 7 additions & 7 deletions crates/oxc_linter/src/rules/eslint/use_isnan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ use schemars::JsonSchema;
use crate::{AstNode, context::LintContext, rule::Rule};

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

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

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

fn index_of_na_n(method_name: &str, span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Requires calls to isNaN() when checking for NaN")
OxcDiagnostic::warn("Requires calls to `isNaN()` when checking for NaN")
.with_help(format!("Array prototype method '{method_name}' cannot find NaN."))
.with_label(span)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/import/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{context::LintContext, module_record::ImportImportName, rule::Rule};

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

Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/import/named.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use oxc_span::Span;
use crate::{AstNode, context::LintContext, rule::Rule};

fn no_empty_named_blocks_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Unexpected empty named import block.").with_label(span)
OxcDiagnostic::warn("Unexpected empty named `import` block.").with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/import/no_self_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use oxc_span::Span;
use crate::{context::LintContext, rule::Rule};

fn no_self_import_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("module importing itself is not allowed").with_label(span)
OxcDiagnostic::warn("A module importing itself is not allowed").with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/jsdoc/check_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn invalid_access_level(span: Span) -> OxcDiagnostic {

fn redundant_access_tags(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(
"Mixing of @access with @public, @private, @protected, or @package on the same doc block.",
"Mixing of `@access` with `@public`, `@private`, `@protected`, or `@package` on the same doc block.",
)
.with_help("There should be only one instance of access tag in a JSDoc comment.")
.with_label(span)
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/jsdoc/check_property_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use crate::{
};

fn no_root(span: Span, x1: &str) -> OxcDiagnostic {
OxcDiagnostic::warn("No root defined for @property path.")
.with_help(format!("@property path declaration `{x1}` appears before any real property."))
OxcDiagnostic::warn("No root defined for `@property` path.")
.with_help(format!("`@property` path declaration `{x1}` appears before any real property."))
.with_label(span)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use crate::{
};

fn require_property_description_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Missing description in @property tag.")
.with_help("Add a description to this @property tag.")
OxcDiagnostic::warn("Missing description in `@property` tag.")
.with_help("Add a description to this `@property` tag.")
.with_label(span)
}

Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/jsdoc/require_property_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use crate::{
};

fn require_property_name_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Missing name in @property tag.")
.with_help("Add a type name to this @property tag.")
OxcDiagnostic::warn("Missing name in `@property` tag.")
.with_help("Add a type name to this `@property` tag.")
.with_label(span)
}

Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/jsdoc/require_property_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use crate::{
};

fn require_property_type_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Missing type in @property tag.")
.with_help("Add a {type} to this @property tag.")
OxcDiagnostic::warn("Missing type in `@property` tag.")
.with_help("Add a {type} to this `@property` tag.")
.with_label(span)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ declare_oxc_lint!(
pub struct AriaUnsupportedElements;

fn aria_unsupported_elements_diagnostic(span: Span, attr_name: &str) -> OxcDiagnostic {
OxcDiagnostic::warn("This element does not support ARIA roles, states and properties.")
OxcDiagnostic::warn("This element does not support ARIA roles, states, or properties.")
.with_help(format!("Try removing the prop `{attr_name}`."))
.with_label(span)
}
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/jsx_a11y/autocomplete_valid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use crate::{
};

fn autocomplete_valid_diagnostic(span: Span, autocomplete: &str) -> OxcDiagnostic {
OxcDiagnostic::warn(format!("`{autocomplete}` is not a valid value for autocomplete."))
.with_help(format!("Change `{autocomplete}` to a valid value for autocomplete."))
OxcDiagnostic::warn(format!("`{autocomplete}` is not a valid value for `autocomplete`."))
.with_help(format!("Change `{autocomplete}` to a valid value for `autocomplete`."))
.with_label(span)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::{

fn click_events_have_key_events_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Enforce a clickable non-interactive element has at least one keyboard event listener.")
.with_help("Visible, non-interactive elements with click handlers must have one of keyup, keydown, or keypress listener.")
.with_help("Visible, non-interactive elements with click handlers must have one of `keyup`, `keydown`, or `keypress` listener.")
.with_label(span)
}

Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/jsx_a11y/html_has_lang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ use crate::{

fn missing_lang_prop(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Missing lang attribute.")
.with_help("Add a lang attribute to the html element whose value represents the primary language of document.")
.with_help("Add a `lang` attribute to the `html` element whose value represents the primary language of document.")
.with_label(span)
}

fn missing_lang_value(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Missing value for lang attribute")
OxcDiagnostic::warn("Missing value for `lang` attribute")
.with_help("Must have meaningful value for `lang` prop.")
.with_label(span)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/jsx_a11y/iframe_has_title.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{

fn iframe_has_title_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Missing `title` attribute for the `iframe` element.")
.with_help("Provide title property for iframe element.")
.with_help("Provide `title` property for `iframe` element.")
.with_label(span)
}

Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/jsx_a11y/img_redundant_alt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use crate::{
};

fn img_redundant_alt_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Redundant alt attribute.")
.with_help("Provide no redundant alt text for image. Screen-readers already announce `img` tags as an image. You dont need to use the words `image`, `photo,` or `picture` (or any specified custom words) in the alt prop.").with_label(span)
OxcDiagnostic::warn("Redundant `alt` attribute.")
.with_help("Provide no redundant alt text for image. Screen-readers already announce `img` tags as an image. You don't need to use the words `image`, `photo,` or `picture` (or any specified custom words) in the `alt` prop.").with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/jsx_a11y/lang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use crate::{
};

fn lang_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Lang attribute must have a valid value.")
.with_help("Set a valid value for lang attribute.")
OxcDiagnostic::warn("`lang` attribute must have a valid value.")
.with_help("Set a valid value for `lang` attribute.")
.with_label(span)
}

Expand Down
8 changes: 5 additions & 3 deletions crates/oxc_linter/src/rules/jsx_a11y/media_has_caption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ use serde_json::Value;
use crate::{AstNode, context::LintContext, rule::Rule, utils::get_element_type};

fn media_has_caption_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Missing <track> element with captions inside <audio> or <video> element")
.with_help("Media elements such as <audio> and <video> must have a <track> for captions.")
.with_label(span)
OxcDiagnostic::warn(
"Missing `<track>` element with captions inside `<audio>` or `<video>` element",
)
.with_help("Media elements such as `<audio>` and `<video>` must have a `<track>` for captions.")
.with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ use crate::{
};

fn miss_on_focus(span: Span, attr_name: &str) -> OxcDiagnostic {
OxcDiagnostic::warn(format!("{attr_name} must be accompanied by onFocus for accessibility."))
.with_help("Try to add onFocus.")
.with_label(span)
OxcDiagnostic::warn(format!(
"`{attr_name}` must be accompanied by `onFocus` for accessibility."
))
.with_help("Try to add `onFocus`.")
.with_label(span)
}

fn miss_on_blur(span: Span, attr_name: &str) -> OxcDiagnostic {
OxcDiagnostic::warn(format!("{attr_name} must be accompanied by onBlur for accessibility."))
.with_help("Try to add onBlur.")
OxcDiagnostic::warn(format!("`{attr_name}` must be accompanied by `onBlur` for accessibility."))
.with_help("Try to add `onBlur`.")
.with_label(span)
}

Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/jsx_a11y/no_access_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{AstNode, context::LintContext, rule::Rule, utils::has_jsx_prop_ignor

fn no_access_key_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("No access key attribute allowed.")
.with_help("Remove the accessKey attribute. Inconsistencies between keyboard shortcuts and keyboard commands used by screenreaders and keyboard-only users create a11y complications.")
.with_help("Remove the `accessKey` attribute. Inconsistencies between keyboard shortcuts and keyboard commands used by screenreaders and keyboard-only users create accessibility complications.")
.with_label(span)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use oxc_span::{GetSpan, Span};
use crate::{LintContext, rule::Rule, utils::get_element_type};

fn no_distracting_elements_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Do not use <marquee> or <blink> elements as they can create visual accessibility issues and are deprecated.")
.with_help("Replace the <marquee> or <blink> element with alternative, more accessible ways to achieve your desired visual effects.")
OxcDiagnostic::warn("Do not use `<marquee>` or `<blink>` elements as they can create visual accessibility issues and are deprecated.")
.with_help("Replace the `<marquee>` or `<blink>` element with alternative, more accessible ways to achieve your desired visual effects.")
.with_label(span)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use crate::{
};

fn no_noninteractive_tabindex_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("tabIndex should only be declared on interactive elements")
.with_help("tabIndex attribute should be removed")
OxcDiagnostic::warn("`tabIndex` should only be declared on interactive elements")
.with_help("`tabIndex` attribute should be removed")
.with_label(span)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{

fn no_redundant_roles_diagnostic(span: Span, element: &str, role: &str) -> OxcDiagnostic {
OxcDiagnostic::warn(format!(
"The element `{element}` has an implicit role of `{role}`. Defining this explicitly is redundant and should be avoided."
"The `{element}` element has an implicit role of `{role}`. Defining this explicitly is redundant and should be avoided."
))
.with_help(format!("Remove the redundant role `{role}` from the element `{element}`."))
.with_label(span)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@ declare_oxc_lint!(
pub struct RoleSupportsAriaProps;

fn default(span: Span, attr_name: &str, role: &str) -> OxcDiagnostic {
OxcDiagnostic::warn(format!("The attribute {attr_name} is not supported by the role {role}."))
.with_help(format!("Try to remove invalid attribute {attr_name}."))
.with_label(span)
OxcDiagnostic::warn(format!(
"The attribute `{attr_name}` is not supported by the role `{role}`."
))
.with_help(format!("Try to remove invalid attribute `{attr_name}`."))
.with_label(span)
}

fn is_implicit_diagnostic(span: Span, attr_name: &str, role: &str, el_name: &str) -> OxcDiagnostic {
OxcDiagnostic::warn(format!("The attribute {attr_name} is not supported by the role {role}. This role is implicit on the element {el_name}."))
.with_help(format!("Try to remove invalid attribute {attr_name}."))
OxcDiagnostic::warn(format!("The attribute `{attr_name}` is not supported by the role `{role}`. This role is implicit on the element `{el_name}`."))
.with_help(format!("Try to remove invalid attribute `{attr_name}`."))
.with_label(span)
}

Expand Down
Loading
Loading