Skip to content

[Bug]: parserOptions.ecmaFeatures.jsx not set when using presets #3523

Closed

Description

Is there an existing issue for this?

  • I have searched the existing issues and my issue is unique
  • My issue appears in the command-line and not only in the text editor

Description Overview

When extending eslint configuration with "extends": ["plugin:react/recommended"], the parserOptions are not set to enable JSX support.

According to the README, parserOptions.ecmaFeatures.jsx should be set to true by all presets.

% cat .eslintrc.cjs
module.exports = {
  parserOptions: {
    ecmaVersion: "latest",
    sourceType: "module"
  },
  extends: [
    "eslint:recommended",
    "plugin:react/all"
  ],
  settings: {
    react: {
      version: "detect"
    }
  }
}

% npx eslint --print-config somefile.js | jq .parserOptions
{
  "ecmaVersion": "latest",
  "sourceType": "module"
}

This property not being set breaks parsing of JavaScript files containing JSX.

Expected Behavior

According to the documentation:

Note: These configurations will import eslint-plugin-react and enable JSX in parser options.

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:

% npx eslint --print-config somefile.js | jq .parserOptions
{
  "ecmaVersion": "latest",
  "sourceType": "module",
  "ecmaFeatures": {
    "jsx": true
  }
}

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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