vulcan-next
vulcan-next copied to clipboard
Detect unimported "React" global
Next does some magic that makes the iconic import React from "react" optional.
But... that barely works with 3rd party tools, that will cringe when they encounter JSX with React not present as a global (it make sense, as built code will massively rely on the React global under the hood).
Repro branch: "bugfix/jest-optional-react-import"
Steps to solve
- [ ] Decide whether we keep React standard behaviour (import React mandatory in JSX/TSX) or Next standard behaviour (import React optional)
- [ ] if we prefer Next manage to make this import optional in Jest, Storybook, Cypress
- [ ] if we prefer React show a warning when React is not imported in Next
https://github.com/vercel/next.js/discussions/13528
It's possible to alter the eslint config using an override:
{
"files": [
/* test files for example */
],
"rules": { "react/react-in-jsx-scope": "off" }
Nowadays Next.js brings Jest support out of the box, we need to handle that