Open
Description
eslint-plugin-n version
17.10.2
What problem do you want to solve?
☝️ gives
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
even though the file is using .mjs
extension. After some digging I found the problem is this plugin's config which enforces languageOptions.sourceType: 'commonjs'
for all files. ESLint 9 already sets the sourceType correctly based on type
field in package.json
and file extensions (.js
/.cjs
/.mjs
), so there's no need for this plugin to configure this.
What do you think is the correct solution?
Don't set sourceType
in language options and let ESLint handle this instead... see this playground where I removed the field from the config object and then it works fine.
Participation
- I am willing to submit a pull request for this change.
Additional comments
Not sure if it's the same for ESLint 8.