Skip to content

Commit 21d82ce

Browse files
authored
Remove unused React imports (jenkinsci#687)
1 parent be35775 commit 21d82ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+123
-120
lines changed

eslint.config.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default [
1515
},
1616
},
1717
},
18+
plugins.react.configs.flat["jsx-runtime"],
1819
plugins.promise.configs["flat/recommended"],
1920
{
2021
plugins: {
@@ -25,4 +26,25 @@ export default [
2526
"simple-import-sort/exports": "error",
2627
},
2728
},
29+
{
30+
rules: {
31+
"no-restricted-imports": [
32+
"error",
33+
{
34+
paths: [
35+
{
36+
name: "react",
37+
importNames: ["default"],
38+
message: "Please use named imports instead.",
39+
},
40+
{
41+
name: "react-dom/client",
42+
importNames: ["default"],
43+
message: "Please use named imports instead.",
44+
},
45+
],
46+
},
47+
],
48+
},
49+
},
2850
];

src/main/frontend/common/RestClient.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {
22
Result,
33
StageInfo,
4-
} from "../pipeline-graph-view/pipeline-graph/main/index.ts";
5-
import { ResourceBundle } from "./i18n/index.ts";
4+
} from "../pipeline-graph-view/pipeline-graph/main/PipelineGraphModel.tsx";
5+
import { ResourceBundle } from "./i18n/messages.ts";
66

77
export interface RunStatus {
88
stages: StageInfo[];
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import React from "react";
2-
import ReactDOM from "react-dom";
1+
import { ReactNode } from "react";
2+
import { createPortal } from "react-dom";
33

44
interface DropdownPortalProps {
5-
children: React.ReactNode;
5+
children: ReactNode;
66
}
77

88
export default function DropdownPortal({ children }: DropdownPortalProps) {
@@ -13,5 +13,5 @@ export default function DropdownPortal({ children }: DropdownPortalProps) {
1313
return null;
1414
}
1515

16-
return ReactDOM.createPortal(children, container);
16+
return createPortal(children, container);
1717
}

src/main/frontend/common/components/dropdown.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Tippy, { TippyProps } from "@tippyjs/react";
2-
import React, { useState } from "react";
2+
import { isValidElement, ReactElement, ReactNode, useState } from "react";
33

44
import Tooltip from "./tooltip.tsx";
55

@@ -33,7 +33,7 @@ export default function Dropdown({
3333
);
3434
}
3535

36-
if (React.isValidElement(item)) {
36+
if (isValidElement(item)) {
3737
return (
3838
<div key={index} className="jenkins-dropdown__custom-item">
3939
{item}
@@ -89,15 +89,15 @@ export const DefaultDropdownProps: TippyProps = {
8989
};
9090

9191
interface DropdownProps {
92-
items: (DropdownItem | React.ReactElement | "separator")[];
92+
items: (DropdownItem | ReactElement | "separator")[];
9393
disabled?: boolean;
9494
className?: string;
9595
}
9696

9797
interface DropdownItem {
9898
text: string;
9999
href?: string;
100-
icon: React.ReactNode;
100+
icon: ReactNode;
101101
target?: string;
102102
download?: string;
103103
}

src/main/frontend/common/components/filter.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import "./filter.scss";
22

33
import Tippy from "@tippyjs/react";
4-
import React, { useState } from "react";
4+
import { useState } from "react";
55

66
import { useFilter } from "../../pipeline-console-view/pipeline-console/main/providers/filter-provider.tsx";
7-
import { Result } from "../../pipeline-graph-view/pipeline-graph/main/index.ts";
7+
import { Result } from "../../pipeline-graph-view/pipeline-graph/main/PipelineGraphModel.tsx";
88
import { classNames } from "../utils/classnames.ts";
99
import { DefaultDropdownProps } from "./dropdown.tsx";
1010
import StatusIcon from "./status-icon.tsx";

src/main/frontend/common/components/status-icon.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import "./status-icon.scss";
22

3-
import React from "react";
3+
import { ReactNode } from "react";
44

5-
import { Result } from "../../pipeline-graph-view/pipeline-graph/main/index.ts";
5+
import { Result } from "../../pipeline-graph-view/pipeline-graph/main/PipelineGraphModel.tsx";
66

77
/**
88
* Visual representation of a job or build status
@@ -176,7 +176,7 @@ function Group({
176176
}: {
177177
currentStatus: Result;
178178
status: Result;
179-
children: React.ReactNode;
179+
children: ReactNode;
180180
}) {
181181
return (
182182
<g

src/main/frontend/common/components/tooltip.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Tippy, { TippyProps } from "@tippyjs/react";
2-
import React from "react";
32

43
/**
54
* A customized (and customizable) implementation of Tippy tooltips

src/main/frontend/common/i18n/i18n-provider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {
1+
import {
22
Context,
33
createContext,
44
FunctionComponent,

src/main/frontend/common/i18n/index.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/main/frontend/common/utils/run-estimator.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
Result,
33
StageInfo,
4-
} from "../../pipeline-graph-view/pipeline-graph/main/index.ts";
4+
} from "../../pipeline-graph-view/pipeline-graph/main/PipelineGraphModel.tsx";
55
import RunEstimator from "./run-estimator.ts";
66

77
const previous: StageInfo[] = [

0 commit comments

Comments
 (0)