Skip to content

createInterpolateElement() triggers jsx-a11y/anchor-has-content #21441

Open

Description

Problem

#20699 introduced createInterpolateElement(), but using it with anchor tags triggers the jsx-a11y/anchor-has-content rule. e.g.,

createInterpolateElement(
	__( 'There was an error trying to render this content, please try another browser or device. If that doesn\'t work, please <a>contact us</a>.', 'wordcamporg' ),
	{
		a: <a href={ 'https://central.wordcamp.org/contact-us/' } />,
	}
);
> npm run lint:js source/utils/render-frontend.js

...
63:9   error  Anchors must have content and the content must be accessible by a screen reader  jsx-a11y/anchor-has-content

Potential solutions

I'm not seeing any great solutions at first glance.

  • Disable the linter rule
  • Replace it with a custom rule that is aware of createInterpolateElement()
  • Refactor createInterpolateElement() to avoid triggering the rule.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions