question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected Identifier

See original GitHub issue

I am using eslint extension along with prettier for vscode.

In my react components, when I type a function name, as I’m typing, the error image from the 2nd screenshot constantly pops up. So for n letters I type, the popup shows up n times.

handleChange() {}

Does not happen if all functions are written like the above.

handleChange = () => {}

Error constantly pops up if I have functions written in this format. (but I want to write it in this format)

screen shot 2017-12-18 at 4 37 52 pm screen shot 2017-12-18 at 4 38 02 pm

My eslintrc file setup like the following

{
  "extends": [
    "standard",
    "plugin:flowtype/recommended",
    "plugin:react/recommended",
    "prettier",
    "prettier/flowtype",
    "prettier/react",
    "prettier/standard"
  ],
  "plugins": [
    "flowtype",
    "react",
    "prettier",
    "standard"
  ],
  "parserOptions": {
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true
    }
  },
  "env": {
    "es6": true,
    "node": true
  },
  "rules": {
    "prettier/prettier": "error"
  }
}

Any idea what could be wrong?

Thanks

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dbaeumercommented, Dec 18, 2017

I tries to running eslint from the command line and here is what I get:

Unexpected identifier (15:3)
  13 |   too
  14 |
> 15 |   handleChange = (e: SyntheticEvent<HTMLInputElement>) => {
     |   ^^^^^^^^^^^^
  16 |     this.setState({ [e.currentTarget.value]: e.currentTarget.value })
  17 |   }
  18 |   render() {
SyntaxError: Unexpected identifier (15:3)
  13 |   too
  14 |
> 15 |   handleChange = (e: SyntheticEvent<HTMLInputElement>) => {
     |   ^^^^^^^^^^^^
  16 |     this.setState({ [e.currentTarget.value]: e.currentTarget.value })
  17 |   }
  18 |   render() {
    at createError$1 (P:\mseng\VSCode\Playgrounds\bugs\eslint\test-eslint-prettier-standard\node_modules\prettier\parser-flow.js:1:183)
    at parse (P:\mseng\VSCode\Playgrounds\bugs\eslint\test-eslint-prettier-standard\node_modules\prettier\parser-flow.js:1:902)
    at Object.parse$1 [as parse] (P:\mseng\VSCode\Playgrounds\bugs\eslint\test-eslint-prettier-standard\node_modules\prettier\index.js:5837:12)
    at formatWithCursor (P:\mseng\VSCode\Playgrounds\bugs\eslint\test-eslint-prettier-standard\node_modules\prettier\index.js:27654:22)
    at format (P:\mseng\VSCode\Playgrounds\bugs\eslint\test-eslint-prettier-standard\node_modules\prettier\index.js:27697:10)
    at Object.format (P:\mseng\VSCode\Playgrounds\bugs\eslint\test-eslint-prettier-standard\node_modules\prettier\index.js:27936:12)
    at Program (P:\mseng\VSCode\Playgrounds\bugs\eslint\test-eslint-prettier-standard\node_modules\eslint-plugin-prettier\eslint-plugin-prettier.js:374:45)
    at listeners.(anonymous function).forEach.listener (P:\mseng\VSCode\Playgrounds\bugs\eslint\test-eslint-prettier-standard\node_modules\eslint\lib\util\safe-emitter.js:47:58)
    at Array.forEach (<anonymous>)
    at Object.emit (P:\mseng\VSCode\Playgrounds\bugs\eslint\test-eslint-prettier-standard\node_modules\eslint\lib\util\safe-emitter.js:47:38)
    at NodeEventGenerator.applySelector (P:\mseng\VSCode\Playgrounds\bugs\eslint\test-eslint-prettier-standard\node_modules\eslint\lib\util\node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (P:\mseng\VSCode\Playgrounds\bugs\eslint\test-eslint-prettier-standard\node_modules\eslint\lib\util\node-event-generator.js:280:22)
    at NodeEventGenerator.enterNode (P:\mseng\VSCode\Playgrounds\bugs\eslint\test-eslint-prettier-standard\node_modules\eslint\lib\util\node-event-generator.js:294:14)
    at CodePathAnalyzer.enterNode (P:\mseng\VSCode\Playgrounds\bugs\eslint\test-eslint-prettier-standard\node_modules\eslint\lib\code-path-analysis\code-path-analyzer.js:608:23)
    at Traverser.enter (P:\mseng\VSCode\Playgrounds\bugs\eslint\test-eslint-prettier-standard\node_modules\eslint\lib\linter.js:956:32)
    at Traverser.__execute (P:\mseng\VSCode\Playgrounds\bugs\eslint\test-eslint-prettier-standard\node_modules\estraverse\estraverse.js:397:31)

You need to put too in the file where you indicated and then run eslint from the terminal (e.g. .\node_modules\.bin\eslint index.js. This looks like a ESLint problem to me. Can you please report it there.

0reactions
sambigelowcommented, Jan 28, 2018

I am having an issue with this as well. I would love it if I could just turn off notifications from vscode-eslint. Is there any way to do that? I still want the squiggly lines, just not the popup notifications.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unexpected Identifier in Chrome's Javascript console
I got this error Unexpected identifier because of a missing semi-colon ; at the end of a line. Anyone wandering here for other...
Read more >
Unexpected identifier Error in JavaScript | bobbyhadz
The "Uncaught SyntaxError: Unexpected identifier" error occurs for 2 main reasons: · You can paste your code into an online Syntax Validator.
Read more >
How To Solve The Unexpected Identifier Error in JavaScript
How do you fix this Unexpected identifier error in your code? The simplest thing you can do to find a specific error like...
Read more >
A Common Cause of "Uncaught syntax error - Techstacker
Uncaught SyntaxError: Unexpected identifier. One of the most common reasons is that you're trying to mutate (change) a const variable.
Read more >
SyntaxError: Unexpected identifier - Codecademy
SyntaxError: Unexpected identifier. I'm trying to create a program which asks the user what they're favorite Big Ten team is, checks if that...
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