Skip to content
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

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

Closed
golopot opened this issue Oct 13, 2022 · 4 comments
Closed

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

golopot opened this issue Oct 13, 2022 · 4 comments

Comments

@golopot
Copy link
Contributor

golopot commented Oct 13, 2022

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

@ljharb
Copy link
Member

ljharb commented Oct 13, 2022

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

@ljharb
Copy link
Member

ljharb commented Oct 13, 2022

@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
Copy link
Contributor Author

golopot commented Oct 13, 2022

@ljharb Adding that line fixed the bug.

@ljharb
Copy link
Member

ljharb commented Oct 14, 2022

Thanks@

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

@ljharb ljharb closed this as completed in 611b9ee Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants