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

feat: migrate to new JSX transform #2006

Merged
merged 31 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2e21192
feat: add react-tsx
u4aew Dec 21, 2024
fe4f40a
feat: add react-jsx
u4aew Dec 21, 2024
ffa2846
feat: add react-jsx
u4aew Dec 21, 2024
f0ec063
feat: add react-jsx
u4aew Dec 23, 2024
92d5278
feat: add react-jsx
u4aew Dec 23, 2024
2809a30
feat: add react-jsx
u4aew Dec 23, 2024
f07a65c
Merge branch 'main' into feat-react-jsx
u4aew Dec 23, 2024
c5931d0
feat: add react-jsx
u4aew Dec 23, 2024
88c1566
Merge branch 'main' into feat-react-jsx
u4aew Dec 25, 2024
86318bd
feat: add react-jsx
u4aew Dec 25, 2024
3cab967
feat: add react-jsx
u4aew Dec 25, 2024
7704e1c
feat: add react-jsx
u4aew Dec 25, 2024
bc78010
feat: add react-jsx
u4aew Dec 25, 2024
9419757
feat: add react-jsx
u4aew Dec 25, 2024
48e2a70
Merge branch 'refs/heads/main' into feat-react-jsx
u4aew Dec 25, 2024
3846822
feat: add react-jsx
u4aew Dec 25, 2024
23835dc
Merge branch 'main' into feat-react-jsx
u4aew Dec 25, 2024
9efc2e8
feat: add react-jsx
u4aew Dec 25, 2024
e45eb9f
feat: add react-jsx
u4aew Dec 25, 2024
80d6c82
feat: add react-jsx
u4aew Dec 25, 2024
593e3f7
feat: add react-jsx
u4aew Dec 25, 2024
a9ead1e
feat: add react-jsx
u4aew Dec 25, 2024
514949d
Merge branch 'main' into feat-react-jsx
u4aew Dec 25, 2024
0ea9b94
feat: add react-jsx
u4aew Dec 25, 2024
3a4a704
feat: add react-jsx
u4aew Dec 25, 2024
5e6228f
feat: add react-jsx
u4aew Dec 25, 2024
dd01d56
Merge branch 'refs/heads/main' into feat-react-jsx
u4aew Dec 25, 2024
ecd060c
feat: add react-jsx
u4aew Dec 25, 2024
1e3715d
feat: add react-jsx
u4aew Dec 25, 2024
e1d77e5
feat: add react-jsx
u4aew Dec 25, 2024
8242795
Merge branch 'main' into feat-react-jsx
amje Dec 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 7 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
}
],
"@babel/preset-typescript",
"@babel/preset-react"
[
"@babel/preset-react",
{
"runtime": "automatic"
}
]
],
"plugins": []
}
}
7 changes: 4 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"@gravity-ui/eslint-config/client",
"@gravity-ui/eslint-config/prettier",
"@gravity-ui/eslint-config/import-order",
"@gravity-ui/eslint-config/a11y"
"@gravity-ui/eslint-config/a11y",
"plugin:react/jsx-runtime"
],
"root": true,
"rules": {
Expand All @@ -15,8 +16,8 @@
"no-restricted-syntax": [
"error",
{
"selector": "ImportDeclaration[source.value='react'] :matches(ImportNamespaceSpecifier, ImportSpecifier)",
"message": "Please use import React from 'react' instead."
"selector": "ImportDeclaration[source.value='react'] :matches(ImportDefaultSpecifier, ImportSpecifier)",
"message": "Please use `import * as React from 'react'` instead."
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using React namespace is our codestyle. So import * as React from 'react' should be the only option.
To accomplish this, change the rule to:

{
    "selector": "ImportDeclaration[source.value='react'] :matches(ImportDefaultSpecifier, ImportSpecifier)",
    "message": "Please use `import * as React from 'react'` instead."
}

{
"selector": "TSTypeReference>TSQualifiedName[left.name='React'][right.name='FC']",
Expand Down
2 changes: 0 additions & 2 deletions .storybook/decorators/withLang.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import type {Decorator} from '@storybook/react';

import {configure} from '../../src';
Expand Down
2 changes: 0 additions & 2 deletions .storybook/decorators/withMobile.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import type {Decorator} from '@storybook/react';

import {MobileProvider} from '../../src';
Expand Down
2 changes: 1 addition & 1 deletion .storybook/decorators/withStrictMode.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';

import type {Decorator} from '@storybook/react';

Expand Down
2 changes: 0 additions & 2 deletions .storybook/decorators/withTheme.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import type {Decorator} from '@storybook/react';

import {ThemeProvider} from '../../src';
Expand Down
2 changes: 1 addition & 1 deletion .storybook/theme-addon/register.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';

import type {API} from '@storybook/manager-api';
import {addons, types, useGlobals} from '@storybook/manager-api';
Expand All @@ -23,6 +23,6 @@
const [{theme}] = useGlobals();
React.useEffect(() => {
api.setOptions({theme: themes[getThemeType(theme)]});
}, [theme]);

Check warning on line 26 in .storybook/theme-addon/register.tsx

View workflow job for this annotation

GitHub Actions / Verify Files

React Hook React.useEffect has a missing dependency: 'api'. Either include it or remove the dependency array
return null;
}
2 changes: 0 additions & 2 deletions playwright/core/mountFixture.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import type {MountFixture, PlaywrightFixture} from './types';

export const mountFixture: PlaywrightFixture<MountFixture> = async ({mount: baseMount}, use) => {
Expand Down
2 changes: 1 addition & 1 deletion playwright/core/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type React from 'react';
import type * as React from 'react';

import type {MountOptions, MountResult} from '@playwright/experimental-ct-react';
import type {
Expand Down
2 changes: 0 additions & 2 deletions playwright/playwright/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import {beforeMount} from '@playwright/experimental-ct-react/hooks';

import {ToasterProvider} from '../../src/components/Toaster';
Expand Down
2 changes: 1 addition & 1 deletion src/components/ActionTooltip/ActionTooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import React from 'react';
import * as React from 'react';

import {useForkRef} from '../../hooks';
import {useTooltipVisible} from '../../hooks/private';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import type {StoryFn} from '@storybook/react';

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

import userEvent from '@testing-library/user-event';

import {createEvent, fireEvent, render, screen} from '../../../../test-utils/utils';
Expand Down
2 changes: 0 additions & 2 deletions src/components/ActionsPanel/ActionsPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use client';

import React from 'react';

import {Xmark} from '@gravity-ui/icons';

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

import type {Meta, StoryObj} from '@storybook/react';

import {ActionsPanel} from '../../ActionsPanel';
Expand Down
2 changes: 0 additions & 2 deletions src/components/ActionsPanel/__stories__/actions.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import {ChevronDown, Files, PencilToSquare, TrashBin} from '@gravity-ui/icons';

import type {ActionsPanelProps} from '../../ActionsPanel';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import React from 'react';
import * as React from 'react';

import {Ellipsis} from '@gravity-ui/icons';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import React from 'react';
import * as React from 'react';

import type {ActionsPanelItem} from '../../types';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import React from 'react';
import * as React from 'react';

import {useDirection} from '../../../theme';

Expand Down
2 changes: 0 additions & 2 deletions src/components/Alert/Alert.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import userEvent from '@testing-library/user-event';

import {render, screen} from '../../../test-utils/utils';
Expand Down
2 changes: 0 additions & 2 deletions src/components/Alert/Alert.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import {Xmark} from '@gravity-ui/icons';

import {Button} from '../Button';
Expand Down
2 changes: 0 additions & 2 deletions src/components/Alert/AlertAction.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use client';

import React from 'react';

import {Button} from '../Button';

import type {AlertActionProps} from './types';
Expand Down
2 changes: 0 additions & 2 deletions src/components/Alert/AlertActions.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use client';

import React from 'react';

import {Flex} from '../layout';

import {AlertAction} from './AlertAction';
Expand Down
2 changes: 1 addition & 1 deletion src/components/Alert/AlertContext.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';

import type {AlertContextType} from './types';

Expand Down
2 changes: 0 additions & 2 deletions src/components/Alert/AlertContextProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use client';

import React from 'react';

import {AlertContext} from './AlertContext';
import type {AlertContextProviderProps} from './types';

Expand Down
2 changes: 1 addition & 1 deletion src/components/Alert/AlertIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type * as React from 'react';

import {
CircleCheck,
Expand Down
2 changes: 0 additions & 2 deletions src/components/Alert/AlertTitle.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import {Text} from '../Text';

import {bAlert} from './constants';
Expand Down
2 changes: 0 additions & 2 deletions src/components/Alert/__stories__/Alert.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import {Gear} from '@gravity-ui/icons';
import {action} from '@storybook/addon-actions';
import type {Meta, StoryObj} from '@storybook/react';
Expand Down
2 changes: 0 additions & 2 deletions src/components/Alert/__tests__/Alert.visual.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import {smokeTest, test} from '~playwright/core';

import {createSmokeScenarios} from '../../../stories/tests-factory/create-smoke-scenarios';
Expand Down
2 changes: 0 additions & 2 deletions src/components/Alert/__tests__/cases.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import type {Cases, CasesWithName} from '../../../stories/tests-factory/models';
import {Alert} from '../Alert';
import type {AlertProps} from '../types';
Expand Down
2 changes: 1 addition & 1 deletion src/components/Alert/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type React from 'react';
import type * as React from 'react';

import type {ButtonProps} from '../Button';
import type {QAProps} from '../types';
Expand Down
2 changes: 1 addition & 1 deletion src/components/Alert/useAlertContext.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import React from 'react';
import * as React from 'react';

import {AlertContext} from './AlertContext';

Expand Down
2 changes: 0 additions & 2 deletions src/components/ArrowToggle/ArrowToggle.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import {ChevronDown} from '@gravity-ui/icons';

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

import type {Meta, StoryFn} from '@storybook/react';

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

import type {Meta, StoryFn} from '@storybook/react';

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

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

import {smokeTest, test} from '~playwright/core';

import {createSmokeScenarios} from '../../../stories/tests-factory/create-smoke-scenarios';
Expand Down
2 changes: 1 addition & 1 deletion src/components/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';

import {block} from '../utils/cn';

Expand Down
2 changes: 0 additions & 2 deletions src/components/Avatar/AvatarIcon/AvatarIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import {Icon} from '../../Icon';
import type {AvatarSize} from '../types/common';

Expand Down
2 changes: 1 addition & 1 deletion src/components/Avatar/AvatarImage/AvatarImage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import React from 'react';
import * as React from 'react';

import {AVATAR_SIZES} from '../constants';

Expand Down
2 changes: 0 additions & 2 deletions src/components/Avatar/AvatarText/AvatarText.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import type {AvatarTextProps} from './types';
import {getAvatarDisplayText} from './utils';

Expand Down
2 changes: 1 addition & 1 deletion src/components/Avatar/__stories__/Avatar.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';

import {faker} from '@faker-js/faker/locale/en';
import {FaceRobot} from '@gravity-ui/icons';
Expand Down
2 changes: 0 additions & 2 deletions src/components/Avatar/__tests__/Avatar.visual.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import {expect} from '@playwright/experimental-ct-react';

import {test} from '~playwright/core';
Expand Down
2 changes: 1 addition & 1 deletion src/components/AvatarStack/AvatarStack.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';

import {block} from '../utils/cn';

Expand Down
2 changes: 1 addition & 1 deletion src/components/AvatarStack/AvatarStackItem.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type * as React from 'react';

import {block} from '../utils/cn';

Expand Down
2 changes: 1 addition & 1 deletion src/components/AvatarStack/AvatarStackMore.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';

import {DEFAULT_AVATAR_SIZE} from '../Avatar';
import {block} from '../utils/cn';
Expand Down
2 changes: 1 addition & 1 deletion src/components/AvatarStack/AvatarStackMoreButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';

import {DEFAULT_AVATAR_SIZE} from '../Avatar';
import {block} from '../utils/cn';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type * as React from 'react';

import {faker} from '@faker-js/faker/locale/en';
import type {Meta, StoryObj} from '@storybook/react';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import {test} from '~playwright/core';

import {AvatarStackStories} from './stories';
Expand Down
2 changes: 1 addition & 1 deletion src/components/AvatarStack/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type React from 'react';
import type * as React from 'react';

import type {AvatarSize} from '../Avatar';

Expand Down
2 changes: 1 addition & 1 deletion src/components/Breadcrumbs/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import React from 'react';
import * as React from 'react';

import _throttle from 'lodash/throttle';

Expand Down
2 changes: 1 addition & 1 deletion src/components/Breadcrumbs/BreadcrumbsButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type * as React from 'react';

import {block} from '../utils/cn';

Expand Down
2 changes: 1 addition & 1 deletion src/components/Breadcrumbs/BreadcrumbsItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import React from 'react';
import * as React from 'react';

import {Link} from '../Link';
import {block} from '../utils/cn';
Expand Down
2 changes: 0 additions & 2 deletions src/components/Breadcrumbs/BreadcrumbsMore.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use client';

import React from 'react';

import {DropdownMenu} from '../DropdownMenu';
import {block} from '../utils/cn';

Expand Down
2 changes: 0 additions & 2 deletions src/components/Breadcrumbs/BreadcrumbsSeparator.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import {block} from '../utils/cn';

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

import type {StoryFn} from '@storybook/react';

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

import {cn} from '../../utils/cn';
import {Breadcrumbs} from '../Breadcrumbs';
Expand Down
2 changes: 0 additions & 2 deletions src/components/Breadcrumbs/__tests__/Breadcrumbs.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import {render, screen} from '../../../../test-utils/utils';
import {Breadcrumbs} from '../Breadcrumbs';

Expand Down
Loading
Loading