Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

jsx-fragments: allowFragment syntax option#3813

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
nicmosc wants to merge2 commits intojsx-eslint:master
base:master
Choose a base branch
Loading
fromnicmosc:patch-1

Conversation

nicmosc
Copy link

@nicmoscnicmosc commentedSep 2, 2024
edited
Loading

Description

Right now one can specify eithersyntax orelement, howeverelement automatically falls back to usingReact.Fragment which is not supported in the case the variable is not exposed as an UMD global - the case when using es modules.

This option allows to use modules instead and import theFragment component from the react library

Note: we need this behaviour for our team so we've patched the library with the same changes you see here for now.

Usage

'react/jsx-fragments': ['warn', 'elementShort'],

Showcase

Screen.Recording.2024-09-02.at.13.27.46.mov

Open to:

  • using a different option name instead ofelementShort e.g.module?
  • if there is a way to achieve this without modifying the rule OR there is a way to infer this from the project settings it's probably better - any ideas?

Right now one can specify either `syntax` or `element`, however `element` automatically falls back to using `React.Fragment` which is not supported in the case the variable is not exposed as an UMD global - the case when using es modules.This option allows to use modules instead and import the `Fragment` component from the react library
@ljharb
Copy link
Member

Historically, you’re required to have React in scope for jsx to work, so this never came up until the new jsx renderer in React 17.

However, in a modern codebase, why wouldn’t you always prefer the syntax?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@nicmosc@ljharb

[8]ページ先頭

©2009-2025 Movatter.jp