-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[utils] [fix] parse
: espree parser isn't working with flat config
#3061
[utils] [fix] parse
: espree parser isn't working with flat config
#3061
Conversation
This change addresses an issue with using the espree parser with flat config. `keysFromParser` is responsible for finding the `visitorKeys` from a combination of the parser instance, parserPath, and the results of a call to `parseForESLint`. When using flat config, the `parserPath` will not be on the context object., and there are no results from `parseForESLint`. The espree parser _does_ provide visitor keys as a prop on the parser itself. However, this logic was only returning it when it found that "espree" was somewhere in the `parserPath` (which doesn't exist on flat config). I changed it so that it first does the check for the old-school babel parser using parser path, and then just checks the parser instance for the presence of `VisitorKeys`, rather than using parserPath at all. The reason for the re-order is that if the old babel-eslint parser, for some reason has `VisitorKeys`, having the new condition first, would change the behavior.
Thinking i should maybe revert the addition of |
fwiw this doesn't seem to have changed or improved anything in my local samples or in #2996 |
Yeah, like I mentioned here #2996 (comment) this will need more work for the v9 tests, due to how the v9 |
I've pushed up https://github.com/G-Rath/eslint-plugin-import-debugging - |
I just added the equivalent test to the legacy and flat examples in this repo and they're both reporting error for |
f8565f4
to
3829bd7
Compare
I don't follow - are you saying that with my repository you're getting |
I wanted to test with this branch, so I just recreated the test in the existing examples here, and yes, it's detecting |
sorry for the doubt but I want to be extra clear since that doesn't match my results locally - you're saying with a fresh clone of https://github.com/G-Rath/eslint-plugin-import-debugging, running just Not saying it's not possible, but it's annoying (for me) if that is the case 😅 I assume I've got a local cache issue |
3829bd7
to
7c53e51
Compare
That wouldn't test it with this code change. Your repo is pulling the release version. Check out the examples folders. It's a very simple setup, just like yours. But it's testing this code. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3061 +/- ##
===========================================
+ Coverage 82.18% 94.92% +12.73%
===========================================
Files 93 82 -11
Lines 4136 3563 -573
Branches 1391 1251 -140
===========================================
- Hits 3399 3382 -17
+ Misses 737 181 -556 ☔ View full report in Codecov by Sentry. |
Sure but either way we need to establish a baseline - happy to have this conversation over on #2996 if you think it's confusing to have here, but either way my request is the same. fwiw I have applied your fix here to the repo manually and it didn't change the output. My whole point with that repo is it's a behaviour that does not seem to be being caught by the test suite, so making changes here is pretty moot because I would expect you to not have matching behaviour. I've now run my repo on two different laptops which give the same result (only legacy config gives |
It occured to me that the examples in this repo are both set up with the TS parser (oops)😅 So, i pulled your repo, and discovered the issue there. For one, I had to add both the changes from this PR and this PR: #3052 since it's not released yet. After doing that, it still wasn't reporting the error. But after debugging I found that the call to |
hmm ok that's interesting - something still seems off there to me. Pulling together a few things:
|
Ah, in that case you're right. I didn't see this blurb at the bottom of the page haha. We aren't passing It's interesting that they moved |
…ptions` This change adds `ecmaVersion` and `sourceType` to the options we're passing to the parsers, if they're present on `languageOptions` (which would only be the case for flat config).
5c91996
to
7a72c3f
Compare
Added a unit test to cover the |
7a72c3f
to
0642419
Compare
parse
: espree parser isn't working with flat config
This change addresses an issue with using the espree parser with flat config.
keysFromParser
is responsible for finding thevisitorKeys
from a combination of the parser instance, parserPath, and the results of a call toparseForESLint
. When using flat config, theparserPath
will not be on the context object, and when using the espree parser there are no results fromparseForESLint
. The espree parser does provide visitor keys as a prop on the parser itself. However, this logic was only returning it when it found that "espree" was somewhere in theparserPath
(which doesn't exist on flat config).I changed it so that it first does the check for the old-school babel parser using parser path, and then just checks the parser instance for the presence of
VisitorKeys
, rather than using parserPath at all. The reason for the re-order is that if the old babel-eslint parser, for some reason hasVisitorKeys
, having the new condition first, would change the behavior.