Skip to content

Prefer destructured named imports in React instead default export #68

@gtkatakura

Description

@gtkatakura

Is your feature request related to a problem? Please describe.

React has a new release candidate with the New JSX Transform that says in the post that destructured named imports will be the preferred style to import code in React. Using named imports we can have tree shaking and more readability. I think we could have a rule to enforces this pattern for React.

Describe the solution you'd like

Create a lint rule for detects the use of React's functions that could be a named import (like React.createContext, React.useEffect, React.useMemo, etc) and notify an error (we could implement an auto-correction to named import based in update-react-imports or see another lint that maybe already do it)

** Maybe we can do it to some imports of TypeScript like React.FC, etc.

Describe alternatives you've considered

  • Create a eslint rule
  • Extra: create a script to run the update-react-imports through the repos of VTEX and opening a PR with these changes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions