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

fix(#185): add langaugeOptions.parserOptions to flat preset / read sourceType w/ fallback #186

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

SukkaW
Copy link
Collaborator

@SukkaW SukkaW commented Nov 19, 2024

Fixes #185

Copy link

codesandbox-ci bot commented Nov 19, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Copy link

changeset-bot bot commented Nov 19, 2024

🦋 Changeset detected

Latest commit: 1c200bf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-plugin-import-x Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

codecov bot commented Nov 19, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 96.12%. Comparing base (e01dce0) to head (ed2126e).
Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
src/utils/source-type.ts 75.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #186      +/-   ##
==========================================
+ Coverage   96.09%   96.12%   +0.03%     
==========================================
  Files         101      102       +1     
  Lines        4688     4700      +12     
  Branches     1613     1619       +6     
==========================================
+ Hits         4505     4518      +13     
+ Misses        177      174       -3     
- Partials        6        8       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@vladshcherbin
Copy link

@SukkaW is it the right fix though?

I'm actually not using any recommended presets with different plugins (e.g. import plugin). They don't give any errors if I don't set languageOptions manually and just use default ones (ecmaVersion, sourceType, parserOptions, etc)

There must be some way the plugin to just use default ones from eslint 🤔

@SukkaW
Copy link
Collaborator Author

SukkaW commented Nov 19, 2024

@SukkaW is it the right fix though?

I'm actually not using any recommended presets with different plugins (e.g. import plugin). They don't give any errors if I don't set languageOptions manually and just use default ones (ecmaVersion, sourceType, parserOptions, etc)

There must be some way the plugin to just use default ones from eslint 🤔

The PR not only changes the default config presets but also changes how the sourceType is read from the eslint context.

@SukkaW SukkaW changed the title fix(#185): add langaugeOptions.parserOptions to flat preset fix(#185): add langaugeOptions.parserOptions to flat preset / read sourceType w/ fallback Nov 19, 2024
@vladshcherbin
Copy link

@SukkaW perfect! Sorry I've somehow missed the second part of update 😅 Will happily switch from import to import-x once the error is resolved. Thank you!

@SukkaW
Copy link
Collaborator Author

SukkaW commented Nov 19, 2024

@SukkaW perfect! Sorry I've somehow missed the second part of update 😅 Will happily switch from import to import-x once the error is resolved. Thank you!

@vladshcherbin In the meantime, you could try out import-x first, and patch your node_modules with the changes from this PR, to validate if my PR has fixed the issue or not! If the issue still persists, the reproduction would be much appreciated!

@JounQin
Copy link
Member

JounQin commented Nov 19, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

There is no need to patch to try out this PR, you can just try using CodeSandbox CI's preview artifacts.

@vladshcherbin
Copy link

vladshcherbin commented Nov 19, 2024

@SukkaW I've tried by patching - the error is still there.

I've also added console.log to current/this version in utils/source-type function to double check and it didn't show anything - I believe it's not even executed in my sample reproduction for some reason. The file is loaded though

Current 4.4.2 reproduction recording
Screen.Recording.2024-11-19.at.13.21.38.mov

reproduction is the same - https://github.com/vladshcherbin/eslint-import

@vladshcherbin
Copy link

@SukkaW The rule which gives the error is namespace - sourceType function is not used there. If I turn off this rule - the error is gone ✨

@SukkaW SukkaW marked this pull request as draft November 20, 2024 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sourceType 'module' is not supported when ecmaVersion < 2015
3 participants