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

parserOptions shouldn't be in recommended config #2868

Open
dword-design opened this issue Aug 30, 2023 · 7 comments · May be fixed by #2869
Open

parserOptions shouldn't be in recommended config #2868

dword-design opened this issue Aug 30, 2023 · 7 comments · May be fixed by #2869

Comments

@dword-design
Copy link

I think the parserOptions options are part of the ESLint config extending from eslint-plugin-import or they should be set to the latest ecmaVersion. Using the recommended config leads to errors parsing new JS features like optional chaining.

@ljharb
Copy link
Member

ljharb commented Aug 30, 2023

They definitely should be there, and if you want to set your own parserOptions, that would always be happening after extending configs, so it shouldn't cause any errors.

@jaydenseric
Copy link

jaydenseric commented Sep 1, 2023

No @ljharb he's right; it's incorrect to set parserOptions.sourceType to "module" for every linted file, including .cjs files which are always CJS and, if the project package.json has type set to "commonjs" (which is the default!) .js files are also CJS.

Less concerning, but setting ecmaVersion: 2018 also seems like it should not be the concern of this particular plugin as ecmaVersion relates to more things than just ESM syntax. Only the user configuring their project can know the intended ECMA version for their codebase. It's not good this plugin's recommended config downgrades an ECMA version higher than 2018 that may have been set by other ESLint configs.

@ljharb
Copy link
Member

ljharb commented Sep 1, 2023

Order of config extends matters, and the end user should be setting these things anyways.

Separately, i don’t recommend using the recommended config from any eslint plugin, including this one - semver constraints mean it’s almost always not in an ideal state. You should be using this plugin via the Airbnb config.

@ghost

This comment was marked as spam.

@ljharb

This comment was marked as resolved.

@ghost

This comment was marked as spam.

@ljharb

This comment was marked as spam.

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

Successfully merging a pull request may close this issue.

3 participants