From 806fba474a4efb28c407104e5054565108e716de Mon Sep 17 00:00:00 2001 From: Shinyaigeek Date: Thu, 30 Nov 2023 01:24:58 +0900 Subject: [PATCH] fixup! feat(linter): Implement img-redundant-alt rule for jsx_a11y plugin --- .../src/rules/jsx_a11y/img_redundant_alt.rs | 4 +- .../src/snapshots/img_redundant_alt.snap | 138 +++++++++--------- 2 files changed, 71 insertions(+), 71 deletions(-) diff --git a/crates/oxc_linter/src/rules/jsx_a11y/img_redundant_alt.rs b/crates/oxc_linter/src/rules/jsx_a11y/img_redundant_alt.rs index e235039143635..939b0af169c23 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/img_redundant_alt.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/img_redundant_alt.rs @@ -18,8 +18,8 @@ use crate::utils::{get_prop_value, has_jsx_prop_lowercase, is_hidden_from_screen use crate::{context::LintContext, rule::Rule, AstNode}; #[derive(Debug, Error, Diagnostic)] -#[error("eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. 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.")] -#[diagnostic(severity(warning), help("Provide no redundant alt text for image."))] +#[error("eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute.")] +#[diagnostic(severity(warning), 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."))] struct ImgRedundantAltDiagnostic(#[label] pub Span); declare_oxc_lint!( diff --git a/crates/oxc_linter/src/snapshots/img_redundant_alt.snap b/crates/oxc_linter/src/snapshots/img_redundant_alt.snap index d5cffd49f7fd3..42030de5ce856 100644 --- a/crates/oxc_linter/src/snapshots/img_redundant_alt.snap +++ b/crates/oxc_linter/src/snapshots/img_redundant_alt.snap @@ -2,188 +2,188 @@ source: crates/oxc_linter/src/tester.rs expression: img_redundant_alt --- - ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. 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. + ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. ╭─[img_redundant_alt.tsx:1:1] 1 │ Photo of friend.; · ─── ╰──── - help: Provide no redundant alt text for image. + 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. - ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. 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. + ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. ╭─[img_redundant_alt.tsx:1:1] 1 │ Picture of friend.; · ─── ╰──── - help: Provide no redundant alt text for image. + 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. - ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. 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. + ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. ╭─[img_redundant_alt.tsx:1:1] 1 │ Image of friend.; · ─── ╰──── - help: Provide no redundant alt text for image. + 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. - ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. 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. + ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. ╭─[img_redundant_alt.tsx:1:1] 1 │ PhOtO of friend.; · ─── ╰──── - help: Provide no redundant alt text for image. + 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. - ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. 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. + ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. ╭─[img_redundant_alt.tsx:1:1] 1 │ {'photo'}; · ─── ╰──── - help: Provide no redundant alt text for image. + 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. - ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. 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. + ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. ╭─[img_redundant_alt.tsx:1:1] 1 │ piCTUre of friend.; · ─── ╰──── - help: Provide no redundant alt text for image. + 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. - ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. 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. + ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. ╭─[img_redundant_alt.tsx:1:1] 1 │ imAGE of friend.; · ─── ╰──── - help: Provide no redundant alt text for image. + 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. - ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. 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. + ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. ╭─[img_redundant_alt.tsx:1:1] 1 │ photo of cool person · ─── ╰──── - help: Provide no redundant alt text for image. + 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. - ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. 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. + ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. ╭─[img_redundant_alt.tsx:1:1] 1 │ picture of cool person · ─── ╰──── - help: Provide no redundant alt text for image. + 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. - ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. 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. + ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. ╭─[img_redundant_alt.tsx:1:1] 1 │ image of cool person · ─── ╰──── - help: Provide no redundant alt text for image. + 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. - ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. 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. + ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. ╭─[img_redundant_alt.tsx:1:1] 1 │ photo · ─── ╰──── - help: Provide no redundant alt text for image. + 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. - ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. 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. + ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. ╭─[img_redundant_alt.tsx:1:1] 1 │ image · ─── ╰──── - help: Provide no redundant alt text for image. + 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. - ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. 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. + ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. ╭─[img_redundant_alt.tsx:1:1] 1 │ picture · ─── ╰──── - help: Provide no redundant alt text for image. + 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. - ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. 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. + ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. ╭─[img_redundant_alt.tsx:1:1] 1 │ {`picture · ─── ╰──── - help: Provide no redundant alt text for image. + 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. - ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. 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. + ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. ╭─[img_redundant_alt.tsx:1:1] 1 │ {`photo · ─── ╰──── - help: Provide no redundant alt text for image. + 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. - ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. 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. + ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. ╭─[img_redundant_alt.tsx:1:1] 1 │ {`image · ─── ╰──── - help: Provide no redundant alt text for image. + 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. - ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. 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. + ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. ╭─[img_redundant_alt.tsx:1:1] 1 │ {`picture · ─── ╰──── - help: Provide no redundant alt text for image. + 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. - ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. 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. + ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. ╭─[img_redundant_alt.tsx:1:1] 1 │ {`photo · ─── ╰──── - help: Provide no redundant alt text for image. + 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. - ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. 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. + ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. ╭─[img_redundant_alt.tsx:1:1] 1 │ {`image · ─── ╰──── - help: Provide no redundant alt text for image. + 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. - ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. 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. + ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. ╭─[img_redundant_alt.tsx:1:1] 1 │ Word1; · ─── ╰──── - help: Provide no redundant alt text for image. + 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. - ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. 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. + ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. ╭─[img_redundant_alt.tsx:1:1] 1 │ Word2; · ─── ╰──── - help: Provide no redundant alt text for image. + 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. - ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. 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. + ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. ╭─[img_redundant_alt.tsx:1:1] 1 │ Word1; · ─── ╰──── - help: Provide no redundant alt text for image. + 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. - ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. 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. + ⚠ eslint-plugin-jsx-a11y(img-redundant-alt): Redundant alt attribute. ╭─[img_redundant_alt.tsx:1:1] 1 │ Word2; · ─── ╰──── - help: Provide no redundant alt text for image. + 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.