Skip to content

Crash for master branch when extending "plugin:react/all" in eslintrc #3461

@golopot

Description

@golopot
Contributor

In master branch of this plugin, extending plugin:react/all in eslintrc cause a crash. This bug comes from #3429.

Reproduction:

mkdir demo-config-bug
cd demo-config-bug
npm init --yes
npm i eslint jsx-eslint/eslint-plugin-react#master
touch a.js
echo '{"extends": ["plugin:react/all"]}' > .eslintrc.json
npx eslint .

Result:
Oops! Something went wrong! :(

ESLint: 8.25.0

Error: ESLint configuration in .eslintrc.json » plugin:react/all is invalid:
- Unexpected top-level property "languageOptions".

@jjangga0214

Activity

ljharb

ljharb commented on Oct 13, 2022

@ljharb
Member

Thanks for catching that. The hope was that we can use the same imports in both config systems.

ljharb

ljharb commented on Oct 13, 2022

@ljharb
Member

@golopot can you try changing node_modules/eslint-plugin-react/configs/all.js to add Object.defineProperty(module.exports, 'languageOptions', { enumerable: false }); as the last line, and try again?

I'm wondering if making it non-enumerable will "hide" it from the legacy config's validation.

golopot

golopot commented on Oct 13, 2022

@golopot
ContributorAuthor

@ljharb Adding that line fixed the bug.

ljharb

ljharb commented on Oct 14, 2022

@ljharb
Member

Thanks@

@jjangga0214 can you confirm that with that line added, the new config system still works?

added a commit that references this issue on Oct 17, 2022
611b9ee

57 remaining items

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ljharb@golopot

        Issue actions

          Crash for master branch when extending "plugin:react/all" in eslintrc · Issue #3461 · jsx-eslint/eslint-plugin-react