-
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(Tile): add deprecated import update mod (#740)
* feat(Tile): add deprecated import update mod * move tile rule to setupRules instead * update md, add more tests
- Loading branch information
Showing
6 changed files
with
102 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/tileDeprecated/tile-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 @@ | ||
### tile-deprecated [(#10821)](https://github.com/patternfly/patternfly-react/pull/10821) | ||
|
||
Tile has been deprecated. Running the fix flag will update your imports to our deprecated package, but we suggest using Card instead. There is a new Card example on our documentation showcasing how to set up a Card as a Tile. | ||
|
||
#### Examples | ||
|
||
In: | ||
|
||
```jsx | ||
%inputExample% | ||
``` | ||
|
||
Out: | ||
|
||
```jsx | ||
%outputExample% | ||
``` |
62 changes: 62 additions & 0 deletions
62
packages/eslint-plugin-pf-codemods/src/rules/v6/tileDeprecated/tile-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,62 @@ | ||
const ruleTester = require('../../ruletester'); | ||
import * as rule from './tile-deprecated'; | ||
|
||
ruleTester.run('tile-deprecated', rule, { | ||
valid: [ | ||
{ | ||
code: `import { Tile } from '@someOtherPackage';`, | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: `import { Tile } from '@patternfly/react-core';`, | ||
output: `import {\n\tTile\n} from '@patternfly/react-core/deprecated';`, | ||
errors: [ | ||
{ | ||
message: `Tile has been deprecated. Running the fix flag will update your imports to our deprecated package, but we suggest using Card instead.`, | ||
type: 'ImportDeclaration', | ||
}, | ||
], | ||
}, | ||
{ | ||
code: `import { Tile as CustomTile } from '@patternfly/react-core';`, | ||
output: `import {\n\tTile as CustomTile\n} from '@patternfly/react-core/deprecated';`, | ||
errors: [ | ||
{ | ||
message: `Tile has been deprecated. Running the fix flag will update your imports to our deprecated package, but we suggest using Card instead.`, | ||
type: 'ImportDeclaration', | ||
}, | ||
], | ||
}, | ||
{ | ||
code: `import { Tile } from '@patternfly/react-core/dist/esm/components/Tile/index.js';`, | ||
output: `import {\n\tTile\n} from '@patternfly/react-core/dist/esm/deprecated/components/Tile/index.js';`, | ||
errors: [ | ||
{ | ||
message: `Tile has been deprecated. Running the fix flag will update your imports to our deprecated package, but we suggest using Card instead.`, | ||
type: 'ImportDeclaration', | ||
}, | ||
], | ||
}, | ||
{ | ||
code: `import { Tile } from '@patternfly/react-core/dist/js/components/Tile/index.js';`, | ||
output: `import {\n\tTile\n} from '@patternfly/react-core/deprecated';`, | ||
errors: [ | ||
{ | ||
message: `Tile has been deprecated. Running the fix flag will update your imports to our deprecated package, but we suggest using Card instead.`, | ||
type: 'ImportDeclaration', | ||
}, | ||
], | ||
}, | ||
{ | ||
code: `import { Tile } from '@patternfly/react-core/dist/dynamic/components/Tile/index.js';`, | ||
output: `import {\n\tTile\n} from '@patternfly/react-core/deprecated';`, | ||
errors: [ | ||
{ | ||
message: `Tile has been deprecated. Running the fix flag will update your imports to our deprecated package, but we suggest using Card instead.`, | ||
type: 'ImportDeclaration', | ||
}, | ||
], | ||
}, | ||
], | ||
}); |
20 changes: 20 additions & 0 deletions
20
packages/eslint-plugin-pf-codemods/src/rules/v6/tileDeprecated/tile-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/10821 | ||
|
||
const specifiersToMove = ['Tile']; | ||
|
||
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 Card 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/tileDeprecated/tileDeprecatedInput.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 { Tile } from "@patternfly/react-core"; |
1 change: 1 addition & 0 deletions
1
packages/eslint-plugin-pf-codemods/src/rules/v6/tileDeprecated/tileDeprecatedOutput.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 { Tile } from "@patternfly/react-core/deprecated"; |