Skip to content

Commit

Permalink
feat(Chip) update to deprecated path
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik-Petrik committed Feb 26, 2024
1 parent e90502b commit a62f2fe
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 0 deletions.
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%
```
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',
},
],
},
],
});
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
),
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Chip } from '@patternfly/react-core';

export const ChipDeprecatedInput = () => <Chip />;
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 />;

0 comments on commit a62f2fe

Please sign in to comment.