-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(DualListSelector): promoted Next implementation
- Loading branch information
1 parent
63aea63
commit df060ac
Showing
10 changed files
with
336 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
...codemods/src/rules/v6/dualListSelectorDeprecated/dualListSelector-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,17 @@ | ||
### dualListSelector-deprecated [(#10359)](https://github.com/patternfly/patternfly-react/pull/10359) | ||
|
||
Our previous implementation of DualListSelector has been deprecated. This rule will update import paths to our deprecated directory, but we recommend using our newly promoted implementation. | ||
|
||
#### Examples | ||
|
||
In: | ||
|
||
```jsx | ||
%inputExample% | ||
``` | ||
|
||
Out: | ||
|
||
```jsx | ||
%outputExample% | ||
``` |
124 changes: 124 additions & 0 deletions
124
...n-pf-codemods/src/rules/v6/dualListSelectorDeprecated/dualListSelector-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,124 @@ | ||
const ruleTester = require("../../ruletester"); | ||
import * as rule from "./dualListSelector-deprecated"; | ||
import { | ||
ValidTests, | ||
InvalidTests, | ||
createValidTest, | ||
createInvalidTest, | ||
} from "../../helpers/testHelpers"; | ||
|
||
const specifiersToMove = [ | ||
"DualListSelector", | ||
"DualListSelectorContext", | ||
"DualListSelectorControl", | ||
"DualListSelectorControlsWrapper", | ||
"DualListSelectorPane", | ||
"DualListSelectorList", | ||
"DualListSelectorListItem", | ||
"DualListSelectorTree", | ||
]; | ||
|
||
const validTests: ValidTests = []; | ||
const invalidTests: InvalidTests = []; | ||
|
||
specifiersToMove.forEach((specifier) => { | ||
validTests.push(createValidTest(`<${specifier} />`)); | ||
validTests.push( | ||
createValidTest( | ||
`import { ${specifier} /* data-codemods */ } from '@patternfly/react-core';` | ||
) | ||
); | ||
validTests.push( | ||
createValidTest( | ||
`import { ${specifier} } from '@patternfly/react-core/deprecated';` | ||
) | ||
); | ||
validTests.push( | ||
createValidTest( | ||
`export { ${specifier} /* data-codemods */ } from '@patternfly/react-core';` | ||
) | ||
); | ||
validTests.push( | ||
createValidTest( | ||
`export { ${specifier} } from '@patternfly/react-core/deprecated';` | ||
) | ||
); | ||
|
||
const errorMessage = `${specifier} has been deprecated. This rule will update import paths to our deprecated directory, but we recommend using our newly promoted DualListSelector implementation.`; | ||
invalidTests.push( | ||
createInvalidTest( | ||
`import { ${specifier} } from '@patternfly/react-core';`, | ||
`import {\n\t${specifier}\n} from '@patternfly/react-core/deprecated';`, | ||
[{ message: errorMessage, type: "ImportDeclaration" }] | ||
) | ||
); | ||
invalidTests.push( | ||
createInvalidTest( | ||
`import { ${specifier} as CustomSpecifier } from '@patternfly/react-core';`, | ||
`import {\n\t${specifier} as CustomSpecifier\n} from '@patternfly/react-core/deprecated';`, | ||
[{ message: errorMessage, type: "ImportDeclaration" }] | ||
) | ||
); | ||
invalidTests.push( | ||
createInvalidTest( | ||
`import { ${specifier} } from '@patternfly/react-core/dist/esm/components/Modal/index.js';`, | ||
`import {\n\t${specifier}\n} from '@patternfly/react-core/dist/esm/deprecated/components/Modal/index.js';`, | ||
[{ message: errorMessage, type: "ImportDeclaration" }] | ||
) | ||
); | ||
invalidTests.push( | ||
createInvalidTest( | ||
`import { ${specifier} } from '@patternfly/react-core/dist/js/components/Modal/index.js';`, | ||
`import {\n\t${specifier}\n} from '@patternfly/react-core/deprecated';`, | ||
[{ message: errorMessage, type: "ImportDeclaration" }] | ||
) | ||
); | ||
invalidTests.push( | ||
createInvalidTest( | ||
`import { ${specifier} } from '@patternfly/react-core/dist/dynamic/components/Modal/index.js';`, | ||
`import {\n\t${specifier}\n} from '@patternfly/react-core/deprecated';`, | ||
[{ message: errorMessage, type: "ImportDeclaration" }] | ||
) | ||
); | ||
invalidTests.push( | ||
createInvalidTest( | ||
`export { ${specifier} } from '@patternfly/react-core';`, | ||
`export {\n\t${specifier}\n} from '@patternfly/react-core/deprecated';`, | ||
[{ message: errorMessage, type: "ExportNamedDeclaration" }] | ||
) | ||
); | ||
invalidTests.push( | ||
createInvalidTest( | ||
`export { ${specifier} } from '@patternfly/react-core/dist/esm/components/Modal/index.js';`, | ||
`export {\n\t${specifier}\n} from '@patternfly/react-core/dist/esm/deprecated/components/Modal/index.js';`, | ||
[{ message: errorMessage, type: "ExportNamedDeclaration" }] | ||
) | ||
); | ||
invalidTests.push( | ||
createInvalidTest( | ||
`export { ${specifier} } from '@patternfly/react-core/dist/js/components/Modal/index.js';`, | ||
`export {\n\t${specifier}\n} from '@patternfly/react-core/deprecated';`, | ||
[{ message: errorMessage, type: "ExportNamedDeclaration" }] | ||
) | ||
); | ||
invalidTests.push( | ||
createInvalidTest( | ||
`export { ${specifier} } from '@patternfly/react-core/dist/dynamic/components/Modal/index.js';`, | ||
`export {\n\t${specifier}\n} from '@patternfly/react-core/deprecated';`, | ||
[{ message: errorMessage, type: "ExportNamedDeclaration" }] | ||
) | ||
); | ||
invalidTests.push( | ||
createInvalidTest( | ||
`import { ${specifier}, Button } from '@patternfly/react-core';`, | ||
`import {\n\tButton\n} from '@patternfly/react-core'; | ||
import {\n\t${specifier}\n} from '@patternfly/react-core/deprecated';`, | ||
[{ message: errorMessage, type: "ImportDeclaration" }] | ||
) | ||
); | ||
}); | ||
|
||
ruleTester.run("dualListSelector-deprecated", rule, { | ||
valid: validTests, | ||
invalid: invalidTests, | ||
}); |
27 changes: 27 additions & 0 deletions
27
...plugin-pf-codemods/src/rules/v6/dualListSelectorDeprecated/dualListSelector-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"; | ||
|
||
// https://github.com/patternfly/patternfly-react/pull/10359 | ||
|
||
const specifiersToMove = [ | ||
"DualListSelector", | ||
"DualListSelectorContext", | ||
"DualListSelectorControl", | ||
"DualListSelectorControlsWrapper", | ||
"DualListSelectorPane", | ||
"DualListSelectorList", | ||
"DualListSelectorListItem", | ||
"DualListSelectorTree", | ||
]; | ||
const fromPackage = "@patternfly/react-core"; | ||
const toPackage = "@patternfly/react-core/deprecated"; | ||
const messageAfterImportNameChange = | ||
"been deprecated. This rule will update import paths to our deprecated directory, but we recommend using our newly promoted DualListSelector implementation."; | ||
module.exports = { | ||
meta: { fixable: "code" }, | ||
create: moveSpecifiers( | ||
specifiersToMove, | ||
fromPackage, | ||
toPackage, | ||
messageAfterImportNameChange | ||
), | ||
}; |
1 change: 1 addition & 0 deletions
1
...n-pf-codemods/src/rules/v6/dualListSelectorDeprecated/dualListSelectorDeprecatedInput.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 @@ | ||
import { DualListSelector } from "@patternfly/react-core"; |
3 changes: 3 additions & 0 deletions
3
...-pf-codemods/src/rules/v6/dualListSelectorDeprecated/dualListSelectorDeprecatedOutput.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,3 @@ | ||
import { | ||
DualListSelector | ||
} from '@patternfly/react-core/deprecated'; |
17 changes: 17 additions & 0 deletions
17
...mods/src/rules/v6/dualListSelectorNextPromoted/dualListSelectorNext-promoted.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,17 @@ | ||
### dualListSelectorNext-promoted [(#10359)](https://github.com/patternfly/patternfly-react/pull/10359) | ||
|
||
Our Next implementation of DualListSelector has been promoted as our recommended implementation. This rule will update import paths. | ||
|
||
#### Examples | ||
|
||
In: | ||
|
||
```jsx | ||
%inputExample% | ||
``` | ||
|
||
Out: | ||
|
||
```jsx | ||
%outputExample% | ||
``` |
118 changes: 118 additions & 0 deletions
118
...-codemods/src/rules/v6/dualListSelectorNextPromoted/dualListSelectorNext-promoted.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,118 @@ | ||
const ruleTester = require("../../ruletester"); | ||
import * as rule from "./dualListSelectorNext-promoted"; | ||
import { | ||
ValidTests, | ||
InvalidTests, | ||
createValidTest, | ||
createInvalidTest, | ||
} from "../../helpers/testHelpers"; | ||
|
||
const specifiersToMove = [ | ||
"DualListSelector", | ||
"DualListSelectorControl", | ||
"DualListSelectorControlsWrapper", | ||
"DualListSelectorPane", | ||
"DualListSelectorList", | ||
"DualListSelectorListItem", | ||
"DualListSelectorTree", | ||
]; | ||
|
||
const validTests: ValidTests = []; | ||
const invalidTests: InvalidTests = []; | ||
|
||
specifiersToMove.forEach((specifier) => { | ||
validTests.push(createValidTest(`<${specifier} />`)); | ||
validTests.push( | ||
createValidTest( | ||
`import { ${specifier} /* data-codemods */ } from '@patternfly/react-core';` | ||
) | ||
); | ||
validTests.push( | ||
createValidTest(`import { ${specifier} } from '@patternfly/react-core';`) | ||
); | ||
validTests.push( | ||
createValidTest( | ||
`export { ${specifier} /* data-codemods */ } from '@patternfly/react-core';` | ||
) | ||
); | ||
validTests.push( | ||
createValidTest(`export { ${specifier} } from '@patternfly/react-core';`) | ||
); | ||
|
||
const errorMessage = `${specifier} has been promoted. This rule will update import paths.`; | ||
invalidTests.push( | ||
createInvalidTest( | ||
`import { ${specifier} } from '@patternfly/react-core/next';`, | ||
`import {\n\t${specifier} /* data-codemods */\n} from '@patternfly/react-core';`, | ||
[{ message: errorMessage, type: "ImportDeclaration" }] | ||
) | ||
); | ||
invalidTests.push( | ||
createInvalidTest( | ||
`import { ${specifier} as CustomSpecifier } from '@patternfly/react-core/next';`, | ||
`import {\n\t${specifier} as CustomSpecifier /* data-codemods */\n} from '@patternfly/react-core';`, | ||
[{ message: errorMessage, type: "ImportDeclaration" }] | ||
) | ||
); | ||
invalidTests.push( | ||
createInvalidTest( | ||
`import { ${specifier} } from '@patternfly/react-core/dist/esm/next/components/Modal/index.js';`, | ||
`import {\n\t${specifier} /* data-codemods */\n} from '@patternfly/react-core/dist/esm/components/Modal/index.js';`, | ||
[{ message: errorMessage, type: "ImportDeclaration" }] | ||
) | ||
); | ||
invalidTests.push( | ||
createInvalidTest( | ||
`import { ${specifier} } from '@patternfly/react-core/dist/js/next/components/Modal/index.js';`, | ||
`import {\n\t${specifier} /* data-codemods */\n} from '@patternfly/react-core';`, | ||
[{ message: errorMessage, type: "ImportDeclaration" }] | ||
) | ||
); | ||
invalidTests.push( | ||
createInvalidTest( | ||
`import { ${specifier} } from '@patternfly/react-core/dist/dynamic/next/components/Modal/index.js';`, | ||
`import {\n\t${specifier} /* data-codemods */\n} from '@patternfly/react-core';`, | ||
[{ message: errorMessage, type: "ImportDeclaration" }] | ||
) | ||
); | ||
invalidTests.push( | ||
createInvalidTest( | ||
`export { ${specifier} } from '@patternfly/react-core/next';`, | ||
`export {\n\t${specifier} /* data-codemods */\n} from '@patternfly/react-core';`, | ||
[{ message: errorMessage, type: "ExportNamedDeclaration" }] | ||
) | ||
); | ||
invalidTests.push( | ||
createInvalidTest( | ||
`export { ${specifier} } from '@patternfly/react-core/dist/esm/next/components/Modal/index.js';`, | ||
`export {\n\t${specifier} /* data-codemods */\n} from '@patternfly/react-core/dist/esm/components/Modal/index.js';`, | ||
[{ message: errorMessage, type: "ExportNamedDeclaration" }] | ||
) | ||
); | ||
invalidTests.push( | ||
createInvalidTest( | ||
`export { ${specifier} } from '@patternfly/react-core/dist/js/next/components/Modal/index.js';`, | ||
`export {\n\t${specifier} /* data-codemods */\n} from '@patternfly/react-core';`, | ||
[{ message: errorMessage, type: "ExportNamedDeclaration" }] | ||
) | ||
); | ||
invalidTests.push( | ||
createInvalidTest( | ||
`export { ${specifier} } from '@patternfly/react-core/dist/dynamic/next/components/Modal/index.js';`, | ||
`export {\n\t${specifier} /* data-codemods */\n} from '@patternfly/react-core';`, | ||
[{ message: errorMessage, type: "ExportNamedDeclaration" }] | ||
) | ||
); | ||
invalidTests.push( | ||
createInvalidTest( | ||
`import { ${specifier} } from '@patternfly/react-core/next';\nimport { Button } from '@patternfly/react-core';`, | ||
`\nimport {\n\tButton,\n\t${specifier} /* data-codemods */\n} from '@patternfly/react-core';`, | ||
[{ message: errorMessage, type: "ImportDeclaration" }] | ||
) | ||
); | ||
}); | ||
|
||
ruleTester.run("dualListSelectorNext-promoted", rule, { | ||
valid: validTests, | ||
invalid: invalidTests, | ||
}); |
25 changes: 25 additions & 0 deletions
25
...in-pf-codemods/src/rules/v6/dualListSelectorNextPromoted/dualListSelectorNext-promoted.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,25 @@ | ||
import { moveSpecifiers } from "../../helpers"; | ||
|
||
// https://github.com/patternfly/patternfly-react/pull/10359 | ||
const specifiersToMove = [ | ||
"DualListSelector", | ||
"DualListSelectorControl", | ||
"DualListSelectorControlsWrapper", | ||
"DualListSelectorPane", | ||
"DualListSelectorList", | ||
"DualListSelectorListItem", | ||
"DualListSelectorTree", | ||
]; | ||
const fromPackage = "@patternfly/react-core/next"; | ||
const toPackage = "@patternfly/react-core"; | ||
const messageAfterImportNameChange = | ||
"been promoted. This rule will update import paths."; | ||
module.exports = { | ||
meta: { fixable: "code" }, | ||
create: moveSpecifiers( | ||
specifiersToMove, | ||
fromPackage, | ||
toPackage, | ||
messageAfterImportNameChange | ||
), | ||
}; |
1 change: 1 addition & 0 deletions
1
...-codemods/src/rules/v6/dualListSelectorNextPromoted/dualListSelectorNextPromotedInput.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 @@ | ||
import { DualListSelector } from "@patternfly/react-core/next"; |
3 changes: 3 additions & 0 deletions
3
...codemods/src/rules/v6/dualListSelectorNextPromoted/dualListSelectorNextPromotedOutput.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,3 @@ | ||
import { | ||
DualListSelector /* data-codemods */ | ||
} from '@patternfly/react-core'; |