Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Run React jsx codemod to remove unnecessary React import #3399

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2023 The Tekton Authors
Copyright 2019-2024 The Tekton 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
Expand All @@ -20,7 +20,8 @@ module.exports = {
'airbnb',
'plugin:prettier/recommended',
'plugin:cypress/recommended',
'plugin:storybook/recommended'
'plugin:storybook/recommended',
'plugin:react/jsx-runtime'
],
globals: {
afterAll: true,
Expand Down Expand Up @@ -90,7 +91,7 @@ module.exports = {
'react/forbid-prop-types': 'off',
'react/function-component-definition': 'off',
'react/jsx-curly-newline': 'off',
'react/jsx-filename-extension': 'off',
'react/jsx-filename-extension': ['error', { allow: 'as-needed' }],
'react/jsx-no-bind': 'off',
'react/jsx-props-no-spreading': 'off',
'react/no-unstable-nested-components': 'off',
Expand Down
8 changes: 4 additions & 4 deletions .storybook/Container.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2023 The Tekton Authors
Copyright 2019-2024 The Tekton 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
Expand All @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import React from 'react';
import { StrictMode } from 'react';
import { IntlProvider } from 'react-intl';
import { createMemoryHistory } from 'history';
import { Router, Switch } from 'react-router-dom';
Expand All @@ -35,9 +35,9 @@ export default function Container({
<CompatRouter>
<Switch>
<CompatRoute path={path}>
<React.StrictMode>
<StrictMode>
AlanGreene marked this conversation as resolved.
Show resolved Hide resolved
<Story />
</React.StrictMode>
</StrictMode>
</CompatRoute>
</Switch>
</CompatRouter>
Expand Down
6 changes: 3 additions & 3 deletions .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ const config = {
},
stories: (_config, { configType }) => ([
{ directory: '.', files: 'Welcome.mdx' },
configType === 'DEVELOPMENT' ? { directory: '../src', files: '**/*.stories.jsx', titlePrefix: 'Containers' } : null,
{ directory: '../packages/components', files: '**/*.stories.jsx', titlePrefix: 'Components' },
{ directory: '../packages/graph', files: '**/*.stories.jsx', titlePrefix: 'Experimental/Graph' }
configType === 'DEVELOPMENT' ? { directory: '../src', files: '**/*.stories.@(js|jsx)', titlePrefix: 'Containers' } : null,
{ directory: '../packages/components', files: '**/*.stories.@(js|jsx)', titlePrefix: 'Components' },
{ directory: '../packages/graph', files: '**/*.stories.@(js|jsx)', titlePrefix: 'Experimental/Graph' }
].filter(Boolean)),
async viteFinal(config, { configType }) {
// fallback to default to resolve issue with MDX rendering
Expand Down
3 changes: 1 addition & 2 deletions .storybook/preview.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020-2023 The Tekton Authors
Copyright 2020-2024 The Tekton 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
Expand All @@ -11,7 +11,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import React from 'react';
import { withThemeByClassName } from '@storybook/addon-themes';

import Container from './Container';
Expand Down
8 changes: 4 additions & 4 deletions index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2023 The Tekton Authors
Copyright 2019-2024 The Tekton 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
Expand All @@ -12,7 +12,7 @@ limitations under the License.
*/
/* istanbul ignore file */

import React from 'react';
import { StrictMode } from 'react';
import ReactDOM from 'react-dom';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
Expand All @@ -39,9 +39,9 @@ const enableReactQueryDevTools =

ReactDOM.render(
<QueryClientProvider client={queryClient}>
<React.StrictMode>
<StrictMode>
<App lang={getLocale(navigator.language)} />
</React.StrictMode>
</StrictMode>
{enableReactQueryDevTools && <ReactQueryDevtools initialIsOpen={false} />}
</QueryClientProvider>,
document.getElementById('root')
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/components/Actions/Actions.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2023 The Tekton Authors
Copyright 2019-2024 The Tekton 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
Expand All @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import React, { Component } from 'react';
import { Component } from 'react';
import { injectIntl } from 'react-intl';
import {
Button,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2023 The Tekton Authors
Copyright 2019-2024 The Tekton 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
Expand All @@ -11,7 +11,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import React from 'react';
import { TrashCan16 } from '@carbon/icons-react';

import Actions from './Actions';
Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/components/Actions/Actions.test.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2023 The Tekton Authors
Copyright 2019-2024 The Tekton 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
Expand All @@ -11,7 +11,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import React from 'react';
import { fireEvent, waitFor } from '@testing-library/react';
import { render } from '../../utils/test';
import Actions from './Actions';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
/* eslint-disable jsx-a11y/control-has-associated-label */

import PropTypes from 'prop-types';
import React from 'react';
import { getCarbonPrefix } from '@tektoncd/dashboard-utils';

const carbonPrefix = getCarbonPrefix();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020-2023 The Tekton Authors
Copyright 2020-2024 The Tekton 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021-2023 The Tekton Authors
Copyright 2021-2024 The Tekton 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
Expand All @@ -12,7 +12,6 @@ limitations under the License.
*/
/* istanbul ignore file */

import React from 'react';
import { useIntl } from 'react-intl';

import Modal from '../Modal';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021-2023 The Tekton Authors
Copyright 2021-2024 The Tekton 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2023 The Tekton Authors
Copyright 2019-2024 The Tekton 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
Expand All @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import React, { Component } from 'react';
import { Component } from 'react';
import { Pending24 as DefaultIcon } from '@carbon/icons-react';
import { injectIntl } from 'react-intl';
import { getStatus } from '@tektoncd/dashboard-utils';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2023 The Tekton Authors
Copyright 2019-2024 The Tekton 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2023 The Tekton Authors
Copyright 2019-2024 The Tekton 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
Expand All @@ -11,8 +11,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import React from 'react';

import DetailsHeader from './DetailsHeader';
import { render } from '../../utils/test';

Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/components/DotSpinner/DotSpinner.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021-2023 The Tekton Authors
Copyright 2021-2024 The Tekton 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
Expand All @@ -11,7 +11,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import React from 'react';
import { classNames } from '@tektoncd/dashboard-utils';

export default function Spinner({ className }) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021-2023 The Tekton Authors
Copyright 2021-2024 The Tekton 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2023 The Tekton Authors
Copyright 2019-2024 The Tekton 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
Expand All @@ -11,12 +11,12 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import React from 'react';
import { Component } from 'react';
import { InlineNotification } from 'carbon-components-react';
import { getErrorMessage } from '@tektoncd/dashboard-utils';
import { injectIntl } from 'react-intl';

class ErrorBoundary extends React.Component {
class ErrorBoundary extends Component {
state = { error: null };

static getDerivedStateFromError(error) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2023 The Tekton Authors
Copyright 2019-2024 The Tekton 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
Expand All @@ -11,7 +11,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import React from 'react';
import { render } from '../../utils/test';

import ErrorBoundary from './ErrorBoundary';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2023 The Tekton Authors
Copyright 2019-2024 The Tekton 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
Expand All @@ -11,7 +11,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import React from 'react';
import { FormattedDate, FormattedRelativeTime, useIntl } from 'react-intl';

const FormattedDateWrapper = ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2023 The Tekton Authors
Copyright 2019-2024 The Tekton 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2023 The Tekton Authors
Copyright 2019-2024 The Tekton 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
Expand All @@ -11,7 +11,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import React from 'react';
import { render } from '../../utils/test';
import FormattedDate from './FormattedDate';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2023 The Tekton Authors
Copyright 2019-2024 The Tekton 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
Expand All @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import React, { Component } from 'react';
import { Component } from 'react';
import { defineMessages, injectIntl } from 'react-intl';
import FormattedDuration from 'react-intl-formatted-duration';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2023 The Tekton Authors
Copyright 2019-2024 The Tekton 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020-2023 The Tekton Authors
Copyright 2020-2024 The Tekton 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
Expand All @@ -11,7 +11,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import React from 'react';
import { render } from '../../utils/test';
import FormattedDuration from './FormattedDuration';

Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/components/Header/Header.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2023 The Tekton Authors
Copyright 2019-2024 The Tekton 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
Expand All @@ -11,7 +11,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import React from 'react';
import { useIntl } from 'react-intl';
import {
Header as CarbonHeader,
Expand Down
4 changes: 1 addition & 3 deletions packages/components/src/components/Header/Header.stories.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2023 The Tekton Authors
Copyright 2019-2024 The Tekton 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
Expand All @@ -11,8 +11,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import React from 'react';

import Header from '.';
import LogoutButton from '../LogoutButton';

Expand Down
Loading
Loading