primer / eslint-plugin-primer-react

ESLint rules for Primer React

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Idea] Opinionated rule that requires `as` to be set for `<Heading>`

khiga8 opened this issue · comments

Currently <Heading> defaults to h3 so consumers don't need to explicitly set as.

Default example:

<Heading>Some heading</Heading>

Should heading as always be set to ensure consumers are intentional, rather than obscuring by default?

Here is an example with the same default heading but with level explicitly set:

<Heading as="h3">Some heading</Heading>

cc: @TylerJDev

I think this is a great idea. Since removing the as prop entirely would result in a breaking change, I think that this is a good way to slowly lower the amount of usages where the heading level isn't defined.

We could also add to this rule to ensure that usage of as is only being used with heading elements. We already have some safeguards around this, but I think adding this as a rule could supplement those safeguards.

Closing as a11y-explicit-heading rule has been added to eslint-plugin-primer-react!