-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[Bug]: 'React' must be in scope when using JSXeslintreact/react-in-jsx-scope #3770
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
This is by design - you need to extend the |
Not sure by which design, since getting started section of ESLint results in this config, so they clearly didn't get the memo: import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";
import pluginReact from "eslint-plugin-react";
export default [
{files: ["./src/**/*.{js,mjs,cjs,ts,jsx,tsx}"]},
{languageOptions: { globals: globals.browser }},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
pluginReact.configs.flat.recommended,
]; And this instantly throws |
You’re reading the “flat config” section - read the entire readme from top down, without skipping anything, and you’ll see the section i also linked to directly in the previous comment. |
The part you link to specifically mentions legacy config which I instantly skipped because I use hot new ESLint 9 flat config. There is also no mention of "extending JSX runtime" in the flat config section. |
A PR to improve the documentation would always be appreciated. |
This assumes I know the source of the problem or is it the problem with the plugin or misconfiguration on ESLint config template. |
At this point, I'd assume you know :-) the jsx-runtime stuff in the eslintrc section should be repeated in the flat config section. The number of years is irrelevant; we haven't had a breaking change in well over twice that. If we do, we can change the default, but until then, this is how it has to work. |
Is there an existing issue for this?
Description Overview
The eslint rule I just created, react18, actually prompts you to introduce react at the top. This should be the default option, right?
Is this the rule intentional and I need to turn it off manually, or is there a problem with my configuration?
Expected Behavior
no error
eslint-plugin-react version
7.34.3
eslint version
^9.5.0
node version
v20.14.0
The text was updated successfully, but these errors were encountered: