-
Notifications
You must be signed in to change notification settings - Fork 18
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 (#588)
* feat(Chip) update to deprecated path * update message, add rule to setup rules * update test output to match actual
- Loading branch information
1 parent
ae3d098
commit ee8b54f
Showing
6 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
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
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 instead. | ||
|
||
#### Examples | ||
|
||
In: | ||
|
||
```jsx | ||
%inputExample% | ||
``` | ||
|
||
Out: | ||
|
||
```jsx | ||
%outputExample% | ||
``` |
22 changes: 22 additions & 0 deletions
22
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,22 @@ | ||
const ruleTester = require('../../ruletester'); | ||
import * as rule from './chip-deprecated'; | ||
|
||
ruleTester.run('chip-deprecated', rule, { | ||
valid: [ | ||
{ | ||
code: `import { Chip } from '@someOtherPackage';`, | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: `import { Chip } from '@patternfly/react-core';`, | ||
output: `import {\n\tChip\n} from '@patternfly/react-core/deprecated';`, | ||
errors: [ | ||
{ | ||
message: `Chip has been deprecated. Running the fix flag will update your imports to our deprecated package, but we suggest using Label instead.`, | ||
type: 'ImportDeclaration', | ||
}, | ||
], | ||
}, | ||
], | ||
}); |
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 | ||
), | ||
}; |
1 change: 1 addition & 0 deletions
1
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 @@ | ||
import { Chip } from '@patternfly/react-core'; |
1 change: 1 addition & 0 deletions
1
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 @@ | ||
import { Chip } from '@patternfly/react-core/deprecated'; |