Skip to content

Replaces references to @primer/components with @primer/react #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/shaggy-coins-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-plugin-primer-react": patch
---

Replace references to `@primer/components` with `@primer/react`
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

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

function ExampleComponent() {
const styles = {
Expand All @@ -51,7 +51,7 @@

### Patch Changes

- [#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.
- [#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.

* [#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:

Expand Down
10 changes: 5 additions & 5 deletions docs/rules/no-deprecated-colors.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This rule disallows references to color variables that are deprecated in [Primer

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

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

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

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

- `skipImportCheck` (default: `false`)

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.
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.

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

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

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

function ExampleComponent() {
const styles = {
Expand Down
6 changes: 3 additions & 3 deletions docs/rules/no-system-props.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This rule disallows the use of any styled-system prop on Primer components, as t

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

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

```jsx
/* eslint primer-react/no-system-props: "error" */
import {Box, Button, ProgressBar} from '@primer/components'
import {Box, Button, ProgressBar} from '@primer/react'
import {Avatar} from 'some-other-library'
// Non-system props are allowed
<Button someOtherProp="foo" />
Expand All @@ -47,7 +47,7 @@ import {Avatar} from 'some-other-library'

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

function App() {
// Enabling `includeUtilityComponents` will find system prop usage on utility components like this:
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 36 additions & 36 deletions src/rules/__tests__/no-deprecated-colors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ const ruleTester = new RuleTester({
ruleTester.run('no-deprecated-colors', rule, {
valid: [
`import {Box} from '@other/design-system'; <Box color="text.primary">Hello</Box>`,
`import {Box} from "@primer/components"; <Box color="fg.default">Hello</Box>`,
`import {hello} from "@primer/components"; hello("colors.text.primary")`,
`import {themeGet} from "@primer/components"; themeGet("space.text.primary")`,
`import {themeGet} from "@primer/components"; themeGet(props.backgroundColorThemeValue)`,
`import {themeGet} from "@primer/components"; themeGet(2)`,
`import {Box} from "@primer/react"; <Box color="fg.default">Hello</Box>`,
`import {hello} from "@primer/react"; hello("colors.text.primary")`,
`import {themeGet} from "@primer/react"; themeGet("space.text.primary")`,
`import {themeGet} from "@primer/react"; themeGet(props.backgroundColorThemeValue)`,
`import {themeGet} from "@primer/react"; themeGet(2)`,
`import {themeGet} from "@other/design-system"; themeGet("colors.text.primary")`,
`import {get} from "@other/constants"; get("space.text.primary")`,
`import {Box} from '@primer/components'; <Box sx={styles}>Hello</Box>`,
`import {Box} from '@primer/components'; <Box sx={{color: text.primary}}>Hello</Box>`,
`import {Box} from '@primer/components'; <Box sx={{color: "fg.default"}}>Hello</Box>`,
`import {Box} from '@primer/react'; <Box sx={styles}>Hello</Box>`,
`import {Box} from '@primer/react'; <Box sx={{color: text.primary}}>Hello</Box>`,
`import {Box} from '@primer/react'; <Box sx={{color: "fg.default"}}>Hello</Box>`,
`{color: 'text.primary'}`
],
invalid: [
Expand All @@ -52,8 +52,8 @@ ruleTester.run('no-deprecated-colors', rule, {
]
},
{
code: `import {Box} from "@primer/components"; function Example() { return <Box color="text.primary">Hello</Box> }`,
output: `import {Box} from "@primer/components"; function Example() { return <Box color="fg.default">Hello</Box> }`,
code: `import {Box} from "@primer/react"; function Example() { return <Box color="text.primary">Hello</Box> }`,
output: `import {Box} from "@primer/react"; function Example() { return <Box color="fg.default">Hello</Box> }`,
errors: [
{
message: '"text.primary" is deprecated. Use "fg.default" instead.'
Expand All @@ -71,97 +71,97 @@ ruleTester.run('no-deprecated-colors', rule, {
]
},
{
code: `import Box from '@primer/components/lib-esm/Box'; function Example() { return <Box color="text.primary">Hello</Box> }`,
output: `import Box from '@primer/components/lib-esm/Box'; function Example() { return <Box color="fg.default">Hello</Box> }`,
code: `import Box from '@primer/react/lib-esm/Box'; function Example() { return <Box color="text.primary">Hello</Box> }`,
output: `import Box from '@primer/react/lib-esm/Box'; function Example() { return <Box color="fg.default">Hello</Box> }`,
errors: [
{
message: '"text.primary" is deprecated. Use "fg.default" instead.'
}
]
},
{
code: `import {Box} from "@primer/components"; const Example = () => <Box color="text.primary">Hello</Box>`,
output: `import {Box} from "@primer/components"; const Example = () => <Box color="fg.default">Hello</Box>`,
code: `import {Box} from "@primer/react"; const Example = () => <Box color="text.primary">Hello</Box>`,
output: `import {Box} from "@primer/react"; const Example = () => <Box color="fg.default">Hello</Box>`,
errors: [
{
message: '"text.primary" is deprecated. Use "fg.default" instead.'
}
]
},
{
code: `import {Box} from "@primer/components"; <Box bg="bg.primary" m={1} />`,
output: `import {Box} from "@primer/components"; <Box bg="canvas.default" m={1} />`,
code: `import {Box} from "@primer/react"; <Box bg="bg.primary" m={1} />`,
output: `import {Box} from "@primer/react"; <Box bg="canvas.default" m={1} />`,
errors: [
{
message: '"bg.primary" is deprecated. Use "canvas.default" instead.'
}
]
},
{
code: `import {Box} from "@primer/components"; <Box sx={{bg: "bg.primary", m: 1, ...rest}} />`,
output: `import {Box} from "@primer/components"; <Box sx={{bg: "canvas.default", m: 1, ...rest}} />`,
code: `import {Box} from "@primer/react"; <Box sx={{bg: "bg.primary", m: 1, ...rest}} />`,
output: `import {Box} from "@primer/react"; <Box sx={{bg: "canvas.default", m: 1, ...rest}} />`,
errors: [
{
message: '"bg.primary" is deprecated. Use "canvas.default" instead.'
}
]
},
{
code: `import {Box} from "@primer/components"; <Box sx={{boxShadow: theme => theme.shadows.autocomplete.shadow}} />`,
output: `import {Box} from "@primer/components"; <Box sx={{boxShadow: theme => theme.shadows.shadow.medium}} />`,
code: `import {Box} from "@primer/react"; <Box sx={{boxShadow: theme => theme.shadows.autocomplete.shadow}} />`,
output: `import {Box} from "@primer/react"; <Box sx={{boxShadow: theme => theme.shadows.shadow.medium}} />`,
errors: [
{
message: '"theme.shadows.autocomplete.shadow" is deprecated. Use "theme.shadows.shadow.medium" instead.'
}
]
},
{
code: `import {Box} from "@primer/components"; <Box sx={{boxShadow: theme => \`0 1px 2px \${theme.colors.text.primary}\`}} />`,
output: `import {Box} from "@primer/components"; <Box sx={{boxShadow: theme => \`0 1px 2px \${theme.colors.fg.default}\`}} />`,
code: `import {Box} from "@primer/react"; <Box sx={{boxShadow: theme => \`0 1px 2px \${theme.colors.text.primary}\`}} />`,
output: `import {Box} from "@primer/react"; <Box sx={{boxShadow: theme => \`0 1px 2px \${theme.colors.fg.default}\`}} />`,
errors: [
{
message: '"theme.colors.text.primary" is deprecated. Use "theme.colors.fg.default" instead.'
}
]
},
{
code: `import {Box} from "@primer/components"; <Box sx={{boxShadow: t => \`0 1px 2px \${t.colors.text.primary}\`}} />`,
output: `import {Box} from "@primer/components"; <Box sx={{boxShadow: t => \`0 1px 2px \${t.colors.fg.default}\`}} />`,
code: `import {Box} from "@primer/react"; <Box sx={{boxShadow: t => \`0 1px 2px \${t.colors.text.primary}\`}} />`,
output: `import {Box} from "@primer/react"; <Box sx={{boxShadow: t => \`0 1px 2px \${t.colors.fg.default}\`}} />`,
errors: [
{
message: '"t.colors.text.primary" is deprecated. Use "t.colors.fg.default" instead.'
}
]
},
{
code: `import {Box} from "@primer/components"; <Box sx={{"&:hover": {bg: "bg.primary"}}} />`,
output: `import {Box} from "@primer/components"; <Box sx={{"&:hover": {bg: "canvas.default"}}} />`,
code: `import {Box} from "@primer/react"; <Box sx={{"&:hover": {bg: "bg.primary"}}} />`,
output: `import {Box} from "@primer/react"; <Box sx={{"&:hover": {bg: "canvas.default"}}} />`,
errors: [
{
message: '"bg.primary" is deprecated. Use "canvas.default" instead.'
}
]
},
{
code: `import {Box} from "@primer/components"; <Box color="auto.green.5" />`,
code: `import {Box} from "@primer/react"; <Box color="auto.green.5" />`,
errors: [
{
message: '"auto.green.5" is deprecated.',
suggestions: [
{
desc: 'Use "success.fg" instead.',
output: `import {Box} from "@primer/components"; <Box color="success.fg" />`
output: `import {Box} from "@primer/react"; <Box color="success.fg" />`
},
{
desc: 'Use "success.emphasis" instead.',
output: `import {Box} from "@primer/components"; <Box color="success.emphasis" />`
output: `import {Box} from "@primer/react"; <Box color="success.emphasis" />`
}
]
}
]
},
{
code: `import {Box} from "@primer/components"; <Box color="fade.fg10" />`,
code: `import {Box} from "@primer/react"; <Box color="fade.fg10" />`,
errors: [
{
message:
Expand All @@ -170,8 +170,8 @@ ruleTester.run('no-deprecated-colors', rule, {
]
},
{
code: `import {Box, Text} from "@primer/components"; <Box bg="bg.primary"><Text color="text.primary">Hello</Text></Box>`,
output: `import {Box, Text} from "@primer/components"; <Box bg="canvas.default"><Text color="fg.default">Hello</Text></Box>`,
code: `import {Box, Text} from "@primer/react"; <Box bg="bg.primary"><Text color="text.primary">Hello</Text></Box>`,
output: `import {Box, Text} from "@primer/react"; <Box bg="canvas.default"><Text color="fg.default">Hello</Text></Box>`,
errors: [
{
message: '"bg.primary" is deprecated. Use "canvas.default" instead.'
Expand All @@ -182,17 +182,17 @@ ruleTester.run('no-deprecated-colors', rule, {
]
},
{
code: `import {themeGet} from "@primer/components"; themeGet("colors.text.primary")`,
output: `import {themeGet} from "@primer/components"; themeGet("colors.fg.default")`,
code: `import {themeGet} from "@primer/react"; themeGet("colors.text.primary")`,
output: `import {themeGet} from "@primer/react"; themeGet("colors.fg.default")`,
errors: [
{
message: '"colors.text.primary" is deprecated. Use "colors.fg.default" instead.'
}
]
},
{
code: `import {themeGet} from "@primer/components"; themeGet("shadows.autocomplete.shadow")`,
output: `import {themeGet} from "@primer/components"; themeGet("shadows.shadow.medium")`,
code: `import {themeGet} from "@primer/react"; themeGet("shadows.autocomplete.shadow")`,
output: `import {themeGet} from "@primer/react"; themeGet("shadows.shadow.medium")`,
errors: [
{
message: '"shadows.autocomplete.shadow" is deprecated. Use "shadows.shadow.medium" instead.'
Expand Down
Loading