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

chore: use new JSX transform #11328

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
presets: ['@babel/preset-typescript', '@babel/preset-react'],
presets: ['@babel/preset-typescript', ['@babel/preset-react', { runtime: 'automatic' }]],
plugins: ['@babel/plugin-transform-modules-commonjs']
};
17 changes: 15 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import patternflyReact from 'eslint-plugin-patternfly-react';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import reactCompiler from 'eslint-plugin-react-compiler';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRecommended from 'eslint-plugin-react/configs/recommended.js';
import react from 'eslint-plugin-react';
import testingLibrary from 'eslint-plugin-testing-library';
import globals from 'globals';
import tseslint from 'typescript-eslint';
Expand All @@ -23,7 +23,8 @@ export default [
},
js.configs.recommended,
...tseslint.configs.recommended,
reactRecommended,
react.configs.flat.recommended,
react.configs.flat['jsx-runtime'],
eslintPluginPrettierRecommended,
{
plugins: {
Expand Down Expand Up @@ -98,6 +99,18 @@ export default [
'no-eval': 'error',
'no-new-wrappers': 'error',
'no-prototype-builtins': 'off',
'no-restricted-imports': [
'warn',
{
paths: [
{
name: 'react',
importNames: ['default'],
message: 'Please use named imports when importing from React.'
}
]
}
],
'no-shadow': 'off',
'no-throw-literal': 'error',
'no-trailing-spaces': 'off',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* eslint-disable camelcase */
import chart_container_cursor_line_Fill from '@patternfly/react-tokens/dist/esm/chart_container_cursor_line_Fill';

import * as React from 'react';
import { ContainerType, createContainer as victoryCreateContainer } from 'victory-create-container';
import { ChartCursorTooltip } from '../ChartCursorTooltip/ChartCursorTooltip';
import { ChartLabel } from '../ChartLabel/ChartLabel';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { Avatar } from '@patternfly/react-core';
import avatarImg from '../../assets/avatarImg.svg';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { Avatar } from '@patternfly/react-core';
import avatarImg from '../../assets/avatarImg.svg';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { ButtonProps } from '../';

export const Button = ({ children, variant, isInline, onClick, iconPosition, icon, ...props }: ButtonProps) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { DrawerPanelDescription } from '../DrawerPanelDescription';
import styles from '@patternfly/react-styles/css/components/Drawer/drawer';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { HelperTextProps } from '../';

export const HelperText = ({ children, isLiveRegion }: HelperTextProps) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { HelperTextItemProps } from '../';

export const HelperTextItem = ({ children, variant }: HelperTextItemProps) => (
Expand Down
1 change: 0 additions & 1 deletion packages/react-core/src/components/Menu/__mocks__/Menu.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { MenuProps } from '../Menu';
import cssMenuMinWidth from '@patternfly/react-tokens/dist/esm/c_menu_MinWidth';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
import React from 'react';

export const MenuContent = ({ children }) => <div>{children}</div>;
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { MenuGroupProps } from '../MenuGroup';

export const MenuGroup = ({ className, children, label, labelHeadingLevel }: MenuGroupProps) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { MenuItemProps } from '../MenuItem';

export const MenuItem = ({ className, children, description, itemId }: MenuItemProps) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { MenuListProps } from '../MenuList';

export const MenuList = ({ className, children }: MenuListProps) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { ProgressStepper, ProgressStep, Popover } from '@patternfly/react-core';

export const PopoverProgressStep = () => (
Expand Down
2 changes: 1 addition & 1 deletion packages/react-core/src/helpers/FocusTrap/FocusTrap.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createFocusTrap, FocusTrap as FocusTrapInstance, Options as FocusTrapOptions } from 'focus-trap';
import React, { ComponentPropsWithRef, forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
import { ComponentPropsWithRef, forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
import { useUnmountEffect } from '../useUnmountEffect';

export interface FocusTrapProps extends ComponentPropsWithRef<'div'> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { PopperProps } from '../Popper';

export const Popper = ({
Expand Down
1 change: 0 additions & 1 deletion packages/react-core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"jsx": "react",
"rootDir": "./src",
"outDir": "./dist/esm",
"tsBuildInfoFile": "dist/esm.tsbuildinfo",
Expand Down
1 change: 0 additions & 1 deletion packages/react-docs/patternfly-docs/pages/icons.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { Tooltip, Grid, GridItem, PageSection, Content } from '@patternfly/react-core';
import spacerMd from '@patternfly/react-tokens/dist/esm/t_global_spacer_md';
import labelFontSize from '@patternfly/react-tokens/dist/esm/t_global_font_size_sm';
Expand Down
1 change: 0 additions & 1 deletion packages/react-docs/patternfly-docs/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { Title, PageSection } from '@patternfly/react-core';

// https://philipwalton.github.io/solved-by-flexbox/demos/vertical-centering/
Expand Down
4 changes: 2 additions & 2 deletions packages/react-icons/scripts/writeIcons.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default ${jsName};
};

const writeDTSExport = (fname, jsName, icon) => {
const text = `import * as React from 'react';
const text = `import { ComponentClass } from 'react';
import { SVGIconProps } from '../createIcon';
export declare const ${jsName}Config: {
name: '${jsName}',
Expand All @@ -61,7 +61,7 @@ export declare const ${jsName}Config: {
yOffset: ${icon.yOffset || 0},
xOffset: ${icon.xOffset || 0},
};
export declare const ${jsName}: React.ComponentClass<SVGIconProps>;
export declare const ${jsName}: ComponentClass<SVGIconProps>;
export default ${jsName};
`.trim();
const filename = `${fname}.d.ts`;
Expand Down
1 change: 0 additions & 1 deletion packages/react-integration/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"noImplicitAny": true,
"module": "es6",
"target": "es5",
"jsx": "react",
"lib": ["dom", "es6"],
"allowJs": true,
"types": ["cypress"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { IExtra, IFormatterValueType, ITransform } from '../../TableTypes';
import { DraggableCell } from '../../DraggableCell';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { IExtra, IFormatterValueType, ITransform, IRowCell, OnRowEdit, RowErrors, RowEditType } from '../../TableTypes';
import { EditColumn } from '../../EditColumn';
import tableStyles from '@patternfly/react-styles/css/components/Table/table';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react';
import { Component } from 'react';
import PropTypes from 'prop-types';
import { TableContext } from '../components/Table/Table';
import { TableHeader } from '../components/Table';
Expand Down
1 change: 0 additions & 1 deletion packages/react-table/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"jsx": "react",
"rootDir": "./src",
"outDir": "./dist/esm",
"tsBuildInfoFile": "dist/esm.tsbuildinfo",
Expand Down
2 changes: 1 addition & 1 deletion packages/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"assumeChangesOnlyAffectDirectDependencies": true,
"jsx": "react",
"jsx": "react-jsx",
"lib": [
"es2015",
"dom"
Expand Down
Loading