We currently have an ESLint rule named a11y-link-in-text-block. This rule suggests usage of the inline prop if the link is within a text block, as suggested in a11y-link-text-block.md. We should add onto this rule by also looking at HTML anchor elements (e.g. <a href>) in a similar fashion to how we currently do it in the rule. Instead of suggesting the inline prop, we should suggest conversion of HTML links to Link components that exist within primer/react.
For HTML anchor elements, we should suggest in the ESLint message that it is suggested to utilize the Link component that we provide in PRC. The autofix should replace the anchor element with the Link component, and keep everything else, such as attributes and text content.
- Update
src/rules/a11y-link-in-text-block.js to introduce a new check for HTML anchor elements
- The new check should mirror the one that we have for the
Link component, but instead suggest usage of the Link component and include an autofix which will replace the anchor element with the Link component
- Update
docs/rules/a11y-link-in-text-block.md with the new addition. The update to the docs should include examples of incorrect usage and correct usage, following the theme of the existing content within that file.
- Add tests in
src/rules/a11y-link-in-text-block.js which should test the new change, and ensure that the anchor element is correctly replaced with the Link component
- Run
npm test to ensure that there are no failures related to the changes added
In summary, the change should ideally be lightweight and follow the themes that already exist.
We currently have an ESLint rule named
a11y-link-in-text-block. This rule suggests usage of theinlineprop if the link is within a text block, as suggested ina11y-link-text-block.md. We should add onto this rule by also looking at HTML anchor elements (e.g.<a href>) in a similar fashion to how we currently do it in the rule. Instead of suggesting theinlineprop, we should suggest conversion of HTML links toLinkcomponents that exist withinprimer/react.For HTML anchor elements, we should suggest in the ESLint message that it is suggested to utilize the
Linkcomponent that we provide in PRC. The autofix should replace the anchor element with theLinkcomponent, and keep everything else, such as attributes and text content.src/rules/a11y-link-in-text-block.jsto introduce a new check for HTML anchor elementsLinkcomponent, but instead suggest usage of theLinkcomponent and include an autofix which will replace the anchor element with theLinkcomponentdocs/rules/a11y-link-in-text-block.mdwith the new addition. The update to the docs should include examples of incorrect usage and correct usage, following the theme of the existing content within that file.src/rules/a11y-link-in-text-block.jswhich should test the new change, and ensure that the anchor element is correctly replaced with theLinkcomponentnpm testto ensure that there are no failures related to the changes addedIn summary, the change should ideally be lightweight and follow the themes that already exist.