Skip to content

Commit

Permalink
feat(DualListSelector): promoted Next implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
thatblindgeye committed Jun 11, 2024
1 parent 63aea63 commit df060ac
Show file tree
Hide file tree
Showing 10 changed files with 336 additions and 0 deletions.
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%
```
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,
});
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
),
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import { DualListSelector } from "@patternfly/react-core";
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import {
DualListSelector
} from '@patternfly/react-core/deprecated';
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%
```
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,
});
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
),
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import { DualListSelector } from "@patternfly/react-core/next";
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import {
DualListSelector /* data-codemods */
} from '@patternfly/react-core';

0 comments on commit df060ac

Please sign in to comment.