-
Notifications
You must be signed in to change notification settings - Fork 21
Added rule enforcing Image alt text #155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
01de64c to
e3d56bf
Compare
| * // <img /> | ||
| * hasDefinedProp(attributes, 'src') // false | ||
| */ | ||
| const hasDefinedProp = (attributes: TSESTree.JSXOpeningElement["attributes"], name: string): boolean => { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
936c38c to
7754859
Compare
Added rule enforcing Image alt text. Implements #146 .
Example:

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: