-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[Bug]: parserOptions.ecmaFeatures.jsx not set when using presets #3523
Comments
I would suggest using the airbnb config, instead of the "recommended" config (which isn't actually recommended, because it's very out of date due to semver constraints). |
That said, it's currently set here: https://github.com/jsx-eslint/eslint-plugin-react/blob/master/configs/all.js#L29-L35 for the flat config, so we should also be setting it for the legacy config, assuming the flat config won't error on it. |
7.34.0: somehow this flat config only applies // @see https://eslint.org/docs/latest/use/configure/migration-guide#predefined-and-shareable-configs
import js from "@eslint/js";
import reactRecommended from "eslint-plugin-react/configs/recommended.js";
export default [
js.configs.recommended,
// reactRecommended, // `languageOptions.parserOptions.ecmaFeatures.jsx` is set, but I don't want it as a global config objet?
{
files: ["apps/admin/**/*.{js,jsx}"],
...reactRecommended, // `languageOptions.parserOptions.ecmaFeatures.jsx` is missing.
},
]; |
That's likely because |
Yeah I suspected this being related after inspecting the code. For a new person, this distinction might be a bit confusing, because Lines 231 to 255 in 2e6b557
languageOptions manually to get jsx parsed.
"You probably want to" doesn't sound like "You really have to". |
That's true. I think long term we need separate entry points for flat config, and until we have those, this plugin should only be used with flat config in concert with eslint's flat compat wrapper. |
Is there an existing issue for this?
Description Overview
When extending eslint configuration with
"extends": ["plugin:react/recommended"]
, theparserOptions
are not set to enable JSX support.According to the README,
parserOptions.ecmaFeatures.jsx
should be set totrue
by all presets.This property not being set breaks parsing of JavaScript files containing JSX.
Expected Behavior
According to the documentation:
But using the presets (all and recommended) do not set this property.
It used to work in v7.31.11 but is broken in v7.32.1, which is actually tagged "latest" on npmjs.
With v7.31.11, the example in the overview above yields this result:
and eslint works fine with files containing JSX.
eslint-plugin-react version
v7.32.1
eslint version
v8.32.0
node version
v18.13.0
The text was updated successfully, but these errors were encountered: