Skip to content
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

feat(Tile): add deprecated import update mod #740

Merged
merged 3 commits into from
Sep 26, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,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: [
kmcfaul marked this conversation as resolved.
Show resolved Hide resolved
{
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";
Loading