Skip to content

Commit 3292438

Browse files
authored
Merge branch 'main' into skip-import-system-props
2 parents 4f3270a + f8381ee commit 3292438

10 files changed

+110
-82
lines changed

CHANGELOG.md

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

3+
## 0.7.3
4+
5+
### Patch Changes
6+
7+
- [#27](https://github.com/primer/eslint-plugin-primer-react/pull/27) [`19cbc53`](https://github.com/primer/eslint-plugin-primer-react/commit/19cbc530471f11c4c053ce830e23cb72f36b2c16) Thanks [@colebemis](https://github.com/colebemis)! - `no-system-props`: Ignore `bg` prop on `PointerBox` component
8+
9+
## 0.7.2
10+
11+
### Patch Changes
12+
13+
- [#24](https://github.com/primer/eslint-plugin-primer-react/pull/24) [`e5565ae`](https://github.com/primer/eslint-plugin-primer-react/commit/e5565ae890f55927c0b1dd96d8943efc1e0bbbfa) Thanks [@colebemis](https://github.com/colebemis)! - Replace references to `@primer/components` with `@primer/react`
14+
15+
## 0.7.1
16+
17+
### Patch Changes
18+
19+
- [#22](https://github.com/primer/eslint-plugin-primer-react/pull/22) [`87d0fd6`](https://github.com/primer/eslint-plugin-primer-react/commit/87d0fd6af8a18a2a570c3770571b16fe3b5c3a30) Thanks [@dmarcey](https://github.com/dmarcey)! - Ignore non-literal, non-string arguments to `themeGet` in `no-deprecated-colors` rule
20+
321
## 0.7.0
422

523
### Minor Changes
@@ -30,7 +48,7 @@
3048

3149
```js
3250
/* eslint primer-react/no-deprecated-colors: ["warn", {"checkAllStrings": true}] */
33-
import {Box} from '@primer/components'
51+
import {Box} from '@primer/react'
3452

3553
function ExampleComponent() {
3654
const styles = {
@@ -45,7 +63,7 @@
4563

4664
### Patch Changes
4765

48-
- [#7](https://github.com/primer/eslint-plugin-primer-react/pull/7) [`d9dfb8d`](https://github.com/primer/eslint-plugin-primer-react/commit/d9dfb8de6d6dc42efe606517db7a0dd90d5c5578) Thanks [@colebemis](https://github.com/colebemis)! - Add `skipImportCheck` option. By default, the `no-deprecated-colors` rule will only check for deprecated colors used in functions and components that are imported from `@primer/components`. You can disable this behavior by setting `skipImportCheck` to `true`. This is useful for linting custom components that pass color-related props down to Primer React components.
66+
- [#7](https://github.com/primer/eslint-plugin-primer-react/pull/7) [`d9dfb8d`](https://github.com/primer/eslint-plugin-primer-react/commit/d9dfb8de6d6dc42efe606517db7a0dd90d5c5578) Thanks [@colebemis](https://github.com/colebemis)! - Add `skipImportCheck` option. By default, the `no-deprecated-colors` rule will only check for deprecated colors 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 color-related props down to Primer React components.
4967

5068
* [#6](https://github.com/primer/eslint-plugin-primer-react/pull/6) [`dd14594`](https://github.com/primer/eslint-plugin-primer-react/commit/dd14594b05e4d800baa76771f5b911d77352a983) Thanks [@colebemis](https://github.com/colebemis)! - The `no-deprecated-colors` rule can now find deprecated colors in the following cases:
5169

docs/rules/no-deprecated-colors.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This rule disallows references to color variables that are deprecated in [Primer
1212

1313
```jsx
1414
/* eslint primer-react/no-deprecated-colors: "error" */
15-
import {Box, themeGet} from '@primer/components'
15+
import {Box, themeGet} from '@primer/react'
1616
import styled from 'styled-components'
1717

1818
const SystemPropExample() = () => <Box color="some.deprecated.color">Incorrect</Box>
@@ -30,7 +30,7 @@ const ThemeGetExample = styled.div`
3030

3131
```jsx
3232
/* eslint primer-react/no-deprecated-colors: "error" */
33-
import {Box, themeGet} from '@primer/components'
33+
import {Box, themeGet} from '@primer/react'
3434
import styled from 'styled-components'
3535

3636
const SystemPropExample() = () => <Box color="some.color">Correct</Box>
@@ -48,11 +48,11 @@ const ThemeGetExample = styled.div`
4848

4949
- `skipImportCheck` (default: `false`)
5050

51-
By default, the `no-deprecated-colors` rule will only check for deprecated colors used in functions and components that are imported from `@primer/components`. You can disable this behavior by setting `skipImportCheck` to `true`. This is useful for linting custom components that pass color-related props down to Primer React components.
51+
By default, the `no-deprecated-colors` rule will only check for deprecated colors 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 color-related props down to Primer React components.
5252

5353
```js
5454
/* eslint primer-react/no-deprecated-colors: ["warn", {"skipImportCheck": true}] */
55-
import {Box} from '@primer/components'
55+
import {Box} from '@primer/react'
5656

5757
function MyBox({color, children}) {
5858
return <Box color={color}>{children}</Box>
@@ -70,7 +70,7 @@ const ThemeGetExample = styled.div`
7070

7171
```js
7272
/* eslint primer-react/no-deprecated-colors: ["warn", {"checkAllStrings": true}] */
73-
import {Box} from '@primer/components'
73+
import {Box} from '@primer/react'
7474

7575
function ExampleComponent() {
7676
const styles = {

docs/rules/no-system-props.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This rule disallows the use of any styled-system prop on Primer components, as t
1414

1515
```jsx
1616
/* eslint primer-react/no-system-props: "error" */
17-
import {Button} from '@primer/components'
17+
import {Button} from '@primer/react'
1818

1919
<Button width={200} />
2020
<Button width={200} sx={{height: 300}} />
@@ -24,7 +24,7 @@ import {Button} from '@primer/components'
2424

2525
```jsx
2626
/* eslint primer-react/no-system-props: "error" */
27-
import {Box, Button, ProgressBar} from '@primer/components'
27+
import {Box, Button, ProgressBar} from '@primer/react'
2828
import {Avatar} from 'some-other-library'
2929
// Non-system props are allowed
3030
<Button someOtherProp="foo" />
@@ -51,7 +51,7 @@ import {Avatar} from 'some-other-library'
5151

5252
```js
5353
/* eslint primer-react/no-system-props: ["warn", {"includeUtilityComponents": true}] */
54-
import {Box} from '@primer/components'
54+
import {Box} from '@primer/react'
5555

5656
function App() {
5757
// Enabling `includeUtilityComponents` will find system prop usage on utility components like this:

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-primer-react",
3-
"version": "0.7.0",
3+
"version": "0.7.3",
44
"description": "ESLint rules for Primer React",
55
"main": "src/index.js",
66
"scripts": {

src/rules/__tests__/no-deprecated-colors.test.js

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,16 @@ const ruleTester = new RuleTester({
2828
ruleTester.run('no-deprecated-colors', rule, {
2929
valid: [
3030
`import {Box} from '@other/design-system'; <Box color="text.primary">Hello</Box>`,
31-
`import {Box} from "@primer/components"; <Box color="fg.default">Hello</Box>`,
32-
`import {hello} from "@primer/components"; hello("colors.text.primary")`,
33-
`import {themeGet} from "@primer/components"; themeGet("space.text.primary")`,
31+
`import {Box} from "@primer/react"; <Box color="fg.default">Hello</Box>`,
32+
`import {hello} from "@primer/react"; hello("colors.text.primary")`,
33+
`import {themeGet} from "@primer/react"; themeGet("space.text.primary")`,
34+
`import {themeGet} from "@primer/react"; themeGet(props.backgroundColorThemeValue)`,
35+
`import {themeGet} from "@primer/react"; themeGet(2)`,
3436
`import {themeGet} from "@other/design-system"; themeGet("colors.text.primary")`,
3537
`import {get} from "@other/constants"; get("space.text.primary")`,
36-
`import {Box} from '@primer/components'; <Box sx={styles}>Hello</Box>`,
37-
`import {Box} from '@primer/components'; <Box sx={{color: text.primary}}>Hello</Box>`,
38-
`import {Box} from '@primer/components'; <Box sx={{color: "fg.default"}}>Hello</Box>`,
38+
`import {Box} from '@primer/react'; <Box sx={styles}>Hello</Box>`,
39+
`import {Box} from '@primer/react'; <Box sx={{color: text.primary}}>Hello</Box>`,
40+
`import {Box} from '@primer/react'; <Box sx={{color: "fg.default"}}>Hello</Box>`,
3941
`{color: 'text.primary'}`
4042
],
4143
invalid: [
@@ -50,8 +52,8 @@ ruleTester.run('no-deprecated-colors', rule, {
5052
]
5153
},
5254
{
53-
code: `import {Box} from "@primer/components"; function Example() { return <Box color="text.primary">Hello</Box> }`,
54-
output: `import {Box} from "@primer/components"; function Example() { return <Box color="fg.default">Hello</Box> }`,
55+
code: `import {Box} from "@primer/react"; function Example() { return <Box color="text.primary">Hello</Box> }`,
56+
output: `import {Box} from "@primer/react"; function Example() { return <Box color="fg.default">Hello</Box> }`,
5557
errors: [
5658
{
5759
message: '"text.primary" is deprecated. Use "fg.default" instead.'
@@ -69,97 +71,97 @@ ruleTester.run('no-deprecated-colors', rule, {
6971
]
7072
},
7173
{
72-
code: `import Box from '@primer/components/lib-esm/Box'; function Example() { return <Box color="text.primary">Hello</Box> }`,
73-
output: `import Box from '@primer/components/lib-esm/Box'; function Example() { return <Box color="fg.default">Hello</Box> }`,
74+
code: `import Box from '@primer/react/lib-esm/Box'; function Example() { return <Box color="text.primary">Hello</Box> }`,
75+
output: `import Box from '@primer/react/lib-esm/Box'; function Example() { return <Box color="fg.default">Hello</Box> }`,
7476
errors: [
7577
{
7678
message: '"text.primary" is deprecated. Use "fg.default" instead.'
7779
}
7880
]
7981
},
8082
{
81-
code: `import {Box} from "@primer/components"; const Example = () => <Box color="text.primary">Hello</Box>`,
82-
output: `import {Box} from "@primer/components"; const Example = () => <Box color="fg.default">Hello</Box>`,
83+
code: `import {Box} from "@primer/react"; const Example = () => <Box color="text.primary">Hello</Box>`,
84+
output: `import {Box} from "@primer/react"; const Example = () => <Box color="fg.default">Hello</Box>`,
8385
errors: [
8486
{
8587
message: '"text.primary" is deprecated. Use "fg.default" instead.'
8688
}
8789
]
8890
},
8991
{
90-
code: `import {Box} from "@primer/components"; <Box bg="bg.primary" m={1} />`,
91-
output: `import {Box} from "@primer/components"; <Box bg="canvas.default" m={1} />`,
92+
code: `import {Box} from "@primer/react"; <Box bg="bg.primary" m={1} />`,
93+
output: `import {Box} from "@primer/react"; <Box bg="canvas.default" m={1} />`,
9294
errors: [
9395
{
9496
message: '"bg.primary" is deprecated. Use "canvas.default" instead.'
9597
}
9698
]
9799
},
98100
{
99-
code: `import {Box} from "@primer/components"; <Box sx={{bg: "bg.primary", m: 1, ...rest}} />`,
100-
output: `import {Box} from "@primer/components"; <Box sx={{bg: "canvas.default", m: 1, ...rest}} />`,
101+
code: `import {Box} from "@primer/react"; <Box sx={{bg: "bg.primary", m: 1, ...rest}} />`,
102+
output: `import {Box} from "@primer/react"; <Box sx={{bg: "canvas.default", m: 1, ...rest}} />`,
101103
errors: [
102104
{
103105
message: '"bg.primary" is deprecated. Use "canvas.default" instead.'
104106
}
105107
]
106108
},
107109
{
108-
code: `import {Box} from "@primer/components"; <Box sx={{boxShadow: theme => theme.shadows.autocomplete.shadow}} />`,
109-
output: `import {Box} from "@primer/components"; <Box sx={{boxShadow: theme => theme.shadows.shadow.medium}} />`,
110+
code: `import {Box} from "@primer/react"; <Box sx={{boxShadow: theme => theme.shadows.autocomplete.shadow}} />`,
111+
output: `import {Box} from "@primer/react"; <Box sx={{boxShadow: theme => theme.shadows.shadow.medium}} />`,
110112
errors: [
111113
{
112114
message: '"theme.shadows.autocomplete.shadow" is deprecated. Use "theme.shadows.shadow.medium" instead.'
113115
}
114116
]
115117
},
116118
{
117-
code: `import {Box} from "@primer/components"; <Box sx={{boxShadow: theme => \`0 1px 2px \${theme.colors.text.primary}\`}} />`,
118-
output: `import {Box} from "@primer/components"; <Box sx={{boxShadow: theme => \`0 1px 2px \${theme.colors.fg.default}\`}} />`,
119+
code: `import {Box} from "@primer/react"; <Box sx={{boxShadow: theme => \`0 1px 2px \${theme.colors.text.primary}\`}} />`,
120+
output: `import {Box} from "@primer/react"; <Box sx={{boxShadow: theme => \`0 1px 2px \${theme.colors.fg.default}\`}} />`,
119121
errors: [
120122
{
121123
message: '"theme.colors.text.primary" is deprecated. Use "theme.colors.fg.default" instead.'
122124
}
123125
]
124126
},
125127
{
126-
code: `import {Box} from "@primer/components"; <Box sx={{boxShadow: t => \`0 1px 2px \${t.colors.text.primary}\`}} />`,
127-
output: `import {Box} from "@primer/components"; <Box sx={{boxShadow: t => \`0 1px 2px \${t.colors.fg.default}\`}} />`,
128+
code: `import {Box} from "@primer/react"; <Box sx={{boxShadow: t => \`0 1px 2px \${t.colors.text.primary}\`}} />`,
129+
output: `import {Box} from "@primer/react"; <Box sx={{boxShadow: t => \`0 1px 2px \${t.colors.fg.default}\`}} />`,
128130
errors: [
129131
{
130132
message: '"t.colors.text.primary" is deprecated. Use "t.colors.fg.default" instead.'
131133
}
132134
]
133135
},
134136
{
135-
code: `import {Box} from "@primer/components"; <Box sx={{"&:hover": {bg: "bg.primary"}}} />`,
136-
output: `import {Box} from "@primer/components"; <Box sx={{"&:hover": {bg: "canvas.default"}}} />`,
137+
code: `import {Box} from "@primer/react"; <Box sx={{"&:hover": {bg: "bg.primary"}}} />`,
138+
output: `import {Box} from "@primer/react"; <Box sx={{"&:hover": {bg: "canvas.default"}}} />`,
137139
errors: [
138140
{
139141
message: '"bg.primary" is deprecated. Use "canvas.default" instead.'
140142
}
141143
]
142144
},
143145
{
144-
code: `import {Box} from "@primer/components"; <Box color="auto.green.5" />`,
146+
code: `import {Box} from "@primer/react"; <Box color="auto.green.5" />`,
145147
errors: [
146148
{
147149
message: '"auto.green.5" is deprecated.',
148150
suggestions: [
149151
{
150152
desc: 'Use "success.fg" instead.',
151-
output: `import {Box} from "@primer/components"; <Box color="success.fg" />`
153+
output: `import {Box} from "@primer/react"; <Box color="success.fg" />`
152154
},
153155
{
154156
desc: 'Use "success.emphasis" instead.',
155-
output: `import {Box} from "@primer/components"; <Box color="success.emphasis" />`
157+
output: `import {Box} from "@primer/react"; <Box color="success.emphasis" />`
156158
}
157159
]
158160
}
159161
]
160162
},
161163
{
162-
code: `import {Box} from "@primer/components"; <Box color="fade.fg10" />`,
164+
code: `import {Box} from "@primer/react"; <Box color="fade.fg10" />`,
163165
errors: [
164166
{
165167
message:
@@ -168,8 +170,8 @@ ruleTester.run('no-deprecated-colors', rule, {
168170
]
169171
},
170172
{
171-
code: `import {Box, Text} from "@primer/components"; <Box bg="bg.primary"><Text color="text.primary">Hello</Text></Box>`,
172-
output: `import {Box, Text} from "@primer/components"; <Box bg="canvas.default"><Text color="fg.default">Hello</Text></Box>`,
173+
code: `import {Box, Text} from "@primer/react"; <Box bg="bg.primary"><Text color="text.primary">Hello</Text></Box>`,
174+
output: `import {Box, Text} from "@primer/react"; <Box bg="canvas.default"><Text color="fg.default">Hello</Text></Box>`,
173175
errors: [
174176
{
175177
message: '"bg.primary" is deprecated. Use "canvas.default" instead.'
@@ -180,17 +182,17 @@ ruleTester.run('no-deprecated-colors', rule, {
180182
]
181183
},
182184
{
183-
code: `import {themeGet} from "@primer/components"; themeGet("colors.text.primary")`,
184-
output: `import {themeGet} from "@primer/components"; themeGet("colors.fg.default")`,
185+
code: `import {themeGet} from "@primer/react"; themeGet("colors.text.primary")`,
186+
output: `import {themeGet} from "@primer/react"; themeGet("colors.fg.default")`,
185187
errors: [
186188
{
187189
message: '"colors.text.primary" is deprecated. Use "colors.fg.default" instead.'
188190
}
189191
]
190192
},
191193
{
192-
code: `import {themeGet} from "@primer/components"; themeGet("shadows.autocomplete.shadow")`,
193-
output: `import {themeGet} from "@primer/components"; themeGet("shadows.shadow.medium")`,
194+
code: `import {themeGet} from "@primer/react"; themeGet("shadows.autocomplete.shadow")`,
195+
output: `import {themeGet} from "@primer/react"; themeGet("shadows.shadow.medium")`,
194196
errors: [
195197
{
196198
message: '"shadows.autocomplete.shadow" is deprecated. Use "shadows.shadow.medium" instead.'

0 commit comments

Comments
 (0)