diff --git a/apps/oxlint/src/snapshots/fixtures__extends_config_overrides@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__extends_config_overrides@oxlint.snap
index 64b41c42442fa..dd0cf95ea3c52 100644
--- a/apps/oxlint/src/snapshots/fixtures__extends_config_overrides@oxlint.snap
+++ b/apps/oxlint/src/snapshots/fixtures__extends_config_overrides@oxlint.snap
@@ -1,5 +1,6 @@
---
source: apps/oxlint/src/tester.rs
+snapshot_kind: text
---
##########
arguments: overrides
@@ -21,13 +22,14 @@ working directory: fixtures/extends_config
`----
help: Use `unknown` instead, this will force you to explicitly, and safely, assert the type is correct.
- x ]8;;https://oxc.rs/docs/guide/usage/linter/rules/jsx_a11y/anchor-ambiguous-text.html\eslint-plugin-jsx-a11y(anchor-ambiguous-text)]8;;\: Unexpected ambagious anchor link text.
+ x ]8;;https://oxc.rs/docs/guide/usage/linter/rules/jsx_a11y/anchor-ambiguous-text.html\eslint-plugin-jsx-a11y(anchor-ambiguous-text)]8;;\: Ambiguous text within anchor, screen reader users rely on link text for context.
,-[overrides/test.tsx:2:10]
1 | function component(): any {
2 | return click here;
: ^^^^^^^^^^^^^^^^^
3 | }
`----
+ help: Avoid using ambiguous text like "click here", replace it with more descriptive text that provides context.
Found 0 warnings and 3 errors.
Finished in ms on 2 files using 1 threads.
diff --git a/crates/oxc_linter/src/rules/jsx_a11y/anchor_ambiguous_text.rs b/crates/oxc_linter/src/rules/jsx_a11y/anchor_ambiguous_text.rs
index e3cc6d859ab1b..5b9777b365bab 100644
--- a/crates/oxc_linter/src/rules/jsx_a11y/anchor_ambiguous_text.rs
+++ b/crates/oxc_linter/src/rules/jsx_a11y/anchor_ambiguous_text.rs
@@ -18,8 +18,12 @@ use crate::{
},
};
-fn anchor_has_ambiguous_text(span: Span) -> OxcDiagnostic {
- OxcDiagnostic::warn("Unexpected ambagious anchor link text.").with_label(span)
+fn anchor_has_ambiguous_text(span: Span, text: &CompactStr) -> OxcDiagnostic {
+ OxcDiagnostic::warn(
+ "Ambiguous text within anchor, screen reader users rely on link text for context.",
+ )
+ .with_label(span)
+ .with_help(format!("Avoid using ambiguous text like \"{text}\", replace it with more descriptive text that provides context."))
}
#[derive(Debug, Default, Clone)]
@@ -122,8 +126,10 @@ impl Rule for AnchorAmbiguousText {
return;
}
- if self.words.contains(&normalize_str(&text)) {
- ctx.diagnostic(anchor_has_ambiguous_text(jsx_el.span));
+ let text = normalize_str(&text);
+
+ if self.words.contains(&text) {
+ ctx.diagnostic(anchor_has_ambiguous_text(jsx_el.span, &text));
}
}
}
diff --git a/crates/oxc_linter/src/snapshots/jsx_a11y_anchor_ambiguous_text.snap b/crates/oxc_linter/src/snapshots/jsx_a11y_anchor_ambiguous_text.snap
index 91bd6b1b715f4..71f04455860d1 100644
--- a/crates/oxc_linter/src/snapshots/jsx_a11y_anchor_ambiguous_text.snap
+++ b/crates/oxc_linter/src/snapshots/jsx_a11y_anchor_ambiguous_text.snap
@@ -1,170 +1,199 @@
---
source: crates/oxc_linter/src/tester.rs
+snapshot_kind: text
---
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ here;
· ───────────
╰────
+ help: Avoid using ambiguous text like "here", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ HERE;
· ───────────
╰────
+ help: Avoid using ambiguous text like "here", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ click here;
· ─────────────────
╰────
+ help: Avoid using ambiguous text like "click here", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ learn more;
· ─────────────────
╰────
+ help: Avoid using ambiguous text like "learn more", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ learn more;
· ──────────────────────
╰────
+ help: Avoid using ambiguous text like "learn more", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ learn more.;
· ──────────────────
╰────
+ help: Avoid using ambiguous text like "learn more", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ learn more?;
· ──────────────────
╰────
+ help: Avoid using ambiguous text like "learn more", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ learn more,;
· ──────────────────
╰────
+ help: Avoid using ambiguous text like "learn more", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ learn more!;
· ──────────────────
╰────
+ help: Avoid using ambiguous text like "learn more", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ learn more;;
· ──────────────────
╰────
+ help: Avoid using ambiguous text like "learn more", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ learn more:;
· ──────────────────
╰────
+ help: Avoid using ambiguous text like "learn more", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ link;
· ───────────
╰────
+ help: Avoid using ambiguous text like "link", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ a link;
· ─────────────
╰────
+ help: Avoid using ambiguous text like "a link", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ something;
· ────────────────────────────────────────
╰────
+ help: Avoid using ambiguous text like "click here", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ a link ;
· ───────────────
╰────
+ help: Avoid using ambiguous text like "a link", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ a link;
· ────────────────────
╰────
+ help: Avoid using ambiguous text like "a link", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ a link;
· ────────────────────
╰────
+ help: Avoid using ambiguous text like "a link", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ click here;
· ──────────────────────────────
╰────
+ help: Avoid using ambiguous text like "click here", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ click here;
· ────────────────────────────────
╰────
+ help: Avoid using ambiguous text like "click here", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ more textlearn more;
· ───────────────────────────────────────────────────
╰────
+ help: Avoid using ambiguous text like "learn more", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ more textlearn more;
· ──────────────────────────────────────────────────────────
╰────
+ help: Avoid using ambiguous text like "learn more", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ ;
· ──────────────────────────────
╰────
+ help: Avoid using ambiguous text like "click here", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ click here;
· ────────────────────────────────────────────────────────────────
╰────
+ help: Avoid using ambiguous text like "click here", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ click here;
· ─────────────────────────────────────────────────────────────────────────────
╰────
+ help: Avoid using ambiguous text like "click here", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ click here;
· ────────────────────────────────────────────────
╰────
+ help: Avoid using ambiguous text like "click here", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ here
· ─────────────────
╰────
+ help: Avoid using ambiguous text like "here", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │
· ─────────────────────────────────
╰────
+ help: Avoid using ambiguous text like "click here", replace it with more descriptive text that provides context.
- ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Unexpected ambagious anchor link text.
+ ⚠ eslint-plugin-jsx-a11y(anchor-ambiguous-text): Ambiguous text within anchor, screen reader users rely on link text for context.
╭─[anchor_ambiguous_text.tsx:1:1]
1 │ a disallowed word
· ────────────────────────
╰────
+ help: Avoid using ambiguous text like "a disallowed word", replace it with more descriptive text that provides context.