Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(DualListSelector): promoted Next implementation #661

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';
Loading