Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

feat: add jsx-a11y/iframe-has-title lint rule #437

Merged
merged 3 commits into from
May 16, 2020
Merged

feat: add jsx-a11y/iframe-has-title lint rule #437

merged 3 commits into from
May 16, 2020

Conversation

bitpshr
Copy link
Contributor

@bitpshr bitpshr commented May 16, 2020

This pull request implements the jsx-a11y/iframe-has-title lint rule, enforcing that <iframe> JSX elements have a title attribute.

References #341

Comment on lines +14 to +29
node.type === 'JSXElement' &&
node.name.type === 'JSXIdentifier' &&
node.name.name === 'iframe' &&
!node.attributes.some((attribute) =>
attribute.type === 'JSXAttribute' &&
attribute.name.name === 'title' &&
attribute.value &&
((attribute.value.type === 'StringLiteral' &&
attribute.value.value.length > 0) ||
(attribute.value.type === 'JSXExpressionContainer' &&
((attribute.value.expression.type === 'ReferenceIdentifier' &&
attribute.value.expression.name !== 'undefined') ||
(attribute.value.expression.type === 'StringLiteral' &&
attribute.value.expression.value.length > 0))))
)
);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should abstract some of the attribute checking out into a util method since it seems to be a common pattern for JSX rules.

@sebmck
Copy link
Contributor

sebmck commented May 16, 2020

Thank you!

@sebmck sebmck merged commit 04da374 into rome:master May 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants