babel / babel-eslint

:tokyo_tower: A wrapper for Babel's parser used for ESLint (renamed to @babel/eslint-parser)
https://github.com/babel/babel/tree/main/eslint/babel-eslint-parser
MIT License
2.96k stars 208 forks source link

11.0.0-beta.0 - Private Instance Methods - Parsing error: params is not iterable #749

Closed filmic closed 4 years ago

filmic commented 5 years ago

I'm getting following error: Parsing error: params is not iterable

while linting a file with a private instance method.

Using: @babel/core@7.2.2 @babel/plugin-proposal-class-properties@7.3.0 @babel/plugin-proposal-private-methods@7.3.2 babel-eslint@11.0.0-beta.0 eslint@5.13.0

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"
    ]
};
satazor commented 5 years ago

I'm also experiencing the same issue. I got around it temporarily by using arrow functions instead:

 #increaseAge = () => {
    this.#age++;
  }
satazor commented 5 years ago

Actually, with the arrow function syntax I get:

Unexpected 'this'. (babel/no-invalid-this)

satazor commented 5 years ago

After digging, I found this related issue: https://github.com/babel/babel/issues/9506

filmic commented 5 years ago

The issue in Babel (babel/babel#9506) is blocked by estree/estree#180.

IAmJulianAcosta commented 5 years ago

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"
sepehr commented 5 years ago

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"
kaicataldo commented 4 years ago

This is caused by https://github.com/babel/babel/issues/9506.

1nfility commented 4 years ago

Any fix..?

filmic commented 4 years ago

It has been fixed in https://github.com/babel/babel/pull/10914 (Babel v7.8.0)