-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Chip) update to deprecated path
- Loading branch information
1 parent
e90502b
commit a62f2fe
Showing
5 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
packages/eslint-plugin-pf-codemods/src/rules/v6/chipDeprecated/chip-deprecated.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
### chip-deprecated [(#)](https://github.com/patternfly/patternfly-react/pull/10049) | ||
|
||
Chip has been deprecated. Running the fix flag will update your imports to our deprecated package, but we suggest using Label. | ||
|
||
#### Examples | ||
|
||
In: | ||
|
||
```jsx | ||
%inputExample% | ||
``` | ||
|
||
Out: | ||
|
||
```jsx | ||
%outputExample% | ||
``` |
25 changes: 25 additions & 0 deletions
25
packages/eslint-plugin-pf-codemods/src/rules/v6/chipDeprecated/chip-deprecated.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const ruleTester = require('../../ruletester'); | ||
import * as rule from './chip-deprecated'; | ||
|
||
ruleTester.run('chip-deprecated', rule, { | ||
valid: [ | ||
{ | ||
code: `<Chip />`, | ||
}, | ||
{ | ||
code: `import { Chip } from '@patternfly/react-core'; <Chip someOtherProp />`, | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: `import { Chip } from '@patternfly/react-core'; <Chip />`, | ||
output: `import { Chip } from '@patternfly/react-core/deprecated'; <Chip />`, | ||
errors: [ | ||
{ | ||
message: `Chip has been deprecated. Running the fix flag will update your imports to our deprecated package, but we suggest using Label.`, | ||
type: 'JSXOpeningElement', | ||
}, | ||
], | ||
}, | ||
], | ||
}); |
20 changes: 20 additions & 0 deletions
20
packages/eslint-plugin-pf-codemods/src/rules/v6/chipDeprecated/chip-deprecated.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { moveSpecifiers } from '../../helpers'; | ||
|
||
// https://github.com/patternfly/patternfly-react/pull/10049 | ||
|
||
const specifiersToMove = ['Chip', 'ChipGroup']; | ||
|
||
const fromPackage = '@patternfly/react-core'; | ||
const toPackage = '@patternfly/react-core/deprecated'; | ||
const messageAfterImportNameChange = | ||
'been deprecated. Running the fix flag will update your imports to our deprecated package, but we suggest using Label instead.'; | ||
|
||
module.exports = { | ||
meta: { fixable: 'code' }, | ||
create: moveSpecifiers( | ||
specifiersToMove, | ||
fromPackage, | ||
toPackage, | ||
messageAfterImportNameChange | ||
), | ||
}; |
3 changes: 3 additions & 0 deletions
3
packages/eslint-plugin-pf-codemods/src/rules/v6/chipDeprecated/chipDeprecatedInput.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { Chip } from '@patternfly/react-core'; | ||
|
||
export const ChipDeprecatedInput = () => <Chip />; |
3 changes: 3 additions & 0 deletions
3
packages/eslint-plugin-pf-codemods/src/rules/v6/chipDeprecated/chipDeprecatedOutput.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { Chip } from '@patternfly/react-core/deprecated'; | ||
|
||
export const ChipDeprecatedInput = () => <Chip />; |