eslint-plugin-primer-react 1.0.1 → 2.0.0-rc.022b246

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # eslint-plugin-primer-react
2
2
 
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#39](https://github.com/primer/eslint-plugin-primer-react/pull/39) [`96a675d`](https://github.com/primer/eslint-plugin-primer-react/commit/96a675d8865450d3be556135947a29181a56551c) Thanks [@colebemis](https://github.com/colebemis)! - Add `direct-slot-children` rule
8
+
9
+ ### Minor Changes
10
+
11
+ - [#21](https://github.com/primer/eslint-plugin-primer-react/pull/21) [`5f68eb7`](https://github.com/primer/eslint-plugin-primer-react/commit/5f68eb7e222e2a41c527b5036b1308ff293e7a0d) Thanks [@SferaDev](https://github.com/SferaDev)! - `no-system-props`: Add `skipImportCheck` option
12
+
3
13
  ## 1.0.1
4
14
 
5
15
  ### Patch Changes
package/README.md CHANGED
@@ -29,5 +29,6 @@ ESLint rules for Primer React
29
29
 
30
30
  ## Rules
31
31
 
32
+ - [direct-slot-children](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/direct-slot-children.md)
32
33
  - [no-deprecated-colors](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/no-deprecated-colors.md)
33
34
  - [no-system-props](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/no-system-props.md)
@@ -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
+ ```
@@ -1,4 +1,4 @@
1
- # Disallow use of styled-system props (no-system-colors)
1
+ # Disallow use of styled-system props (no-system-props)
2
2
 
3
3
  🔧 The `--fix` option on the [ESLint CLI](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
4
4
 
@@ -41,6 +41,10 @@ import {Avatar} from 'some-other-library'
41
41
 
42
42
  ## Options
43
43
 
44
+ - `skipImportCheck` (default: `false`)
45
+
46
+ By default, the `no-system-props` rule will only check for styled system props used in functions and components that are imported from `@primer/react`. You can disable this behavior by setting `skipImportCheck` to `true`. This is useful for linting custom components that pass styled system props down to Primer React components.
47
+
44
48
  - `includeUtilityComponents` (default: `false`)
45
49
 
46
50
  By default, `Box` and `Text` are excluded because styled system props are not deprecated in our utility components. If you prefer to avoid styled system props there as well for consistency, you can set `includeUtilityComponents` to `true`.