Skip to content

Commit 02bcea1

Browse files
feat(react-dropzone): updated to latest version (#216)
1 parent 6348aa3 commit 02bcea1

File tree

6 files changed

+108
-30
lines changed

6 files changed

+108
-30
lines changed

packages/eslint-plugin-pf-codemods/index.js

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,36 @@
11
const createListOfRules = (version) => {
22
const rules = {};
3-
require('glob').sync(`./packages/eslint-plugin-pf-codemods/lib/rules/v${version}/*.js`).forEach( function( file ) {
4-
const ruleName = /.*\/([^.]+)/.exec(file)[1];
5-
rules[ruleName] = require(`./lib/rules/v${version}/${ruleName}`);
6-
});
3+
require("glob")
4+
.sync(`./packages/eslint-plugin-pf-codemods/lib/rules/v${version}/*.js`)
5+
.forEach(function (file) {
6+
const ruleName = /.*\/([^.]+)/.exec(file)[1];
7+
rules[ruleName] = require(`./lib/rules/v${version}/${ruleName}`);
8+
});
79
return rules;
8-
}
10+
};
911

1012
const v5rules = createListOfRules("5");
1113
const v4rules = createListOfRules("4");
1214

1315
// if you want a rule to have a severity that defaults to warning rather than error, add the rule name to the below array
14-
const warningRules = ["applicationLauncher-warn-input", "card-warn-component", "horizontalSubnav-ariaLabel", "tabs-warn-children-type-changed", "wizard-warn-button-order"]
16+
const warningRules = [
17+
"applicationLauncher-warn-input",
18+
"card-warn-component",
19+
"horizontalSubnav-ariaLabel",
20+
"react-dropzone-warn-upgrade",
21+
"tabs-warn-children-type-changed",
22+
"wizard-warn-button-order",
23+
];
1524

1625
const createRules = (rules) => {
1726
return Object.keys(rules).reduce((acc, rule) => {
18-
const severity = warningRules.includes(rule) ? "warn" : "error"
27+
const severity = warningRules.includes(rule) ? "warn" : "error";
1928
acc[`@patternfly/pf-codemods/${rule}`] = severity;
2029
return acc;
21-
}, {})
22-
}
30+
}, {});
31+
};
2332

24-
const mappedRules = {...createRules(v5rules), ...createRules(v4rules)};
33+
const mappedRules = { ...createRules(v5rules), ...createRules(v4rules) };
2534

2635
module.exports = {
2736
configs: {
@@ -44,6 +53,6 @@ module.exports = {
4453
rules: mappedRules,
4554
},
4655
},
47-
rules: {...v5rules, ...v4rules},
48-
ruleVersionMapping: {"v4": Object.keys(v4rules), "v5": Object.keys(v5rules)}
56+
rules: { ...v5rules, ...v4rules },
57+
ruleVersionMapping: { v4: Object.keys(v4rules), v5: Object.keys(v5rules) },
4958
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// https://github.com/patternfly/patternfly-react/pull/7926
2+
module.exports = {
3+
meta: {},
4+
create: function (context) {
5+
return {
6+
ImportDeclaration(node) {
7+
const importsWithDropzone = node.specifiers.find(
8+
(specifier) =>
9+
(["FileUpload", "MultipleFileUpload"].includes(
10+
specifier.imported.name
11+
) &&
12+
node.source.value === "@patternfly/react-core") ||
13+
(specifier.imported.name === "CodeEditor" &&
14+
node.source.value === "@patternfly/react-code-editor")
15+
);
16+
17+
if (importsWithDropzone) {
18+
context.report({
19+
node,
20+
message: `The react-dropzone dependency used within ${importsWithDropzone.imported.name} has been updated from version 9 to version 14.`,
21+
});
22+
}
23+
},
24+
};
25+
},
26+
};

packages/eslint-plugin-pf-codemods/lib/rules/v5/wizard-warn-button-order.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const { getPackageImports } = require("../../helpers");
2-
31
// https://github.com/patternfly/patternfly-react/pull/8409
42
module.exports = {
53
create: function (context) {
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const ruleTester = require("../../ruletester");
2+
const rule = require("../../../lib/rules/v5/react-dropzone-warn-upgrade");
3+
4+
ruleTester.run("react-dropzone-warn-upgrade", rule, {
5+
valid: [],
6+
invalid: [
7+
{
8+
code: `import { FileUpload } from '@patternfly/react-core';`,
9+
output: `import { FileUpload } from '@patternfly/react-core';`,
10+
errors: [
11+
{
12+
message: `The react-dropzone dependency used within FileUpload has been updated from version 9 to version 14.`,
13+
type: "ImportDeclaration",
14+
},
15+
],
16+
},
17+
{
18+
code: `import { MultipleFileUpload } from '@patternfly/react-core';`,
19+
output: `import { MultipleFileUpload } from '@patternfly/react-core';`,
20+
errors: [
21+
{
22+
message: `The react-dropzone dependency used within MultipleFileUpload has been updated from version 9 to version 14.`,
23+
type: "ImportDeclaration",
24+
},
25+
],
26+
},
27+
{
28+
code: `import { CodeEditor } from '@patternfly/react-code-editor';`,
29+
output: `import { CodeEditor } from '@patternfly/react-code-editor';`,
30+
errors: [
31+
{
32+
message: `The react-dropzone dependency used within CodeEditor has been updated from version 9 to version 14.`,
33+
type: "ImportDeclaration",
34+
},
35+
],
36+
},
37+
],
38+
});

packages/pf-codemods/README.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,10 @@ Out:
386386
/>
387387
```
388388

389+
### react-dropzone-warn-upgrade [(#7926)](// https://github.com/patternfly/patternfly-react/pull/7926)
390+
391+
The `react-dropzone` dependency used with FileUpload, MultipleFileUpload, and CodeEditor has been updated from version 9 to version 14.
392+
389393
### remove-removeFindDomNode [(#8371)](https://github.com/patternfly/patternfly-react/pull/8371) [(#8316)](https://github.com/patternfly/patternfly-react/pull/8316)
390394

391395
We've removed the `removeFindDomNode` property as it is now the default behavior. The affected components are as follows: ApplicationLauncher, ClipboardCopy, ContextSelector, Dropdown, NavItem, OptionsMenu, Popover, SearchInput, Select, OverflowTab, Timepicker, Tooltip, Truncate.
@@ -458,58 +462,58 @@ We've removed the deprecated `ToggleMenuBaseProps` interface.
458462

459463
We've updated the default value of the `getResizeObserver` helper function's third parameter, `useRequestAnimationFrame`. This rule will only provide two suggestions detailing when to pass which boolean into this parameter.
460464

461-
### tableComposable-remove-hasSelectableRowCaption [(#8352)](https://github.com/patternfly/patternfly-react/pull/8352)
465+
### simpleList-remove-isCurrent [(#8132)](https://github.com/patternfly/patternfly-react/pull/8132)
462466

463-
We've removed the deprecated `hasSelectableRowCaption` prop.
467+
We've removed the deprecated the `isCurrent` prop. This rule wil replace it with `isActive`.
464468

465469
#### Examples
466470

467471
In:
468472

469473
```jsx
470-
<TableComposable hasSelectableRowCaption />
474+
<SimpleList isCurrent />
471475
```
472476

473477
Out:
474478

475479
```jsx
476-
<TableComposable />
480+
<SimpleList isActive />
477481
```
478482

479-
### simpleList-remove-isCurrent [(#8132)](https://github.com/patternfly/patternfly-react/pull/8132)
483+
### spinner-svg-default [(#8183)](https://github.com/patternfly/patternfly-react/pull/8183)
480484

481-
We've removed the deprecated the `isCurrent` prop. This rule wil replace it with `isActive`.
485+
We've updated the Spinner to default to an svg, so the `isSVG` property is no longer required.
482486

483487
#### Examples
484488

485489
In:
486490

487491
```jsx
488-
<SimpleList isCurrent />
492+
<Spinner isSVG />
489493
```
490494

491495
Out:
492496

493497
```jsx
494-
<SimpleList isActive />
498+
<Spinner />
495499
```
496500

497-
### spinner-svg-default [(#8183)](https://github.com/patternfly/patternfly-react/pull/8183)
501+
### tableComposable-remove-hasSelectableRowCaption [(#8352)](https://github.com/patternfly/patternfly-react/pull/8352)
498502

499-
We've updated the Spinner to default to an svg, so the `isSVG` property is no longer required.
503+
We've removed the deprecated `hasSelectableRowCaption` prop.
500504

501505
#### Examples
502506

503507
In:
504508

505509
```jsx
506-
<Spinner isSVG />
510+
<TableComposable hasSelectableRowCaption />
507511
```
508512

509513
Out:
510514

511515
```jsx
512-
<Spinner />
516+
<TableComposable />
513517
```
514518

515519
### tabs-rename-hasBorderBottom [(#8517)](https://github.com/patternfly/patternfly-react/pull/8517)

test/test.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
import { AccordionExpandableContent } from "@patternfly/react-core";
22
import { ApplicationLauncher } from "@patternfly/react-core";
33
import { Card } from "@patternfly/react-core";
4+
import { CodeEditor } from "@patternfly/react-code-editor";
45
import { DropdownToggle, Toggle } from "@patternfly/react-core";
6+
import { FileUpload } from "@patternfly/react-core";
57
import { KEY_CODES } from "@patternfly/react-core";
8+
import { MultipleFileUpload } from "@patternfly/react-core";
69
import { Nav } from "@patternfly/react-core";
710
import { Tabs } from "@patternfly/react-core";
811
import { Wizard } from "@patternfly/react-core";
912
import { WizardFooter } from "@patternfly/react-core/next";
1013

1114
<>
12-
<DropdownToggle isPrimary />
13-
<Nav variant='horizontal-subnav' />;
14-
<Toggle isPrimary />
15-
</>
15+
<DropdownToggle isPrimary />
16+
<Nav variant='horizontal-subnav' />;
17+
<Toggle isPrimary />
18+
</>;

0 commit comments

Comments
 (0)