@@ -9,15 +9,15 @@ export const Root = ({ children }: { children: React.ReactNode }) => {
);
};
-export const Header = ({ children }: { children: React.ReactNode }) => {
+export const Header = ({ children }: { children: ReactNode }) => {
return
{children};
};
-export const Body = ({ children }: { children: React.ReactNode }) => {
+export const Body = ({ children }: { children: ReactNode }) => {
return
{children};
};
-export const HeaderRow = ({ children }: { children: React.ReactNode }) => {
+export const HeaderRow = ({ children }: { children: ReactNode }) => {
return
{children}
;
};
@@ -25,8 +25,8 @@ export const HeaderCell = ({
children,
style,
}: {
- children: React.ReactNode;
- style?: React.CSSProperties;
+ children: ReactNode;
+ style?: CSSProperties;
}) => {
return (
{
+export const Row = ({ children }: { children: ReactNode }) => {
return | {children}
;
};
@@ -46,8 +46,8 @@ export const Cell = ({
children,
style,
}: {
- children: React.ReactNode;
- style?: React.CSSProperties;
+ children: ReactNode;
+ style?: CSSProperties;
}) => {
return (
diff --git a/canon-docs/src/mdx-components.tsx b/canon-docs/src/mdx-components.tsx
index 9517e882cc..22b389a641 100644
--- a/canon-docs/src/mdx-components.tsx
+++ b/canon-docs/src/mdx-components.tsx
@@ -1,4 +1,4 @@
-import React, { ReactNode } from 'react';
+import { isValidElement, ReactNode } from 'react';
import type { MDXComponents } from 'mdx/types';
import Image, { ImageProps } from 'next/image';
import { CodeBlock } from '@/components/CodeBlock';
@@ -28,7 +28,7 @@ export function useMDXComponents(components: MDXComponents): MDXComponents {
{children as ReactNode}
),
pre: ({ children }) => {
- const codeContent = React.isValidElement(children)
+ const codeContent = isValidElement(children)
? (children.props as { children: string }).children
: '';
diff --git a/canon-docs/src/utils/playground-context.tsx b/canon-docs/src/utils/playground-context.tsx
index 721851c3e4..9d4e23217f 100644
--- a/canon-docs/src/utils/playground-context.tsx
+++ b/canon-docs/src/utils/playground-context.tsx
@@ -1,4 +1,4 @@
-import React, {
+import {
createContext,
useContext,
ReactNode,
diff --git a/contrib/docs/tutorials/aws-alb-aad-oidc-auth.md b/contrib/docs/tutorials/aws-alb-aad-oidc-auth.md
index d742c33498..178c45567f 100644
--- a/contrib/docs/tutorials/aws-alb-aad-oidc-auth.md
+++ b/contrib/docs/tutorials/aws-alb-aad-oidc-auth.md
@@ -55,15 +55,15 @@ When using ALB authentication Backstage will only be loaded once the user has su
- add the following definition just before the app is created (`const app = createApp`):
```ts
-import React from 'react';
+import { useState, useEffect } from 'react';
import { UserIdentity } from '@backstage/core-components';
import { SignInPageProps } from '@backstage/core-app-api';
import { useApi, configApiRef } from '@backstage/core-plugin-api';
const SampleSignInComponent: any = (props: SignInPageProps) => {
- const [error, setError] = React.useState();
+ const [error, setError] = useState();
const config = useApi(configApiRef);
- React.useEffect(() => {
+ useEffect(() => {
const shouldAuth = !!config.getOptionalConfig('auth.providers.awsalb');
if (shouldAuth) {
fetch(`${window.location.origin}/api/auth/awsalb/refresh`)
diff --git a/contrib/docs/tutorials/quickstart-app-plugin/ExampleComponent.md b/contrib/docs/tutorials/quickstart-app-plugin/ExampleComponent.md
index fe56adddd8..78b76cd1a2 100644
--- a/contrib/docs/tutorials/quickstart-app-plugin/ExampleComponent.md
+++ b/contrib/docs/tutorials/quickstart-app-plugin/ExampleComponent.md
@@ -3,7 +3,6 @@
ExampleComponent.tsx reference
```tsx
-import React from 'react';
import { Typography, Grid } from '@material-ui/core';
import { identityApiRef, useApi } from '@backstage/core-plugin-api';
import {
diff --git a/contrib/docs/tutorials/quickstart-app-plugin/ExampleFetchComponent.md b/contrib/docs/tutorials/quickstart-app-plugin/ExampleFetchComponent.md
index f45b70cdb1..d2c0553e34 100644
--- a/contrib/docs/tutorials/quickstart-app-plugin/ExampleFetchComponent.md
+++ b/contrib/docs/tutorials/quickstart-app-plugin/ExampleFetchComponent.md
@@ -3,7 +3,6 @@
ExampleFetchComponent.tsx reference
```tsx
-import React from 'react';
import useAsync from 'react-use/lib/useAsync';
import Alert from '@material-ui/lab/Alert';
import { githubAuthApiRef, useApi } from '@backstage/core-plugin-api';
diff --git a/contrib/search/confluence/ConfluenceResultListItem.md b/contrib/search/confluence/ConfluenceResultListItem.md
index 059048d731..4061f833bd 100644
--- a/contrib/search/confluence/ConfluenceResultListItem.md
+++ b/contrib/search/confluence/ConfluenceResultListItem.md
@@ -1,7 +1,6 @@
ConfluenceResultListItem.tsx reference
```tsx
-import React from 'react';
import { Link } from '@backstage/core-components';
import { IndexableDocument } from '@backstage/plugin-search-common';
import {
diff --git a/docs/api/utility-apis.md b/docs/api/utility-apis.md
index 06183f1fc0..fbb71221fc 100644
--- a/docs/api/utility-apis.md
+++ b/docs/api/utility-apis.md
@@ -37,7 +37,6 @@ components. For example, the
[`ErrorApi`](../reference/core-plugin-api.errorapi.md) can be accessed like this:
```tsx
-import React from 'react';
import { useApi, errorApiRef } from '@backstage/core-plugin-api';
export const MyComponent = () => {
diff --git a/docs/features/search/getting-started.md b/docs/features/search/getting-started.md
index e543df5ab8..e5029ed35f 100644
--- a/docs/features/search/getting-started.md
+++ b/docs/features/search/getting-started.md
@@ -24,7 +24,6 @@ Create a new `packages/app/src/components/search/SearchPage.tsx` file in your
Backstage app with the following contents:
```tsx
-import React from 'react';
import { Content, Header, Page } from '@backstage/core-components';
import { Grid, List, Card, CardContent } from '@material-ui/core';
import {
diff --git a/docs/features/search/how-to-guides.md b/docs/features/search/how-to-guides.md
index 0476ef6c24..7055db1138 100644
--- a/docs/features/search/how-to-guides.md
+++ b/docs/features/search/how-to-guides.md
@@ -242,8 +242,6 @@ which renderers to use. Note that the order of the renderers matters! The first
Here is an example of customizing your `SearchPage`:
```tsx title="packages/app/src/components/searchPage.tsx"
-import React from 'react';
-
import { Grid, Paper } from '@material-ui/core';
import BuildIcon from '@material-ui/icons/Build';
@@ -325,8 +323,6 @@ export const Root = ({ children }: PropsWithChildren<{}>) => {
Assuming you have completely customized your SearchModal, here's an example that renders results with extensions:
```tsx title="packages/app/src/components/searchModal.tsx"
-import React from 'react';
-
import { DialogContent, DialogTitle, Paper } from '@material-ui/core';
import BuildIcon from '@material-ui/icons/Build';
diff --git a/docs/features/software-catalog/catalog-customization.md b/docs/features/software-catalog/catalog-customization.md
index 38c4b2a951..1c36301605 100644
--- a/docs/features/software-catalog/catalog-customization.md
+++ b/docs/features/software-catalog/catalog-customization.md
@@ -442,7 +442,6 @@ import {
EntityTypePicker,
UserListPicker,
} from '@backstage/plugin-catalog-react';
-import React from 'react';
export const CustomCatalogPage = () => {
const orgName =
diff --git a/docs/features/software-templates/writing-custom-field-extensions.md b/docs/features/software-templates/writing-custom-field-extensions.md
index 6ff9f195eb..20f36fd1a6 100644
--- a/docs/features/software-templates/writing-custom-field-extensions.md
+++ b/docs/features/software-templates/writing-custom-field-extensions.md
@@ -29,7 +29,6 @@ As an example, we will create a component that validates whether a string is in
```tsx
//packages/app/src/scaffolder/ValidateKebabCase/ValidateKebabCaseExtension.tsx
-import React from 'react';
import { FieldExtensionComponentProps } from '@backstage/plugin-scaffolder-react';
import type { FieldValidation } from '@rjsf/utils';
import FormControl from '@material-ui/core/FormControl';
diff --git a/docs/features/software-templates/writing-custom-step-layouts.md b/docs/features/software-templates/writing-custom-step-layouts.md
index 93e49efb44..f2ed5eb96d 100644
--- a/docs/features/software-templates/writing-custom-step-layouts.md
+++ b/docs/features/software-templates/writing-custom-step-layouts.md
@@ -18,8 +18,7 @@ This is the same [field](https://rjsf-team.github.io/react-jsonschema-form/docs/
The [createScaffolderLayout](https://backstage.io/docs/reference/plugin-scaffolder-react.createscaffolderlayout) function is used to mark a component as a custom step layout:
-```ts
-import React from 'react';
+```tsx
import { scaffolderPlugin } from '@backstage/plugin-scaffolder';
import {
createScaffolderLayout,
diff --git a/docs/features/techdocs/addons.md b/docs/features/techdocs/addons.md
index a34c2f1162..435239794b 100644
--- a/docs/features/techdocs/addons.md
+++ b/docs/features/techdocs/addons.md
@@ -181,8 +181,7 @@ provided by the Addon framework.
```tsx
// plugins/your-plugin/src/addons/MakeAllImagesCatGifs.tsx
-
-import React, { useEffect } from 'react';
+import { useEffect } from 'react';
import { useShadowRootElements } from '@backstage/plugin-techdocs-react';
// This is a normal react component; in order to make it an Addon, you would
diff --git a/docs/features/techdocs/how-to-guides.md b/docs/features/techdocs/how-to-guides.md
index 9444dc9b6e..014c8309b0 100644
--- a/docs/features/techdocs/how-to-guides.md
+++ b/docs/features/techdocs/how-to-guides.md
@@ -135,6 +135,7 @@ You can easily customize the TechDocs home page using TechDocs panel layout
Modify your `App.tsx` as follows:
```tsx
+import { Fragment, PropsWithChildren } from 'react';
import { TechDocsCustomHome } from '@backstage/plugin-techdocs';
//...
@@ -175,7 +176,7 @@ const techDocsTabsConfig = [
filterPredicate: filterEntity,
panelType: 'TechDocsIndexPage',
title: 'All',
- panelProps: { PageWrapper: React.Fragment, CustomHeader: React.Fragment, options: options },
+ panelProps: { PageWrapper: Fragment, CustomHeader: Fragment, options: options },
},
],
},
@@ -184,7 +185,7 @@ const docsFilter = {
kind: ['Location', 'Resource', 'Component'],
'metadata.annotations.featured-docs': CATALOG_FILTER_EXISTS,
}
-const customPageWrapper = ({ children }: React.PropsWithChildren<{}>) =>
+const customPageWrapper = ({ children }: PropsWithChildren<{}>) =>
({children})
const AppRoutes = () => {
@@ -212,7 +213,7 @@ maintain such a component in a new directory at
For example, you can define the following Custom home page component:
```tsx
-import React from 'react';
+import { ReactNode } from 'react';
import { Content } from '@backstage/core-components';
import {
@@ -232,7 +233,7 @@ import { EntityListDocsGrid } from '@backstage/plugin-techdocs';
export type CustomTechDocsHomeProps = {
groups?: Array<{
- title: React.ReactNode;
+ title: ReactNode;
filterPredicate: ((entity: Entity) => boolean) | string;
}>;
};
diff --git a/docs/frontend-system/architecture/36-routes.md b/docs/frontend-system/architecture/36-routes.md
index 8ed3024edd..e5d316e751 100644
--- a/docs/frontend-system/architecture/36-routes.md
+++ b/docs/frontend-system/architecture/36-routes.md
@@ -40,7 +40,6 @@ Route refs do not have any behavior themselves. They are an opaque value that re
The code snippet in the previous section does not indicate which plugin the route belongs to. To do so, you have to use it in the creation of any kind of routable extension, such as a page extension:
```tsx title="plugins/catalog/src/plugin.tsx"
-import React from 'react';
import {
createFrontendPlugin,
createPageExtension,
@@ -91,7 +90,6 @@ Route references can be used to link to page in the same plugin, or to pages in
Suppose we are creating a plugin that renders a Catalog index page with a link to a "Foo" component details page. Here is the code for the index page:
```tsx title="plugins/catalog/src/components/IndexPage.tsx"
-import React from 'react';
import { useRouteRef } from '@backstage/frontend-plugin-api';
import { detailsRouteRef } from '../routes';
@@ -125,7 +123,6 @@ We use the `useRouteRef` hook to create a link generator function that returns t
Let's see how the details page can get the parameters from the URL:
```tsx title="plugins/catalog/src/components/DetailsPage.tsx"
-import React from 'react';
import { useRouteRefParams } from '@backstage/frontend-plugin-api';
import { detailsRouteRef } from '../routes';
@@ -169,7 +166,6 @@ export const createComponentExternalRouteRef = createExternalRouteRef();
External routes are also used in a similar way as regular routes:
```tsx title="plugins/catalog/src/components/IndexPage.tsx"
-import React from 'react';
import { useRouteRef } from '@backstage/frontend-plugin-api';
import { createComponentExternalRouteRef } from '../routes';
@@ -194,7 +190,6 @@ Given the above binding, using `useRouteRef(createComponentExternalRouteRef)` wi
Now the only thing left is to provide the page and external route via a plugin:
```tsx title="plugins/catalog/src/plugin.tsx"
-import React from 'react';
import {
createFrontendPlugin,
createPageExtension,
@@ -333,7 +328,6 @@ export const detailsSubRouteRef = createSubRouteRef({
Using subroutes in a page extension is as simple as this:
```tsx title="plugins/catalog/src/components/IndexPage.tsx"
-import React from 'react';
import { Routes, Route, useLocation } from 'react-router-dom';
import { useRouteRef } from '@backstage/frontend-plugin-api';
import { indexRouteRef, detailsSubRouteRef } from '../routes';
@@ -381,7 +375,6 @@ export const IndexPage = () => {
This is how you can get the parameters of a sub route URL:
```tsx title="plugins/catalog/src/components/DetailsPage.tsx"
-import React from 'react';
import { useParams } from 'react-router-dom';
export const DetailsPage = () => {
@@ -405,7 +398,6 @@ export const DetailsPage = () => {
Finally, see how a plugin can provide subroutes:
```tsx title="plugins/catalog/src/plugin.tsx"
-import React from 'react';
import {
createFrontendPlugin,
createPageExtension,
diff --git a/docs/frontend-system/building-apps/08-migrating.md b/docs/frontend-system/building-apps/08-migrating.md
index 304bc0f84b..ecd036af61 100644
--- a/docs/frontend-system/building-apps/08-migrating.md
+++ b/docs/frontend-system/building-apps/08-migrating.md
@@ -86,7 +86,6 @@ There is one more detail that we need to deal with before moving on. The `app.cr
```tsx title="in packages/app/src/index.tsx"
import '@backstage/cli/asset-types';
-import React from 'react';
import ReactDOM from 'react-dom/client';
// highlight-remove-next-line
import App from './App';
diff --git a/docs/frontend-system/building-plugins/02-testing.md b/docs/frontend-system/building-plugins/02-testing.md
index 225c570fbd..87c22b839b 100644
--- a/docs/frontend-system/building-plugins/02-testing.md
+++ b/docs/frontend-system/building-plugins/02-testing.md
@@ -25,7 +25,6 @@ A component can be used for more than one extension, and it should be tested ind
Use the `renderInTestApp` helper to render a given component inside a Backstage test app:
```tsx
-import React from 'react';
import { screen } from '@testing-library/react';
import { renderInTestApp } from '@backstage/frontend-test-utils';
import { EntityDetails } from './plugin';
@@ -44,7 +43,6 @@ describe('Entity details component', () => {
To mock [Utility APIs](../architecture/33-utility-apis.md) that are used by your component you can use the `TestApiProvider` to override individual API implementations. In the snippet below, we wrap the component within a `TestApiProvider` in order to mock the catalog client API:
```tsx
-import React from 'react';
import { screen } from '@testing-library/react';
import {
renderInTestApp,
diff --git a/docs/getting-started/app-custom-theme.md b/docs/getting-started/app-custom-theme.md
index 1bff5b1eb0..c8c4ee8e5a 100644
--- a/docs/getting-started/app-custom-theme.md
+++ b/docs/getting-started/app-custom-theme.md
@@ -416,8 +416,6 @@ In your front-end application, locate the `src` folder. We suggest creating the
```tsx title="customIcons.tsx"
import { SvgIcon, SvgIconProps } from '@material-ui/core';
-import React from 'react';
-
export const ExampleIcon = (props: SvgIconProps) => (
(
/* We will shortly compose a pretty homepage here. */
Welcome to Backstage!
@@ -156,7 +154,6 @@ contribute, check the
> [Contributing documentation](https://github.com/backstage/backstage/blob/master/plugins/home/README.md#contributing)
```tsx
-import React from 'react';
import Grid from '@material-ui/core/Grid';
import { HomePageCompanyLogo } from '@backstage/plugin-home';
diff --git a/docs/tutorials/enable-public-entry.md b/docs/tutorials/enable-public-entry.md
index 1ba4983618..e430768785 100644
--- a/docs/tutorials/enable-public-entry.md
+++ b/docs/tutorials/enable-public-entry.md
@@ -32,7 +32,6 @@ With that, Backstage's cli and backend will detect public entry point and serve
2. This file is the public entry point for your application, and it should only contain what unauthenticated users should see:
```tsx title="in packages/app/src/index-public-experimental.tsx"
- import React from 'react';
import ReactDOM from 'react-dom/client';
import { createApp } from '@backstage/app-defaults';
import { AppRouter } from '@backstage/core-app-api';
diff --git a/docs/tutorials/quickstart-app-plugin.md b/docs/tutorials/quickstart-app-plugin.md
index e02d2f546f..e9b670c3ba 100644
--- a/docs/tutorials/quickstart-app-plugin.md
+++ b/docs/tutorials/quickstart-app-plugin.md
@@ -134,7 +134,6 @@ changes, let's start by wiping this component clean.
1. Replace everything in the file with the following:
```tsx
-import React from 'react';
import useAsync from 'react-use/lib/useAsync';
import Alert from '@material-ui/lab/Alert';
import { Table, TableColumn, Progress } from '@backstage/core-components';
diff --git a/docs/tutorials/react18-migration.md b/docs/tutorials/react18-migration.md
index c11bc83a7e..67f3dabb5d 100644
--- a/docs/tutorials/react18-migration.md
+++ b/docs/tutorials/react18-migration.md
@@ -50,7 +50,6 @@ To switch a project to React 18, there are generally three changes that need to
```tsx title="packages/app/src/index.tsx"
import '@backstage/cli/asset-types';
-import React from 'react';
// highlight-remove-next-line
import ReactDOM from 'react-dom';
// highlight-add-next-line
diff --git a/packages/app-defaults/src/createApp.test.tsx b/packages/app-defaults/src/createApp.test.tsx
index 45988a4840..a3bc7eacb7 100644
--- a/packages/app-defaults/src/createApp.test.tsx
+++ b/packages/app-defaults/src/createApp.test.tsx
@@ -16,7 +16,7 @@
import { screen } from '@testing-library/react';
import { renderWithEffects } from '@backstage/test-utils';
-import React, { PropsWithChildren } from 'react';
+import { PropsWithChildren } from 'react';
import { MemoryRouter } from 'react-router-dom';
import { createApp } from './createApp';
diff --git a/packages/app-defaults/src/defaults/components.test.tsx b/packages/app-defaults/src/defaults/components.test.tsx
index 865eeed8a7..14e32be99e 100644
--- a/packages/app-defaults/src/defaults/components.test.tsx
+++ b/packages/app-defaults/src/defaults/components.test.tsx
@@ -15,7 +15,6 @@
*/
import { render, screen } from '@testing-library/react';
-import React from 'react';
import { MemoryRouter } from 'react-router-dom';
import { OptionallyWrapInRouter } from './components';
diff --git a/packages/app-defaults/src/defaults/components.tsx b/packages/app-defaults/src/defaults/components.tsx
index 9b58694f2b..609bc6a7dd 100644
--- a/packages/app-defaults/src/defaults/components.tsx
+++ b/packages/app-defaults/src/defaults/components.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { ReactNode } from 'react';
+import { ReactNode } from 'react';
import Button from '@material-ui/core/Button';
import { ErrorPanel, Progress, ErrorPage } from '@backstage/core-components';
import {
diff --git a/packages/app-defaults/src/defaults/themes.tsx b/packages/app-defaults/src/defaults/themes.tsx
index 10368bd3bc..6929b53727 100644
--- a/packages/app-defaults/src/defaults/themes.tsx
+++ b/packages/app-defaults/src/defaults/themes.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import {
UnifiedThemeProvider,
themes as builtinThemes,
diff --git a/packages/app-next-example-plugin/src/Component.tsx b/packages/app-next-example-plugin/src/Component.tsx
index e90be162ed..225af0454b 100644
--- a/packages/app-next-example-plugin/src/Component.tsx
+++ b/packages/app-next-example-plugin/src/Component.tsx
@@ -14,8 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
-
export const Component = () => (
SHIP IT!
diff --git a/packages/app-next-example-plugin/src/ExampleSidebarItem.tsx b/packages/app-next-example-plugin/src/ExampleSidebarItem.tsx
index 20e84f1933..1b206d7d1c 100644
--- a/packages/app-next-example-plugin/src/ExampleSidebarItem.tsx
+++ b/packages/app-next-example-plugin/src/ExampleSidebarItem.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { SidebarItem } from '@backstage/core-components';
import SaveIcon from '@material-ui/icons/Save';
diff --git a/packages/app-next-example-plugin/src/plugin.tsx b/packages/app-next-example-plugin/src/plugin.tsx
index 818e8abc84..9d335f480c 100644
--- a/packages/app-next-example-plugin/src/plugin.tsx
+++ b/packages/app-next-example-plugin/src/plugin.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import {
PageBlueprint,
createFrontendPlugin,
diff --git a/packages/app-next/src/App.tsx b/packages/app-next/src/App.tsx
index 1992d5b35f..0ecb46e06a 100644
--- a/packages/app-next/src/App.tsx
+++ b/packages/app-next/src/App.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { createApp } from '@backstage/frontend-defaults';
import { pagesPlugin } from './examples/pagesPlugin';
import notFoundErrorPage from './examples/notFoundErrorPageExtension';
diff --git a/packages/app-next/src/HomePage.tsx b/packages/app-next/src/HomePage.tsx
index d6ee5cbb04..574f285f19 100644
--- a/packages/app-next/src/HomePage.tsx
+++ b/packages/app-next/src/HomePage.tsx
@@ -27,7 +27,6 @@ import {
WelcomeTitle,
} from '@backstage/plugin-home';
import { Content, Header, Page } from '@backstage/core-components';
-import React from 'react';
import HomeIcon from '@material-ui/icons/Home';
const clockConfigs: ClockConfig[] = [
diff --git a/packages/app-next/src/examples/notFoundErrorPageExtension.tsx b/packages/app-next/src/examples/notFoundErrorPageExtension.tsx
index 458e716910..a636b2b220 100644
--- a/packages/app-next/src/examples/notFoundErrorPageExtension.tsx
+++ b/packages/app-next/src/examples/notFoundErrorPageExtension.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import {
createComponentExtension,
coreComponentRefs,
diff --git a/packages/app-next/src/examples/pagesPlugin.tsx b/packages/app-next/src/examples/pagesPlugin.tsx
index 8eca7d1e6c..1d0f9f3e0e 100644
--- a/packages/app-next/src/examples/pagesPlugin.tsx
+++ b/packages/app-next/src/examples/pagesPlugin.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { Link } from '@backstage/core-components';
import {
createFrontendPlugin,
diff --git a/packages/app/src/App.test.tsx b/packages/app/src/App.test.tsx
index 919a60e53d..c29eb2f3d9 100644
--- a/packages/app/src/App.test.tsx
+++ b/packages/app/src/App.test.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { render, waitFor } from '@testing-library/react';
import App from './App';
diff --git a/packages/app/src/App.tsx b/packages/app/src/App.tsx
index 7e914bdc9b..3927992fd4 100644
--- a/packages/app/src/App.tsx
+++ b/packages/app/src/App.tsx
@@ -63,7 +63,6 @@ import {
} from '@backstage/plugin-user-settings';
import { AdvancedSettings } from './components/advancedSettings';
import AlarmIcon from '@material-ui/icons/Alarm';
-import React from 'react';
import { Navigate, Route } from 'react-router-dom';
import { apis } from './apis';
import { entityPage } from './components/catalog/EntityPage';
diff --git a/packages/app/src/components/Root/LogoFull.tsx b/packages/app/src/components/Root/LogoFull.tsx
index da6911bb17..e25416f5dc 100644
--- a/packages/app/src/components/Root/LogoFull.tsx
+++ b/packages/app/src/components/Root/LogoFull.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
const useStyles = makeStyles({
diff --git a/packages/app/src/components/Root/LogoIcon.jsx b/packages/app/src/components/Root/LogoIcon.jsx
index 966b491674..9ebb7800cf 100644
--- a/packages/app/src/components/Root/LogoIcon.jsx
+++ b/packages/app/src/components/Root/LogoIcon.jsx
@@ -16,7 +16,6 @@
// @ts-check
// NOTE: This file is intentionally .jsx, so that there is one file in this repo where we make sure .jsx files work.
-import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
const useStyles = makeStyles({
diff --git a/packages/app/src/components/Root/Root.tsx b/packages/app/src/components/Root/Root.tsx
index b74c6459d8..6f2c85c934 100644
--- a/packages/app/src/components/Root/Root.tsx
+++ b/packages/app/src/components/Root/Root.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { PropsWithChildren } from 'react';
+import { PropsWithChildren } from 'react';
import { makeStyles } from '@material-ui/core/styles';
import HomeIcon from '@material-ui/icons/Home';
import RuleIcon from '@material-ui/icons/AssignmentTurnedIn';
diff --git a/packages/app/src/components/advancedSettings/AdvancedSettings.tsx b/packages/app/src/components/advancedSettings/AdvancedSettings.tsx
index 3383198a1f..a67db21fff 100644
--- a/packages/app/src/components/advancedSettings/AdvancedSettings.tsx
+++ b/packages/app/src/components/advancedSettings/AdvancedSettings.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React from 'react';
+import { ChangeEvent } from 'react';
import { InfoCard } from '@backstage/core-components';
import List from '@material-ui/core/List';
import Grid from '@material-ui/core/Grid';
@@ -30,7 +30,7 @@ export function AdvancedSettings() {
'off',
);
- const toggleValue = (ev: React.ChangeEvent ) => {
+ const toggleValue = (ev: ChangeEvent) => {
setValue(ev.currentTarget.checked ? 'on' : 'off');
};
diff --git a/packages/app/src/components/catalog/EntityPage.test.tsx b/packages/app/src/components/catalog/EntityPage.test.tsx
index 06a568279b..effa2d09ad 100644
--- a/packages/app/src/components/catalog/EntityPage.test.tsx
+++ b/packages/app/src/components/catalog/EntityPage.test.tsx
@@ -26,7 +26,6 @@ import {
renderInTestApp,
TestApiProvider,
} from '@backstage/test-utils';
-import React from 'react';
import { cicdContent } from './EntityPage';
import { catalogApiMock } from '@backstage/plugin-catalog-react/testUtils';
diff --git a/packages/app/src/components/catalog/EntityPage.tsx b/packages/app/src/components/catalog/EntityPage.tsx
index 11fc60bd0e..08d4d921b5 100644
--- a/packages/app/src/components/catalog/EntityPage.tsx
+++ b/packages/app/src/components/catalog/EntityPage.tsx
@@ -72,7 +72,7 @@ import {
} from '@backstage/plugin-org';
import Button from '@material-ui/core/Button';
import Grid from '@material-ui/core/Grid';
-import React, { ReactNode } from 'react';
+import { ReactNode } from 'react';
import { TechDocsAddons } from '@backstage/plugin-techdocs-react';
import {
TextSize,
diff --git a/packages/app/src/components/devtools/CustomDevToolsPage.tsx b/packages/app/src/components/devtools/CustomDevToolsPage.tsx
index 788b555c6d..d1c68d9884 100644
--- a/packages/app/src/components/devtools/CustomDevToolsPage.tsx
+++ b/packages/app/src/components/devtools/CustomDevToolsPage.tsx
@@ -20,7 +20,6 @@ import {
InfoContent,
} from '@backstage/plugin-devtools';
import { DevToolsLayout } from '@backstage/plugin-devtools';
-import React from 'react';
import { UnprocessedEntitiesContent } from '@backstage/plugin-catalog-unprocessed-entities';
const DevToolsPage = () => {
diff --git a/packages/app/src/components/home/HomePage.tsx b/packages/app/src/components/home/HomePage.tsx
index 026cd5faff..f0f49ab34e 100644
--- a/packages/app/src/components/home/HomePage.tsx
+++ b/packages/app/src/components/home/HomePage.tsx
@@ -28,7 +28,6 @@ import {
} from '@backstage/plugin-home';
import { Content, Header, Page } from '@backstage/core-components';
import { HomePageSearchBar } from '@backstage/plugin-search';
-import React from 'react';
import HomeIcon from '@material-ui/icons/Home';
const clockConfigs: ClockConfig[] = [
diff --git a/packages/app/src/components/home/templates/CustomizableTemplate.stories.tsx b/packages/app/src/components/home/templates/CustomizableTemplate.stories.tsx
index eb90b1fe84..325fee4ca4 100644
--- a/packages/app/src/components/home/templates/CustomizableTemplate.stories.tsx
+++ b/packages/app/src/components/home/templates/CustomizableTemplate.stories.tsx
@@ -1,148 +1,148 @@
-/*
- * Copyright 2023 The Backstage Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import {
- HomePageStarredEntities,
- HomePageRandomJoke,
- CustomHomepageGrid,
-} from '@backstage/plugin-home';
-import {
- starredEntitiesApiRef,
- MockStarredEntitiesApi,
- entityRouteRef,
- catalogApiRef,
-} from '@backstage/plugin-catalog-react';
-import { catalogApiMock } from '@backstage/plugin-catalog-react/testUtils';
-import { wrapInTestApp, TestApiProvider } from '@backstage/test-utils';
-import { configApiRef } from '@backstage/core-plugin-api';
-import { ConfigReader } from '@backstage/config';
-import { searchApiRef } from '@backstage/plugin-search-react';
-import { HomePageSearchBar, searchPlugin } from '@backstage/plugin-search';
-import React, { ComponentType } from 'react';
-
-const entities = [
- {
- apiVersion: '1',
- kind: 'Component',
- metadata: {
- name: 'mock-starred-entity',
- title: 'Mock Starred Entity!',
- },
- },
- {
- apiVersion: '1',
- kind: 'Component',
- metadata: {
- name: 'mock-starred-entity-2',
- title: 'Mock Starred Entity 2!',
- },
- },
- {
- apiVersion: '1',
- kind: 'Component',
- metadata: {
- name: 'mock-starred-entity-3',
- title: 'Mock Starred Entity 3!',
- },
- },
- {
- apiVersion: '1',
- kind: 'Component',
- metadata: {
- name: 'mock-starred-entity-4',
- title: 'Mock Starred Entity 4!',
- },
- },
-];
-
-const catalogApi = catalogApiMock({ entities });
-
-const starredEntitiesApi = new MockStarredEntitiesApi();
-starredEntitiesApi.toggleStarred('component:default/example-starred-entity');
-starredEntitiesApi.toggleStarred('component:default/example-starred-entity-2');
-starredEntitiesApi.toggleStarred('component:default/example-starred-entity-3');
-starredEntitiesApi.toggleStarred('component:default/example-starred-entity-4');
-
-export default {
- title: 'Plugins/Home/Templates',
- decorators: [
- (Story: ComponentType<{}>) =>
- wrapInTestApp(
- <>
- Promise.resolve({ results: [] }) }],
- [
- configApiRef,
- new ConfigReader({
- backend: {
- baseUrl: 'https://localhost:7007',
- },
- }),
- ],
- ]}
- >
-
-
- >,
- {
- mountedRoutes: {
- '/hello-company': searchPlugin.routes.root,
- '/catalog/:namespace/:kind/:name': entityRouteRef,
- },
- },
- ),
- ],
-};
-export const CustomizableTemplate = () => {
- // This is the default configuration that is shown to the user
- // when first arriving to the homepage.
- const defaultConfig = [
- {
- component: 'HomePageSearchBar',
- x: 0,
- y: 0,
- width: 12,
- height: 5,
- },
- {
- component: 'HomePageRandomJoke',
- x: 0,
- y: 2,
- width: 6,
- height: 16,
- },
- {
- component: 'HomePageStarredEntities',
- x: 6,
- y: 2,
- width: 6,
- height: 12,
- },
- ];
-
- return (
-
- // Insert the allowed widgets inside the grid. User can add, organize and
- // remove the widgets as they want.
-
-
-
-
- );
-};
+/*
+ * Copyright 2023 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import {
+ HomePageStarredEntities,
+ HomePageRandomJoke,
+ CustomHomepageGrid,
+} from '@backstage/plugin-home';
+import {
+ starredEntitiesApiRef,
+ MockStarredEntitiesApi,
+ entityRouteRef,
+ catalogApiRef,
+} from '@backstage/plugin-catalog-react';
+import { catalogApiMock } from '@backstage/plugin-catalog-react/testUtils';
+import { wrapInTestApp, TestApiProvider } from '@backstage/test-utils';
+import { configApiRef } from '@backstage/core-plugin-api';
+import { ConfigReader } from '@backstage/config';
+import { searchApiRef } from '@backstage/plugin-search-react';
+import { HomePageSearchBar, searchPlugin } from '@backstage/plugin-search';
+import { ComponentType } from 'react';
+
+const entities = [
+ {
+ apiVersion: '1',
+ kind: 'Component',
+ metadata: {
+ name: 'mock-starred-entity',
+ title: 'Mock Starred Entity!',
+ },
+ },
+ {
+ apiVersion: '1',
+ kind: 'Component',
+ metadata: {
+ name: 'mock-starred-entity-2',
+ title: 'Mock Starred Entity 2!',
+ },
+ },
+ {
+ apiVersion: '1',
+ kind: 'Component',
+ metadata: {
+ name: 'mock-starred-entity-3',
+ title: 'Mock Starred Entity 3!',
+ },
+ },
+ {
+ apiVersion: '1',
+ kind: 'Component',
+ metadata: {
+ name: 'mock-starred-entity-4',
+ title: 'Mock Starred Entity 4!',
+ },
+ },
+];
+
+const catalogApi = catalogApiMock({ entities });
+
+const starredEntitiesApi = new MockStarredEntitiesApi();
+starredEntitiesApi.toggleStarred('component:default/example-starred-entity');
+starredEntitiesApi.toggleStarred('component:default/example-starred-entity-2');
+starredEntitiesApi.toggleStarred('component:default/example-starred-entity-3');
+starredEntitiesApi.toggleStarred('component:default/example-starred-entity-4');
+
+export default {
+ title: 'Plugins/Home/Templates',
+ decorators: [
+ (Story: ComponentType<{}>) =>
+ wrapInTestApp(
+ <>
+ Promise.resolve({ results: [] }) }],
+ [
+ configApiRef,
+ new ConfigReader({
+ backend: {
+ baseUrl: 'https://localhost:7007',
+ },
+ }),
+ ],
+ ]}
+ >
+
+
+ >,
+ {
+ mountedRoutes: {
+ '/hello-company': searchPlugin.routes.root,
+ '/catalog/:namespace/:kind/:name': entityRouteRef,
+ },
+ },
+ ),
+ ],
+};
+export const CustomizableTemplate = () => {
+ // This is the default configuration that is shown to the user
+ // when first arriving to the homepage.
+ const defaultConfig = [
+ {
+ component: 'HomePageSearchBar',
+ x: 0,
+ y: 0,
+ width: 12,
+ height: 5,
+ },
+ {
+ component: 'HomePageRandomJoke',
+ x: 0,
+ y: 2,
+ width: 6,
+ height: 16,
+ },
+ {
+ component: 'HomePageStarredEntities',
+ x: 6,
+ y: 2,
+ width: 6,
+ height: 12,
+ },
+ ];
+
+ return (
+
+ // Insert the allowed widgets inside the grid. User can add, organize and
+ // remove the widgets as they want.
+
+
+
+
+ );
+};
diff --git a/packages/app/src/components/home/templates/DefaultTemplate.stories.tsx b/packages/app/src/components/home/templates/DefaultTemplate.stories.tsx
index f16f98f9af..9ac8bdaaf8 100644
--- a/packages/app/src/components/home/templates/DefaultTemplate.stories.tsx
+++ b/packages/app/src/components/home/templates/DefaultTemplate.stories.tsx
@@ -1,196 +1,196 @@
-/*
- * Copyright 2021 The Backstage Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import {
- HomePageToolkit,
- HomePageCompanyLogo,
- HomePageStarredEntities,
- TemplateBackstageLogo,
- TemplateBackstageLogoIcon,
-} from '@backstage/plugin-home';
-import { wrapInTestApp, TestApiProvider } from '@backstage/test-utils';
-import { Content, Page, InfoCard } from '@backstage/core-components';
-import {
- starredEntitiesApiRef,
- MockStarredEntitiesApi,
- entityRouteRef,
- catalogApiRef,
-} from '@backstage/plugin-catalog-react';
-import { catalogApiMock } from '@backstage/plugin-catalog-react/testUtils';
-import { configApiRef } from '@backstage/core-plugin-api';
-import { ConfigReader } from '@backstage/config';
-import { HomePageSearchBar, searchPlugin } from '@backstage/plugin-search';
-import {
- searchApiRef,
- SearchContextProvider,
-} from '@backstage/plugin-search-react';
-import Grid from '@material-ui/core/Grid';
-import { makeStyles } from '@material-ui/core/styles';
-import React, { ComponentType, PropsWithChildren } from 'react';
-
-const entities = [
- {
- apiVersion: '1',
- kind: 'Component',
- metadata: {
- name: 'mock-starred-entity',
- title: 'Mock Starred Entity!',
- },
- },
- {
- apiVersion: '1',
- kind: 'Component',
- metadata: {
- name: 'mock-starred-entity-2',
- title: 'Mock Starred Entity 2!',
- },
- },
- {
- apiVersion: '1',
- kind: 'Component',
- metadata: {
- name: 'mock-starred-entity-3',
- title: 'Mock Starred Entity 3!',
- },
- },
- {
- apiVersion: '1',
- kind: 'Component',
- metadata: {
- name: 'mock-starred-entity-4',
- title: 'Mock Starred Entity 4!',
- },
- },
-];
-
-const catalogApi = catalogApiMock({ entities });
-
-const starredEntitiesApi = new MockStarredEntitiesApi();
-starredEntitiesApi.toggleStarred('component:default/example-starred-entity');
-starredEntitiesApi.toggleStarred('component:default/example-starred-entity-2');
-starredEntitiesApi.toggleStarred('component:default/example-starred-entity-3');
-starredEntitiesApi.toggleStarred('component:default/example-starred-entity-4');
-
-export default {
- title: 'Plugins/Home/Templates',
- decorators: [
- (Story: ComponentType>) =>
- wrapInTestApp(
- <>
- Promise.resolve({ results: [] }) }],
- [
- configApiRef,
- new ConfigReader({
- stackoverflow: {
- baseUrl: 'https://api.stackexchange.com/2.2',
- },
- }),
- ],
- ]}
- >
-
-
- >,
- {
- mountedRoutes: {
- '/hello-company': searchPlugin.routes.root,
- '/catalog/:namespace/:kind/:name': entityRouteRef,
- },
- },
- ),
- ],
-};
-
-const useStyles = makeStyles(theme => ({
- searchBarInput: {
- maxWidth: '60vw',
- margin: 'auto',
- backgroundColor: theme.palette.background.paper,
- borderRadius: '50px',
- boxShadow: theme.shadows[1],
- },
- searchBarOutline: {
- borderStyle: 'none',
- },
-}));
-
-const useLogoStyles = makeStyles(theme => ({
- container: {
- margin: theme.spacing(5, 0),
- },
- svg: {
- width: 'auto',
- height: 100,
- },
- path: {
- fill: '#7df3e1',
- },
-}));
-
-export const DefaultTemplate = () => {
- const classes = useStyles();
- const { svg, path, container } = useLogoStyles();
-
- return (
-
-
-
-
- }
- />
-
-
-
-
-
-
-
-
- ,
- })}
- />
-
-
-
- {/* placeholder for content */}
-
-
-
-
-
-
-
-
- );
-};
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import {
+ HomePageToolkit,
+ HomePageCompanyLogo,
+ HomePageStarredEntities,
+ TemplateBackstageLogo,
+ TemplateBackstageLogoIcon,
+} from '@backstage/plugin-home';
+import { wrapInTestApp, TestApiProvider } from '@backstage/test-utils';
+import { Content, Page, InfoCard } from '@backstage/core-components';
+import {
+ starredEntitiesApiRef,
+ MockStarredEntitiesApi,
+ entityRouteRef,
+ catalogApiRef,
+} from '@backstage/plugin-catalog-react';
+import { catalogApiMock } from '@backstage/plugin-catalog-react/testUtils';
+import { configApiRef } from '@backstage/core-plugin-api';
+import { ConfigReader } from '@backstage/config';
+import { HomePageSearchBar, searchPlugin } from '@backstage/plugin-search';
+import {
+ searchApiRef,
+ SearchContextProvider,
+} from '@backstage/plugin-search-react';
+import Grid from '@material-ui/core/Grid';
+import { makeStyles } from '@material-ui/core/styles';
+import { ComponentType, PropsWithChildren } from 'react';
+
+const entities = [
+ {
+ apiVersion: '1',
+ kind: 'Component',
+ metadata: {
+ name: 'mock-starred-entity',
+ title: 'Mock Starred Entity!',
+ },
+ },
+ {
+ apiVersion: '1',
+ kind: 'Component',
+ metadata: {
+ name: 'mock-starred-entity-2',
+ title: 'Mock Starred Entity 2!',
+ },
+ },
+ {
+ apiVersion: '1',
+ kind: 'Component',
+ metadata: {
+ name: 'mock-starred-entity-3',
+ title: 'Mock Starred Entity 3!',
+ },
+ },
+ {
+ apiVersion: '1',
+ kind: 'Component',
+ metadata: {
+ name: 'mock-starred-entity-4',
+ title: 'Mock Starred Entity 4!',
+ },
+ },
+];
+
+const catalogApi = catalogApiMock({ entities });
+
+const starredEntitiesApi = new MockStarredEntitiesApi();
+starredEntitiesApi.toggleStarred('component:default/example-starred-entity');
+starredEntitiesApi.toggleStarred('component:default/example-starred-entity-2');
+starredEntitiesApi.toggleStarred('component:default/example-starred-entity-3');
+starredEntitiesApi.toggleStarred('component:default/example-starred-entity-4');
+
+export default {
+ title: 'Plugins/Home/Templates',
+ decorators: [
+ (Story: ComponentType>) =>
+ wrapInTestApp(
+ <>
+ Promise.resolve({ results: [] }) }],
+ [
+ configApiRef,
+ new ConfigReader({
+ stackoverflow: {
+ baseUrl: 'https://api.stackexchange.com/2.2',
+ },
+ }),
+ ],
+ ]}
+ >
+
+
+ >,
+ {
+ mountedRoutes: {
+ '/hello-company': searchPlugin.routes.root,
+ '/catalog/:namespace/:kind/:name': entityRouteRef,
+ },
+ },
+ ),
+ ],
+};
+
+const useStyles = makeStyles(theme => ({
+ searchBarInput: {
+ maxWidth: '60vw',
+ margin: 'auto',
+ backgroundColor: theme.palette.background.paper,
+ borderRadius: '50px',
+ boxShadow: theme.shadows[1],
+ },
+ searchBarOutline: {
+ borderStyle: 'none',
+ },
+}));
+
+const useLogoStyles = makeStyles(theme => ({
+ container: {
+ margin: theme.spacing(5, 0),
+ },
+ svg: {
+ width: 'auto',
+ height: 100,
+ },
+ path: {
+ fill: '#7df3e1',
+ },
+}));
+
+export const DefaultTemplate = () => {
+ const classes = useStyles();
+ const { svg, path, container } = useLogoStyles();
+
+ return (
+
+
+
+
+ }
+ />
+
+
+
+
+
+
+
+
+ ,
+ })}
+ />
+
+
+
+ {/* placeholder for content */}
+
+
+
+
+
+
+
+
+ );
+};
diff --git a/packages/app/src/components/scaffolder/customScaffolderExtensions.tsx b/packages/app/src/components/scaffolder/customScaffolderExtensions.tsx
index 953420c3e6..b8a1021804 100644
--- a/packages/app/src/components/scaffolder/customScaffolderExtensions.tsx
+++ b/packages/app/src/components/scaffolder/customScaffolderExtensions.tsx
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import React from 'react';
import type { FieldValidation } from '@rjsf/utils';
import { scaffolderPlugin } from '@backstage/plugin-scaffolder';
import TextField from '@material-ui/core/TextField';
diff --git a/packages/app/src/components/scaffolder/customScaffolderLayouts.tsx b/packages/app/src/components/scaffolder/customScaffolderLayouts.tsx
index d05635314f..cd5ffd30d2 100644
--- a/packages/app/src/components/scaffolder/customScaffolderLayouts.tsx
+++ b/packages/app/src/components/scaffolder/customScaffolderLayouts.tsx
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import React from 'react';
import {
createScaffolderLayout,
LayoutTemplate,
diff --git a/packages/app/src/components/search/SearchModal.tsx b/packages/app/src/components/search/SearchModal.tsx
index 0f80d0fc68..77c95399d0 100644
--- a/packages/app/src/components/search/SearchModal.tsx
+++ b/packages/app/src/components/search/SearchModal.tsx
@@ -39,7 +39,7 @@ import Button from '@material-ui/core/Button';
import IconButton from '@material-ui/core/IconButton';
import ArrowForwardIcon from '@material-ui/icons/ArrowForward';
import CloseIcon from '@material-ui/icons/Close';
-import React, { useCallback, useEffect, useRef } from 'react';
+import { useCallback, useEffect, useRef } from 'react';
import { useNavigate } from 'react-router-dom';
const useStyles = makeStyles(theme => ({
diff --git a/packages/app/src/components/search/SearchPage.tsx b/packages/app/src/components/search/SearchPage.tsx
index 5a520e9211..9d45583044 100644
--- a/packages/app/src/components/search/SearchPage.tsx
+++ b/packages/app/src/components/search/SearchPage.tsx
@@ -42,7 +42,6 @@ import Paper from '@material-ui/core/Paper';
import Grid from '@material-ui/core/Grid';
import { Theme } from '@material-ui/core/styles/createTheme';
import { makeStyles } from '@material-ui/core/styles';
-import React from 'react';
const useStyles = makeStyles((theme: Theme) => ({
filter: {
diff --git a/packages/app/src/components/techdocs/TechDocsPage.tsx b/packages/app/src/components/techdocs/TechDocsPage.tsx
index d79acbe0a7..158df00069 100644
--- a/packages/app/src/components/techdocs/TechDocsPage.tsx
+++ b/packages/app/src/components/techdocs/TechDocsPage.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { Page } from '@backstage/core-components';
import {
TechDocsReaderPageHeader,
diff --git a/packages/app/src/index-public-experimental.tsx b/packages/app/src/index-public-experimental.tsx
index d295c7da09..fb79eb921a 100644
--- a/packages/app/src/index-public-experimental.tsx
+++ b/packages/app/src/index-public-experimental.tsx
@@ -22,7 +22,6 @@ import {
SignInPage,
} from '@backstage/core-components';
import { CookieAuthRedirect } from '@backstage/plugin-auth-react';
-import React from 'react';
import ReactDOM from 'react-dom/client';
import { providers } from '../src/identityProviders';
import {
diff --git a/packages/app/src/index.tsx b/packages/app/src/index.tsx
index a26c26e284..cb6eeb3185 100644
--- a/packages/app/src/index.tsx
+++ b/packages/app/src/index.tsx
@@ -15,7 +15,6 @@
*/
import '@backstage/cli/asset-types';
-import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
import '@backstage/canon/css/styles.css';
diff --git a/packages/canon/.storybook/preview.tsx b/packages/canon/.storybook/preview.tsx
index b1bfa2dc88..405cdfa093 100644
--- a/packages/canon/.storybook/preview.tsx
+++ b/packages/canon/.storybook/preview.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import type { Preview, ReactRenderer } from '@storybook/react';
import { withThemeByDataAttribute } from '@storybook/addon-themes';
import '../src/css/styles.css';
diff --git a/packages/canon/src/components/Box/Box.stories.tsx b/packages/canon/src/components/Box/Box.stories.tsx
index e46dadb60a..620b2818a1 100644
--- a/packages/canon/src/components/Box/Box.stories.tsx
+++ b/packages/canon/src/components/Box/Box.stories.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React from 'react';
+import { ReactNode } from 'react';
import type { Meta, StoryObj } from '@storybook/react';
import { Box } from './Box';
import { Flex } from '../Flex';
@@ -67,7 +67,7 @@ export const Preview: Story = {
},
};
-const CardDisplay = ({ children }: { children?: React.ReactNode }) => {
+const CardDisplay = ({ children }: { children?: ReactNode }) => {
return (
(
+export const Checkbox = forwardRef (
(props, ref) => {
const {
label,
diff --git a/packages/canon/src/components/Container/Container.stories.tsx b/packages/canon/src/components/Container/Container.stories.tsx
index c1b886f530..5e434b7eb0 100644
--- a/packages/canon/src/components/Container/Container.stories.tsx
+++ b/packages/canon/src/components/Container/Container.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import type { Meta, StoryObj } from '@storybook/react';
import { Box } from '../Box/Box';
import { Container } from './Container';
diff --git a/packages/canon/src/components/Flex/Flex.stories.tsx b/packages/canon/src/components/Flex/Flex.stories.tsx
index 58f96ce157..bbb5e84692 100644
--- a/packages/canon/src/components/Flex/Flex.stories.tsx
+++ b/packages/canon/src/components/Flex/Flex.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import type { Meta, StoryObj } from '@storybook/react';
import { Flex } from './Flex';
diff --git a/packages/canon/src/components/Grid/Grid.stories.tsx b/packages/canon/src/components/Grid/Grid.stories.tsx
index b767c687b7..233d66bae7 100644
--- a/packages/canon/src/components/Grid/Grid.stories.tsx
+++ b/packages/canon/src/components/Grid/Grid.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import type { Meta, StoryObj } from '@storybook/react';
import { Grid } from './Grid';
import type { GridItemProps } from './types';
diff --git a/packages/canon/src/components/Heading/Heading.stories.tsx b/packages/canon/src/components/Heading/Heading.stories.tsx
index d568bcaf7f..1fbc882d5d 100644
--- a/packages/canon/src/components/Heading/Heading.stories.tsx
+++ b/packages/canon/src/components/Heading/Heading.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import type { Meta, StoryObj } from '@storybook/react';
import { Heading } from './Heading';
import { Flex } from '../Flex';
diff --git a/packages/canon/src/components/Heading/Heading.tsx b/packages/canon/src/components/Heading/Heading.tsx
index 6c16f32ffd..5fe69bbc57 100644
--- a/packages/canon/src/components/Heading/Heading.tsx
+++ b/packages/canon/src/components/Heading/Heading.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { forwardRef } from 'react';
+import { forwardRef } from 'react';
import clsx from 'clsx';
import { useResponsiveValue } from '../../hooks/useResponsiveValue';
diff --git a/packages/canon/src/components/Icon/Icon.stories.tsx b/packages/canon/src/components/Icon/Icon.stories.tsx
index 0325e04914..92f15d8ce2 100644
--- a/packages/canon/src/components/Icon/Icon.stories.tsx
+++ b/packages/canon/src/components/Icon/Icon.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { Meta, StoryObj } from '@storybook/react';
import { Icon } from './Icon';
import { IconProvider } from './provider';
diff --git a/packages/canon/src/components/Icon/Icon.tsx b/packages/canon/src/components/Icon/Icon.tsx
index e81acd4c74..8877420a84 100644
--- a/packages/canon/src/components/Icon/Icon.tsx
+++ b/packages/canon/src/components/Icon/Icon.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React from 'react';
+import { ComponentType } from 'react';
import { useIcons } from './context';
import type { IconProps } from './types';
import clsx from 'clsx';
@@ -24,7 +24,7 @@ export const Icon = (props: IconProps) => {
const { name, size, className, style, ...restProps } = props;
const { icons } = useIcons();
- const CanonIcon = icons[name] as React.ComponentType>;
+ const CanonIcon = icons[name] as ComponentType>;
if (!CanonIcon) {
console.error(`Icon "${name}" not found or is not a valid component.`);
diff --git a/packages/canon/src/components/Icon/provider.tsx b/packages/canon/src/components/Icon/provider.tsx
index 0f296cfee4..7f78096edb 100644
--- a/packages/canon/src/components/Icon/provider.tsx
+++ b/packages/canon/src/components/Icon/provider.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { icons } from './icons';
import { IconContext } from './context';
import type { IconProviderProps } from './types';
diff --git a/packages/canon/src/components/IconButton/IconButton.stories.tsx b/packages/canon/src/components/IconButton/IconButton.stories.tsx
index d9b591cec8..edac9bd7e8 100644
--- a/packages/canon/src/components/IconButton/IconButton.stories.tsx
+++ b/packages/canon/src/components/IconButton/IconButton.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import type { Meta, StoryObj } from '@storybook/react';
import { IconButton } from './IconButton';
import { Flex } from '../Flex';
diff --git a/packages/canon/src/components/IconButton/IconButton.tsx b/packages/canon/src/components/IconButton/IconButton.tsx
index 0f28ed963f..e05e27e372 100644
--- a/packages/canon/src/components/IconButton/IconButton.tsx
+++ b/packages/canon/src/components/IconButton/IconButton.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { forwardRef } from 'react';
+import { forwardRef } from 'react';
import { Icon } from '../Icon';
import clsx from 'clsx';
import { useResponsiveValue } from '../../hooks/useResponsiveValue';
diff --git a/packages/canon/src/components/Link/Link.stories.tsx b/packages/canon/src/components/Link/Link.stories.tsx
index bdaa4006ae..03850a5be3 100644
--- a/packages/canon/src/components/Link/Link.stories.tsx
+++ b/packages/canon/src/components/Link/Link.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import type { Meta, StoryObj } from '@storybook/react';
import { Link } from './Link';
import { Flex } from '../Flex';
diff --git a/packages/canon/src/components/Link/Link.tsx b/packages/canon/src/components/Link/Link.tsx
index e9d0d6aadf..a4ccb8428b 100644
--- a/packages/canon/src/components/Link/Link.tsx
+++ b/packages/canon/src/components/Link/Link.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { forwardRef } from 'react';
+import { useRef, forwardRef } from 'react';
import { useRender } from '@base-ui-components/react/use-render';
import { useResponsiveValue } from '../../hooks/useResponsiveValue';
import clsx from 'clsx';
@@ -33,7 +33,7 @@ export const Link = forwardRef((props, ref) => {
const responsiveVariant = useResponsiveValue(variant);
const responsiveWeight = useResponsiveValue(weight);
- const internalRef = React.useRef(null);
+ const internalRef = useRef(null);
const { renderElement } = useRender({
render,
diff --git a/packages/canon/src/components/Menu/Menu.stories.tsx b/packages/canon/src/components/Menu/Menu.stories.tsx
index 58284052af..77bff661e3 100644
--- a/packages/canon/src/components/Menu/Menu.stories.tsx
+++ b/packages/canon/src/components/Menu/Menu.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import type { Meta, StoryObj } from '@storybook/react';
import { Menu } from './Menu';
import { Button } from '../Button';
diff --git a/packages/canon/src/components/Menu/Menu.tsx b/packages/canon/src/components/Menu/Menu.tsx
index b1f5224bf0..6b93d14865 100644
--- a/packages/canon/src/components/Menu/Menu.tsx
+++ b/packages/canon/src/components/Menu/Menu.tsx
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-import React from 'react';
+import { forwardRef } from 'react';
import { Menu as MenuPrimitive } from '@base-ui-components/react/menu';
import clsx from 'clsx';
import { MenuComponent } from './types';
-const MenuTrigger = React.forwardRef<
+const MenuTrigger = forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef
>(({ className, ...props }, ref) => (
@@ -31,7 +31,7 @@ const MenuTrigger = React.forwardRef<
));
MenuTrigger.displayName = MenuPrimitive.Trigger.displayName;
-const MenuBackdrop = React.forwardRef<
+const MenuBackdrop = forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef
>(({ className, ...props }, ref) => (
@@ -43,7 +43,7 @@ const MenuBackdrop = React.forwardRef<
));
MenuBackdrop.displayName = MenuPrimitive.Backdrop.displayName;
-const MenuPositioner = React.forwardRef<
+const MenuPositioner = forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef
>(({ className, ...props }, ref) => (
@@ -55,7 +55,7 @@ const MenuPositioner = React.forwardRef<
));
MenuPositioner.displayName = MenuPrimitive.Positioner.displayName;
-const MenuPopup = React.forwardRef<
+const MenuPopup = forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef
>(({ className, ...props }, ref) => (
@@ -67,7 +67,7 @@ const MenuPopup = React.forwardRef<
));
MenuPopup.displayName = MenuPrimitive.Popup.displayName;
-const MenuArrow = React.forwardRef<
+const MenuArrow = forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef
>(({ className, ...props }, ref) => (
@@ -79,7 +79,7 @@ const MenuArrow = React.forwardRef<
));
MenuArrow.displayName = MenuPrimitive.Arrow.displayName;
-const MenuItem = React.forwardRef<
+const MenuItem = forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef
>(({ className, ...props }, ref) => (
@@ -91,7 +91,7 @@ const MenuItem = React.forwardRef<
));
MenuItem.displayName = MenuPrimitive.Item.displayName;
-const MenuGroup = React.forwardRef<
+const MenuGroup = forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef
>(({ className, ...props }, ref) => (
@@ -103,7 +103,7 @@ const MenuGroup = React.forwardRef<
));
MenuGroup.displayName = MenuPrimitive.Group.displayName;
-const MenuGroupLabel = React.forwardRef<
+const MenuGroupLabel = forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef
>(({ className, ...props }, ref) => (
@@ -115,7 +115,7 @@ const MenuGroupLabel = React.forwardRef<
));
MenuGroupLabel.displayName = MenuPrimitive.GroupLabel.displayName;
-const MenuRadioGroup = React.forwardRef<
+const MenuRadioGroup = forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef
>(({ className, ...props }, ref) => (
@@ -127,7 +127,7 @@ const MenuRadioGroup = React.forwardRef<
));
MenuRadioGroup.displayName = MenuPrimitive.RadioGroup.displayName;
-const MenuRadioItem = React.forwardRef<
+const MenuRadioItem = forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef
>(({ className, ...props }, ref) => (
@@ -139,7 +139,7 @@ const MenuRadioItem = React.forwardRef<
));
MenuRadioItem.displayName = MenuPrimitive.RadioItem.displayName;
-const MenuRadioItemIndicator = React.forwardRef<
+const MenuRadioItemIndicator = forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef
>(({ className, ...props }, ref) => (
@@ -152,7 +152,7 @@ const MenuRadioItemIndicator = React.forwardRef<
MenuRadioItemIndicator.displayName =
MenuPrimitive.RadioItemIndicator.displayName;
-const MenuCheckboxItem = React.forwardRef<
+const MenuCheckboxItem = forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef
>(({ className, ...props }, ref) => (
@@ -164,7 +164,7 @@ const MenuCheckboxItem = React.forwardRef<
));
MenuCheckboxItem.displayName = MenuPrimitive.CheckboxItem.displayName;
-const MenuCheckboxItemIndicator = React.forwardRef<
+const MenuCheckboxItemIndicator = forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef
>(({ className, ...props }, ref) => (
@@ -177,7 +177,7 @@ const MenuCheckboxItemIndicator = React.forwardRef<
MenuCheckboxItemIndicator.displayName =
MenuPrimitive.CheckboxItemIndicator.displayName;
-const MenuSubmenuTrigger = React.forwardRef<
+const MenuSubmenuTrigger = forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef
>(({ className, ...props }, ref) => (
@@ -189,7 +189,7 @@ const MenuSubmenuTrigger = React.forwardRef<
));
MenuSubmenuTrigger.displayName = MenuPrimitive.SubmenuTrigger.displayName;
-const MenuSeparator = React.forwardRef<
+const MenuSeparator = forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef
>(({ className, ...props }, ref) => (
diff --git a/packages/canon/src/components/ScrollArea/ScrollArea.stories.tsx b/packages/canon/src/components/ScrollArea/ScrollArea.stories.tsx
index 3caf39a29e..25a3d5f3d8 100644
--- a/packages/canon/src/components/ScrollArea/ScrollArea.stories.tsx
+++ b/packages/canon/src/components/ScrollArea/ScrollArea.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import type { Meta, StoryObj } from '@storybook/react';
import { ScrollArea } from './ScrollArea';
import { Text } from '../Text/Text';
diff --git a/packages/canon/src/components/ScrollArea/ScrollArea.tsx b/packages/canon/src/components/ScrollArea/ScrollArea.tsx
index 1c0036d005..e96e76c29b 100644
--- a/packages/canon/src/components/ScrollArea/ScrollArea.tsx
+++ b/packages/canon/src/components/ScrollArea/ScrollArea.tsx
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-import React from 'react';
+import { forwardRef } from 'react';
import { ScrollArea as ScrollAreaPrimitive } from '@base-ui-components/react/scroll-area';
import clsx from 'clsx';
-const ScrollAreaRoot = React.forwardRef<
+const ScrollAreaRoot = forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef
>(({ className, ...props }, ref) => (
@@ -30,7 +30,7 @@ const ScrollAreaRoot = React.forwardRef<
));
ScrollAreaRoot.displayName = ScrollAreaPrimitive.Root.displayName;
-const ScrollAreaViewport = React.forwardRef<
+const ScrollAreaViewport = forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef
>(({ className, ...props }, ref) => (
@@ -42,7 +42,7 @@ const ScrollAreaViewport = React.forwardRef<
));
ScrollAreaViewport.displayName = ScrollAreaPrimitive.Viewport.displayName;
-const ScrollAreaScrollbar = React.forwardRef<
+const ScrollAreaScrollbar = forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef
>(({ className, ...props }, ref) => (
@@ -54,7 +54,7 @@ const ScrollAreaScrollbar = React.forwardRef<
));
ScrollAreaScrollbar.displayName = ScrollAreaPrimitive.Scrollbar.displayName;
-const ScrollAreaThumb = React.forwardRef<
+const ScrollAreaThumb = forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef
>(({ className, ...props }, ref) => (
diff --git a/packages/canon/src/components/Select/Select.stories.tsx b/packages/canon/src/components/Select/Select.stories.tsx
index 96bfb31f9f..a4a06a810b 100644
--- a/packages/canon/src/components/Select/Select.stories.tsx
+++ b/packages/canon/src/components/Select/Select.stories.tsx
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import React from 'react';
import type { Meta, StoryObj } from '@storybook/react';
import { Select } from './Select';
import { Flex } from '../Flex';
diff --git a/packages/canon/src/components/Select/Select.tsx b/packages/canon/src/components/Select/Select.tsx
index 835bb8303a..9463735829 100644
--- a/packages/canon/src/components/Select/Select.tsx
+++ b/packages/canon/src/components/Select/Select.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React from 'react';
+import { forwardRef, useId } from 'react';
import { Select as SelectPrimitive } from '@base-ui-components/react/select';
import { Icon } from '../Icon';
import clsx from 'clsx';
@@ -23,91 +23,89 @@ import { SelectProps } from './types';
import { useResponsiveValue } from '../../hooks/useResponsiveValue';
/** @public */
-export const Select = React.forwardRef(
- (props, ref) => {
- const {
- className,
- label,
- description,
- options,
- placeholder = 'Select an option',
- size = 'medium',
- required,
- error,
- style,
- ...rest
- } = props;
+export const Select = forwardRef((props, ref) => {
+ const {
+ className,
+ label,
+ description,
+ options,
+ placeholder = 'Select an option',
+ size = 'medium',
+ required,
+ error,
+ style,
+ ...rest
+ } = props;
- // Get the responsive value for the variant
- const responsiveSize = useResponsiveValue(size);
+ // Get the responsive value for the variant
+ const responsiveSize = useResponsiveValue(size);
- // Generate unique IDs for accessibility
- const selectId = React.useId();
- const descriptionId = React.useId();
- const errorId = React.useId();
+ // Generate unique IDs for accessibility
+ const selectId = useId();
+ const descriptionId = useId();
+ const errorId = useId();
- return (
-
- {label && (
-
- )}
-
-
-
-
-
-
-
-
-
-
-
- {options?.map(option => (
-
-
-
-
-
- {option.label}
-
-
- ))}
-
-
-
-
- {description && (
-
- {description}
-
- )}
- {error && (
-
- {error}
-
- )}
-
- );
- },
-);
+ return (
+
+ {label && (
+
+ )}
+
+
+
+
+
+
+
+
+
+
+
+ {options?.map(option => (
+
+
+
+
+
+ {option.label}
+
+
+ ))}
+
+
+
+
+ {description && (
+
+ {description}
+
+ )}
+ {error && (
+
+ {error}
+
+ )}
+
+ );
+});
Select.displayName = 'Select';
diff --git a/packages/canon/src/components/Table/Table.stories.tsx b/packages/canon/src/components/Table/Table.stories.tsx
index c4c08be527..baf840878d 100644
--- a/packages/canon/src/components/Table/Table.stories.tsx
+++ b/packages/canon/src/components/Table/Table.stories.tsx
@@ -59,7 +59,7 @@ const invoices = [
},
];
-import React from 'react';
+import { ComponentType } from 'react';
import type { Meta, StoryObj } from '@storybook/react';
import {
Table,
@@ -75,12 +75,12 @@ const meta = {
title: 'Components/Table',
component: Table,
subcomponents: {
- TableBody: TableBody as React.ComponentType,
- TableCell: TableCell as React.ComponentType,
- TableFooter: TableFooter as React.ComponentType,
- TableHead: TableHead as React.ComponentType,
- TableHeader: TableHeader as React.ComponentType,
- TableRow: TableRow as React.ComponentType,
+ TableBody: TableBody as ComponentType,
+ TableCell: TableCell as ComponentType,
+ TableFooter: TableFooter as ComponentType,
+ TableHead: TableHead as ComponentType,
+ TableHeader: TableHeader as ComponentType,
+ TableRow: TableRow as ComponentType,
},
} satisfies Meta;
diff --git a/packages/canon/src/components/Table/Table.tsx b/packages/canon/src/components/Table/Table.tsx
index efd5181036..08b613104d 100644
--- a/packages/canon/src/components/Table/Table.tsx
+++ b/packages/canon/src/components/Table/Table.tsx
@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import * as React from 'react';
+import { forwardRef } from 'react';
/** @public */
-const Table = React.forwardRef<
+const Table = forwardRef<
HTMLTableElement,
React.HTMLAttributes
>(({ className, ...props }, ref) => (
@@ -27,7 +27,7 @@ const Table = React.forwardRef<
Table.displayName = 'Table';
/** @public */
-const TableHeader = React.forwardRef<
+const TableHeader = forwardRef<
HTMLTableSectionElement,
React.HTMLAttributes
>(({ className, ...props }, ref) => (
@@ -40,7 +40,7 @@ const TableHeader = React.forwardRef<
TableHeader.displayName = 'TableHeader';
/** @public */
-const TableBody = React.forwardRef<
+const TableBody = forwardRef<
HTMLTableSectionElement,
React.HTMLAttributes
>(({ className, ...props }, ref) => (
@@ -49,7 +49,7 @@ const TableBody = React.forwardRef<
TableBody.displayName = 'TableBody';
/** @public */
-const TableFooter = React.forwardRef<
+const TableFooter = forwardRef<
HTMLTableSectionElement,
React.HTMLAttributes
>(({ className, ...props }, ref) => (
@@ -62,7 +62,7 @@ const TableFooter = React.forwardRef<
TableFooter.displayName = 'TableFooter';
/** @public */
-const TableRow = React.forwardRef<
+const TableRow = forwardRef<
HTMLTableRowElement,
React.HTMLAttributes
>(({ className, ...props }, ref) => (
@@ -73,7 +73,7 @@ const TableRow = React.forwardRef<
TableRow.displayName = 'TableRow';
/** @public */
-const TableHead = React.forwardRef<
+const TableHead = forwardRef<
HTMLTableCellElement,
React.ThHTMLAttributes
>(({ className, ...props }, ref) => (
@@ -82,7 +82,7 @@ const TableHead = React.forwardRef<
TableHead.displayName = 'TableHead';
/** @public */
-const TableCell = React.forwardRef<
+const TableCell = forwardRef<
HTMLTableCellElement,
React.TdHTMLAttributes
>(({ className, ...props }, ref) => (
@@ -91,7 +91,7 @@ const TableCell = React.forwardRef<
TableCell.displayName = 'TableCell';
/** @public */
-const TableCaption = React.forwardRef<
+const TableCaption = forwardRef<
HTMLTableCaptionElement,
React.HTMLAttributes
>(({ className, ...props }, ref) => (
diff --git a/packages/canon/src/components/Text/Text.stories.tsx b/packages/canon/src/components/Text/Text.stories.tsx
index ab904f524c..0b0ffd2712 100644
--- a/packages/canon/src/components/Text/Text.stories.tsx
+++ b/packages/canon/src/components/Text/Text.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import type { Meta, StoryObj } from '@storybook/react';
import { Text } from './Text';
import { Flex } from '../Flex';
diff --git a/packages/canon/src/components/Text/Text.tsx b/packages/canon/src/components/Text/Text.tsx
index 8bc1daf465..643afc539a 100644
--- a/packages/canon/src/components/Text/Text.tsx
+++ b/packages/canon/src/components/Text/Text.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { forwardRef } from 'react';
+import { forwardRef } from 'react';
import { useResponsiveValue } from '../../hooks/useResponsiveValue';
import clsx from 'clsx';
diff --git a/packages/canon/src/components/TextField/TextField.stories.tsx b/packages/canon/src/components/TextField/TextField.stories.tsx
index 70affa6cf6..34f81af4f4 100644
--- a/packages/canon/src/components/TextField/TextField.stories.tsx
+++ b/packages/canon/src/components/TextField/TextField.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import type { Meta, StoryObj } from '@storybook/react';
import { TextField } from './TextField';
import { Flex } from '../Flex';
diff --git a/packages/canon/src/components/TextField/TextField.tsx b/packages/canon/src/components/TextField/TextField.tsx
index d144781983..8a22ee305b 100644
--- a/packages/canon/src/components/TextField/TextField.tsx
+++ b/packages/canon/src/components/TextField/TextField.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { forwardRef } from 'react';
+import { useId, forwardRef } from 'react';
import { Input } from '@base-ui-components/react/input';
import { useResponsiveValue } from '../../hooks/useResponsiveValue';
import clsx from 'clsx';
@@ -39,9 +39,9 @@ export const TextField = forwardRef(
const responsiveSize = useResponsiveValue(size);
// Generate unique IDs for accessibility
- const inputId = React.useId();
- const descriptionId = React.useId();
- const errorId = React.useId();
+ const inputId = useId();
+ const descriptionId = useId();
+ const errorId = useId();
return (
,
React.ComponentPropsWithoutRef
>(({ className, ...props }, ref) => (
@@ -30,7 +30,7 @@ const TooltipTrigger = React.forwardRef<
));
TooltipTrigger.displayName = TooltipPrimitive.Trigger.displayName;
-const TooltipPositioner = React.forwardRef<
+const TooltipPositioner = forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef
>(({ className, ...props }, ref) => (
@@ -42,7 +42,7 @@ const TooltipPositioner = React.forwardRef<
));
TooltipPositioner.displayName = TooltipPrimitive.Positioner.displayName;
-const TooltipPopup = React.forwardRef<
+const TooltipPopup = forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef
>(({ className, ...props }, ref) => (
@@ -54,7 +54,7 @@ const TooltipPopup = React.forwardRef<
));
TooltipPopup.displayName = TooltipPrimitive.Popup.displayName;
-const TooltipArrow = React.forwardRef<
+const TooltipArrow = forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef
>(({ className, ...props }, ref) => (
diff --git a/packages/canon/src/stories/Form.stories.tsx b/packages/canon/src/stories/Form.stories.tsx
index 457d0470f8..3bffca6554 100644
--- a/packages/canon/src/stories/Form.stories.tsx
+++ b/packages/canon/src/stories/Form.stories.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React from 'react';
+import { useState } from 'react';
import type { Meta, StoryObj } from '@storybook/react';
import { useForm, SubmitHandler, Controller } from 'react-hook-form';
import { TextField } from '../components/TextField';
@@ -105,9 +105,9 @@ export const Controlled: Story = {
formState: { errors },
} = useForm();
- const [firstname, setFirstname] = React.useState('John');
- const [lastname, setLastname] = React.useState('Doe');
- const [city, setCity] = React.useState('london');
+ const [firstname, setFirstname] = useState('John');
+ const [lastname, setLastname] = useState('Doe');
+ const [city, setCity] = useState('london');
const onSubmit: SubmitHandler = data => {
console.log('data', data);
diff --git a/packages/cli/config/eslint-factory.js b/packages/cli/config/eslint-factory.js
index 8f50e184ff..914979043e 100644
--- a/packages/cli/config/eslint-factory.js
+++ b/packages/cli/config/eslint-factory.js
@@ -243,8 +243,26 @@ function createConfigForRole(dir, role, extraConfig = {}) {
'@mui/*/*/*',
...(extraConfig.restrictedImportPatterns ?? []),
],
+ rules: {
+ 'react/react-in-jsx-scope': 'off',
+ 'no-restricted-syntax': [
+ 'error',
+ {
+ message: 'Default React import not allowed.',
+ selector:
+ "ImportDeclaration[source.value='react'][specifiers.0.type='ImportDefaultSpecifier']",
+ },
+ {
+ message:
+ 'Default React import not allowed. If you need a global type that collides with a React named export (such as `MouseEvent`), try using `globalThis.MouseHandler`.',
+ selector:
+ "ImportDeclaration[source.value='react'] :matches(ImportDefaultSpecifier, ImportNamespaceSpecifier)",
+ },
+ ],
+ ...extraConfig.rules,
+ },
tsRules: {
- 'react/prop-types': 0,
+ 'react/prop-types': 'off',
...extraConfig.tsRules,
},
});
diff --git a/packages/cli/config/tsconfig.json b/packages/cli/config/tsconfig.json
index ac5e62b52e..4aa5665b02 100644
--- a/packages/cli/config/tsconfig.json
+++ b/packages/cli/config/tsconfig.json
@@ -11,7 +11,7 @@
"importHelpers": false,
"incremental": true,
"isolatedModules": true,
- "jsx": "react",
+ "jsx": "react-jsx",
"lib": ["DOM", "DOM.Iterable", "ScriptHost", "ES2022"],
"module": "ESNext",
"moduleResolution": "node",
diff --git a/packages/cli/templates/frontend-plugin/dev/index.tsx.hbs b/packages/cli/templates/frontend-plugin/dev/index.tsx.hbs
index 61cd8f2695..dd17ae58c5 100644
--- a/packages/cli/templates/frontend-plugin/dev/index.tsx.hbs
+++ b/packages/cli/templates/frontend-plugin/dev/index.tsx.hbs
@@ -1,4 +1,3 @@
-import React from 'react';
import { createDevApp } from '@backstage/dev-utils';
import { {{ pluginVar }}, {{ extensionName }} } from '../src/plugin';
diff --git a/packages/cli/templates/frontend-plugin/src/components/ExampleComponent/ExampleComponent.test.tsx.hbs b/packages/cli/templates/frontend-plugin/src/components/ExampleComponent/ExampleComponent.test.tsx.hbs
index 81b4dec2c3..c7c20863c2 100644
--- a/packages/cli/templates/frontend-plugin/src/components/ExampleComponent/ExampleComponent.test.tsx.hbs
+++ b/packages/cli/templates/frontend-plugin/src/components/ExampleComponent/ExampleComponent.test.tsx.hbs
@@ -1,4 +1,3 @@
-import React from 'react';
import { ExampleComponent } from './ExampleComponent';
import { rest } from 'msw';
import { setupServer } from 'msw/node';
diff --git a/packages/cli/templates/frontend-plugin/src/components/ExampleComponent/ExampleComponent.tsx.hbs b/packages/cli/templates/frontend-plugin/src/components/ExampleComponent/ExampleComponent.tsx.hbs
index 95a8f044d1..d117fad131 100644
--- a/packages/cli/templates/frontend-plugin/src/components/ExampleComponent/ExampleComponent.tsx.hbs
+++ b/packages/cli/templates/frontend-plugin/src/components/ExampleComponent/ExampleComponent.tsx.hbs
@@ -1,4 +1,3 @@
-import React from 'react';
import { Typography, Grid } from '@material-ui/core';
import {
InfoCard,
diff --git a/packages/cli/templates/frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx.hbs b/packages/cli/templates/frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx.hbs
index be43c05ba2..820e54fa37 100644
--- a/packages/cli/templates/frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx.hbs
+++ b/packages/cli/templates/frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx.hbs
@@ -1,4 +1,3 @@
-import React from 'react';
import { renderInTestApp } from '@backstage/test-utils';
import { ExampleFetchComponent } from './ExampleFetchComponent';
diff --git a/packages/cli/templates/frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx.hbs b/packages/cli/templates/frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx.hbs
index 6134ee9b06..bd6bd9d75b 100644
--- a/packages/cli/templates/frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx.hbs
+++ b/packages/cli/templates/frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx.hbs
@@ -1,4 +1,3 @@
-import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import {
Table,
diff --git a/packages/cli/templates/plugin-web-library/src/components/ExampleComponent/ExampleComponent.test.tsx b/packages/cli/templates/plugin-web-library/src/components/ExampleComponent/ExampleComponent.test.tsx
index c421e05209..0a7703ddb2 100644
--- a/packages/cli/templates/plugin-web-library/src/components/ExampleComponent/ExampleComponent.test.tsx
+++ b/packages/cli/templates/plugin-web-library/src/components/ExampleComponent/ExampleComponent.test.tsx
@@ -1,18 +1,17 @@
-import React from 'react';
-import { screen } from '@testing-library/react';
-import { renderInTestApp } from '@backstage/test-utils';
-import { ExampleComponent } from './ExampleComponent';
-
-describe('ExampleComponent', () => {
- it('should render', async () => {
- await renderInTestApp();
-
- expect(screen.getByText('Hello World')).toBeInTheDocument();
- });
-
- it('should display a custom message', async () => {
- await renderInTestApp();
-
- expect(screen.getByText('Hello Example')).toBeInTheDocument();
- });
-});
+import { screen } from '@testing-library/react';
+import { renderInTestApp } from '@backstage/test-utils';
+import { ExampleComponent } from './ExampleComponent';
+
+describe('ExampleComponent', () => {
+ it('should render', async () => {
+ await renderInTestApp();
+
+ expect(screen.getByText('Hello World')).toBeInTheDocument();
+ });
+
+ it('should display a custom message', async () => {
+ await renderInTestApp();
+
+ expect(screen.getByText('Hello Example')).toBeInTheDocument();
+ });
+});
diff --git a/packages/cli/templates/plugin-web-library/src/components/ExampleComponent/ExampleComponent.tsx b/packages/cli/templates/plugin-web-library/src/components/ExampleComponent/ExampleComponent.tsx
index a1ab0937db..f29135a6a8 100644
--- a/packages/cli/templates/plugin-web-library/src/components/ExampleComponent/ExampleComponent.tsx
+++ b/packages/cli/templates/plugin-web-library/src/components/ExampleComponent/ExampleComponent.tsx
@@ -1,29 +1,28 @@
-import React from 'react';
-import { Typography } from '@material-ui/core';
-
-/**
- * Props for {@link ExampleComponent}.
- *
- * @public
- */
-export interface ExampleComponentProps {
- message?: string;
-}
-
-/**
- * Displays an example.
- *
- * @remarks
- *
- * Longer descriptions should be put after the `@remarks` tag. That way the initial summary
- * will show up in the API docs overview section, while the longer description will only be
- * displayed on the page for the specific API.
- *
- * @public
- */
-export function ExampleComponent(props: ExampleComponentProps) {
- // By destructuring props here rather than in the signature the API docs will look nicer
- const { message = 'Hello World' } = props;
-
- return {message};
-}
+import { Typography } from '@material-ui/core';
+
+/**
+ * Props for {@link ExampleComponent}.
+ *
+ * @public
+ */
+export interface ExampleComponentProps {
+ message?: string;
+}
+
+/**
+ * Displays an example.
+ *
+ * @remarks
+ *
+ * Longer descriptions should be put after the `@remarks` tag. That way the initial summary
+ * will show up in the API docs overview section, while the longer description will only be
+ * displayed on the page for the specific API.
+ *
+ * @public
+ */
+export function ExampleComponent(props: ExampleComponentProps) {
+ // By destructuring props here rather than in the signature the API docs will look nicer
+ const { message = 'Hello World' } = props;
+
+ return {message};
+}
diff --git a/packages/core-app-api/src/apis/system/ApiProvider.test.tsx b/packages/core-app-api/src/apis/system/ApiProvider.test.tsx
index ceb3a0d12a..095fc88627 100644
--- a/packages/core-app-api/src/apis/system/ApiProvider.test.tsx
+++ b/packages/core-app-api/src/apis/system/ApiProvider.test.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import {
useApi,
createApiRef,
diff --git a/packages/core-app-api/src/apis/system/ApiProvider.tsx b/packages/core-app-api/src/apis/system/ApiProvider.tsx
index c75f883a51..5d0a13f84d 100644
--- a/packages/core-app-api/src/apis/system/ApiProvider.tsx
+++ b/packages/core-app-api/src/apis/system/ApiProvider.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { useContext, ReactNode, PropsWithChildren } from 'react';
+import { useContext, ReactNode, PropsWithChildren } from 'react';
import PropTypes from 'prop-types';
import { ApiHolder } from '@backstage/core-plugin-api';
import { ApiAggregator } from './ApiAggregator';
diff --git a/packages/core-app-api/src/app/AppContext.test.tsx b/packages/core-app-api/src/app/AppContext.test.tsx
index a011b5966b..e281a3809a 100644
--- a/packages/core-app-api/src/app/AppContext.test.tsx
+++ b/packages/core-app-api/src/app/AppContext.test.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React from 'react';
+import { PropsWithChildren } from 'react';
import { renderHook } from '@testing-library/react';
import { useVersionedContext } from '@backstage/version-bridge';
import { AppContext as AppContextV1 } from './types';
@@ -40,7 +40,7 @@ describe('v1 consumer', () => {
};
const renderedHook = renderHook(() => useMockAppV1(), {
- wrapper: ({ children }: React.PropsWithChildren<{}>) => (
+ wrapper: ({ children }: PropsWithChildren<{}>) => (
),
});
diff --git a/packages/core-app-api/src/app/AppContext.tsx b/packages/core-app-api/src/app/AppContext.tsx
index f39d9a095e..b402c1abd6 100644
--- a/packages/core-app-api/src/app/AppContext.tsx
+++ b/packages/core-app-api/src/app/AppContext.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { PropsWithChildren } from 'react';
+import { PropsWithChildren } from 'react';
import {
createVersionedValueMap,
createVersionedContext,
diff --git a/packages/core-app-api/src/app/AppManager.compat.test.tsx b/packages/core-app-api/src/app/AppManager.compat.test.tsx
index cfbcc87a01..ae2c75dbc3 100644
--- a/packages/core-app-api/src/app/AppManager.compat.test.tsx
+++ b/packages/core-app-api/src/app/AppManager.compat.test.tsx
@@ -14,8 +14,8 @@
* limitations under the License.
*/
+import { default as React } from 'react';
import tlr, { render } from '@testing-library/react';
-import React from 'react';
describe.each(['beta', 'stable'])('react-router %s', rrVersion => {
beforeAll(() => {
diff --git a/packages/core-app-api/src/app/AppManager.stable.test.tsx b/packages/core-app-api/src/app/AppManager.stable.test.tsx
index ba16353d47..d45a3282d7 100644
--- a/packages/core-app-api/src/app/AppManager.stable.test.tsx
+++ b/packages/core-app-api/src/app/AppManager.stable.test.tsx
@@ -15,7 +15,6 @@
*/
import { render } from '@testing-library/react';
-import React from 'react';
import { MemoryRouter, Navigate, Route } from 'react-router-dom';
import { FlatRoutes } from '../routing';
import { AppManager } from './AppManager';
diff --git a/packages/core-app-api/src/app/AppManager.test.tsx b/packages/core-app-api/src/app/AppManager.test.tsx
index d995edffdf..054c28ad03 100644
--- a/packages/core-app-api/src/app/AppManager.test.tsx
+++ b/packages/core-app-api/src/app/AppManager.test.tsx
@@ -25,7 +25,7 @@ import { screen, act } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { setupServer } from 'msw/node';
import { rest } from 'msw';
-import React, { PropsWithChildren, ReactNode } from 'react';
+import { PropsWithChildren, ReactNode } from 'react';
import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom';
import {
configApiRef,
diff --git a/packages/core-app-api/src/app/AppManager.tsx b/packages/core-app-api/src/app/AppManager.tsx
index b28b843d34..98067267b5 100644
--- a/packages/core-app-api/src/app/AppManager.tsx
+++ b/packages/core-app-api/src/app/AppManager.tsx
@@ -15,7 +15,7 @@
*/
import { Config } from '@backstage/config';
-import React, {
+import {
ComponentType,
PropsWithChildren,
Suspense,
diff --git a/packages/core-app-api/src/app/AppRouter.test.tsx b/packages/core-app-api/src/app/AppRouter.test.tsx
index b595f91794..7658db0168 100644
--- a/packages/core-app-api/src/app/AppRouter.test.tsx
+++ b/packages/core-app-api/src/app/AppRouter.test.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import {
AppComponents,
configApiRef,
diff --git a/packages/core-app-api/src/app/AppRouter.tsx b/packages/core-app-api/src/app/AppRouter.tsx
index 7481f6662a..afc87d6753 100644
--- a/packages/core-app-api/src/app/AppRouter.tsx
+++ b/packages/core-app-api/src/app/AppRouter.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { useContext, ReactNode, ComponentType, useState } from 'react';
+import { useContext, ReactNode, ComponentType, useState } from 'react';
import {
attachComponentData,
ConfigApi,
diff --git a/packages/core-app-api/src/app/AppThemeProvider.tsx b/packages/core-app-api/src/app/AppThemeProvider.tsx
index b6fba540ec..719736eabb 100644
--- a/packages/core-app-api/src/app/AppThemeProvider.tsx
+++ b/packages/core-app-api/src/app/AppThemeProvider.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { useMemo, useEffect, useState, PropsWithChildren } from 'react';
+import { useMemo, useEffect, useState, PropsWithChildren } from 'react';
import { useApi, appThemeApiRef, AppTheme } from '@backstage/core-plugin-api';
import useObservable from 'react-use/esm/useObservable';
diff --git a/packages/core-app-api/src/app/defaultConfigLoader.test.tsx b/packages/core-app-api/src/app/defaultConfigLoader.test.tsx
index 556e4c928e..603a321fb1 100644
--- a/packages/core-app-api/src/app/defaultConfigLoader.test.tsx
+++ b/packages/core-app-api/src/app/defaultConfigLoader.test.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { render } from '@testing-library/react';
import { defaultConfigLoaderSync } from './defaultConfigLoader';
import { ConfigReader } from '@backstage/config';
diff --git a/packages/core-app-api/src/app/isReactRouterBeta.tsx b/packages/core-app-api/src/app/isReactRouterBeta.tsx
index bef4f8521f..82702c0ee3 100644
--- a/packages/core-app-api/src/app/isReactRouterBeta.tsx
+++ b/packages/core-app-api/src/app/isReactRouterBeta.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { createRoutesFromChildren, Route } from 'react-router-dom';
export function isReactRouterBeta(): boolean {
diff --git a/packages/core-app-api/src/extensions/traversal.test.tsx b/packages/core-app-api/src/extensions/traversal.test.tsx
index 0acc51fb27..d129120971 100644
--- a/packages/core-app-api/src/extensions/traversal.test.tsx
+++ b/packages/core-app-api/src/extensions/traversal.test.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { Children, isValidElement } from 'react';
+import { Children, isValidElement } from 'react';
import {
childDiscoverer,
createCollector,
diff --git a/packages/core-app-api/src/plugins/collectors.test.tsx b/packages/core-app-api/src/plugins/collectors.test.tsx
index 056652423e..b85cdaac05 100644
--- a/packages/core-app-api/src/plugins/collectors.test.tsx
+++ b/packages/core-app-api/src/plugins/collectors.test.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { PropsWithChildren } from 'react';
+import { PropsWithChildren } from 'react';
import {
createPlugin,
createRouteRef,
diff --git a/packages/core-app-api/src/routing/FeatureFlagged.test.tsx b/packages/core-app-api/src/routing/FeatureFlagged.test.tsx
index 8ee74c0a23..8bd32b6dd9 100644
--- a/packages/core-app-api/src/routing/FeatureFlagged.test.tsx
+++ b/packages/core-app-api/src/routing/FeatureFlagged.test.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React from 'react';
+import { ReactNode } from 'react';
import { FeatureFlagged } from './FeatureFlagged';
import { render, screen } from '@testing-library/react';
import { LocalStorageFeatureFlags } from '../apis';
@@ -22,7 +22,7 @@ import { TestApiProvider } from '@backstage/test-utils';
import { featureFlagsApiRef } from '@backstage/core-plugin-api';
const mockFeatureFlagsApi = new LocalStorageFeatureFlags();
-const Wrapper = ({ children }: { children?: React.ReactNode }) => (
+const Wrapper = ({ children }: { children?: ReactNode }) => (
{children}
diff --git a/packages/core-app-api/src/routing/FeatureFlagged.tsx b/packages/core-app-api/src/routing/FeatureFlagged.tsx
index 2b0b5afe34..2a4dc8b877 100644
--- a/packages/core-app-api/src/routing/FeatureFlagged.tsx
+++ b/packages/core-app-api/src/routing/FeatureFlagged.tsx
@@ -19,7 +19,7 @@ import {
useApi,
attachComponentData,
} from '@backstage/core-plugin-api';
-import React, { ReactNode } from 'react';
+import { ReactNode } from 'react';
/**
* Props for the {@link FeatureFlagged} component.
diff --git a/packages/core-app-api/src/routing/FlatRoutes.beta.test.tsx b/packages/core-app-api/src/routing/FlatRoutes.beta.test.tsx
index 8d4d10c52a..f6b4348aa1 100644
--- a/packages/core-app-api/src/routing/FlatRoutes.beta.test.tsx
+++ b/packages/core-app-api/src/routing/FlatRoutes.beta.test.tsx
@@ -15,7 +15,7 @@
*/
import { render, RenderResult } from '@testing-library/react';
-import React, { ReactNode } from 'react';
+import { ReactNode } from 'react';
import { MemoryRouter, Route, Routes, useOutlet } from 'react-router-dom';
import { LocalStorageFeatureFlags } from '../apis';
import { featureFlagsApiRef } from '@backstage/core-plugin-api';
@@ -30,7 +30,7 @@ jest.mock('react-router-dom', () =>
);
const mockFeatureFlagsApi = new LocalStorageFeatureFlags();
-const Wrapper = ({ children }: { children?: React.ReactNode }) => (
+const Wrapper = ({ children }: { children?: ReactNode }) => (
{children}
diff --git a/packages/core-app-api/src/routing/FlatRoutes.compat.test.tsx b/packages/core-app-api/src/routing/FlatRoutes.compat.test.tsx
index c32b306387..24a7c592ff 100644
--- a/packages/core-app-api/src/routing/FlatRoutes.compat.test.tsx
+++ b/packages/core-app-api/src/routing/FlatRoutes.compat.test.tsx
@@ -15,7 +15,7 @@
*/
import tlr, { render, RenderResult } from '@testing-library/react';
-import React, { ReactNode } from 'react';
+import { default as React, ReactNode } from 'react';
import { LocalStorageFeatureFlags } from '../apis';
import { featureFlagsApiRef } from '@backstage/core-plugin-api';
import { AppContext } from '../app';
@@ -59,7 +59,7 @@ describe.each(['beta', 'stable'])('FlatRoutes %s', rrVersion => {
const { MemoryRouter, TestApiProvider } = requireDeps();
let rendered: RenderResult | undefined = undefined;
- const Wrapper = ({ children }: { children?: React.ReactNode }) => (
+ const Wrapper = ({ children }: { children?: ReactNode }) => (
{children}
diff --git a/packages/core-app-api/src/routing/FlatRoutes.stable.test.tsx b/packages/core-app-api/src/routing/FlatRoutes.stable.test.tsx
index ece6c22ff2..093b0635e7 100644
--- a/packages/core-app-api/src/routing/FlatRoutes.stable.test.tsx
+++ b/packages/core-app-api/src/routing/FlatRoutes.stable.test.tsx
@@ -15,7 +15,7 @@
*/
import { render, RenderResult } from '@testing-library/react';
-import React, { ReactNode } from 'react';
+import { ReactNode } from 'react';
import { MemoryRouter, Route, useOutlet } from 'react-router-dom';
import { LocalStorageFeatureFlags } from '../apis';
import { featureFlagsApiRef } from '@backstage/core-plugin-api';
@@ -30,7 +30,7 @@ jest.mock('react-router-dom', () =>
);
const mockFeatureFlagsApi = new LocalStorageFeatureFlags();
-const Wrapper = ({ children }: { children?: React.ReactNode }) => (
+const Wrapper = ({ children }: { children?: ReactNode }) => (
{children}
diff --git a/packages/core-app-api/src/routing/FlatRoutes.tsx b/packages/core-app-api/src/routing/FlatRoutes.tsx
index 46c2270d0d..32c3db7615 100644
--- a/packages/core-app-api/src/routing/FlatRoutes.tsx
+++ b/packages/core-app-api/src/routing/FlatRoutes.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { ReactNode, useMemo } from 'react';
+import { ReactNode, useMemo } from 'react';
import { useRoutes } from 'react-router-dom';
import {
attachComponentData,
diff --git a/packages/core-app-api/src/routing/RouteTracker.test.tsx b/packages/core-app-api/src/routing/RouteTracker.test.tsx
index ecbd44315d..03441ffa20 100644
--- a/packages/core-app-api/src/routing/RouteTracker.test.tsx
+++ b/packages/core-app-api/src/routing/RouteTracker.test.tsx
@@ -15,7 +15,6 @@
*/
import { TestApiProvider, mockApis } from '@backstage/test-utils';
-import React from 'react';
import { BackstageRouteObject } from './types';
import { fireEvent, render } from '@testing-library/react';
import { RouteTracker } from './RouteTracker';
diff --git a/packages/core-app-api/src/routing/RouteTracker.tsx b/packages/core-app-api/src/routing/RouteTracker.tsx
index 69903268ac..7a4614dc33 100644
--- a/packages/core-app-api/src/routing/RouteTracker.tsx
+++ b/packages/core-app-api/src/routing/RouteTracker.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { useEffect } from 'react';
+import { useEffect } from 'react';
import { matchRoutes, useLocation } from 'react-router-dom';
import {
useAnalytics,
diff --git a/packages/core-app-api/src/routing/RoutingProvider.beta.test.tsx b/packages/core-app-api/src/routing/RoutingProvider.beta.test.tsx
index ca089d0014..e7c45bfb25 100644
--- a/packages/core-app-api/src/routing/RoutingProvider.beta.test.tsx
+++ b/packages/core-app-api/src/routing/RoutingProvider.beta.test.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { PropsWithChildren, ReactElement } from 'react';
+import { Suspense, PropsWithChildren, ReactElement } from 'react';
import { MemoryRouter, Routes } from 'react-router-dom';
import { render } from '@testing-library/react';
import { renderHook } from '@testing-library/react';
@@ -246,7 +246,7 @@ describe('discovery', () => {
const root = (
-
+
@@ -259,7 +259,7 @@ describe('discovery', () => {
routeRef={ref3}
params={{ id: 'blob' }}
/>
-
+
);
diff --git a/packages/core-app-api/src/routing/RoutingProvider.compat.test.tsx b/packages/core-app-api/src/routing/RoutingProvider.compat.test.tsx
index ac54780f7c..2fb6892b9b 100644
--- a/packages/core-app-api/src/routing/RoutingProvider.compat.test.tsx
+++ b/packages/core-app-api/src/routing/RoutingProvider.compat.test.tsx
@@ -14,7 +14,12 @@
* limitations under the License.
*/
-import React, { PropsWithChildren, ReactElement } from 'react';
+import {
+ default as React,
+ PropsWithChildren,
+ ReactElement,
+ Suspense,
+} from 'react';
import { render } from '@testing-library/react';
import type {
BackstagePlugin,
@@ -315,7 +320,7 @@ describe.each(['beta', 'stable'])('react-router %s', rrVersion => {
const root = (
-
+
}>
{
routeRef={refPage2}
params={{ id: 'other' }}
/>
-
+
);
diff --git a/packages/core-app-api/src/routing/RoutingProvider.stable.test.tsx b/packages/core-app-api/src/routing/RoutingProvider.stable.test.tsx
index df0ce32e2b..dd53165fb0 100644
--- a/packages/core-app-api/src/routing/RoutingProvider.stable.test.tsx
+++ b/packages/core-app-api/src/routing/RoutingProvider.stable.test.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { PropsWithChildren, ReactElement } from 'react';
+import { Suspense, PropsWithChildren, ReactElement } from 'react';
import { MemoryRouter, Routes, Route, useOutlet } from 'react-router-dom';
import { render } from '@testing-library/react';
import { renderHook } from '@testing-library/react';
@@ -266,7 +266,7 @@ describe('discovery', () => {
const root = (
-
+
}>
{
routeRef={refPage2}
params={{ id: 'other' }}
/>
-
+
);
diff --git a/packages/core-app-api/src/routing/RoutingProvider.tsx b/packages/core-app-api/src/routing/RoutingProvider.tsx
index 3d8a274922..67121d6429 100644
--- a/packages/core-app-api/src/routing/RoutingProvider.tsx
+++ b/packages/core-app-api/src/routing/RoutingProvider.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { ReactNode } from 'react';
+import { ReactNode } from 'react';
import {
ExternalRouteRef,
RouteRef,
diff --git a/packages/core-app-api/src/routing/collectors.beta.test.tsx b/packages/core-app-api/src/routing/collectors.beta.test.tsx
index 057674a7e4..366557573c 100644
--- a/packages/core-app-api/src/routing/collectors.beta.test.tsx
+++ b/packages/core-app-api/src/routing/collectors.beta.test.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { PropsWithChildren } from 'react';
+import { PropsWithChildren } from 'react';
import { routingV1Collector } from './collectors';
import {
diff --git a/packages/core-app-api/src/routing/collectors.compat.test.tsx b/packages/core-app-api/src/routing/collectors.compat.test.tsx
index 5dab06d03e..8e88013b7c 100644
--- a/packages/core-app-api/src/routing/collectors.compat.test.tsx
+++ b/packages/core-app-api/src/routing/collectors.compat.test.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import type { PropsWithChildren } from 'react';
import {
RouteRef,
diff --git a/packages/core-app-api/src/routing/collectors.stable.test.tsx b/packages/core-app-api/src/routing/collectors.stable.test.tsx
index 20c7643b9e..e9a5512b28 100644
--- a/packages/core-app-api/src/routing/collectors.stable.test.tsx
+++ b/packages/core-app-api/src/routing/collectors.stable.test.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { ComponentType, PropsWithChildren } from 'react';
+import { ComponentType, PropsWithChildren } from 'react';
import { routingV2Collector } from './collectors';
import {
diff --git a/packages/core-compat-api/src/collectEntityPageContents.test.tsx b/packages/core-compat-api/src/collectEntityPageContents.test.tsx
index 53aa90f247..fd74a7e89b 100644
--- a/packages/core-compat-api/src/collectEntityPageContents.test.tsx
+++ b/packages/core-compat-api/src/collectEntityPageContents.test.tsx
@@ -16,7 +16,7 @@
import { ExtensionAttachToSpec } from '@backstage/frontend-plugin-api';
import { EntityLayout, EntitySwitch, isKind } from '@backstage/plugin-catalog';
-import React from 'react';
+import { JSX } from 'react';
import { collectEntityPageContents } from './collectEntityPageContents';
import {
createComponentExtension,
@@ -70,7 +70,7 @@ const otherTestContent = (
);
-function collect(element: React.JSX.Element) {
+function collect(element: JSX.Element) {
const result = new Array<{
id: string;
attachTo: ExtensionAttachToSpec;
diff --git a/packages/core-compat-api/src/collectEntityPageContents.ts b/packages/core-compat-api/src/collectEntityPageContents.ts
index 503642733e..6748c8939a 100644
--- a/packages/core-compat-api/src/collectEntityPageContents.ts
+++ b/packages/core-compat-api/src/collectEntityPageContents.ts
@@ -20,7 +20,7 @@ import {
BackstagePlugin as LegacyBackstagePlugin,
} from '@backstage/core-plugin-api';
import { ExtensionDefinition } from '@backstage/frontend-plugin-api';
-import React from 'react';
+import { JSX, ReactNode, isValidElement, Children } from 'react';
import {
EntityCardBlueprint,
EntityContentBlueprint,
@@ -73,7 +73,7 @@ function invertFilter(ifFunc?: EntityFilter): EntityFilter {
}
export function collectEntityPageContents(
- entityPageElement: React.JSX.Element,
+ entityPageElement: JSX.Element,
context: {
discoverExtension(
extension: ExtensionDefinition,
@@ -84,8 +84,8 @@ export function collectEntityPageContents(
let cardCounter = 1;
let routeCounter = 1;
- function traverse(element: React.ReactNode, parentFilter?: EntityFilter) {
- if (!React.isValidElement(element)) {
+ function traverse(element: ReactNode, parentFilter?: EntityFilter) {
+ if (!isValidElement(element)) {
return;
}
@@ -152,8 +152,8 @@ export function collectEntityPageContents(
return;
}
- React.Children.forEach(
- (element.props as { children?: React.ReactNode })?.children,
+ Children.forEach(
+ (element.props as { children?: ReactNode })?.children,
child => {
traverse(child, parentFilter);
},
@@ -173,7 +173,7 @@ type EntityRoute = {
type EntitySwitchCase = {
if?: EntityFilter;
- children: React.ReactNode;
+ children: ReactNode;
};
type EntitySwitch = {
@@ -206,7 +206,7 @@ function wrapAsyncEntityFilter(
}
function maybeParseEntityPageNode(
- element: React.JSX.Element,
+ element: JSX.Element,
): EntityRoute | EntitySwitch | undefined {
if (getComponentData(element, ENTITY_ROUTE_KEY)) {
const props = element.props as EntityRoute;
@@ -220,11 +220,11 @@ function maybeParseEntityPageNode(
}
const parentProps = element.props as {
- children?: React.ReactNode;
+ children?: ReactNode;
renderMultipleMatches?: 'first' | 'all';
};
- const children = React.Children.toArray(parentProps?.children);
+ const children = Children.toArray(parentProps?.children);
if (!children.length) {
return undefined;
}
diff --git a/packages/core-compat-api/src/collectLegacyRoutes.test.tsx b/packages/core-compat-api/src/collectLegacyRoutes.test.tsx
index 2d64f88535..d536fbe9a1 100644
--- a/packages/core-compat-api/src/collectLegacyRoutes.test.tsx
+++ b/packages/core-compat-api/src/collectLegacyRoutes.test.tsx
@@ -26,7 +26,7 @@ import {
import { PuppetDbPage } from '@backstage-community/plugin-puppetdb';
import { StackstormPage } from '@backstage-community/plugin-stackstorm';
import { ScoreBoardPage } from '@oriflame/backstage-plugin-score-card';
-import React, { Fragment } from 'react';
+import { Fragment } from 'react';
// TODO(rugvip): this should take into account that this is a test file, so these deps don't need to be in the dependencies
// eslint-disable-next-line @backstage/no-undeclared-imports
import { OpaqueFrontendPlugin } from '@internal/frontend';
diff --git a/packages/core-compat-api/src/collectLegacyRoutes.tsx b/packages/core-compat-api/src/collectLegacyRoutes.tsx
index 072e6b3bb2..f65856ec08 100644
--- a/packages/core-compat-api/src/collectLegacyRoutes.tsx
+++ b/packages/core-compat-api/src/collectLegacyRoutes.tsx
@@ -33,7 +33,7 @@ import {
FrontendModule,
createFrontendModule,
} from '@backstage/frontend-plugin-api';
-import React, { Children, ReactNode, isValidElement } from 'react';
+import { Children, ReactNode, isValidElement } from 'react';
import { Route, Routes } from 'react-router-dom';
import {
convertLegacyRouteRef,
@@ -187,87 +187,84 @@ export function collectLegacyRoutes(
return extensions;
};
- React.Children.forEach(
- flatRoutesElement.props.children,
- (route: ReactNode) => {
- if (route === null) {
- return;
- }
- // TODO(freben): Handle feature flag and permissions framework wrapper elements
- if (!React.isValidElement(route)) {
- throw new Error(
- `Invalid element inside FlatRoutes, expected Route but found element of type ${typeof route}.`,
- );
- }
- if (route.type !== Route) {
- throw new Error(
- `Invalid element inside FlatRoutes, expected Route but found ${route.type}.`,
- );
- }
- const routeElement = route.props.element;
- const path: string | undefined = route.props.path;
- const plugin =
- getComponentData(routeElement, 'core.plugin') ??
- orphanRoutesPlugin;
- const routeRef = getComponentData(
- routeElement,
- 'core.mountPoint',
+ Children.forEach(flatRoutesElement.props.children, (route: ReactNode) => {
+ if (route === null) {
+ return;
+ }
+ // TODO(freben): Handle feature flag and permissions framework wrapper elements
+ if (!isValidElement(route)) {
+ throw new Error(
+ `Invalid element inside FlatRoutes, expected Route but found element of type ${typeof route}.`,
);
- if (path === undefined) {
- throw new Error(
- `Route element inside FlatRoutes had no path prop value given`,
- );
- }
-
- const extensions = getPluginExtensions(plugin);
- const pageExtensionName = extensions.length ? getUniqueName() : undefined;
- const pageExtensionId = `page:${plugin.getId()}${
- pageExtensionName ? `/${pageExtensionName}` : pageExtensionName
- }`;
-
- extensions.push(
- PageBlueprint.makeWithOverrides({
- name: pageExtensionName,
- inputs: {
- childRoutingShims: createExtensionInput([
- coreExtensionData.routePath.optional(),
- coreExtensionData.routeRef.optional(),
- ]),
- },
- factory(originalFactory, { inputs: _inputs }) {
- // todo(blam): why do we not use the inputs here?
- return originalFactory({
- defaultPath: normalizeRoutePath(path),
- routeRef: routeRef ? convertLegacyRouteRef(routeRef) : undefined,
- loader: async () =>
- compatWrapper(
- route.props.children ? (
-
-
-
-
-
- ) : (
- routeElement
- ),
- ),
- });
- },
- }),
+ }
+ if (route.type !== Route) {
+ throw new Error(
+ `Invalid element inside FlatRoutes, expected Route but found ${route.type}.`,
);
+ }
+ const routeElement = route.props.element;
+ const path: string | undefined = route.props.path;
+ const plugin =
+ getComponentData(routeElement, 'core.plugin') ??
+ orphanRoutesPlugin;
+ const routeRef = getComponentData(
+ routeElement,
+ 'core.mountPoint',
+ );
+ if (path === undefined) {
+ throw new Error(
+ `Route element inside FlatRoutes had no path prop value given`,
+ );
+ }
- visitRouteChildren({
- children: route.props.children,
- parentExtensionId: pageExtensionId,
- context: {
- pluginId: plugin.getId(),
- extensions,
- getUniqueName,
- discoverPlugin: getPluginExtensions,
+ const extensions = getPluginExtensions(plugin);
+ const pageExtensionName = extensions.length ? getUniqueName() : undefined;
+ const pageExtensionId = `page:${plugin.getId()}${
+ pageExtensionName ? `/${pageExtensionName}` : pageExtensionName
+ }`;
+
+ extensions.push(
+ PageBlueprint.makeWithOverrides({
+ name: pageExtensionName,
+ inputs: {
+ childRoutingShims: createExtensionInput([
+ coreExtensionData.routePath.optional(),
+ coreExtensionData.routeRef.optional(),
+ ]),
},
- });
- },
- );
+ factory(originalFactory, { inputs: _inputs }) {
+ // todo(blam): why do we not use the inputs here?
+ return originalFactory({
+ defaultPath: normalizeRoutePath(path),
+ routeRef: routeRef ? convertLegacyRouteRef(routeRef) : undefined,
+ loader: async () =>
+ compatWrapper(
+ route.props.children ? (
+
+
+
+
+
+ ) : (
+ routeElement
+ ),
+ ),
+ });
+ },
+ }),
+ );
+
+ visitRouteChildren({
+ children: route.props.children,
+ parentExtensionId: pageExtensionId,
+ context: {
+ pluginId: plugin.getId(),
+ extensions,
+ getUniqueName,
+ discoverPlugin: getPluginExtensions,
+ },
+ });
+ });
if (entityPage) {
collectEntityPageContents(entityPage, {
diff --git a/packages/core-compat-api/src/compatWrapper/BackwardsCompatProvider.tsx b/packages/core-compat-api/src/compatWrapper/BackwardsCompatProvider.tsx
index 0f9ccfb2ad..3faaf124fd 100644
--- a/packages/core-compat-api/src/compatWrapper/BackwardsCompatProvider.tsx
+++ b/packages/core-compat-api/src/compatWrapper/BackwardsCompatProvider.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { useMemo } from 'react';
+import { useMemo } from 'react';
import { ReactNode } from 'react';
// eslint-disable-next-line @backstage/no-relative-monorepo-imports
import { AppContextProvider } from '../../../core-app-api/src/app/AppContext';
diff --git a/packages/core-compat-api/src/compatWrapper/ForwardsCompatProvider.tsx b/packages/core-compat-api/src/compatWrapper/ForwardsCompatProvider.tsx
index 9c646d5b00..ffa8bea9ab 100644
--- a/packages/core-compat-api/src/compatWrapper/ForwardsCompatProvider.tsx
+++ b/packages/core-compat-api/src/compatWrapper/ForwardsCompatProvider.tsx
@@ -40,7 +40,7 @@ import {
iconsApiRef,
routeResolutionApiRef,
} from '@backstage/frontend-plugin-api';
-import React, { ComponentType, useMemo } from 'react';
+import { ComponentType, useMemo } from 'react';
import { ReactNode } from 'react';
import { toLegacyPlugin } from './BackwardsCompatProvider';
// eslint-disable-next-line @backstage/no-relative-monorepo-imports
diff --git a/packages/core-compat-api/src/compatWrapper/compatWrapper.test.tsx b/packages/core-compat-api/src/compatWrapper/compatWrapper.test.tsx
index 94fc8705e6..f1418e545f 100644
--- a/packages/core-compat-api/src/compatWrapper/compatWrapper.test.tsx
+++ b/packages/core-compat-api/src/compatWrapper/compatWrapper.test.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import {
componentsApiRef,
coreComponentRefs,
diff --git a/packages/core-compat-api/src/compatWrapper/compatWrapper.tsx b/packages/core-compat-api/src/compatWrapper/compatWrapper.tsx
index cd7378a384..206422ffa9 100644
--- a/packages/core-compat-api/src/compatWrapper/compatWrapper.tsx
+++ b/packages/core-compat-api/src/compatWrapper/compatWrapper.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { useVersionedContext } from '@backstage/version-bridge';
import { ReactNode } from 'react';
import { BackwardsCompatProvider } from './BackwardsCompatProvider';
diff --git a/packages/core-compat-api/src/convertLegacyApp.test.tsx b/packages/core-compat-api/src/convertLegacyApp.test.tsx
index c532c6da1a..810a5d3c97 100644
--- a/packages/core-compat-api/src/convertLegacyApp.test.tsx
+++ b/packages/core-compat-api/src/convertLegacyApp.test.tsx
@@ -18,7 +18,7 @@ import { AppRouter, FlatRoutes } from '@backstage/core-app-api';
import { PuppetDbPage } from '@backstage-community/plugin-puppetdb';
import { StackstormPage } from '@backstage-community/plugin-stackstorm';
import { ScoreBoardPage } from '@oriflame/backstage-plugin-score-card';
-import React, { ReactNode } from 'react';
+import { ReactNode } from 'react';
import { Route } from 'react-router-dom';
import { convertLegacyApp } from './convertLegacyApp';
import {
diff --git a/packages/core-compat-api/src/convertLegacyApp.ts b/packages/core-compat-api/src/convertLegacyApp.ts
index 2a62a6c1c6..0c3a8c0060 100644
--- a/packages/core-compat-api/src/convertLegacyApp.ts
+++ b/packages/core-compat-api/src/convertLegacyApp.ts
@@ -14,7 +14,9 @@
* limitations under the License.
*/
-import React, {
+import {
+ JSX,
+ cloneElement,
Children,
Fragment,
ReactElement,
@@ -78,12 +80,12 @@ export interface ConvertLegacyAppOptions {
* page content provided both via the old structure and the new plugins. Any
* duplicate content needs to be removed from the old structure.
*/
- entityPage?: React.JSX.Element;
+ entityPage?: JSX.Element;
}
/** @public */
export function convertLegacyApp(
- rootElement: React.JSX.Element,
+ rootElement: JSX.Element,
options: ConvertLegacyAppOptions = {},
): (FrontendPlugin | FrontendModule)[] {
if (getComponentData(rootElement, 'core.type') === 'FlatRoutes') {
@@ -141,7 +143,7 @@ export function convertLegacyApp(
return [
coreExtensionData.reactElement(
compatWrapper(
- React.cloneElement(
+ cloneElement(
rootEl,
undefined,
inputs.content.get(coreExtensionData.reactElement),
diff --git a/packages/core-compat-api/src/convertLegacyAppOptions.tsx b/packages/core-compat-api/src/convertLegacyAppOptions.tsx
index 7a0a016161..56aec7c1c5 100644
--- a/packages/core-compat-api/src/convertLegacyAppOptions.tsx
+++ b/packages/core-compat-api/src/convertLegacyAppOptions.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React from 'react';
+import { ComponentType } from 'react';
import {
ApiBlueprint,
coreComponentRefs,
@@ -41,7 +41,7 @@ import { toLegacyPlugin } from './compatWrapper/BackwardsCompatProvider';
import { compatWrapper } from './compatWrapper';
function componentCompatWrapper(
- Component: React.ComponentType,
+ Component: ComponentType,
) {
return (props: TProps) => compatWrapper();
}
diff --git a/packages/core-compat-api/src/convertLegacyPageExtension.test.tsx b/packages/core-compat-api/src/convertLegacyPageExtension.test.tsx
index c1630b31b5..4248cef098 100644
--- a/packages/core-compat-api/src/convertLegacyPageExtension.test.tsx
+++ b/packages/core-compat-api/src/convertLegacyPageExtension.test.tsx
@@ -25,7 +25,6 @@ import {
renderInTestApp,
} from '@backstage/frontend-test-utils';
import { screen } from '@testing-library/react';
-import React from 'react';
import { convertLegacyPageExtension } from './convertLegacyPageExtension';
import { convertLegacyRouteRef } from './convertLegacyRouteRef';
diff --git a/packages/core-compat-api/src/convertLegacyPageExtension.tsx b/packages/core-compat-api/src/convertLegacyPageExtension.tsx
index 3931a730c8..f14b297047 100644
--- a/packages/core-compat-api/src/convertLegacyPageExtension.tsx
+++ b/packages/core-compat-api/src/convertLegacyPageExtension.tsx
@@ -25,7 +25,6 @@ import {
import kebabCase from 'lodash/kebabCase';
import { convertLegacyRouteRef } from './convertLegacyRouteRef';
import { ComponentType } from 'react';
-import React from 'react';
import { compatWrapper } from './compatWrapper';
/** @public */
diff --git a/packages/core-components/src/components/AlertDisplay/AlertDisplay.test.tsx b/packages/core-components/src/components/AlertDisplay/AlertDisplay.test.tsx
index f2f904a3e0..c934737065 100644
--- a/packages/core-components/src/components/AlertDisplay/AlertDisplay.test.tsx
+++ b/packages/core-components/src/components/AlertDisplay/AlertDisplay.test.tsx
@@ -21,7 +21,6 @@ import { fireEvent, screen } from '@testing-library/react';
import { AlertApiForwarder } from '@backstage/core-app-api';
import { AlertDisplay } from './AlertDisplay';
import Observable from 'zen-observable';
-import React from 'react';
import { act } from '@testing-library/react';
const TEST_MESSAGE = 'TEST_MESSAGE';
diff --git a/packages/core-components/src/components/AlertDisplay/AlertDisplay.tsx b/packages/core-components/src/components/AlertDisplay/AlertDisplay.tsx
index 61876bd58b..a21192c91b 100644
--- a/packages/core-components/src/components/AlertDisplay/AlertDisplay.tsx
+++ b/packages/core-components/src/components/AlertDisplay/AlertDisplay.tsx
@@ -20,7 +20,7 @@ import Snackbar from '@material-ui/core/Snackbar';
import Typography from '@material-ui/core/Typography';
import CloseIcon from '@material-ui/icons/Close';
import Alert from '@material-ui/lab/Alert';
-import React, { useEffect, useState } from 'react';
+import { useEffect, useState } from 'react';
import { coreComponentsTranslationRef } from '../../translation';
/**
diff --git a/packages/core-components/src/components/AutoLogout/AutoLogout.tsx b/packages/core-components/src/components/AutoLogout/AutoLogout.tsx
index a345ca4b2d..b328705e51 100644
--- a/packages/core-components/src/components/AutoLogout/AutoLogout.tsx
+++ b/packages/core-components/src/components/AutoLogout/AutoLogout.tsx
@@ -21,7 +21,7 @@ import {
identityApiRef,
useApi,
} from '@backstage/core-plugin-api';
-import React, { useEffect, useMemo, useState } from 'react';
+import { useEffect, useMemo, useState } from 'react';
import {
EventsType,
IIdleTimer,
diff --git a/packages/core-components/src/components/AutoLogout/Autologout.test.tsx b/packages/core-components/src/components/AutoLogout/Autologout.test.tsx
index 5a555cd215..2885f12f31 100644
--- a/packages/core-components/src/components/AutoLogout/Autologout.test.tsx
+++ b/packages/core-components/src/components/AutoLogout/Autologout.test.tsx
@@ -24,7 +24,6 @@ import {
renderInTestApp,
mockApis,
} from '@backstage/test-utils';
-import React from 'react';
import { AutoLogout } from './AutoLogout';
import { cleanup } from '@testing-library/react';
diff --git a/packages/core-components/src/components/AutoLogout/StillTherePrompt.stories.tsx b/packages/core-components/src/components/AutoLogout/StillTherePrompt.stories.tsx
index 446afc226e..7de1bef509 100644
--- a/packages/core-components/src/components/AutoLogout/StillTherePrompt.stories.tsx
+++ b/packages/core-components/src/components/AutoLogout/StillTherePrompt.stories.tsx
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import React from 'react';
import { StillTherePrompt, StillTherePromptProps } from './StillTherePrompt';
export default {
diff --git a/packages/core-components/src/components/AutoLogout/StillTherePrompt.tsx b/packages/core-components/src/components/AutoLogout/StillTherePrompt.tsx
index 9496199fd9..b42295fba2 100644
--- a/packages/core-components/src/components/AutoLogout/StillTherePrompt.tsx
+++ b/packages/core-components/src/components/AutoLogout/StillTherePrompt.tsx
@@ -20,7 +20,7 @@ import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import DialogContentText from '@material-ui/core/DialogContentText';
import DialogTitle from '@material-ui/core/DialogTitle';
-import React, { useEffect } from 'react';
+import { useEffect } from 'react';
import { IIdleTimer } from 'react-idle-timer';
import { coreComponentsTranslationRef } from '../../translation';
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
diff --git a/packages/core-components/src/components/Avatar/Avatar.stories.tsx b/packages/core-components/src/components/Avatar/Avatar.stories.tsx
index dc0f7c00e7..4843e2bb73 100644
--- a/packages/core-components/src/components/Avatar/Avatar.stories.tsx
+++ b/packages/core-components/src/components/Avatar/Avatar.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { Avatar } from './Avatar';
import { makeStyles } from '@material-ui/core/styles';
diff --git a/packages/core-components/src/components/Avatar/Avatar.test.tsx b/packages/core-components/src/components/Avatar/Avatar.test.tsx
index 1c08d57679..3f8b401277 100644
--- a/packages/core-components/src/components/Avatar/Avatar.test.tsx
+++ b/packages/core-components/src/components/Avatar/Avatar.test.tsx
@@ -15,7 +15,6 @@
*/
import { render } from '@testing-library/react';
-import React from 'react';
import { Avatar } from './Avatar';
describe('', () => {
diff --git a/packages/core-components/src/components/Avatar/Avatar.tsx b/packages/core-components/src/components/Avatar/Avatar.tsx
index d3b0a13602..de1f76bcab 100644
--- a/packages/core-components/src/components/Avatar/Avatar.tsx
+++ b/packages/core-components/src/components/Avatar/Avatar.tsx
@@ -16,7 +16,7 @@
import MaterialAvatar from '@material-ui/core/Avatar';
import { makeStyles, Theme } from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';
-import React, { CSSProperties } from 'react';
+import { CSSProperties } from 'react';
import { extractInitials, stringToColor } from './utils';
import classNames from 'classnames';
diff --git a/packages/core-components/src/components/Chip/Chip.stories.tsx b/packages/core-components/src/components/Chip/Chip.stories.tsx
index 5e00779209..4423a2ca58 100644
--- a/packages/core-components/src/components/Chip/Chip.stories.tsx
+++ b/packages/core-components/src/components/Chip/Chip.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import AddIcon from '@material-ui/icons/Add';
import WarningIcon from '@material-ui/icons/Warning';
import EditIcon from '@material-ui/icons/Edit';
diff --git a/packages/core-components/src/components/CodeSnippet/CodeSnippet.stories.tsx b/packages/core-components/src/components/CodeSnippet/CodeSnippet.stories.tsx
index c4ed5ae072..bea5cf778e 100644
--- a/packages/core-components/src/components/CodeSnippet/CodeSnippet.stories.tsx
+++ b/packages/core-components/src/components/CodeSnippet/CodeSnippet.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { CodeSnippet } from './CodeSnippet';
import { InfoCard } from '../../layout/InfoCard';
diff --git a/packages/core-components/src/components/CodeSnippet/CodeSnippet.test.tsx b/packages/core-components/src/components/CodeSnippet/CodeSnippet.test.tsx
index c0096e7ae9..753b9e69c4 100644
--- a/packages/core-components/src/components/CodeSnippet/CodeSnippet.test.tsx
+++ b/packages/core-components/src/components/CodeSnippet/CodeSnippet.test.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { renderInTestApp } from '@backstage/test-utils';
import { CodeSnippet } from './CodeSnippet';
diff --git a/packages/core-components/src/components/CodeSnippet/CodeSnippet.tsx b/packages/core-components/src/components/CodeSnippet/CodeSnippet.tsx
index 6eb274b015..8c31bc4e6d 100644
--- a/packages/core-components/src/components/CodeSnippet/CodeSnippet.tsx
+++ b/packages/core-components/src/components/CodeSnippet/CodeSnippet.tsx
@@ -16,7 +16,6 @@
import Box from '@material-ui/core/Box';
import { useTheme } from '@material-ui/core/styles';
-import React from 'react';
import type {} from 'react-syntax-highlighter';
import LightAsync from 'react-syntax-highlighter/dist/esm/light-async';
import dark from 'react-syntax-highlighter/dist/esm/styles/hljs/dark';
diff --git a/packages/core-components/src/components/CopyTextButton/CopyTextButton.stories.tsx b/packages/core-components/src/components/CopyTextButton/CopyTextButton.stories.tsx
index 3e6435ddad..39c6782207 100644
--- a/packages/core-components/src/components/CopyTextButton/CopyTextButton.stories.tsx
+++ b/packages/core-components/src/components/CopyTextButton/CopyTextButton.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { CopyTextButton } from './CopyTextButton';
export default {
diff --git a/packages/core-components/src/components/CopyTextButton/CopyTextButton.test.tsx b/packages/core-components/src/components/CopyTextButton/CopyTextButton.test.tsx
index 92dcb9163e..3430daaf73 100644
--- a/packages/core-components/src/components/CopyTextButton/CopyTextButton.test.tsx
+++ b/packages/core-components/src/components/CopyTextButton/CopyTextButton.test.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { act, fireEvent } from '@testing-library/react';
import { renderInTestApp, TestApiProvider } from '@backstage/test-utils';
import { CopyTextButton } from './CopyTextButton';
diff --git a/packages/core-components/src/components/CopyTextButton/CopyTextButton.tsx b/packages/core-components/src/components/CopyTextButton/CopyTextButton.tsx
index a82965916f..fd8179c6f9 100644
--- a/packages/core-components/src/components/CopyTextButton/CopyTextButton.tsx
+++ b/packages/core-components/src/components/CopyTextButton/CopyTextButton.tsx
@@ -18,7 +18,7 @@ import { errorApiRef, useApi } from '@backstage/core-plugin-api';
import IconButton from '@material-ui/core/IconButton';
import Tooltip from '@material-ui/core/Tooltip';
import CopyIcon from '@material-ui/icons/FileCopy';
-import React, { MouseEventHandler, useEffect, useState } from 'react';
+import { MouseEventHandler, useEffect, useState } from 'react';
import useCopyToClipboard from 'react-use/esm/useCopyToClipboard';
import { coreComponentsTranslationRef } from '../../translation';
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
diff --git a/packages/core-components/src/components/CreateButton/CreateButton.tsx b/packages/core-components/src/components/CreateButton/CreateButton.tsx
index beca7e8c73..04105b3182 100644
--- a/packages/core-components/src/components/CreateButton/CreateButton.tsx
+++ b/packages/core-components/src/components/CreateButton/CreateButton.tsx
@@ -17,7 +17,6 @@
import Button from '@material-ui/core/Button';
import IconButton from '@material-ui/core/IconButton';
import useMediaQuery from '@material-ui/core/useMediaQuery';
-import React from 'react';
import { Link as RouterLink, LinkProps } from 'react-router-dom';
import AddCircleOutline from '@material-ui/icons/AddCircleOutline';
import { Theme } from '@material-ui/core/styles';
diff --git a/packages/core-components/src/components/DependencyGraph/DefaultLabel.tsx b/packages/core-components/src/components/DependencyGraph/DefaultLabel.tsx
index d4a91e50db..88816d5b45 100644
--- a/packages/core-components/src/components/DependencyGraph/DefaultLabel.tsx
+++ b/packages/core-components/src/components/DependencyGraph/DefaultLabel.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import makeStyles from '@material-ui/core/styles/makeStyles';
import { DependencyGraphTypes as Types } from './types';
diff --git a/packages/core-components/src/components/DependencyGraph/DefaultNode.tsx b/packages/core-components/src/components/DependencyGraph/DefaultNode.tsx
index 81a918c7b8..71138001f7 100644
--- a/packages/core-components/src/components/DependencyGraph/DefaultNode.tsx
+++ b/packages/core-components/src/components/DependencyGraph/DefaultNode.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React from 'react';
+import { useState, useRef, useLayoutEffect } from 'react';
import { makeStyles } from '@material-ui/core/styles';
import { DependencyGraphTypes as Types } from './types';
@@ -37,11 +37,11 @@ const useStyles = makeStyles(
/** @public */
export function DefaultNode({ node: { id } }: Types.RenderNodeProps) {
const classes = useStyles();
- const [width, setWidth] = React.useState(0);
- const [height, setHeight] = React.useState(0);
- const idRef = React.useRef(null);
+ const [width, setWidth] = useState(0);
+ const [height, setHeight] = useState(0);
+ const idRef = useRef(null);
- React.useLayoutEffect(() => {
+ useLayoutEffect(() => {
// set the width to the length of the ID
if (idRef.current) {
let { height: renderedHeight, width: renderedWidth } =
diff --git a/packages/core-components/src/components/DependencyGraph/DependencyGraph.stories.tsx b/packages/core-components/src/components/DependencyGraph/DependencyGraph.stories.tsx
index 99d6e7d0fd..3ed4a25730 100644
--- a/packages/core-components/src/components/DependencyGraph/DependencyGraph.stories.tsx
+++ b/packages/core-components/src/components/DependencyGraph/DependencyGraph.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { DependencyGraph } from './DependencyGraph';
import { DependencyGraphTypes as Types } from './types';
diff --git a/packages/core-components/src/components/DependencyGraph/DependencyGraph.test.tsx b/packages/core-components/src/components/DependencyGraph/DependencyGraph.test.tsx
index 30481a7c85..6535808059 100644
--- a/packages/core-components/src/components/DependencyGraph/DependencyGraph.test.tsx
+++ b/packages/core-components/src/components/DependencyGraph/DependencyGraph.test.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { render } from '@testing-library/react';
import { DependencyGraph } from './DependencyGraph';
import { DependencyGraphTypes as Types } from './types';
diff --git a/packages/core-components/src/components/DependencyGraph/DependencyGraph.tsx b/packages/core-components/src/components/DependencyGraph/DependencyGraph.tsx
index 770f1c9c23..d690253b06 100644
--- a/packages/core-components/src/components/DependencyGraph/DependencyGraph.tsx
+++ b/packages/core-components/src/components/DependencyGraph/DependencyGraph.tsx
@@ -14,7 +14,14 @@
* limitations under the License.
*/
-import React from 'react';
+import {
+ SVGProps,
+ useState,
+ useRef,
+ useMemo,
+ useCallback,
+ useEffect,
+} from 'react';
import * as d3Zoom from 'd3-zoom';
import * as d3Selection from 'd3-selection';
import useTheme from '@material-ui/core/styles/useTheme';
@@ -33,7 +40,7 @@ import { ARROW_MARKER_ID } from './constants';
* `` and `` are useful when rendering custom or edge labels
*/
export interface DependencyGraphProps
- extends React.SVGProps {
+ extends SVGProps {
/**
* Edges of graph
*/
@@ -212,20 +219,20 @@ export function DependencyGraph(
...svgProps
} = props;
const theme = useTheme();
- const [containerWidth, setContainerWidth] = React.useState(100);
- const [containerHeight, setContainerHeight] = React.useState(100);
+ const [containerWidth, setContainerWidth] = useState(100);
+ const [containerHeight, setContainerHeight] = useState(100);
- const graph = React.useRef<
- dagre.graphlib.Graph>
- >(new dagre.graphlib.Graph());
- const [graphWidth, setGraphWidth] = React.useState(
+ const graph = useRef>>(
+ new dagre.graphlib.Graph(),
+ );
+ const [graphWidth, setGraphWidth] = useState(
graph.current.graph()?.width || 0,
);
- const [graphHeight, setGraphHeight] = React.useState(
+ const [graphHeight, setGraphHeight] = useState(
graph.current.graph()?.height || 0,
);
- const [graphNodes, setGraphNodes] = React.useState([]);
- const [graphEdges, setGraphEdges] = React.useState([]);
+ const [graphNodes, setGraphNodes] = useState([]);
+ const [graphEdges, setGraphEdges] = useState([]);
const maxWidth = Math.max(graphWidth, containerWidth);
const maxHeight = Math.max(graphHeight, containerHeight);
@@ -233,7 +240,7 @@ export function DependencyGraph(
const scalableHeight = fit === 'grow' ? maxHeight : minHeight;
- const containerRef = React.useMemo(
+ const containerRef = useMemo(
() =>
debounce((node: SVGSVGElement) => {
if (!node) {
@@ -286,7 +293,7 @@ export function DependencyGraph(
[containerHeight, containerWidth, maxWidth, maxHeight, zoom],
);
- const setNodesAndEdges = React.useCallback(() => {
+ const setNodesAndEdges = useCallback(() => {
// Cleaning up lingering nodes and edges
const currentGraphNodes = graph.current.nodes();
const currentGraphEdges = graph.current.edges();
@@ -335,7 +342,7 @@ export function DependencyGraph(
});
}, [edges, nodes, labelPosition, labelOffset, edgeWeight, edgeRanks]);
- const updateGraph = React.useMemo(
+ const updateGraph = useMemo(
() =>
debounce(
() => {
@@ -355,7 +362,7 @@ export function DependencyGraph(
[],
);
- React.useEffect(() => {
+ useEffect(() => {
graph.current.setGraph({
rankdir: direction,
align,
diff --git a/packages/core-components/src/components/DependencyGraph/Edge.test.tsx b/packages/core-components/src/components/DependencyGraph/Edge.test.tsx
index 78fb27f15f..78d63fa48e 100644
--- a/packages/core-components/src/components/DependencyGraph/Edge.test.tsx
+++ b/packages/core-components/src/components/DependencyGraph/Edge.test.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { render } from '@testing-library/react';
import { Edge } from './Edge';
import { DependencyGraphTypes as Types } from './types';
diff --git a/packages/core-components/src/components/DependencyGraph/Edge.tsx b/packages/core-components/src/components/DependencyGraph/Edge.tsx
index cd8dd0642a..0f28c59403 100644
--- a/packages/core-components/src/components/DependencyGraph/Edge.tsx
+++ b/packages/core-components/src/components/DependencyGraph/Edge.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React from 'react';
+import { useRef, useLayoutEffect, useMemo } from 'react';
import * as d3Shape from 'd3-shape';
import isFinite from 'lodash/isFinite';
import makeStyles from '@material-ui/core/styles/makeStyles';
@@ -86,9 +86,9 @@ export function Edge({
const labelProps: Types.DependencyEdge = edge;
const classes = useStyles();
- const labelRef = React.useRef(null);
+ const labelRef = useRef(null);
- React.useLayoutEffect(() => {
+ useLayoutEffect(() => {
// set the label width to the actual rendered width to properly layout graph
if (labelRef.current) {
let { height: renderedHeight, width: renderedWidth } =
@@ -108,7 +108,7 @@ export function Edge({
let path: string = '';
- const createPath = React.useMemo(
+ const createPath = useMemo(
() =>
d3Shape
.line()
diff --git a/packages/core-components/src/components/DependencyGraph/Node.test.tsx b/packages/core-components/src/components/DependencyGraph/Node.test.tsx
index a507213495..4879b4fda3 100644
--- a/packages/core-components/src/components/DependencyGraph/Node.test.tsx
+++ b/packages/core-components/src/components/DependencyGraph/Node.test.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import dagre from '@dagrejs/dagre';
import { render } from '@testing-library/react';
import { Node } from './Node';
diff --git a/packages/core-components/src/components/DependencyGraph/Node.tsx b/packages/core-components/src/components/DependencyGraph/Node.tsx
index aac1cd81aa..4ed06b17f7 100644
--- a/packages/core-components/src/components/DependencyGraph/Node.tsx
+++ b/packages/core-components/src/components/DependencyGraph/Node.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React from 'react';
+import { useRef, useLayoutEffect } from 'react';
import makeStyles from '@material-ui/core/styles/makeStyles';
import { DefaultNode } from './DefaultNode';
import { DependencyGraphTypes as Types } from './types';
@@ -53,9 +53,9 @@ export function Node({
const { width, height, x = 0, y = 0 } = node;
const nodeProps: Types.DependencyNode = node;
const classes = useStyles();
- const nodeRef = React.useRef(null);
+ const nodeRef = useRef(null);
- React.useLayoutEffect(() => {
+ useLayoutEffect(() => {
// set the node width to the actual rendered width to properly layout graph
if (nodeRef.current) {
let { height: renderedHeight, width: renderedWidth } =
diff --git a/packages/core-components/src/components/DependencyGraph/types.ts b/packages/core-components/src/components/DependencyGraph/types.ts
index f4df5b3066..e8fc9f6da3 100644
--- a/packages/core-components/src/components/DependencyGraph/types.ts
+++ b/packages/core-components/src/components/DependencyGraph/types.ts
@@ -20,7 +20,7 @@
* @packageDocumentation
*/
-import React from 'react';
+import { ReactNode } from 'react';
/**
* Types for the {@link DependencyGraph} component.
@@ -62,7 +62,7 @@ export namespace DependencyGraphTypes {
*/
export type RenderLabelFunction = (
props: RenderLabelProps,
- ) => React.ReactNode;
+ ) => ReactNode;
/**
* Node of {@link DependencyGraph}
@@ -87,7 +87,7 @@ export namespace DependencyGraphTypes {
*/
export type RenderNodeFunction = (
props: RenderNodeProps,
- ) => React.ReactNode;
+ ) => ReactNode;
/**
* Graph direction
diff --git a/packages/core-components/src/components/Dialog/Dialog.stories.tsx b/packages/core-components/src/components/Dialog/Dialog.stories.tsx
index ecdd218cf6..7171e9c543 100644
--- a/packages/core-components/src/components/Dialog/Dialog.stories.tsx
+++ b/packages/core-components/src/components/Dialog/Dialog.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import Button from '@material-ui/core/Button';
import Dialog from '@material-ui/core/Dialog';
import DialogActions from '@material-ui/core/DialogActions';
diff --git a/packages/core-components/src/components/DismissableBanner/DismissableBanner.stories.tsx b/packages/core-components/src/components/DismissableBanner/DismissableBanner.stories.tsx
index ac341071bf..7cf6374e13 100644
--- a/packages/core-components/src/components/DismissableBanner/DismissableBanner.stories.tsx
+++ b/packages/core-components/src/components/DismissableBanner/DismissableBanner.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { DismissableBanner, Props } from './DismissableBanner';
import Typography from '@material-ui/core/Typography';
import { WebStorage } from '@backstage/core-app-api';
diff --git a/packages/core-components/src/components/DismissableBanner/DismissableBanner.test.tsx b/packages/core-components/src/components/DismissableBanner/DismissableBanner.test.tsx
index 6f6da1231f..c48989a7a5 100644
--- a/packages/core-components/src/components/DismissableBanner/DismissableBanner.test.tsx
+++ b/packages/core-components/src/components/DismissableBanner/DismissableBanner.test.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { fireEvent } from '@testing-library/react';
import {
TestApiRegistry,
diff --git a/packages/core-components/src/components/DismissableBanner/DismissableBanner.tsx b/packages/core-components/src/components/DismissableBanner/DismissableBanner.tsx
index f65db08393..ceca5861ab 100644
--- a/packages/core-components/src/components/DismissableBanner/DismissableBanner.tsx
+++ b/packages/core-components/src/components/DismissableBanner/DismissableBanner.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { ReactNode, useMemo } from 'react';
+import { ReactNode, useMemo } from 'react';
import { useApi, storageApiRef } from '@backstage/core-plugin-api';
import useObservable from 'react-use/esm/useObservable';
import classNames from 'classnames';
diff --git a/packages/core-components/src/components/Drawer/Drawer.stories.tsx b/packages/core-components/src/components/Drawer/Drawer.stories.tsx
index 7e1c8a728f..0c7e8dbfdb 100644
--- a/packages/core-components/src/components/Drawer/Drawer.stories.tsx
+++ b/packages/core-components/src/components/Drawer/Drawer.stories.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { useState } from 'react';
+import { useState } from 'react';
import { makeStyles, createStyles, Theme } from '@material-ui/core/styles';
import Drawer from '@material-ui/core/Drawer';
import Button from '@material-ui/core/Button';
diff --git a/packages/core-components/src/components/EmptyState/EmptyState.stories.tsx b/packages/core-components/src/components/EmptyState/EmptyState.stories.tsx
index f87d0a82ce..07f6ea8fa1 100644
--- a/packages/core-components/src/components/EmptyState/EmptyState.stories.tsx
+++ b/packages/core-components/src/components/EmptyState/EmptyState.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { EmptyState } from './EmptyState';
import Button from '@material-ui/core/Button';
import { MissingAnnotationEmptyState } from './MissingAnnotationEmptyState';
diff --git a/packages/core-components/src/components/EmptyState/EmptyState.test.tsx b/packages/core-components/src/components/EmptyState/EmptyState.test.tsx
index 35dc3a80f2..5d54d686f5 100644
--- a/packages/core-components/src/components/EmptyState/EmptyState.test.tsx
+++ b/packages/core-components/src/components/EmptyState/EmptyState.test.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { EmptyState } from './EmptyState';
import { renderInTestApp } from '@backstage/test-utils';
import Button from '@material-ui/core/Button';
diff --git a/packages/core-components/src/components/EmptyState/EmptyState.tsx b/packages/core-components/src/components/EmptyState/EmptyState.tsx
index 3691ffca9e..51c860327c 100644
--- a/packages/core-components/src/components/EmptyState/EmptyState.tsx
+++ b/packages/core-components/src/components/EmptyState/EmptyState.tsx
@@ -17,7 +17,6 @@
import Grid from '@material-ui/core/Grid';
import { makeStyles } from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';
-import React from 'react';
import { EmptyStateImage } from './EmptyStateImage';
/** @public */
diff --git a/packages/core-components/src/components/EmptyState/EmptyStateImage.test.tsx b/packages/core-components/src/components/EmptyState/EmptyStateImage.test.tsx
index 6b7d01ea3f..4750540660 100644
--- a/packages/core-components/src/components/EmptyState/EmptyStateImage.test.tsx
+++ b/packages/core-components/src/components/EmptyState/EmptyStateImage.test.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { renderInTestApp } from '@backstage/test-utils';
import { EmptyStateImage } from './EmptyStateImage';
import { screen } from '@testing-library/react';
diff --git a/packages/core-components/src/components/EmptyState/EmptyStateImage.tsx b/packages/core-components/src/components/EmptyState/EmptyStateImage.tsx
index 0200e3a39b..2d738ac7fd 100644
--- a/packages/core-components/src/components/EmptyState/EmptyStateImage.tsx
+++ b/packages/core-components/src/components/EmptyState/EmptyStateImage.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import missingAnnotation from './assets/missingAnnotation.svg';
import noInformation from './assets/noInformation.svg';
import createComponent from './assets/createComponent.svg';
diff --git a/packages/core-components/src/components/EmptyState/MissingAnnotationEmptyState.tsx b/packages/core-components/src/components/EmptyState/MissingAnnotationEmptyState.tsx
index 31168b4ac7..67481ed97a 100644
--- a/packages/core-components/src/components/EmptyState/MissingAnnotationEmptyState.tsx
+++ b/packages/core-components/src/components/EmptyState/MissingAnnotationEmptyState.tsx
@@ -18,7 +18,6 @@ import Box from '@material-ui/core/Box';
import Button from '@material-ui/core/Button';
import { makeStyles } from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';
-import React from 'react';
import { CodeSnippet } from '../CodeSnippet';
import { Link } from '../Link';
diff --git a/packages/core-components/src/components/ErrorPanel/ErrorPanel.test.tsx b/packages/core-components/src/components/ErrorPanel/ErrorPanel.test.tsx
index 3158f9a1d4..3d3c2c8d4c 100644
--- a/packages/core-components/src/components/ErrorPanel/ErrorPanel.test.tsx
+++ b/packages/core-components/src/components/ErrorPanel/ErrorPanel.test.tsx
@@ -16,7 +16,6 @@
import { WarningPanel } from '../WarningPanel';
import { screen } from '@testing-library/react';
-import React from 'react';
import { renderInTestApp } from '@backstage/test-utils';
import { WarningProps } from '../WarningPanel/WarningPanel';
diff --git a/packages/core-components/src/components/ErrorPanel/ErrorPanel.tsx b/packages/core-components/src/components/ErrorPanel/ErrorPanel.tsx
index 848dc51d75..f86b65e257 100644
--- a/packages/core-components/src/components/ErrorPanel/ErrorPanel.tsx
+++ b/packages/core-components/src/components/ErrorPanel/ErrorPanel.tsx
@@ -18,7 +18,7 @@ import { makeStyles } from '@material-ui/core/styles';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemText from '@material-ui/core/ListItemText';
-import React, { PropsWithChildren } from 'react';
+import { PropsWithChildren } from 'react';
import { CopyTextButton } from '../CopyTextButton';
import { WarningPanel } from '../WarningPanel';
diff --git a/packages/core-components/src/components/FavoriteToggle/FavoriteToggle.stories.tsx b/packages/core-components/src/components/FavoriteToggle/FavoriteToggle.stories.tsx
index e531e9b254..af3787023a 100644
--- a/packages/core-components/src/components/FavoriteToggle/FavoriteToggle.stories.tsx
+++ b/packages/core-components/src/components/FavoriteToggle/FavoriteToggle.stories.tsx
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import React, { ComponentType, PropsWithChildren } from 'react';
+import { useState, ComponentType, PropsWithChildren } from 'react';
import { FavoriteToggle } from './FavoriteToggle';
import {
UnifiedThemeProvider,
@@ -32,7 +32,7 @@ export default {
};
export const Default = () => {
- const [isFavorite, setFavorite] = React.useState(false);
+ const [isFavorite, setFavorite] = useState(false);
return (
{
- const [isFavorite, setFavorite] = React.useState(false);
+ const [isFavorite, setFavorite] = useState(false);
return (
', () => {
diff --git a/packages/core-components/src/components/FavoriteToggle/FavoriteToggle.tsx b/packages/core-components/src/components/FavoriteToggle/FavoriteToggle.tsx
index ba7b4edb99..df6b367b57 100644
--- a/packages/core-components/src/components/FavoriteToggle/FavoriteToggle.tsx
+++ b/packages/core-components/src/components/FavoriteToggle/FavoriteToggle.tsx
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import React, { ComponentProps } from 'react';
+import { ComponentProps } from 'react';
import IconButton from '@material-ui/core/IconButton';
import Tooltip from '@material-ui/core/Tooltip';
import Typography from '@material-ui/core/Typography';
diff --git a/packages/core-components/src/components/FeatureDiscovery/FeatureCalloutCircular.test.tsx b/packages/core-components/src/components/FeatureDiscovery/FeatureCalloutCircular.test.tsx
index b5106e1bf9..f1c8b159df 100644
--- a/packages/core-components/src/components/FeatureDiscovery/FeatureCalloutCircular.test.tsx
+++ b/packages/core-components/src/components/FeatureDiscovery/FeatureCalloutCircular.test.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { act, fireEvent } from '@testing-library/react';
import { renderInTestApp } from '@backstage/test-utils';
import { FeatureCalloutCircular } from './FeatureCalloutCircular';
diff --git a/packages/core-components/src/components/FeatureDiscovery/FeatureCalloutCircular.tsx b/packages/core-components/src/components/FeatureDiscovery/FeatureCalloutCircular.tsx
index 92c10497f4..0131c3ac81 100644
--- a/packages/core-components/src/components/FeatureDiscovery/FeatureCalloutCircular.tsx
+++ b/packages/core-components/src/components/FeatureDiscovery/FeatureCalloutCircular.tsx
@@ -17,7 +17,7 @@ import Box from '@material-ui/core/Box';
import ClickAwayListener from '@material-ui/core/ClickAwayListener';
import { makeStyles } from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';
-import React, {
+import {
PropsWithChildren,
useCallback,
useEffect,
diff --git a/packages/core-components/src/components/HeaderIconLinkRow/HeaderIconLinkRow.stories.tsx b/packages/core-components/src/components/HeaderIconLinkRow/HeaderIconLinkRow.stories.tsx
index e472ab5599..a02944a827 100644
--- a/packages/core-components/src/components/HeaderIconLinkRow/HeaderIconLinkRow.stories.tsx
+++ b/packages/core-components/src/components/HeaderIconLinkRow/HeaderIconLinkRow.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { HeaderIconLinkRow } from '../HeaderIconLinkRow';
import { IconLinkVerticalProps } from './IconLinkVertical';
diff --git a/packages/core-components/src/components/HeaderIconLinkRow/HeaderIconLinkRow.tsx b/packages/core-components/src/components/HeaderIconLinkRow/HeaderIconLinkRow.tsx
index e30d407377..1fcf664bab 100644
--- a/packages/core-components/src/components/HeaderIconLinkRow/HeaderIconLinkRow.tsx
+++ b/packages/core-components/src/components/HeaderIconLinkRow/HeaderIconLinkRow.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
import { makeStyles } from '@material-ui/core/styles';
-import React from 'react';
import { IconLinkVertical, IconLinkVerticalProps } from './IconLinkVertical';
/** @public */
diff --git a/packages/core-components/src/components/HeaderIconLinkRow/IconLinkVertical.stories.tsx b/packages/core-components/src/components/HeaderIconLinkRow/IconLinkVertical.stories.tsx
index de5e8144fb..956ee6fd0e 100644
--- a/packages/core-components/src/components/HeaderIconLinkRow/IconLinkVertical.stories.tsx
+++ b/packages/core-components/src/components/HeaderIconLinkRow/IconLinkVertical.stories.tsx
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import React from 'react';
import { IconLinkVertical, IconLinkVerticalProps } from './IconLinkVertical';
import LinkIcon from '@material-ui/icons/Link';
diff --git a/packages/core-components/src/components/HeaderIconLinkRow/IconLinkVertical.tsx b/packages/core-components/src/components/HeaderIconLinkRow/IconLinkVertical.tsx
index c1c0bd4ec8..a15e600e8c 100644
--- a/packages/core-components/src/components/HeaderIconLinkRow/IconLinkVertical.tsx
+++ b/packages/core-components/src/components/HeaderIconLinkRow/IconLinkVertical.tsx
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import React from 'react';
+import { ReactNode, MouseEventHandler } from 'react';
import classnames from 'classnames';
import { makeStyles } from '@material-ui/core/styles';
import LinkIcon from '@material-ui/icons/Link';
@@ -25,9 +25,9 @@ export type IconLinkVerticalProps = {
color?: 'primary' | 'secondary';
disabled?: boolean;
href?: string;
- icon?: React.ReactNode;
+ icon?: ReactNode;
label: string;
- onClick?: React.MouseEventHandler;
+ onClick?: MouseEventHandler;
title?: string;
};
diff --git a/packages/core-components/src/components/HorizontalScrollGrid/HorizontalScrollGrid.stories.tsx b/packages/core-components/src/components/HorizontalScrollGrid/HorizontalScrollGrid.stories.tsx
index 55fff2430a..8f5904bc1d 100644
--- a/packages/core-components/src/components/HorizontalScrollGrid/HorizontalScrollGrid.stories.tsx
+++ b/packages/core-components/src/components/HorizontalScrollGrid/HorizontalScrollGrid.stories.tsx
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import React from 'react';
import { HorizontalScrollGrid } from './HorizontalScrollGrid';
const cardContentStyle = { height: 0, padding: 150, margin: 20 };
diff --git a/packages/core-components/src/components/HorizontalScrollGrid/HorizontalScrollGrid.test.tsx b/packages/core-components/src/components/HorizontalScrollGrid/HorizontalScrollGrid.test.tsx
index a3ef93d9fa..31ec7dbaae 100644
--- a/packages/core-components/src/components/HorizontalScrollGrid/HorizontalScrollGrid.test.tsx
+++ b/packages/core-components/src/components/HorizontalScrollGrid/HorizontalScrollGrid.test.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { fireEvent } from '@testing-library/react';
import { renderInTestApp } from '@backstage/test-utils';
import { HorizontalScrollGrid } from './HorizontalScrollGrid';
diff --git a/packages/core-components/src/components/HorizontalScrollGrid/HorizontalScrollGrid.tsx b/packages/core-components/src/components/HorizontalScrollGrid/HorizontalScrollGrid.tsx
index e89b7896dd..bc72a6ac3f 100644
--- a/packages/core-components/src/components/HorizontalScrollGrid/HorizontalScrollGrid.tsx
+++ b/packages/core-components/src/components/HorizontalScrollGrid/HorizontalScrollGrid.tsx
@@ -20,7 +20,13 @@ import { makeStyles } from '@material-ui/core/styles';
import ChevronLeftIcon from '@material-ui/icons/ChevronLeft';
import ChevronRightIcon from '@material-ui/icons/ChevronRight';
import classNames from 'classnames';
-import React, { PropsWithChildren } from 'react';
+import {
+ MutableRefObject,
+ useState,
+ useLayoutEffect,
+ useRef,
+ PropsWithChildren,
+} from 'react';
const generateGradientStops = (themeType: 'dark' | 'light') => {
// 97% corresponds to the theme.palette.background.default for the light theme
@@ -120,13 +126,13 @@ const useStyles = makeStyles(
// Returns scroll distance from left and right
function useScrollDistance(
- ref: React.MutableRefObject,
+ ref: MutableRefObject,
): [number, number] {
- const [[scrollLeft, scrollRight], setScroll] = React.useState<
- [number, number]
- >([0, 0]);
+ const [[scrollLeft, scrollRight], setScroll] = useState<[number, number]>([
+ 0, 0,
+ ]);
- React.useLayoutEffect(() => {
+ useLayoutEffect(() => {
const el = ref.current;
if (!el) {
setScroll([0, 0]);
@@ -158,13 +164,13 @@ function useScrollDistance(
// Used to animate scrolling. Returns a single setScrollTarget function, when called with e.g. 200,
// the element pointer to by the ref will be scrolled 200px forwards over time.
function useSmoothScroll(
- ref: React.MutableRefObject,
+ ref: MutableRefObject,
speed: number,
minDistance: number,
) {
- const [scrollTarget, setScrollTarget] = React.useState(0);
+ const [scrollTarget, setScrollTarget] = useState(0);
- React.useLayoutEffect(() => {
+ useLayoutEffect(() => {
if (scrollTarget === 0) {
return;
}
@@ -213,7 +219,7 @@ export function HorizontalScrollGrid(props: PropsWithChildren) {
...otherProps
} = props;
const classes = useStyles(props);
- const ref = React.useRef();
+ const ref = useRef();
const [scrollLeft, scrollRight] = useScrollDistance(ref);
const setScrollTarget = useSmoothScroll(ref, scrollSpeed, minScrollDistance);
diff --git a/packages/core-components/src/components/Lifecycle/Lifecycle.stories.tsx b/packages/core-components/src/components/Lifecycle/Lifecycle.stories.tsx
index 8640dd28e9..1e7db283c8 100644
--- a/packages/core-components/src/components/Lifecycle/Lifecycle.stories.tsx
+++ b/packages/core-components/src/components/Lifecycle/Lifecycle.stories.tsx
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import React from 'react';
import { Lifecycle } from './Lifecycle';
export default {
diff --git a/packages/core-components/src/components/Lifecycle/Lifecycle.test.tsx b/packages/core-components/src/components/Lifecycle/Lifecycle.test.tsx
index 05b0f650dd..3d78a76ba1 100644
--- a/packages/core-components/src/components/Lifecycle/Lifecycle.test.tsx
+++ b/packages/core-components/src/components/Lifecycle/Lifecycle.test.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { renderInTestApp } from '@backstage/test-utils';
import { Lifecycle } from './Lifecycle';
diff --git a/packages/core-components/src/components/Lifecycle/Lifecycle.tsx b/packages/core-components/src/components/Lifecycle/Lifecycle.tsx
index f6f4c3cd3e..0478f7dee1 100644
--- a/packages/core-components/src/components/Lifecycle/Lifecycle.tsx
+++ b/packages/core-components/src/components/Lifecycle/Lifecycle.tsx
@@ -16,7 +16,6 @@
import { makeStyles } from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';
import CSS from 'csstype';
-import React from 'react';
type Props = CSS.Properties & {
shorthand?: boolean;
diff --git a/packages/core-components/src/components/Link/Link.stories.tsx b/packages/core-components/src/components/Link/Link.stories.tsx
index e069459e76..cd9cb825e5 100644
--- a/packages/core-components/src/components/Link/Link.stories.tsx
+++ b/packages/core-components/src/components/Link/Link.stories.tsx
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import React, { ComponentType, PropsWithChildren } from 'react';
+import { ComponentType, PropsWithChildren } from 'react';
import { Link } from './Link';
import {
Route,
diff --git a/packages/core-components/src/components/Link/Link.test.tsx b/packages/core-components/src/components/Link/Link.test.tsx
index 0a86c06d43..c132d832a2 100644
--- a/packages/core-components/src/components/Link/Link.test.tsx
+++ b/packages/core-components/src/components/Link/Link.test.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { ComponentType } from 'react';
+import { PropsWithChildren, ComponentType } from 'react';
import { fireEvent, waitFor, screen, renderHook } from '@testing-library/react';
import {
mockApis,
@@ -153,9 +153,7 @@ describe('', () => {
});
describe('useResolvedPath', () => {
- const wrapper: ComponentType> = ({
- children,
- }) => {
+ const wrapper: ComponentType> = ({ children }) => {
const configApi = new ConfigReader({
app: { baseUrl: 'http://localhost:3000/example' },
});
diff --git a/packages/core-components/src/components/Link/Link.tsx b/packages/core-components/src/components/Link/Link.tsx
index 0008a9ff2c..f968d7b098 100644
--- a/packages/core-components/src/components/Link/Link.tsx
+++ b/packages/core-components/src/components/Link/Link.tsx
@@ -13,7 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import { configApiRef, useAnalytics, useApi } from '@backstage/core-plugin-api';
+import {
+ configApiRef,
+ useAnalytics,
+ useApi,
+ useApp,
+} from '@backstage/core-plugin-api';
// eslint-disable-next-line no-restricted-imports
import MaterialLink, {
LinkProps as MaterialLinkProps,
@@ -22,7 +27,13 @@ import { makeStyles } from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';
import classnames from 'classnames';
import { trimEnd } from 'lodash';
-import React, { ElementType } from 'react';
+import {
+ ReactNode,
+ ReactElement,
+ MouseEvent as ReactMouseEvent,
+ ElementType,
+ forwardRef,
+} from 'react';
import {
createRoutesFromChildren,
Link as RouterLink,
@@ -30,7 +41,6 @@ import {
Route,
} from 'react-router-dom';
import OpenInNew from '@material-ui/icons/OpenInNew';
-import { useApp } from '@backstage/core-plugin-api';
export function isReactRouterBeta(): boolean {
const [obj] = createRoutesFromChildren(} />);
@@ -149,7 +159,7 @@ export const useResolvedPath = (uri: LinkProps['to']) => {
/**
* Given a react node, try to retrieve its text content.
*/
-const getNodeText = (node: React.ReactNode): string => {
+const getNodeText = (node: ReactNode): string => {
// If the node is an array of children, recurse and join.
if (node instanceof Array) {
return node.map(getNodeText).join(' ').trim();
@@ -157,7 +167,7 @@ const getNodeText = (node: React.ReactNode): string => {
// If the node is a react element, recurse on its children.
if (typeof node === 'object' && node) {
- return getNodeText((node as React.ReactElement)?.props?.children);
+ return getNodeText((node as ReactElement)?.props?.children);
}
// Base case: the node is just text. Return it.
@@ -174,7 +184,7 @@ const getNodeText = (node: React.ReactNode): string => {
* - Makes the Link use react-router
* - Captures Link clicks as analytics events.
*/
-export const Link = React.forwardRef(
+export const Link = forwardRef(
({ onClick, noTrack, externalLinkIcon, ...props }, ref) => {
const classes = useStyles();
const analytics = useAnalytics();
@@ -194,7 +204,7 @@ export const Link = React.forwardRef(
);
}
- const handleClick = (event: React.MouseEvent) => {
+ const handleClick = (event: ReactMouseEvent) => {
onClick?.(event);
if (!noTrack) {
analytics.captureEvent('click', linkText, { attributes: { to } });
diff --git a/packages/core-components/src/components/LinkButton/LinkButton.stories.tsx b/packages/core-components/src/components/LinkButton/LinkButton.stories.tsx
index da8ef51db1..9d33ad3fc1 100644
--- a/packages/core-components/src/components/LinkButton/LinkButton.stories.tsx
+++ b/packages/core-components/src/components/LinkButton/LinkButton.stories.tsx
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import React, { ComponentType, PropsWithChildren } from 'react';
+import { ComponentType, PropsWithChildren } from 'react';
import { LinkButton } from './LinkButton';
import { useLocation } from 'react-router-dom';
import { createRouteRef, useRouteRef } from '@backstage/core-plugin-api';
diff --git a/packages/core-components/src/components/LinkButton/LinkButton.test.tsx b/packages/core-components/src/components/LinkButton/LinkButton.test.tsx
index 39ba7bc498..9334bffaf8 100644
--- a/packages/core-components/src/components/LinkButton/LinkButton.test.tsx
+++ b/packages/core-components/src/components/LinkButton/LinkButton.test.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { screen, fireEvent, act } from '@testing-library/react';
import { renderInTestApp } from '@backstage/test-utils';
import { LinkButton } from './LinkButton';
diff --git a/packages/core-components/src/components/LinkButton/LinkButton.tsx b/packages/core-components/src/components/LinkButton/LinkButton.tsx
index a093aa6628..820a438955 100644
--- a/packages/core-components/src/components/LinkButton/LinkButton.tsx
+++ b/packages/core-components/src/components/LinkButton/LinkButton.tsx
@@ -17,7 +17,7 @@
import MaterialButton, {
ButtonProps as MaterialButtonProps,
} from '@material-ui/core/Button';
-import React from 'react';
+import { forwardRef } from 'react';
import { Link, LinkProps } from '../Link';
/**
@@ -34,7 +34,7 @@ export type LinkButtonProps = MaterialButtonProps &
/**
* This wrapper is here to reset the color of the Link and make typescript happy.
*/
-const LinkWrapper = React.forwardRef((props, ref) => (
+const LinkWrapper = forwardRef((props, ref) => (
));
@@ -44,11 +44,9 @@ const LinkWrapper = React.forwardRef((props, ref) => (
* @public
* @remarks
*/
-export const LinkButton = React.forwardRef(
- (props, ref) => (
-
- ),
-) as (props: LinkButtonProps) => JSX.Element;
+export const LinkButton = forwardRef((props, ref) => (
+
+)) as (props: LinkButtonProps) => JSX.Element;
/**
* @public
diff --git a/packages/core-components/src/components/LogViewer/LogLine.test.tsx b/packages/core-components/src/components/LogViewer/LogLine.test.tsx
index 73c58d1e3e..30d9bbbd15 100644
--- a/packages/core-components/src/components/LogViewer/LogLine.test.tsx
+++ b/packages/core-components/src/components/LogViewer/LogLine.test.tsx
@@ -22,7 +22,6 @@ import {
findSearchResults,
getModifierClasses,
} from './LogLine';
-import React from 'react';
describe('getModifierClasses', () => {
const classes = {
diff --git a/packages/core-components/src/components/LogViewer/LogLine.tsx b/packages/core-components/src/components/LogViewer/LogLine.tsx
index 951b2154bf..4ec7e21d2f 100644
--- a/packages/core-components/src/components/LogViewer/LogLine.tsx
+++ b/packages/core-components/src/components/LogViewer/LogLine.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { useMemo } from 'react';
+import { useMemo } from 'react';
import { AnsiChunk, AnsiLine, ChunkModifiers } from './AnsiProcessor';
import startCase from 'lodash/startCase';
import classnames from 'classnames';
diff --git a/packages/core-components/src/components/LogViewer/LogViewer.stories.tsx b/packages/core-components/src/components/LogViewer/LogViewer.stories.tsx
index fca963eb74..86a2b2ebcd 100644
--- a/packages/core-components/src/components/LogViewer/LogViewer.stories.tsx
+++ b/packages/core-components/src/components/LogViewer/LogViewer.stories.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { ComponentType, PropsWithChildren } from 'react';
+import { ComponentType, PropsWithChildren } from 'react';
import { wrapInTestApp } from '@backstage/test-utils';
import { LogViewer } from './LogViewer';
diff --git a/packages/core-components/src/components/LogViewer/LogViewer.tsx b/packages/core-components/src/components/LogViewer/LogViewer.tsx
index 20530cffaf..afe20b9dc9 100644
--- a/packages/core-components/src/components/LogViewer/LogViewer.tsx
+++ b/packages/core-components/src/components/LogViewer/LogViewer.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { lazy, Suspense } from 'react';
+import { lazy, Suspense } from 'react';
import { useApp } from '@backstage/core-plugin-api';
const RealLogViewer = lazy(() =>
diff --git a/packages/core-components/src/components/LogViewer/LogViewerControls.tsx b/packages/core-components/src/components/LogViewer/LogViewerControls.tsx
index 4d3baae68d..e920d623e8 100644
--- a/packages/core-components/src/components/LogViewer/LogViewerControls.tsx
+++ b/packages/core-components/src/components/LogViewer/LogViewerControls.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React from 'react';
+import { KeyboardEvent } from 'react';
import IconButton from '@material-ui/core/IconButton';
import TextField from '@material-ui/core/TextField';
import Typography from '@material-ui/core/Typography';
@@ -29,7 +29,7 @@ export function LogViewerControls(props: LogViewerControlsProps) {
const { resultCount, resultIndexStep, toggleShouldFilter } = props;
const resultIndex = props.resultIndex ?? 0;
- const handleKeyPress = (event: React.KeyboardEvent) => {
+ const handleKeyPress = (event: KeyboardEvent) => {
if (event.key === 'Enter') {
if (event.metaKey || event.ctrlKey || event.altKey) {
toggleShouldFilter();
diff --git a/packages/core-components/src/components/LogViewer/RealLogViewer.test.tsx b/packages/core-components/src/components/LogViewer/RealLogViewer.test.tsx
index e1aac76381..928bc77678 100644
--- a/packages/core-components/src/components/LogViewer/RealLogViewer.test.tsx
+++ b/packages/core-components/src/components/LogViewer/RealLogViewer.test.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { ReactNode } from 'react';
+import { ReactNode } from 'react';
import userEvent from '@testing-library/user-event';
import { renderInTestApp } from '@backstage/test-utils';
import { RealLogViewer } from './RealLogViewer';
diff --git a/packages/core-components/src/components/LogViewer/RealLogViewer.tsx b/packages/core-components/src/components/LogViewer/RealLogViewer.tsx
index 37768ad80b..8430ac4bd0 100644
--- a/packages/core-components/src/components/LogViewer/RealLogViewer.tsx
+++ b/packages/core-components/src/components/LogViewer/RealLogViewer.tsx
@@ -18,7 +18,7 @@ import Box from '@material-ui/core/Box';
import IconButton from '@material-ui/core/IconButton';
import CopyIcon from '@material-ui/icons/FileCopy';
import classnames from 'classnames';
-import React, { useEffect, useMemo, useState } from 'react';
+import { useEffect, useMemo, useState } from 'react';
import { useLocation } from 'react-router-dom';
import AutoSizer from 'react-virtualized-auto-sizer';
import { FixedSizeList } from 'react-window';
diff --git a/packages/core-components/src/components/LogViewer/useLogViewerSelection.test.tsx b/packages/core-components/src/components/LogViewer/useLogViewerSelection.test.tsx
index 6c6f7da71b..5314f4e7f6 100644
--- a/packages/core-components/src/components/LogViewer/useLogViewerSelection.test.tsx
+++ b/packages/core-components/src/components/LogViewer/useLogViewerSelection.test.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React from 'react';
+import { PropsWithChildren } from 'react';
import { act, renderHook } from '@testing-library/react';
import { TestApiProvider, MockErrorApi } from '@backstage/test-utils';
import { errorApiRef } from '@backstage/core-plugin-api';
@@ -40,7 +40,7 @@ const lines = [
describe('useLogViewerSelection', () => {
it('should manage a selection', () => {
const rendered = renderHook(() => useLogViewerSelection(lines), {
- wrapper: ({ children }: React.PropsWithChildren<{}>) => (
+ wrapper: ({ children }: PropsWithChildren<{}>) => (
{children}
diff --git a/packages/core-components/src/components/MarkdownContent/MarkdownContent.stories.tsx b/packages/core-components/src/components/MarkdownContent/MarkdownContent.stories.tsx
index b16eea150c..b6770e7d37 100644
--- a/packages/core-components/src/components/MarkdownContent/MarkdownContent.stories.tsx
+++ b/packages/core-components/src/components/MarkdownContent/MarkdownContent.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { MarkdownContent } from './MarkdownContent';
export default {
diff --git a/packages/core-components/src/components/MarkdownContent/MarkdownContent.test.tsx b/packages/core-components/src/components/MarkdownContent/MarkdownContent.test.tsx
index 21b576dd9f..6f20f776e3 100644
--- a/packages/core-components/src/components/MarkdownContent/MarkdownContent.test.tsx
+++ b/packages/core-components/src/components/MarkdownContent/MarkdownContent.test.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { renderInTestApp } from '@backstage/test-utils';
import { MarkdownContent } from './MarkdownContent';
import { screen } from '@testing-library/react';
diff --git a/packages/core-components/src/components/MarkdownContent/MarkdownContent.tsx b/packages/core-components/src/components/MarkdownContent/MarkdownContent.tsx
index f536b20106..5ad23cce09 100644
--- a/packages/core-components/src/components/MarkdownContent/MarkdownContent.tsx
+++ b/packages/core-components/src/components/MarkdownContent/MarkdownContent.tsx
@@ -17,7 +17,7 @@
import { makeStyles } from '@material-ui/core/styles';
import ReactMarkdown, { Options } from 'react-markdown';
import gfm from 'remark-gfm';
-import React from 'react';
+import { Children, createElement } from 'react';
import { CodeSnippet } from '../CodeSnippet';
import { HeadingProps } from 'react-markdown/lib/ast-to-react';
@@ -78,14 +78,14 @@ const flatten = (text: string, child: any): string => {
return typeof child === 'string'
? text + child
- : React.Children.toArray(child.props.children).reduce(flatten, text);
+ : Children.toArray(child.props.children).reduce(flatten, text);
};
const headingRenderer = ({ level, children }: HeadingProps) => {
- const childrenArray = React.Children.toArray(children);
+ const childrenArray = Children.toArray(children);
const text = childrenArray.reduce(flatten, '');
const slug = text.toLocaleLowerCase('en-US').replace(/\W/g, '-');
- return React.createElement(`h${level}`, { id: slug }, children);
+ return createElement(`h${level}`, { id: slug }, children);
};
const components: Options['components'] = {
diff --git a/packages/core-components/src/components/OAuthRequestDialog/LoginRequestListItem.tsx b/packages/core-components/src/components/OAuthRequestDialog/LoginRequestListItem.tsx
index 375ea66953..7c85b1608f 100644
--- a/packages/core-components/src/components/OAuthRequestDialog/LoginRequestListItem.tsx
+++ b/packages/core-components/src/components/OAuthRequestDialog/LoginRequestListItem.tsx
@@ -20,7 +20,7 @@ import ListItemAvatar from '@material-ui/core/ListItemAvatar';
import ListItemText from '@material-ui/core/ListItemText';
import Typography from '@material-ui/core/Typography';
import Button from '@material-ui/core/Button';
-import React, { useState } from 'react';
+import { useState } from 'react';
import { isError } from '@backstage/errors';
import { PendingOAuthRequest } from '@backstage/core-plugin-api';
import { coreComponentsTranslationRef } from '../../translation';
diff --git a/packages/core-components/src/components/OAuthRequestDialog/OAuthRequestDialog.tsx b/packages/core-components/src/components/OAuthRequestDialog/OAuthRequestDialog.tsx
index 79366da310..162adc5a9c 100644
--- a/packages/core-components/src/components/OAuthRequestDialog/OAuthRequestDialog.tsx
+++ b/packages/core-components/src/components/OAuthRequestDialog/OAuthRequestDialog.tsx
@@ -21,7 +21,7 @@ import DialogContent from '@material-ui/core/DialogContent';
import DialogTitle from '@material-ui/core/DialogTitle';
import List from '@material-ui/core/List';
import Button from '@material-ui/core/Button';
-import React, { useMemo, useState } from 'react';
+import { useMemo, useState } from 'react';
import useObservable from 'react-use/esm/useObservable';
import LoginRequestListItem from './LoginRequestListItem';
import {
diff --git a/packages/core-components/src/components/OverflowTooltip/OverflowTooltip.stories.tsx b/packages/core-components/src/components/OverflowTooltip/OverflowTooltip.stories.tsx
index 5ab5ba7dc4..3b5df0e358 100644
--- a/packages/core-components/src/components/OverflowTooltip/OverflowTooltip.stories.tsx
+++ b/packages/core-components/src/components/OverflowTooltip/OverflowTooltip.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
import Box from '@material-ui/core/Box';
-import React from 'react';
import { OverflowTooltip } from './OverflowTooltip';
export default {
diff --git a/packages/core-components/src/components/OverflowTooltip/OverflowTooltip.test.tsx b/packages/core-components/src/components/OverflowTooltip/OverflowTooltip.test.tsx
index a65c758c28..1cfc3edf55 100644
--- a/packages/core-components/src/components/OverflowTooltip/OverflowTooltip.test.tsx
+++ b/packages/core-components/src/components/OverflowTooltip/OverflowTooltip.test.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { render } from '@testing-library/react';
import { OverflowTooltip } from './OverflowTooltip';
diff --git a/packages/core-components/src/components/OverflowTooltip/OverflowTooltip.tsx b/packages/core-components/src/components/OverflowTooltip/OverflowTooltip.tsx
index dd4838bd8d..68499e2dc1 100644
--- a/packages/core-components/src/components/OverflowTooltip/OverflowTooltip.tsx
+++ b/packages/core-components/src/components/OverflowTooltip/OverflowTooltip.tsx
@@ -16,7 +16,6 @@
import { makeStyles } from '@material-ui/core/styles';
import Tooltip, { TooltipProps } from '@material-ui/core/Tooltip';
-import React from 'react';
import Typography from '@material-ui/core/Typography';
type Props = {
diff --git a/packages/core-components/src/components/Progress/Progress.stories.tsx b/packages/core-components/src/components/Progress/Progress.stories.tsx
index af24019a69..7c7932101e 100644
--- a/packages/core-components/src/components/Progress/Progress.stories.tsx
+++ b/packages/core-components/src/components/Progress/Progress.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { Progress } from './Progress';
export default {
diff --git a/packages/core-components/src/components/Progress/Progress.test.tsx b/packages/core-components/src/components/Progress/Progress.test.tsx
index 71e2e70f23..918c9ba518 100644
--- a/packages/core-components/src/components/Progress/Progress.test.tsx
+++ b/packages/core-components/src/components/Progress/Progress.test.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { renderInTestApp } from '@backstage/test-utils';
import { Progress } from './Progress';
diff --git a/packages/core-components/src/components/Progress/Progress.tsx b/packages/core-components/src/components/Progress/Progress.tsx
index 865c4673b8..b7176a5825 100644
--- a/packages/core-components/src/components/Progress/Progress.tsx
+++ b/packages/core-components/src/components/Progress/Progress.tsx
@@ -19,7 +19,7 @@ import LinearProgress, {
LinearProgressProps,
} from '@material-ui/core/LinearProgress';
import { useTheme } from '@material-ui/core/styles';
-import React, { PropsWithChildren, useEffect, useState } from 'react';
+import { PropsWithChildren, useEffect, useState } from 'react';
export function Progress(props: PropsWithChildren) {
const theme = useTheme();
diff --git a/packages/core-components/src/components/ProgressBars/Gauge.stories.tsx b/packages/core-components/src/components/ProgressBars/Gauge.stories.tsx
index 401f502697..4dcb788289 100644
--- a/packages/core-components/src/components/ProgressBars/Gauge.stories.tsx
+++ b/packages/core-components/src/components/ProgressBars/Gauge.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { Gauge } from './Gauge';
const containerStyle = { width: 300 };
diff --git a/packages/core-components/src/components/ProgressBars/Gauge.test.tsx b/packages/core-components/src/components/ProgressBars/Gauge.test.tsx
index 0c19d5acb2..a1827f1ec6 100644
--- a/packages/core-components/src/components/ProgressBars/Gauge.test.tsx
+++ b/packages/core-components/src/components/ProgressBars/Gauge.test.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { renderInTestApp } from '@backstage/test-utils';
import { Gauge, getProgressColor } from './Gauge';
import * as theme from '@backstage/theme';
diff --git a/packages/core-components/src/components/ProgressBars/Gauge.tsx b/packages/core-components/src/components/ProgressBars/Gauge.tsx
index a1ddbff4ea..1eaa7cae59 100644
--- a/packages/core-components/src/components/ProgressBars/Gauge.tsx
+++ b/packages/core-components/src/components/ProgressBars/Gauge.tsx
@@ -17,7 +17,7 @@
import { BackstagePalette } from '@backstage/theme';
import { makeStyles, useTheme } from '@material-ui/core/styles';
import { Circle } from 'rc-progress';
-import React, { ReactNode, useEffect, useState } from 'react';
+import { ReactNode, useEffect, useState } from 'react';
import Box from '@material-ui/core/Box';
import classNames from 'classnames';
diff --git a/packages/core-components/src/components/ProgressBars/GaugeCard.stories.tsx b/packages/core-components/src/components/ProgressBars/GaugeCard.stories.tsx
index f7e2eb69c6..0377c37ef0 100644
--- a/packages/core-components/src/components/ProgressBars/GaugeCard.stories.tsx
+++ b/packages/core-components/src/components/ProgressBars/GaugeCard.stories.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React, { PropsWithChildren } from 'react';
+import { PropsWithChildren } from 'react';
import { GaugeCard } from './GaugeCard';
import Grid from '@material-ui/core/Grid';
import { MemoryRouter } from 'react-router-dom';
diff --git a/packages/core-components/src/components/ProgressBars/GaugeCard.test.tsx b/packages/core-components/src/components/ProgressBars/GaugeCard.test.tsx
index e4d84ca059..baa0137fe0 100644
--- a/packages/core-components/src/components/ProgressBars/GaugeCard.test.tsx
+++ b/packages/core-components/src/components/ProgressBars/GaugeCard.test.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { renderInTestApp, withLogCollector } from '@backstage/test-utils';
import { GaugeCard } from './GaugeCard';
diff --git a/packages/core-components/src/components/ProgressBars/GaugeCard.tsx b/packages/core-components/src/components/ProgressBars/GaugeCard.tsx
index 9f6de8eafe..b1249d2ff8 100644
--- a/packages/core-components/src/components/ProgressBars/GaugeCard.tsx
+++ b/packages/core-components/src/components/ProgressBars/GaugeCard.tsx
@@ -15,7 +15,7 @@
*/
import Box from '@material-ui/core/Box';
import { makeStyles } from '@material-ui/core/styles';
-import React, { ReactNode } from 'react';
+import { ReactNode } from 'react';
import { BottomLinkProps } from '../../layout/BottomLink';
import { InfoCard, InfoCardVariants } from '../../layout/InfoCard';
diff --git a/packages/core-components/src/components/ProgressBars/LinearGauge.stories.tsx b/packages/core-components/src/components/ProgressBars/LinearGauge.stories.tsx
index 5d36ea9178..295856bd51 100644
--- a/packages/core-components/src/components/ProgressBars/LinearGauge.stories.tsx
+++ b/packages/core-components/src/components/ProgressBars/LinearGauge.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { LinearGauge } from './LinearGauge';
const containerStyle = { width: 300 };
diff --git a/packages/core-components/src/components/ProgressBars/LinearGauge.test.tsx b/packages/core-components/src/components/ProgressBars/LinearGauge.test.tsx
index 1d76f59faf..fd22de608e 100644
--- a/packages/core-components/src/components/ProgressBars/LinearGauge.test.tsx
+++ b/packages/core-components/src/components/ProgressBars/LinearGauge.test.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { renderInTestApp } from '@backstage/test-utils';
import { LinearGauge } from './LinearGauge';
diff --git a/packages/core-components/src/components/ProgressBars/LinearGauge.tsx b/packages/core-components/src/components/ProgressBars/LinearGauge.tsx
index a41b41f3dc..4fcbb6511f 100644
--- a/packages/core-components/src/components/ProgressBars/LinearGauge.tsx
+++ b/packages/core-components/src/components/ProgressBars/LinearGauge.tsx
@@ -18,7 +18,6 @@ import { useTheme } from '@material-ui/core/styles';
import Tooltip from '@material-ui/core/Tooltip';
import Typography from '@material-ui/core/Typography';
import { Line } from 'rc-progress';
-import React from 'react';
import { GaugePropsGetColor, getProgressColor } from './Gauge';
diff --git a/packages/core-components/src/components/ResponseErrorPanel/ResponseErrorPanel.stories.tsx b/packages/core-components/src/components/ResponseErrorPanel/ResponseErrorPanel.stories.tsx
index 8d03e7359f..7eab08f55f 100644
--- a/packages/core-components/src/components/ResponseErrorPanel/ResponseErrorPanel.stories.tsx
+++ b/packages/core-components/src/components/ResponseErrorPanel/ResponseErrorPanel.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { ResponseErrorPanel } from '../ResponseErrorPanel';
import { ErrorPanelProps } from '../ErrorPanel';
diff --git a/packages/core-components/src/components/ResponseErrorPanel/ResponseErrorPanel.tsx b/packages/core-components/src/components/ResponseErrorPanel/ResponseErrorPanel.tsx
index f51c73195c..9f0886aa9b 100644
--- a/packages/core-components/src/components/ResponseErrorPanel/ResponseErrorPanel.tsx
+++ b/packages/core-components/src/components/ResponseErrorPanel/ResponseErrorPanel.tsx
@@ -19,7 +19,6 @@ import { makeStyles } from '@material-ui/core/styles';
import Divider from '@material-ui/core/Divider';
import ListItem from '@material-ui/core/ListItem';
import ListItemText from '@material-ui/core/ListItemText';
-import React from 'react';
import { CodeSnippet } from '../CodeSnippet';
import { CopyTextButton } from '../CopyTextButton';
import { ErrorPanel, ErrorPanelProps } from '../ErrorPanel';
diff --git a/packages/core-components/src/components/Select/Select.stories.tsx b/packages/core-components/src/components/Select/Select.stories.tsx
index af595605c7..f3eaea1021 100644
--- a/packages/core-components/src/components/Select/Select.stories.tsx
+++ b/packages/core-components/src/components/Select/Select.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { SelectComponent as Select, SelectProps } from './Select';
export default {
diff --git a/packages/core-components/src/components/Select/Select.test.tsx b/packages/core-components/src/components/Select/Select.test.tsx
index 505152db5f..892bedba84 100644
--- a/packages/core-components/src/components/Select/Select.test.tsx
+++ b/packages/core-components/src/components/Select/Select.test.tsx
@@ -15,7 +15,6 @@
*/
import { fireEvent, render, within } from '@testing-library/react';
-import React from 'react';
import { SelectComponent as Select } from './Select';
const SELECT_ITEMS = [
diff --git a/packages/core-components/src/components/Select/Select.tsx b/packages/core-components/src/components/Select/Select.tsx
index 7a862678b8..72512b3ec2 100644
--- a/packages/core-components/src/components/Select/Select.tsx
+++ b/packages/core-components/src/components/Select/Select.tsx
@@ -29,7 +29,7 @@ import {
} from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';
import CancelIcon from '@material-ui/icons/Cancel';
-import React, { useEffect, useState } from 'react';
+import { ChangeEvent, useEffect, useState } from 'react';
import ClosedDropdown from './static/ClosedDropdown';
import OpenedDropdown from './static/OpenedDropdown';
@@ -169,12 +169,12 @@ export function SelectComponent(props: SelectProps) {
setValue(selected || (multiple ? [] : ''));
}, [selected, multiple]);
- const handleChange = (event: React.ChangeEvent<{ value: unknown }>) => {
+ const handleChange = (event: ChangeEvent<{ value: unknown }>) => {
setValue(event.target.value as SelectedItems);
onChange(event.target.value as SelectedItems);
};
- const handleOpen = (event: React.ChangeEvent) => {
+ const handleOpen = (event: ChangeEvent) => {
if (disabled) {
event.preventDefault();
return;
diff --git a/packages/core-components/src/components/Select/static/ClosedDropdown.tsx b/packages/core-components/src/components/Select/static/ClosedDropdown.tsx
index 00c748ce29..46f222bdfb 100644
--- a/packages/core-components/src/components/Select/static/ClosedDropdown.tsx
+++ b/packages/core-components/src/components/Select/static/ClosedDropdown.tsx
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import React from 'react';
import { makeStyles, createStyles } from '@material-ui/core/styles';
import SvgIcon from '@material-ui/core/SvgIcon';
diff --git a/packages/core-components/src/components/Select/static/OpenedDropdown.tsx b/packages/core-components/src/components/Select/static/OpenedDropdown.tsx
index 4ca2a5a065..4e61e2e78d 100644
--- a/packages/core-components/src/components/Select/static/OpenedDropdown.tsx
+++ b/packages/core-components/src/components/Select/static/OpenedDropdown.tsx
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import React from 'react';
import { makeStyles, createStyles } from '@material-ui/core/styles';
import SvgIcon from '@material-ui/core/SvgIcon';
diff --git a/packages/core-components/src/components/SimpleStepper/SimpleStepper.stories.tsx b/packages/core-components/src/components/SimpleStepper/SimpleStepper.stories.tsx
index aedd5e6b80..a50183b179 100644
--- a/packages/core-components/src/components/SimpleStepper/SimpleStepper.stories.tsx
+++ b/packages/core-components/src/components/SimpleStepper/SimpleStepper.stories.tsx
@@ -15,7 +15,7 @@
*/
import TextField from '@material-ui/core/TextField';
-import React, { useState } from 'react';
+import { useState } from 'react';
import { SimpleStepper, StepperProps } from './SimpleStepper';
import { SimpleStepperStep } from './SimpleStepperStep';
diff --git a/packages/core-components/src/components/SimpleStepper/SimpleStepper.test.tsx b/packages/core-components/src/components/SimpleStepper/SimpleStepper.test.tsx
index e4093f07d2..2ff685c19f 100644
--- a/packages/core-components/src/components/SimpleStepper/SimpleStepper.test.tsx
+++ b/packages/core-components/src/components/SimpleStepper/SimpleStepper.test.tsx
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import React from 'react';
import { fireEvent, within } from '@testing-library/react';
import { renderInTestApp } from '@backstage/test-utils';
import { SimpleStepper as Stepper } from './SimpleStepper';
diff --git a/packages/core-components/src/components/SimpleStepper/SimpleStepper.tsx b/packages/core-components/src/components/SimpleStepper/SimpleStepper.tsx
index b0b6c1afd0..04dc7bf3c7 100644
--- a/packages/core-components/src/components/SimpleStepper/SimpleStepper.tsx
+++ b/packages/core-components/src/components/SimpleStepper/SimpleStepper.tsx
@@ -13,7 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import React, {
+import {
+ ReactNode,
+ createContext,
Children,
isValidElement,
useState,
@@ -33,7 +35,7 @@ type InternalState = {
const noop = () => {};
-export const VerticalStepperContext = React.createContext({
+export const VerticalStepperContext = createContext({
stepperLength: 0,
stepIndex: 0,
setStepIndex: noop,
@@ -67,7 +69,7 @@ export function SimpleStepper(props: PropsWithChildren) {
setStepIndex(activeStep);
}, [activeStep]);
- const steps: React.ReactNode[] = [];
+ const steps: ReactNode[] = [];
let endStep;
Children.forEach(children, child => {
if (isValidElement(child)) {
diff --git a/packages/core-components/src/components/SimpleStepper/SimpleStepperFooter.tsx b/packages/core-components/src/components/SimpleStepper/SimpleStepperFooter.tsx
index 8db3ac8d72..cf7d968495 100644
--- a/packages/core-components/src/components/SimpleStepper/SimpleStepperFooter.tsx
+++ b/packages/core-components/src/components/SimpleStepper/SimpleStepperFooter.tsx
@@ -16,7 +16,7 @@
import Box from '@material-ui/core/Box';
import Button from '@material-ui/core/Button';
import { makeStyles } from '@material-ui/core/styles';
-import React, { PropsWithChildren, ReactNode, useContext } from 'react';
+import { PropsWithChildren, ReactNode, useContext } from 'react';
import { VerticalStepperContext } from './SimpleStepper';
import { StepActions } from './types';
diff --git a/packages/core-components/src/components/SimpleStepper/SimpleStepperStep.tsx b/packages/core-components/src/components/SimpleStepper/SimpleStepperStep.tsx
index 911ad2e73e..aca5d882f8 100644
--- a/packages/core-components/src/components/SimpleStepper/SimpleStepperStep.tsx
+++ b/packages/core-components/src/components/SimpleStepper/SimpleStepperStep.tsx
@@ -19,7 +19,7 @@ import StepContent from '@material-ui/core/StepContent';
import StepLabel from '@material-ui/core/StepLabel';
import { makeStyles } from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';
-import React, { PropsWithChildren } from 'react';
+import { PropsWithChildren } from 'react';
import { SimpleStepperFooter } from './SimpleStepperFooter';
import { StepProps } from './types';
diff --git a/packages/core-components/src/components/SimpleStepper/types.ts b/packages/core-components/src/components/SimpleStepper/types.ts
index eacfc94065..66e78565f2 100644
--- a/packages/core-components/src/components/SimpleStepper/types.ts
+++ b/packages/core-components/src/components/SimpleStepper/types.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import React from 'react';
+import { ReactElement } from 'react';
export type StepActions = {
showNext?: boolean;
@@ -40,7 +40,7 @@ export type StepActions = {
export type StepProps = {
title: string;
- children: React.ReactElement;
+ children: ReactElement;
end?: boolean;
actions?: StepActions;
};
diff --git a/packages/core-components/src/components/Status/Status.stories.tsx b/packages/core-components/src/components/Status/Status.stories.tsx
index 26a6fd2219..1237a02432 100644
--- a/packages/core-components/src/components/Status/Status.stories.tsx
+++ b/packages/core-components/src/components/Status/Status.stories.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import {
StatusError,
StatusAborted,
diff --git a/packages/core-components/src/components/Status/Status.test.tsx b/packages/core-components/src/components/Status/Status.test.tsx
index 34f1a587bd..b795f98c67 100644
--- a/packages/core-components/src/components/Status/Status.test.tsx
+++ b/packages/core-components/src/components/Status/Status.test.tsx
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import React from 'react';
import { renderInTestApp } from '@backstage/test-utils';
import {
diff --git a/packages/core-components/src/components/Status/Status.tsx b/packages/core-components/src/components/Status/Status.tsx
index 63e3d3d3a6..9e4ec0f892 100644
--- a/packages/core-components/src/components/Status/Status.tsx
+++ b/packages/core-components/src/components/Status/Status.tsx
@@ -20,7 +20,7 @@ import CheckCircleOutline from '@material-ui/icons/CheckCircleOutline';
import WarningOutline from '@material-ui/icons/ReportProblemOutlined';
import ErrorOutline from '@material-ui/icons/ErrorOutline';
import classNames from 'classnames';
-import React, { PropsWithChildren } from 'react';
+import { PropsWithChildren } from 'react';
import { PendingIcon } from './icons/PendingIcon';
import { RunningIcon } from './icons/RunningIcon';
import { AbortedIcon } from './icons/AbortedIcon';
diff --git a/packages/core-components/src/components/Status/icons/AbortedIcon.tsx b/packages/core-components/src/components/Status/icons/AbortedIcon.tsx
index 397f613e4a..0512de67f7 100644
--- a/packages/core-components/src/components/Status/icons/AbortedIcon.tsx
+++ b/packages/core-components/src/components/Status/icons/AbortedIcon.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import * as React from 'react';
+import { ReactElement } from 'react';
export const AbortedIcon = ({
className,
@@ -22,7 +22,7 @@ export const AbortedIcon = ({
}: {
className: string;
dataTestId: string;
-}): React.ReactElement => {
+}): ReactElement => {
return (
|