Skip to content

Commit a89654d

Browse files
authored
Merge branch 'main' into skip-import-system-props
2 parents 5f68eb7 + 015237e commit a89654d

14 files changed

+9635
-436
lines changed

.changeset/soft-rabbits-stare.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-primer-react": major
3+
---
4+
5+
Add `direct-slot-children` rule

.github/workflows/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# All changes should be reviewed by a member of the @react-reviewers team
2+
* @primer/react-reviewers

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# eslint-plugin-primer-react
22

3+
## 1.0.1
4+
5+
### Patch Changes
6+
7+
- [#36](https://github.com/primer/eslint-plugin-primer-react/pull/36) [`f03cd7d`](https://github.com/primer/eslint-plugin-primer-react/commit/f03cd7defd45e1587dbbfac55a0290172c3b5af3) Thanks [@khiga8](https://github.com/khiga8)! - Define some component mappings for jsx-a11y
8+
9+
## 1.0.0
10+
11+
### Major Changes
12+
13+
- [#34](https://github.com/primer/eslint-plugin-primer-react/pull/34) [`efd4f67`](https://github.com/primer/eslint-plugin-primer-react/commit/efd4f675d8c24b74e7fd0bcfb4524b42ed3378ea) Thanks [@khiga8](https://github.com/khiga8)! - Provide component mapping for `github/react` preset and add dependencies to `eslint-plugin-github` and `eslint-plugin-jsx-a11y`.
14+
15+
`eslint` peer dependency is now `^8.0.1`.
16+
17+
## 0.7.4
18+
19+
### Patch Changes
20+
21+
- [#31](https://github.com/primer/eslint-plugin-primer-react/pull/31) [`a64413a`](https://github.com/primer/eslint-plugin-primer-react/commit/a64413aef359e8f16ca088f1975c5e2411c5ffb3) Thanks [@colebemis](https://github.com/colebemis)! - `no-system-props`: Always ignore `size` prop
22+
323
## 0.7.3
424

525
### Patch Changes

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ ESLint rules for Primer React
2929

3030
## Rules
3131

32+
- [direct-slot-children](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/direct-slot-children.md)
3233
- [no-deprecated-colors](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/no-deprecated-colors.md)
3334
- [no-system-props](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/no-system-props.md)

docs/rules/direct-slot-children.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Enforce direct parent-child relationship of slot components (direct-slot-children)
2+
3+
Some Primer React components use a slots pattern under the hood to render subcomponents in specific places. For example, the `PageLayout` component renders `PageLayout.Header` in the header area, and `PageLayout.Footer` in the footer area. These subcomponents must be direct children of the parent component, and cannot be nested inside other components.
4+
5+
## Rule details
6+
7+
This rule enforces that slot components are direct children of their parent component.
8+
9+
👎 Examples of **incorrect** code for this rule:
10+
11+
```jsx
12+
/* eslint primer-react/direct-slot-children: "error" */
13+
import {PageLayout} from '@primer/react'
14+
15+
const MyHeader = () => <PageLayout.Header>Header</PageLayout.Header>
16+
17+
const App = () => (
18+
<PageLayout>
19+
<MyHeader />
20+
</PageLayout>
21+
)
22+
```
23+
24+
👍 Examples of **correct** code for this rule:
25+
26+
```jsx
27+
/* eslint primer-react/direct-slot-children: "error" */
28+
import {PageLayout} from '@primer/react'
29+
30+
const MyHeader = () => <div>Header</div>
31+
32+
const App = () => (
33+
<PageLayout>
34+
<PageLayout.Header>
35+
<MyHeader />
36+
</PageLayout.Header>
37+
</PageLayout>
38+
)
39+
```

0 commit comments

Comments
 (0)