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

feat: migrate to new JSX transform #2006

merged 31 commits into from
Dec 25, 2024

Conversation

u4aew
Copy link
Contributor

@u4aew u4aew commented Dec 21, 2024

Description

Added react-jsx to tsconfig.json | tsconfig.test.json, updated rules in .eslintrc, updated presets in .babelrc and removed React imports.

docs

issue: #2003

@gravity-ui-bot
Copy link
Contributor

Preview is ready.

@gravity-ui-bot
Copy link
Contributor

Visual Tests Report is ready.

.eslintrc Outdated
@@ -32,7 +28,8 @@
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
"@typescript-eslint/prefer-ts-expect-error": "error",
"@typescript-eslint/consistent-type-imports": ["error", {"prefer": "type-imports", "fixStyle": "separate-type-imports"}],
"complexity": "off"
"complexity": "off",
"react/react-in-jsx-scope": "off"
Copy link
Contributor

Choose a reason for hiding this comment

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

Guide also suggest react/jsx-uses-react

Copy link
Contributor

Choose a reason for hiding this comment

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

We can simply extend plugin:react/jsx-runtime which does the job. No need to off the rules here.

{
"selector": "ImportDeclaration[source.value='react'] :matches(ImportNamespaceSpecifier, ImportSpecifier)",
"message": "Please use import 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."
}

.babelrc Outdated
}
}
"sourceType": "unambiguous",
"presets": [
Copy link
Contributor

Choose a reason for hiding this comment

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

Please keep current preset order

.eslintrc Outdated
@@ -32,7 +28,8 @@
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
"@typescript-eslint/prefer-ts-expect-error": "error",
"@typescript-eslint/consistent-type-imports": ["error", {"prefer": "type-imports", "fixStyle": "separate-type-imports"}],
"complexity": "off"
"complexity": "off",
"react/react-in-jsx-scope": "off"
Copy link
Contributor

Choose a reason for hiding this comment

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

We can simply extend plugin:react/jsx-runtime which does the job. No need to off the rules here.

@amje amje merged commit 300a013 into gravity-ui:main Dec 25, 2024
6 checks passed
@amje
Copy link
Contributor

amje commented Dec 25, 2024

@u4aew Thanks for contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants