Skip to content

Conversation

@rbitting
Copy link
Collaborator

@rbitting rbitting commented Sep 17, 2025

Added rule enforcing Image alt text. Implements #146 .

Example:
Screenshot of a demo of the rule in action

Also fixed a linting issue resulting from running the rule creation script, stemming from the last prettier update. Fixes this problem where every line is shown as a linting error:

Screenshot of an autogenerated file showing a lint error on every line

@rbitting rbitting force-pushed the users/rbitting/image-rule branch from 01de64c to e3d56bf Compare September 17, 2025 13:40
@rbitting rbitting linked an issue Sep 17, 2025 that may be closed by this pull request
* // <img />
* hasDefinedProp(attributes, 'src') // false
*/
const hasDefinedProp = (attributes: TSESTree.JSXOpeningElement["attributes"], name: string): boolean => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think there is already a function that checks for a non-empty prop? Maybe that function could be adjusted to include null and undefined checks?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There's hasNonEmptyProp but adding a flag to that to specifically allow an empty value seemed counter-intuitive. Could rename it from hasNonEmptyProp to hasDefinedProp with a flag to allow non-empty values, but that would require a lot of files to be touched for the name change and I was trying to keep this PR small-ish. If you feel strongly about this I could implement this in a follow-up PR?

@rbitting rbitting force-pushed the users/rbitting/image-rule branch from 936c38c to 7754859 Compare September 18, 2025 14:36
@aubreyquinn aubreyquinn merged commit 80724a6 into main Sep 18, 2025
11 checks passed
@aubreyquinn aubreyquinn deleted the users/rbitting/image-rule branch September 18, 2025 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature: Image coverage

3 participants