eslint-plugin-primer-react 5.1.0 → 5.2.0-rc.dc08e82

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.
@@ -0,0 +1,19 @@
1
+ name: Release Event Tracking
2
+ # Measure a datadog event every time a release occurs
3
+
4
+ on:
5
+ pull_request:
6
+ types:
7
+ - closed
8
+ - opened
9
+ - reopened
10
+
11
+ release:
12
+ types: [published]
13
+
14
+ jobs:
15
+ release-tracking:
16
+ name: Release Tracking
17
+ uses: primer/.github/.github/workflows/release_tracking.yml@v2.1.0
18
+ secrets:
19
+ datadog_api_key: ${{ secrets.DATADOG_API_KEY }}
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # eslint-plugin-primer-react
2
2
 
3
+ ## 5.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#190](https://github.com/primer/eslint-plugin-primer-react/pull/190) [`a02a188`](https://github.com/primer/eslint-plugin-primer-react/commit/a02a1884c1334e1cdb43d7c5cafacdfd4ec92e33) Thanks [@khiga8](https://github.com/khiga8)! - \* bump eslint-plugin-github to v5.0.0
8
+
9
+ ### Patch Changes
10
+
11
+ - [#183](https://github.com/primer/eslint-plugin-primer-react/pull/183) [`7bd36d2`](https://github.com/primer/eslint-plugin-primer-react/commit/7bd36d2a9a594a49ab8317a2986eda7c948b16b6) Thanks [@khiga8](https://github.com/khiga8)! - New rule to flag `Link` in text block missing the `inline` prop
12
+
3
13
  ## 5.1.0
4
14
 
5
15
  ### Minor Changes
@@ -0,0 +1,100 @@
1
+ ## Require `inline` prop on `<Link>` component inside a text block
2
+
3
+ The `Link` component should have the `inline` prop when it is used inside of a text block.
4
+
5
+ ## Rule Details
6
+
7
+ This rule enforces setting `inline` on the `<Link>` component when a `<Link>` is detected inside of a text block without distiguishable styling.
8
+
9
+ The lint rule will essentially flag any `<Link>` without the `inline` property (equal to `true`) detected with string nodes on either side.
10
+
11
+ This rule will not catch all instances of link in text block due to the limitations of static analysis, so be sure to also have in-browser checks in place such as the [link-in-text-block Axe rule](https://dequeuniversity.com/rules/axe/4.9/link-in-text-block) for additional coverage.
12
+
13
+ The edge cases that the linter skips to avoid false positives will include:
14
+
15
+ - `<Link sx={{fontWeight:...}}>` or `<Link sx={{fontFamily:...}}>` because these technically may provide sufficient distinguishing styling.
16
+ - `<Link>` where the only adjacent text is a period, since that can't really be considered a text block.
17
+ - `<Link>` where the children is a JSX component, rather than a string literal, because then it might be an icon link rather than a text link.
18
+ - `<Link>` that are nested inside of headings as these have often been breadcrumbs.
19
+
20
+ 👎 Examples of **incorrect** code for this rule
21
+
22
+ ```jsx
23
+ import {Link} from '@primer/react'
24
+
25
+ function ExampleComponent() {
26
+ return (
27
+ <SomeComponent>
28
+ <Link>Say hello</Link> or not.
29
+ </SomeComponent>
30
+ )
31
+ }
32
+ ```
33
+
34
+ ```jsx
35
+ import {Link} from '@primer/react'
36
+
37
+ function ExampleComponent() {
38
+ return (
39
+ <SomeComponent>
40
+ Say hello or <Link>sign-up</Link>.
41
+ </SomeComponent>
42
+ )
43
+ }
44
+ ```
45
+
46
+ 👍 Examples of **correct** code for this rule:
47
+
48
+ ```jsx
49
+ function ExampleComponent() {
50
+ return (
51
+ <SomeComponent>
52
+ <Link inline>Say hello</Link> or not.
53
+ </SomeComponent>
54
+ )
55
+ }
56
+ ```
57
+
58
+ ```jsx
59
+ function ExampleComponent() {
60
+ return (
61
+ <SomeComponent>
62
+ <Link inline={true}>Say hello</Link> or not.
63
+ </SomeComponent>
64
+ )
65
+ }
66
+ ```
67
+
68
+ This rule will skip `Link`s containing JSX elements to minimize potential false positives because it is possible the JSX element sufficiently distinguishes the link from surrounding text.
69
+
70
+ ```jsx
71
+ function ExampleComponent() {
72
+ return (
73
+ <SomeComponent>
74
+ <Link>
75
+ <SomeAvatar />
76
+ @monalisa
77
+ </Link>{' '}
78
+ commented on your account.
79
+ </SomeComponent>
80
+ )
81
+ }
82
+ ```
83
+
84
+ This rule will skip `Link`s nested inside of a `Heading`.
85
+
86
+ ```jsx
87
+ function ExampleComponent() {
88
+ return (
89
+ <Heading>
90
+ <Link>Previous location</Link>/ Current location
91
+ </Heading>
92
+ )
93
+ }
94
+ ```
95
+
96
+ ## Options
97
+
98
+ - `skipImportCheck` (default: `false`)
99
+
100
+ By default, the `a11y-explicit-heading` rule will only check for `<Heading>` components imported directly from `@primer/react`. You can disable this behavior by setting `skipImportCheck` to `true`.