eslint-plugin-primer-react 8.4.0 → 8.5.0-rc.1eb9de5

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.
@@ -14,6 +14,6 @@ on:
14
14
  jobs:
15
15
  release-tracking:
16
16
  name: Release Tracking
17
- uses: primer/.github/.github/workflows/release_tracking.yml@v2.2.0
17
+ uses: primer/.github/.github/workflows/release_tracking.yml@v2.2.1
18
18
  secrets:
19
19
  datadog_api_key: ${{ secrets.DATADOG_API_KEY }}
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # eslint-plugin-primer-react
2
2
 
3
+ ## 8.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#443](https://github.com/primer/eslint-plugin-primer-react/pull/443) [`8865e3a`](https://github.com/primer/eslint-plugin-primer-react/commit/8865e3af43dfd302ed345c5b9243c32abe7cebad) Thanks [@hectahertz](https://github.com/hectahertz)! - Add no-use-responsive-value
8
+
3
9
  ## 8.4.0
4
10
 
5
11
  ### Minor Changes
@@ -0,0 +1,102 @@
1
+ # no-use-responsive-value
2
+
3
+ Disallow using `useResponsiveValue` hook from `@primer/react` or local imports.
4
+
5
+ ## Rule Details
6
+
7
+ This rule prevents the use of the `useResponsiveValue` hook from:
8
+
9
+ - `@primer/react` package imports (including `/experimental` and `/deprecated` entrypoints)
10
+ - Local file imports (relative paths containing `useResponsiveValue`)
11
+
12
+ ### Why?
13
+
14
+ This hook is not fully SSR compatible as it relies on `useMediaUnsafeSSR` without a `defaultState`. Using `getResponsiveAttributes` is preferred to avoid hydration mismatches. This rule helps enforce consistent usage of SSR-safe responsive patterns across the codebase.
15
+
16
+ ## Examples
17
+
18
+ ### ❌ Incorrect
19
+
20
+ ```js
21
+ import {useResponsiveValue} from '@primer/react'
22
+
23
+ function Component() {
24
+ const value = useResponsiveValue(['sm', 'md', 'lg'])
25
+ return <div>{value}</div>
26
+ }
27
+ ```
28
+
29
+ ```js
30
+ import {Button, useResponsiveValue} from '@primer/react'
31
+ ```
32
+
33
+ ```js
34
+ import {useResponsiveValue} from '@primer/react/experimental'
35
+ ```
36
+
37
+ ```js
38
+ import {useResponsiveValue} from '../hooks/useResponsiveValue'
39
+ ```
40
+
41
+ ```js
42
+ import useResponsiveValue from '../hooks/useResponsiveValue'
43
+ ```
44
+
45
+ ```js
46
+ import {useResponsiveValue} from './useResponsiveValue'
47
+ ```
48
+
49
+ ### ✅ Correct
50
+
51
+ ```js
52
+ import {Button} from '@primer/react'
53
+
54
+ function Component() {
55
+ // Use alternative responsive patterns
56
+ return <Button>Click me</Button>
57
+ }
58
+ ```
59
+
60
+ ```js
61
+ import {useResponsiveValue} from 'other-library'
62
+
63
+ function Component() {
64
+ // Using useResponsiveValue from a different library is allowed
65
+ const value = useResponsiveValue(['sm', 'md', 'lg'])
66
+ return <div>{value}</div>
67
+ }
68
+ ```
69
+
70
+ ```js
71
+ import {useCustomHook} from '../hooks/useCustomHook'
72
+
73
+ function Component() {
74
+ // Importing other hooks from local paths is allowed
75
+ const value = useCustomHook(['sm', 'md', 'lg'])
76
+ return <div>{value}</div>
77
+ }
78
+ ```
79
+
80
+ ```js
81
+ function useResponsiveValue() {
82
+ // Local function definitions are allowed
83
+ return 'custom implementation'
84
+ }
85
+
86
+ function Component() {
87
+ const value = useResponsiveValue()
88
+ return <div>{value}</div>
89
+ }
90
+ ```
91
+
92
+ ## When Not To Use It
93
+
94
+ If your project needs to use `useResponsiveValue` from `@primer/react`, you can disable this rule:
95
+
96
+ ```js
97
+ /* eslint primer-react/no-use-responsive-value: "off" */
98
+ ```
99
+
100
+ ## Options
101
+
102
+ This rule has no options.