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

fix: use new JSX transform in preparation for React 19 #5837

Merged
merged 2 commits into from
Jun 3, 2024
Merged
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
5 changes: 1 addition & 4 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ env:
es2022: true
extends:
- plugin:react/recommended
- plugin:react/jsx-runtime
- plugin:react-hooks/recommended
- plugin:import/recommended
- plugin:prettier/recommended
@@ -112,8 +113,6 @@ overrides:

- files:
- 'cypress/**/*'
extends:
- 'plugin:react/jsx-runtime'
rules:
'@typescript-eslint/no-namespace': 'off'

@@ -124,7 +123,6 @@ overrides:
- no-only-tests
rules:
'@typescript-eslint/no-empty-function': 'off'
'react/react-in-jsx-scope': 'off'
'import/order': 'warn'
'import/no-unresolved': 'off'
'react/no-unescaped-entities': 'off'
@@ -135,7 +133,6 @@ overrides:
- files:
- '*.stories.tsx'
extends:
- 'plugin:react/jsx-runtime'
- 'plugin:storybook/recommended'
rules:
'react/prop-types': 'off' # inline custom components within stories don't need prop types
2 changes: 1 addition & 1 deletion .storybook/components/ArgTypesWithNote.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ArgTypes } from '@storybook/blocks';
import { MessageStrip, MessageStripDesign } from '@ui5/webcomponents-react';
import React, { ComponentProps, ReactNode } from 'react';
import { ComponentProps, ReactNode } from 'react';
import classes from './ArgTypesWithNote.module.css';

interface ArgTypesWithNotePropTypes {
2 changes: 1 addition & 1 deletion .storybook/components/ControlsWithNote.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Controls } from '@storybook/blocks';
import { MessageStrip, MessageStripDesign } from '@ui5/webcomponents-react';
import React, { ComponentProps, ReactNode } from 'react';
import { ComponentProps, ReactNode } from 'react';
import classes from './ControlsWithNote.module.css';
import { DomRefTable } from './DomRefTable';

2 changes: 1 addition & 1 deletion .storybook/components/DocsHeader.tsx
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ import {
ThemeProvider
} from '@ui5/webcomponents-react';
import { clsx } from 'clsx';
import React, { useContext } from 'react';
import { useContext } from 'react';
import { useGetSubComponentsOfModule } from '../utils';
import classes from './DocsHeader.module.css';
import { GitHubLogo } from './GitHub-Mark';
2 changes: 1 addition & 1 deletion .storybook/components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ import {
PopoverPlacementType,
WrappingType
} from '@ui5/webcomponents-react';
import React, { useRef } from 'react';
import { useRef } from 'react';
import { createPortal } from 'react-dom';
import BestRunLogo from '../../assets/SAP_Best_R_grad_blk_scrn.png';
import classes from './Footer.module.css';
2 changes: 0 additions & 2 deletions .storybook/components/GitHub-Mark.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

export const GitHubLogo = () => (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32.58 31.77" style={{ height: '1.75rem' }}>
<g id="Layer_2" data-name="Layer 2">
6 changes: 3 additions & 3 deletions .storybook/components/Import.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DocsContext } from '@storybook/addon-docs';
import React, { useContext } from 'react';
import { Fragment, useContext } from 'react';
import { useGetCem, useGetSubComponentsOfModule } from '../utils';

interface ImportStatementPropTypes {
@@ -39,11 +39,11 @@ export const ImportStatement = ({ moduleNames, packageName }: ImportStatementPro
<>
{moduleNames.map((item) => {
return (
<React.Fragment key={item}>
<Fragment key={item}>
<br />
&nbsp;&nbsp;
{item},
</React.Fragment>
</Fragment>
);
})}
<br />
1 change: 0 additions & 1 deletion .storybook/components/LabelWithWrapping.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Label, WrappingType } from '@ui5/webcomponents-react';
import React from 'react';

//mdx adds a paragraph to children if added inline, this component prevents that.
export const LabelWithWrapping = ({ children }) => {
1 change: 0 additions & 1 deletion .storybook/components/ProductsTable.tsx
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@ import {
TableRow,
Text
} from '@ui5/webcomponents-react';
import React from 'react';
import { ProductCollection } from './products.json';

export const ProductsTable = () => {
1 change: 0 additions & 1 deletion .storybook/components/SplitterElementContent.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { FlexBox, Text } from '@ui5/webcomponents-react';
import React from 'react';

export const SplitterElementContent = ({ text, background = 'transparent' }) => (
<FlexBox style={{ height: '100%', width: '100%', background }} alignItems="Center" justifyContent="Center">
26 changes: 0 additions & 26 deletions babel.config.cjs

This file was deleted.

1 change: 0 additions & 1 deletion docs/knowledge-base/SsrLimitations.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { MessageStrip, MessageStripDesign } from '@ui5/webcomponents-react';

export function SsrLimitations() {
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getTheme, setTheme } from '@ui5/webcomponents-base/dist/config/Theme.js';
import React, { useEffect, useReducer, useState } from 'react';
import { useEffect, useReducer, useState } from 'react';
import type { CSSProperties } from 'react';
import { MAPPED_THEMES } from '../../.storybook/utils';
import { FlexBox, FlexBoxDirection, Label, Option, Panel, Select, Text, ThemeProvider } from '@ui5/webcomponents-react';
2 changes: 1 addition & 1 deletion docs/knowledgeBaseExamples/formExamples.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import { useState } from 'react';
import {
ThemeProvider,
Form,
6 changes: 3 additions & 3 deletions docs/knowledgeBaseExamples/slotExamples.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable react/prop-types */
import { Bar, Button } from '@ui5/webcomponents-react';
import React from 'react';

const FaultyBarStart = () => {
return <div>Start</div>;
@@ -10,7 +10,7 @@ const FaultyBarEnd = () => {
export const FaultyBarComponent = () => {
return (
<Bar startContent={<FaultyBarStart />} endContent={<FaultyBarEnd />}>
<div>I'm not a custom component</div>
<div>Not a custom component</div>
</Bar>
);
};
@@ -24,7 +24,7 @@ const BarEnd = (props) => {
export const BarComponent = () => {
return (
<Bar startContent={<BarStart />} endContent={<BarEnd />}>
<div>I'm not a custom component</div>
<div>Not a custom component</div>
</Bar>
);
};
1 change: 0 additions & 1 deletion docs/styling/MyCustomElement.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { ThemingParameters } from '@ui5/webcomponents-react-base';
import './MyCustomElement.css';

76 changes: 36 additions & 40 deletions examples/remix-ts/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -8,77 +8,73 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
jsx: true
}
},
env: {
browser: true,
commonjs: true,
es6: true,
es6: true
},
ignorePatterns: ["!**/.server", "!**/.client"],
ignorePatterns: ['!**/.server', '!**/.client'],

// Base config
extends: ["eslint:recommended"],
extends: ['eslint:recommended'],

overrides: [
// React
{
files: ["**/*.{js,jsx,ts,tsx}"],
plugins: ["react", "jsx-a11y"],
files: ['**/*.{js,jsx,ts,tsx}'],
plugins: ['react', 'jsx-a11y'],
extends: [
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:react-hooks/recommended",
"plugin:jsx-a11y/recommended",
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
'plugin:jsx-a11y/recommended'
],
settings: {
react: {
version: "detect",
version: 'detect'
},
formComponents: ["Form"],
formComponents: ['Form'],
linkComponents: [
{ name: "Link", linkAttribute: "to" },
{ name: "NavLink", linkAttribute: "to" },
{ name: 'Link', linkAttribute: 'to' },
{ name: 'NavLink', linkAttribute: 'to' }
],
"import/resolver": {
typescript: {},
},
},
'import/resolver': {
typescript: {}
}
}
},

// Typescript
{
files: ["**/*.{ts,tsx}"],
plugins: ["@typescript-eslint", "import"],
parser: "@typescript-eslint/parser",
files: ['**/*.{ts,tsx}'],
plugins: ['@typescript-eslint', 'import'],
parser: '@typescript-eslint/parser',
settings: {
"import/internal-regex": "^~/",
"import/resolver": {
'import/internal-regex': '^~/',
'import/resolver': {
node: {
extensions: [".ts", ".tsx"],
extensions: ['.ts', '.tsx']
},
typescript: {
alwaysTryTypes: true,
},
},
alwaysTryTypes: true
}
}
},
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
],
extends: ['plugin:@typescript-eslint/recommended', 'plugin:import/recommended', 'plugin:import/typescript']
},

// Node
{
files: [".eslintrc.cjs"],
files: ['.eslintrc.cjs'],
env: {
node: true,
},
},
],
node: true
}
}
]
};
10 changes: 5 additions & 5 deletions examples/remix-ts/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { vitePlugin as remix } from "@remix-run/dev";
import { installGlobals } from "@remix-run/node";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
import { vitePlugin as remix } from '@remix-run/dev';
import { installGlobals } from '@remix-run/node';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';

installGlobals();

export default defineConfig({
plugins: [remix(), tsconfigPaths()],
plugins: [remix(), tsconfigPaths()]
});
2 changes: 1 addition & 1 deletion packages/base/src/Device/Media.cy.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react';
import { useEffect, useState } from 'react';
import { MediaEventProvider } from './EventProvider';
import { attachMediaHandler, detachMediaHandler, getCurrentRange } from './Media';

2 changes: 1 addition & 1 deletion packages/charts/src/components/BarChart/BarChart.tsx
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

import { enrichEventWithDetails, ThemingParameters, useIsRTL, useSyncRef } from '@ui5/webcomponents-react-base';
import type { CSSProperties } from 'react';
import React, { forwardRef, useCallback } from 'react';
import { forwardRef, useCallback } from 'react';
import {
Bar,
BarChart as BarChartLib,
@@ -76,7 +76,7 @@
* @param measure {IChartMeasure} Current measure object
* @param dataElement {object} Current data element
*/
highlightColor?: (value: number, measure: MeasureConfig, dataElement: Record<string, any>) => CSSProperties['color'];

Check warning on line 79 in packages/charts/src/components/BarChart/BarChart.tsx

GitHub Actions / lint

Unexpected any. Specify a different type
}

interface DimensionConfig extends IChartDimension {
@@ -185,7 +185,7 @@
? dataKeys.findIndex((key) => key === chartConfig.secondYAxis?.dataKey)
: 0;

const [componentRef, chartRef] = useSyncRef<any>(ref);

Check warning on line 188 in packages/charts/src/components/BarChart/BarChart.tsx

GitHub Actions / lint

Unexpected any. Specify a different type

const onItemLegendClick = useLegendItemClick(onLegendClick);
const labelFormatter = useLabelFormatter(primaryDimension);
1 change: 0 additions & 1 deletion packages/charts/src/components/BarChart/Placeholder.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ThemingParameters } from '@ui5/webcomponents-react-base';
import React from 'react';
import ContentLoader from 'react-content-loader';

export const BarChartPlaceholder = () => {
@@ -13,7 +12,7 @@
speed={2}
backgroundColor={ThemingParameters.sapContent_ImagePlaceholderBackground}
foregroundColor={ThemingParameters.sapContent_ImagePlaceholderForegroundColor}
backgroundOpacity={ThemingParameters.sapContent_DisabledOpacity as any}

Check warning on line 15 in packages/charts/src/components/BarChart/Placeholder.tsx

GitHub Actions / lint

Unexpected any. Specify a different type
>
<rect x="20" y="10" width="1" height="135" />
<rect x="20" y="20" width="85" height="15" />
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

import { enrichEventWithDetails, ThemingParameters, useIsRTL, useSyncRef } from '@ui5/webcomponents-react-base';
import type { CSSProperties } from 'react';
import React, { forwardRef, useCallback, useMemo } from 'react';
import { forwardRef, useCallback, useMemo } from 'react';
import {
Bar,
Brush,
@@ -66,7 +66,7 @@
* @param measure {IChartMeasure} Current measure object
* @param dataElement {object} Current data element
*/
highlightColor?: (value: number, measure: MeasureConfig, dataElement: Record<string, any>) => CSSProperties['color'];

Check warning on line 69 in packages/charts/src/components/BulletChart/BulletChart.tsx

GitHub Actions / lint

Unexpected any. Specify a different type
}

interface DimensionConfig extends IChartDimension {
@@ -143,7 +143,7 @@
...rest
} = props;

const [componentRef, chartRef] = useSyncRef<any>(ref);

Check warning on line 146 in packages/charts/src/components/BulletChart/BulletChart.tsx

GitHub Actions / lint

Unexpected any. Specify a different type

const chartConfig = {
yAxisVisible: false,
@@ -222,7 +222,7 @@
);
} else {
onDataPointClick(
enrichEventWithDetails({} as any, {

Check warning on line 225 in packages/charts/src/components/BulletChart/BulletChart.tsx

GitHub Actions / lint

Unexpected any. Specify a different type
value: eventOrIndex.value,
dataKey: eventOrIndex.dataKey,
dataIndex: eventOrIndex.index,
@@ -296,7 +296,7 @@
{chartConfig.xAxisVisible &&
dimensions.map((dimension, index) => {
let AxisComponent;
const axisProps: any = {

Check warning on line 299 in packages/charts/src/components/BulletChart/BulletChart.tsx

GitHub Actions / lint

Unexpected any. Specify a different type
dataKey: dimension.accessor,
interval: dimension?.interval ?? (isBigDataSet ? 'preserveStart' : 0),
tickLine: index < 1,
@@ -434,7 +434,7 @@
/>
)}
{sortedMeasures?.map((element, index) => {
const chartElementProps: any = {

Check warning on line 437 in packages/charts/src/components/BulletChart/BulletChart.tsx

GitHub Actions / lint

Unexpected any. Specify a different type
isAnimationActive: noAnimation === false
};
let labelPosition = 'top';
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { CSSProperties } from 'react';
import React from 'react';

interface ComparisonLine {
x?: number;
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ThemingParameters } from '@ui5/webcomponents-react-base';
import React from 'react';
import ContentLoader from 'react-content-loader';
import type { IChartMeasure } from '../../interfaces/IChartMeasure.js';

Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

import { enrichEventWithDetails, ThemingParameters, useIsRTL, useSyncRef } from '@ui5/webcomponents-react-base';
import type { CSSProperties } from 'react';
import React, { forwardRef, useCallback } from 'react';
import { forwardRef, useCallback } from 'react';
import {
Bar as Column,
BarChart as ColumnChartLib,
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ThemingParameters } from '@ui5/webcomponents-react-base';
import React from 'react';
import ContentLoader from 'react-content-loader';

export const ColumnChartPlaceholder = (props) => {
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

import { ThemingParameters, useIsomorphicId } from '@ui5/webcomponents-react-base';
import type { CSSProperties } from 'react';
import React, { forwardRef } from 'react';
import { forwardRef } from 'react';
import type { TooltipProps, YAxisProps } from 'recharts';
import { useLongestYAxisLabel } from '../../hooks/useLongestYAxisLabel.js';
import { usePrepareDimensionsAndMeasures } from '../../hooks/usePrepareDimensionsAndMeasures.js';
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ThemingParameters } from '@ui5/webcomponents-react-base';
import React from 'react';
import ContentLoader from 'react-content-loader';

export const ColumnChartWithTrendPlaceholder = (props) => {
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ThemingParameters } from '@ui5/webcomponents-react-base';
import React from 'react';
import ContentLoader from 'react-content-loader';
import type { IChartMeasure } from '../../interfaces/IChartMeasure.js';

Loading

Unchanged files with check annotations Beta

function ResizeTestComponent({ onChange }: { onChange: (event: { width: number; height: number }) => void }) {
useEffect(() => {
attachResizeHandler(onChange);
}, []);

Check warning on line 12 in packages/base/src/Device/index.cy.tsx

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'onChange'. Either include it or remove the dependency array
const unregister = () => {
detachResizeHandler(onChange);
}) {
useEffect(() => {
attachOrientationChangeHandler(onChange);
}, []);

Check warning on line 32 in packages/base/src/Device/index.cy.tsx

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'onChange'. Either include it or remove the dependency array
const unregister = () => {
detachOrientationChangeHandler(onChange);