Parsing error: Unexpected character '#' (ES11)

See original GitHub issue

With this source code on VSCode:


class P {
	#p = 0;
	ppp() {
	  return this.#p;
	}
}

It does detect an error that shouldn’t be so in ES11:

Parsing error: Unexpected character '#'

My .eslintrc.json is:

{
    "env": {
        "browser": true,
        "node": true,
        "commonjs": true,
        "es2020": true
        //"es6": true
    },
    "extends": "eslint:recommended",
    "globals": {
        "Atomics": "readonly",
        "SharedArrayBuffer": "readonly"
    },
    "parserOptions": {
        "ecmaVersion": 11
    },
    "rules": {
    }
}

I have eslint installed globabally:

$ eslint --version
v6.8.0
$ node --version
v13.11.0
$ npm --version
6.14.4

VSCODE Version: 1.43.2

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
yeonjuancommented, Mar 29, 2020

@JavierRSobrino The private fields(#) proposal is in stage3, And the ESLint default parser didn’t support it now. So, as @anikethsaha mentioned, you can use other parsers (e.g.babel-eslint) to support it.

1reaction
ljharbcommented, Jul 11, 2020

@greggman stage 3 is when browsers ship; stage 4 is when it’s in the spec (after it’s been shipped in at least 2 impls). As unfortunate as it is, eslint doesn’t support anything until it’s in a spec document, even if it’s already shipped on the web.

Read more comments on GitHub >

github_iconTop Results From Across the Web

eslint - Parsing error: Unexpected character '#' while declaring ...
When using '#' to declare a private member in a javascript class, eslint throws an error Parsing error: Unexpected character '#' .
Read more >
Please help me fix this error Parse error - WordPress.org
Please help me fix this error Parse error: syntax error, unexpected character · 1. Download the latest version of WordPress CMS. · 2....
Read more >
JSHint Options Reference
This can lead to unexpected warnings/errors in when upgrading between minor versions of JSHint. This option is a short hand for the most...
Read more >
SonarJS fails parsing a file: Unexpected character '#'
This is because SonarJS relies on babel-eslint which fails to recognize the “@babel/plugin-proposal-class-properties” plugin properly and ...
Read more >
SyntaxError: JSON.parse: bad parsing - JavaScript | MDN
JSON.parse('[1, 2, 3, 4,]'); JSON.parse('{"foo": 1,}'); // SyntaxError JSON.parse: unexpected character // at line 1 column 14 of the JSON data
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found