Skip to content

Commit

Permalink
feat(Chip) update to deprecated path (#588)
Browse files Browse the repository at this point in the history
* feat(Chip) update to deprecated path

* update message, add rule to setup rules

* update test output to match actual
  • Loading branch information
Dominik-Petrik authored Feb 28, 2024
1 parent ae3d098 commit ee8b54f
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const warningRules = [
// rules that will run before other rules (move to deprecated?)
export const setupRules = [
"applicationLauncher-deprecated",
"chip-deprecated",
"contextSelector-update-deprecatedPath",
"dropdown-update-deprecatedPath",
"datalist-remove-selectableRow",
Expand Down
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%
```
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',
},
],
},
],
});
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 @@
import { Chip } from '@patternfly/react-core';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import { Chip } from '@patternfly/react-core/deprecated';

0 comments on commit ee8b54f

Please sign in to comment.