Skip to content

Commit

Permalink
Add docs for explicit-heading
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerJDev committed Jul 11, 2023
1 parent d17554f commit e738a4b
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions docs/rules/explicit-heading.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## Require explicit heading level on `<Heading>` component

The `Heading` component does not require you to use `as` to specify the heading level, as it will default to an `h2` if one isn't specified. This may lead to inaccessible usage if the default is out of order in the existing heading hierarchy.

## Rule Details

This rule enforces using `as` on the `<Heading>` component to specify a heading level (`h1`-`h6`). In addition, it enforces `as` usage to only be used for headings.

👎 Examples of **incorrect** code for this rule

```jsx
import {Heading} from '@primer/react'

<Heading>Heading without explicit heading level</Heading>
```

`as` must only be for headings (`h1`-`h6`)

```jsx
import {Heading} from '@primer/react'

<Heading as="span">Heading component used as "span"</Heading>
```

👍 Examples of **correct** code for this rule:

```jsx
import {Heading} from '@primer/react';

<Heading as="h2">Heading level 2</Heading>
```

## Options

- `skipImportCheck` (default: `false`)

By default, the `explicit-heading` rule will only check for `<Heading>` components imported directly from `@primer/react`. You can disable this behavior by setting `skipImportCheck` to `true`.

0 comments on commit e738a4b

Please sign in to comment.