babel / babel-eslint

:tokyo_tower: A wrapper for Babel's parser used for ESLint (renamed to @babel/eslint-parser)

Home Page:https://github.com/babel/babel/tree/main/eslint/babel-eslint-parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

filmic opened this issue · comments

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"
	]
};

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: babel/babel#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 babel/babel#9506.

Any fix..?

It has been fixed in babel/babel#10914 (Babel v7.8.0)