Skip to content

Commit

Permalink
feat(Tile): add deprecated import update mod (#740)
Browse files Browse the repository at this point in the history
* feat(Tile): add deprecated import update mod

* move tile rule to setupRules instead

* update md, add more tests
  • Loading branch information
kmcfaul authored Sep 26, 2024
1 parent ed1b131 commit 2d23f34
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const setupRules = [
"pageHeader-deprecated",
"select-deprecated",
"table-update-deprecatedPath",
"tile-deprecated",
"wizard-update-deprecatedPath",
];

Expand Down
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%
```
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',
},
],
},
],
});
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
),
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import { Tile } from "@patternfly/react-core";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import { Tile } from "@patternfly/react-core/deprecated";

0 comments on commit 2d23f34

Please sign in to comment.