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
[no-unused-vars] TypeError: Cannot read property 'type' of undefined
on first import
when having private methods
#13575
Comments
It seems could be somewhat related to #12584, but I'm not using Typescript, just only vanilla Javascript, I'm using Babel to transpile to older browser versions, no more. |
Thanks for the report! private fields (now class fields) are still in stage 3 and eslint only supports stage 4 features. So that's why the core eslint rules like The solution can be, Either the core rule has to be extended to a new rule from babel eslint plugin or needs to wait for the proposal to reach stage 4 and then implementing the support in eslint rules and the underlining parser/analyzers. |
I think it makes more sense to wait for stage 4... The idea of adding an overwrite rule in |
Actually eslint runs the rules that are mentioned in the config i.e for your config it is |
Make sense... then probably the best would be to wait until it gets to stage 4. At least I've been able to replace the deprecated packages for the new ones :-) |
I don't think this is happening on the import. ESLint prints the line where the currently traversed node starts, which is usually very helpful, but in the case of a crash in the |
It's crashing on private method params. This is reproducible with the following code: /*eslint no-unused-vars: ["error"]*/
class A {
#foo(p) {}
} I believe this is an issue with The main problem is: visitor keys for Because of that, ESLint doesn't set parent property on @piranna can you please open an issue in https://github.com/babel/babel repository? |
Just to note that per our policy about experimental features we do make changes in core rules to avoid crashes on stage 3 syntax:
However, this particular problem seems to be something that should be fixed in Anyway, I think this should be reported in the babel/babel repo. |
Make sense, probably that's what happening here.
Done at babel/babel#11972. |
Fix at babel/babel#11973 scheduled for Babel 7.11.4. |
Fix in |
Thanks for the info! We can keep this issue open to see if the new |
Checked on two different projects, I confirm |
Glad the issue is solved, thanks for the update! |
You are welcome :-) |
I seem to be having this issue, or something similar. But I'm not using I'm using I have a class that uses private properties (not private methods, I already was avoiding those because of lack of support in various tools). ESLint gives me this error:
Oddly, I never got this error in other files where I used private properties. But the error goes away if I rename all the private properties to make them not private, so I assume it's related. What could be causing this? My .eslintrc (minus the rules) is:
|
@adelespinasse that could be a different problem, can you please open a new bug report issue with a code example and other details? |
Ok, to my surprise, I've managed to make a fairly minimal-ish reproduction of the issue, reported separately here: #13994 |
Tell us about your environment
Environment Info:
Node version: v14.4.0
npm version: v6.14.5
Local ESLint version: v7.7.0 (Currently used)
Global ESLint version: Not found
What parser (default, Babel-ESLint, etc.) are you using?
@babel/eslint-parser
Please show your full configuration:
Configuration
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
I have updated
babel-eslint
to new@babel/eslint-parser
so I can make use of private methods (there was an error on previous ones that only allowed private properties). After doing so, I'm getting the error attached at the end.The code at
WebRtcPeerCore.js:30
isimport EventEmitter from 'events'
, and the failing repository is https://github.com/piranna/kurento-utils-js/blob/master/src/WebRtcPeerCore.js (there's another one, but it's company private). It only happen when changing any of the arrow functions set to a private property to be a private method, like this:What did you expect to happen?
Eslint parsing the file as normally does.
What actually happened? Please include the actual, raw output from ESLint.
Are you willing to submit a pull request to fix this bug?
Yes, I can write one with some guidance about what's the source of this error.
The text was updated successfully, but these errors were encountered: