-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
262eb07
commit e0f6dd0
Showing
5 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
...slint-plugin-pf-codemods/src/rules/v6/dragDropDeprecated/dragDrop-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,18 @@ | ||
### dragDrop-deprecated [(#10181)](https://github.com/patternfly/patternfly-react/pull/10181) | ||
|
||
DragDrop has been deprecated. Running the fix flag will update your imports to our deprecated package, but we suggest using our new drag and drop implementation (DragDropSort component), that lives in '@patternfly/react-drag-drop' package. | ||
|
||
#### Examples | ||
|
||
In: | ||
|
||
```jsx | ||
%inputExample% | ||
``` | ||
|
||
Out: | ||
|
||
```jsx | ||
%outputExample% | ||
``` | ||
|
47 changes: 47 additions & 0 deletions
47
...ges/eslint-plugin-pf-codemods/src/rules/v6/dragDropDeprecated/dragDrop-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,47 @@ | ||
const ruleTester = require('../../ruletester'); | ||
import * as rule from './dragDrop-deprecated'; | ||
|
||
ruleTester.run('dragDrop-deprecated', rule, { | ||
valid: [ | ||
{ | ||
code: `<DragDrop onDrop={onDrop}> | ||
<Droppable> | ||
<Draggable key={1}>Item 1</Draggable> | ||
<Draggable key={2}>Item 2</Draggable> | ||
</Droppable> | ||
</DragDrop>`, | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: `import { DragDrop, Droppable, Draggable } from '@patternfly/react-core'; | ||
export const DragDropDeprecatedInput = () => ( | ||
<DragDrop onDrop={onDrop}> | ||
<Droppable> | ||
<Draggable key={1}>Item 1</Draggable> | ||
<Draggable key={2}>Item 2</Draggable> | ||
</Droppable> | ||
</DragDrop> | ||
); | ||
`, | ||
output: `import {\n\tDragDrop,\n\tDroppable,\n\tDraggable\n} from '@patternfly/react-core/deprecated'; | ||
export const DragDropDeprecatedInput = () => ( | ||
<DragDrop onDrop={onDrop}> | ||
<Droppable> | ||
<Draggable key={1}>Item 1</Draggable> | ||
<Draggable key={2}>Item 2</Draggable> | ||
</Droppable> | ||
</DragDrop> | ||
); | ||
`, | ||
errors: [ | ||
{ | ||
message: `DragDrop, Droppable, and Draggable have been deprecated. Running the fix flag will update your imports to our deprecated package, but we suggest using our new drag and drop implementation (DragDropSort component), that lives in '@patternfly/react-drag-drop' package.`, | ||
type: 'ImportDeclaration', | ||
}, | ||
], | ||
}, | ||
], | ||
}); |
27 changes: 27 additions & 0 deletions
27
packages/eslint-plugin-pf-codemods/src/rules/v6/dragDropDeprecated/dragDrop-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,27 @@ | ||
import { moveSpecifiers } from '../../helpers'; | ||
|
||
const specifiersToMove = [ | ||
'DraggableItemPosition', | ||
'DragDropContext', | ||
'DragDrop', | ||
'DraggableProps', | ||
'Draggable', | ||
'Droppable', | ||
'DroppableContext', | ||
]; | ||
|
||
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 our new drag and drop implementation (DragDropSort component), that lives in '@patternfly/react-drag-drop' package."; | ||
|
||
// https://github.com/patternfly/patternfly-react/pull/10181 | ||
module.exports = { | ||
meta: { fixable: 'code' }, | ||
create: moveSpecifiers( | ||
specifiersToMove, | ||
fromPackage, | ||
toPackage, | ||
messageAfterImportNameChange | ||
), | ||
}; |
10 changes: 10 additions & 0 deletions
10
...ges/eslint-plugin-pf-codemods/src/rules/v6/dragDropDeprecated/dragDropDeprecatedInput.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,10 @@ | ||
import { DragDrop, Droppable, Draggable } from '@patternfly/react-core'; | ||
|
||
export const DragDropDeprecatedInput = () => ( | ||
<DragDrop onDrop={onDrop}> | ||
<Droppable> | ||
<Draggable key={1}>Item 1</Draggable> | ||
<Draggable key={2}>Item 2</Draggable> | ||
</Droppable> | ||
</DragDrop> | ||
); |
14 changes: 14 additions & 0 deletions
14
...es/eslint-plugin-pf-codemods/src/rules/v6/dragDropDeprecated/dragDropDeprecatedOutput.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,14 @@ | ||
import { | ||
DragDrop, | ||
Droppable, | ||
Draggable, | ||
} from '@patternfly/react-core/deprecated'; | ||
|
||
export const DragDropDeprecatedInput = () => ( | ||
<DragDrop onDrop={onDrop}> | ||
<Droppable> | ||
<Draggable key={1}>Item 1</Draggable> | ||
<Draggable key={2}>Item 2</Draggable> | ||
</Droppable> | ||
</DragDrop> | ||
); |