Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

11.0.0-beta.2 - Private method is not defined. (eslintno-undef) #826

Closed
sKopheK opened this issue Mar 30, 2020 · 7 comments
Closed

11.0.0-beta.2 - Private method is not defined. (eslintno-undef) #826

sKopheK opened this issue Mar 30, 2020 · 7 comments

Comments

@sKopheK
Copy link

sKopheK commented Mar 30, 2020

Hello,
I'm using experimental implementation of babel's private methods proposal and getting following error:

'setType' is not defined (no-undef)

for the following linted file:

export default class Ship {
  #type = null;

  constructor(type) {
    this.#setType(type);
  }

  #setType(type) {        // error raised on this line
    this.#type = type;
  }
}

Config files:

package.json - devDependencies (more dependencies included as I'm using NeutrinoJS):

...
"@babel/plugin-proposal-private-methods": "^7.8.3",
"babel-eslint": "^11.0.0-beta.2",
"eslint": "^6.8.0",
...

.eslintrc.js

module.exports = {
    ...
    "parser": "babel-eslint",
    ...
};

babel.config.js (actually have more presents and plugins, but the error persist even when omitted)

module.exports = {
    babelrc: false,
    presets: [],
    plugins: [
        ['@babel/plugin-proposal-class-properties', { loose: true }],
        ['@babel/plugin-proposal-private-methods', { loose: true }],
    ]
};

Furthermore, no linting occurs in the whole method marked as not defined.

@tirithen
Copy link

tirithen commented Apr 3, 2020

I'm getting the same issue, also it looks like any code within the private method is ignored so the linter thinks that imported methods used inside the private method is not used and asks me to remove the imports, which are needed.

private-methods-linter-issues

@seahindeniz
Copy link

I think this has discussed in here #746 but still there is no valid solution for the problem

@sKopheK
Copy link
Author

sKopheK commented May 7, 2020

I think this has discussed in here #746 but still there is no valid solution for the problem

tnx, I believe it's fixed, but waiting for next major Babel release according babel/babel#10752

@hadnet
Copy link

hadnet commented Jun 2, 2020

Same here. I don't believe this. I'm struggling with this private method since early 2019! Babel v8 completion is at 38%, so when we got this working properly?

@piranna
Copy link

piranna commented Jun 30, 2020

Is there any solution for that? Private methods are correctly working on babel, but workflow is blocked due to linter...

@fabis94
Copy link

fabis94 commented Jul 8, 2020

So we have to wait for Babel 8 to be out for this to be fixed? No workarounds available?

@JLHwung
Copy link
Contributor

JLHwung commented Jul 30, 2020

Fixed in @babel/eslint-parser 7.11.0, see https://babel.dev/blog/2020/07/13/the-state-of-babel-eslint#the-future for the renaming guide.

@JLHwung JLHwung closed this as completed Jul 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants