I'm getting following error:
Parsing error: params is not iterable
while linting a file with a private instance method.
Using:
@babel/[email protected]
@babel/[email protected]
@babel/[email protected]
[email protected]
[email protected]
test.js (linted file):
class Person {
#age = 19;
#increaseAge() {
this.#age++;
}
birthday() {
this.#increaseAge();
alert("Happy Birthday!");
}
}
.eslintrc.js:
module.exports = {
"parser": "babel-eslint",
};
babel.config.js:
module.exports = {
presets: [],
plugins: [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-private-methods"
]
};
I'm also experiencing the same issue. I got around it temporarily by using arrow functions instead:
#increaseAge = () => {
this.#age++;
}
Actually, with the arrow function syntax I get:
Unexpected 'this'. (babel/no-invalid-this)
After digging, I found this related issue: https://github.com/babel/babel/issues/9506
The issue in Babel (babel/babel#9506) is blocked by estree/estree#180.
I can confirm this:
"@babel/plugin-proposal-class-properties": "^7.3.4",
"@babel/plugin-proposal-private-methods": "^7.3.4",
"eslint": "5.15.1",
"babel-eslint": "11.0.0-beta.0"
I also second this:
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-proposal-private-methods": "^7.6.0",
"eslint": "6.1.0",
"babel-eslint": "11.0.0-beta.0"
This is caused by https://github.com/babel/babel/issues/9506.
Any fix..?
It has been fixed in https://github.com/babel/babel/pull/10914 (Babel v7.8.0)
Most helpful comment
I can confirm this: