Skip to content

Conversation

@connorshea
Copy link
Contributor

@connorshea connorshea commented Dec 6, 2025

These were wrong previously due to the fields having different names in the config object than the actual configuration passed to the rule. The docs will now match the result we expect to see from the

Also updated the tests to cover more cases, and found a few places where the current logic is problematic.

Generated docs:

## Configuration

This rule accepts a configuration object with the following properties:

### components

type: `string[]`

default: `["img"]`

JSX element types to validate (component names) where the rule applies.
For example, `["img", "Image"]`.

### words

type: `string[]`

default: `["image", "photo", "picture"]`

Words considered redundant in alt text that should trigger a warning.

Copilot AI review requested due to automatic review settings December 6, 2025 01:51
@connorshea connorshea requested a review from camc314 as a code owner December 6, 2025 01:51
@github-actions github-actions bot added A-linter Area - Linter C-docs Category - Documentation. Related to user-facing or internal documentation labels Dec 6, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug in the jsx-a11y/img-redundant-alt linter rule where the configuration option names in the struct didn't match the keys used in the from_configuration() method. The internal field names types_to_validate and redundant_words have been renamed to components and words respectively, aligning with what users actually configure in their .oxlintrc.json files. Additionally, a minor typo in the diagnostic help message was corrected.

Key Changes:

  • Renamed internal struct fields to match user-facing configuration keys (types_to_validatecomponents, redundant_wordswords)
  • Fixed punctuation typo in diagnostic message (`photo,``photo`)

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
crates/oxc_linter/src/rules/jsx_a11y/img_redundant_alt.rs Updated struct field names and all references to align with configuration keys; fixed punctuation in diagnostic help message
crates/oxc_linter/src/snapshots/jsx_a11y_img_redundant_alt.snap Updated snapshot to reflect the corrected diagnostic help message punctuation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 6, 2025

CodSpeed Performance Report

Merging #16552 will not alter performance

Comparing fix-img-redundant (9302e63) with main (40b0134)1

Summary

✅ 4 untouched
⏩ 41 skipped2

Footnotes

  1. No successful run was found on main (e24aabd) during the generation of this report, so 40b0134 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 41 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

…mes.

These were wrong previously due to the fields having different names in the config object than the actual configuration passed to the rule.

Also, I'm not sure that the tests for this rule adequately cover the configuration options? I didn't update those here, though. Separate problem.
The last two are commented-out, but are from the upstream rule's tests.

Also add a todo message for the diagnostic.
autofix-ci bot and others added 2 commits December 6, 2025 22:13
Also rename 'array' to 'config_array' for clarity.
@connorshea
Copy link
Contributor Author

Added a few tests and some notes on fixes that need to be made in the future, ready to go now.

@camc314 camc314 self-assigned this Dec 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-docs Category - Documentation. Related to user-facing or internal documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants