Skip to content

Commit d432c5e

Browse files
authored
fix(compat): use deep import paths for main imports (#6554)
1 parent fd31359 commit d432c5e

File tree

18 files changed

+84
-45
lines changed

18 files changed

+84
-45
lines changed

eslint.config.mjs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ const ignorePatterns = {
2525
'**/scripts',
2626
'**/shared',
2727
'**/examples',
28-
'**/templates'
28+
'**/templates',
29+
'**/*.module.css.ts'
2930
]
3031
};
32+
3133
const config = tseslint.config(
3234
ignorePatterns,
3335
eslint.configs.recommended,
@@ -224,6 +226,25 @@ const config = tseslint.config(
224226
}
225227
},
226228

229+
// no-restricted-imports rule for compat package
230+
{
231+
files: ['packages/compat/**/*.{js,jsx,ts,tsx}'],
232+
rules: {
233+
'no-restricted-imports': [
234+
'error',
235+
{
236+
paths: [
237+
{
238+
name: '@ui5/webcomponents-react',
239+
message:
240+
"Please use deep imports from @ui5/webcomponents-react. Example: import { Button } from '@ui5/webcomponents-react/dist/webComponents/Button/index.js';"
241+
}
242+
]
243+
}
244+
]
245+
}
246+
},
247+
227248
// prettier plugin must be the last entry in the config!
228249
prettierPlugin
229250
);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"lerna:version-dryrun": "lerna version --conventional-graduate --no-git-tag-version --no-push",
2424
"wrappers:main": "WITH_WEB_COMPONENT_IMPORT_PATH='../../internal/withWebComponent.js' INTERFACES_IMPORT_PATH='../../types/index.js' node packages/cli/dist/bin/index.js create-wrappers --packageName @ui5/webcomponents --out ./packages/main/src/webComponents --additionalComponentNote 'This is a UI5 Web Component! [Repository](https://github.com/SAP/ui5-webcomponents) | [Documentation](https://sap.github.io/ui5-webcomponents/)'",
2525
"wrappers:fiori": "WITH_WEB_COMPONENT_IMPORT_PATH='../../internal/withWebComponent.js' INTERFACES_IMPORT_PATH='../../types/index.js' node packages/cli/dist/bin/index.js create-wrappers --packageName @ui5/webcomponents-fiori --out ./packages/main/src/webComponents --additionalComponentNote 'This is a UI5 Web Component! [Repository](https://github.com/SAP/ui5-webcomponents) | [Documentation](https://sap.github.io/ui5-webcomponents/)'",
26-
"wrappers:compat": "node packages/cli/dist/bin/index.js create-wrappers --packageName @ui5/webcomponents-compat --out ./packages/compat/src/components --additionalComponentNote 'This is a UI5 Web Component! [Repository](https://github.com/SAP/ui5-webcomponents) | [Documentation](https://sap.github.io/ui5-webcomponents/)' && prettier --log-level silent --write ./packages/compat/src/components && eslint --ext .ts,.tsx --fix ./packages/compat/src/components/*/index.tsx",
26+
"wrappers:compat": "WITH_WEB_COMPONENT_IMPORT_PATH='@ui5/webcomponents-react/dist/internal/withWebComponent.js' node packages/cli/dist/bin/index.js create-wrappers --packageName @ui5/webcomponents-compat --out ./packages/compat/src/components --additionalComponentNote 'This is a UI5 Web Component! [Repository](https://github.com/SAP/ui5-webcomponents) | [Documentation](https://sap.github.io/ui5-webcomponents/)' && prettier --log-level silent --write ./packages/compat/src/components && eslint --ext .ts,.tsx --fix ./packages/compat/src/components/*/index.tsx",
2727
"create-webcomponents-wrapper": "(cd packages/cli && tsc) && yarn run wrappers:main && yarn run wrappers:fiori && yarn run wrappers:compat && prettier --log-level silent --write ./packages/main/src/webComponents && eslint --ext .ts,.tsx --fix ./packages/main/src/webComponents/*/index.tsx && yarn run sb:prepare-cem",
2828
"chromatic": "cross-env STORYBOOK_ENV=chromatic npx chromatic --build-script-name build:storybook",
2929
"postinstall": "husky && yarn setup",

packages/compat/src/components/Loader/Loader.stories.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import type { Meta, StoryObj } from '@storybook/react';
22
import activateIcon from '@ui5/webcomponents-icons/dist/activate.js';
3-
import { Card, CardHeader, FlexBox, FlexBoxDirection, Icon, Text } from '@ui5/webcomponents-react';
3+
import { FlexBox } from '@ui5/webcomponents-react/dist/components/FlexBox/index.js';
4+
import { FlexBoxDirection } from '@ui5/webcomponents-react/dist/enums/FlexBoxDirection.js';
5+
import { Card } from '@ui5/webcomponents-react/dist/webComponents/Card/index.js';
6+
import { CardHeader } from '@ui5/webcomponents-react/dist/webComponents/CardHeader/index.js';
7+
import { Icon } from '@ui5/webcomponents-react/dist/webComponents/Icon/index.js';
8+
import { Text } from '@ui5/webcomponents-react/dist/webComponents/Text/index.js';
49
import { useEffect, useRef, useState } from 'react';
510
import { LoaderType } from '../../enums/LoaderType.js';
611
import { Loader } from './index.js';

packages/compat/src/components/Loader/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client';
22

3-
import type { CommonProps } from '@ui5/webcomponents-react';
43
import { PLEASE_WAIT } from '@ui5/webcomponents-react/dist/i18n/i18n-defaults.js';
4+
import type { CommonProps } from '@ui5/webcomponents-react/dist/types/CommonProps.js';
55
import { useI18nBundle, useStylesheet } from '@ui5/webcomponents-react-base';
66
import { clsx } from 'clsx';
77
import type { CSSProperties } from 'react';

packages/compat/src/components/OverflowToolbarButton/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client';
22

3-
import { Button } from '@ui5/webcomponents-react';
4-
import type { ButtonDomRef, ButtonPropTypes } from '@ui5/webcomponents-react';
3+
import { Button } from '@ui5/webcomponents-react/dist/webComponents/Button/index.js';
4+
import type { ButtonDomRef, ButtonPropTypes } from '@ui5/webcomponents-react/dist/webComponents/Button/index.js';
55
import type { ReactNode } from 'react';
66
import { forwardRef } from 'react';
77
import { useOverflowPopoverContext } from '../../internal/OverflowPopoverContext.js';

packages/compat/src/components/OverflowToolbarToggleButton/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
'use client';
22

3-
import type { ToggleButtonDomRef, ToggleButtonPropTypes } from '@ui5/webcomponents-react';
4-
import { ToggleButton } from '@ui5/webcomponents-react';
3+
import { ToggleButton } from '@ui5/webcomponents-react/dist/webComponents/ToggleButton/index.js';
4+
import type {
5+
ToggleButtonDomRef,
6+
ToggleButtonPropTypes
7+
} from '@ui5/webcomponents-react/dist/webComponents/ToggleButton/index.js';
58
import type { ReactNode } from 'react';
69
import { forwardRef } from 'react';
710
import { useOverflowPopoverContext } from '../../internal/OverflowPopoverContext.js';

packages/compat/src/components/Table/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ import type {
88
import type { TableRowClickEventDetail } from '@ui5/webcomponents-compat/dist/TableRow.js';
99
import type TableGrowingMode from '@ui5/webcomponents-compat/dist/types/TableGrowingMode.js';
1010
import type TableMode from '@ui5/webcomponents-compat/dist/types/TableMode.js';
11-
import { withWebComponent } from '@ui5/webcomponents-react';
12-
import type { CommonProps, Ui5CustomEvent, Ui5DomRef, UI5WCSlotsNode } from '@ui5/webcomponents-react';
11+
import { withWebComponent } from '@ui5/webcomponents-react/dist/internal/withWebComponent.js';
12+
import type { CommonProps } from '@ui5/webcomponents-react/dist/types/CommonProps.js';
13+
import type { UI5WCSlotsNode } from '@ui5/webcomponents-react/dist/types/index.js';
14+
import type { Ui5CustomEvent } from '@ui5/webcomponents-react/dist/types/Ui5CustomEvent.js';
15+
import type { Ui5DomRef } from '@ui5/webcomponents-react/dist/types/Ui5DomRef.js';
1316
import type { ReactNode } from 'react';
1417

1518
interface TableAttributes {

packages/compat/src/components/TableCell/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
'use client';
22

33
import '@ui5/webcomponents-compat/dist/TableCell.js';
4-
import { withWebComponent } from '@ui5/webcomponents-react';
5-
import type { CommonProps, Ui5DomRef } from '@ui5/webcomponents-react';
4+
import { withWebComponent } from '@ui5/webcomponents-react/dist/internal/withWebComponent.js';
5+
import type { CommonProps } from '@ui5/webcomponents-react/dist/types/CommonProps.js';
6+
import type { Ui5DomRef } from '@ui5/webcomponents-react/dist/types/Ui5DomRef.js';
67
import type { ReactNode } from 'react';
78

89
interface TableCellAttributes {}

packages/compat/src/components/TableColumn/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
import '@ui5/webcomponents-compat/dist/TableColumn.js';
44
import type TableColumnPopinDisplay from '@ui5/webcomponents-compat/dist/types/TableColumnPopinDisplay.js';
5-
import { withWebComponent } from '@ui5/webcomponents-react';
6-
import type { CommonProps, Ui5DomRef } from '@ui5/webcomponents-react';
5+
import { withWebComponent } from '@ui5/webcomponents-react/dist/internal/withWebComponent.js';
6+
import type { CommonProps } from '@ui5/webcomponents-react/dist/types/CommonProps.js';
7+
import type { Ui5DomRef } from '@ui5/webcomponents-react/dist/types/Ui5DomRef.js';
78
import type { ReactNode } from 'react';
89

910
interface TableColumnAttributes {

packages/compat/src/components/TableGroupRow/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
'use client';
22

33
import '@ui5/webcomponents-compat/dist/TableGroupRow.js';
4-
import { withWebComponent } from '@ui5/webcomponents-react';
5-
import type { CommonProps, Ui5DomRef } from '@ui5/webcomponents-react';
4+
import { withWebComponent } from '@ui5/webcomponents-react/dist/internal/withWebComponent.js';
5+
import type { CommonProps } from '@ui5/webcomponents-react/dist/types/CommonProps.js';
6+
import type { Ui5DomRef } from '@ui5/webcomponents-react/dist/types/Ui5DomRef.js';
67
import type { ReactNode } from 'react';
78

89
interface TableGroupRowAttributes {}

0 commit comments

Comments
 (0)