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.

From @pronebird on February 8, 2017 12:34

Hi,

I use babel-eslint 7.1.1. and I see syntax issue with the following piece in my JSX:

<button onClick={::this.handleLogin}>Log In</button>

It points at :: and says that “expression expected”

My .eslintrc:

{
  "extends": [
    "eslint:recommended", 
    "plugin:react/recommended"
  ],
  "parser": "babel-eslint",
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true,
      "modules": true
    }
  },
  "plugins": [ "react" ], 
  "rules": {
    "indent": [ 2, 2 ],
    "quotes": [ 2, "single" ],
    "linebreak-style": [ 2, "unix" ],
    "semi": [ 2, "always" ],
    "no-console": [ 0 ],
    "no-loop-func": [ 0 ],
    "new-cap": [ 0 ],
    "no-trailing-spaces": [ 0 ],
    "no-param-reassign": [ 0 ],
    "func-names": [ 0 ],
    "comma-dangle": [ 0 ],
    "no-unused-expressions" : [ 0 ], // until fixed https://github.com/babel/babel-eslint/issues/158
    "block-scoped-var": [ 0 ], // until fixed https://github.com/eslint/eslint/issues/2253
    "react/prop-types": [ 0 ]
  },
  "env": {
    "es6": true,
    "node": true,
    "browser": true,
    "mocha": true
  }
}

ESLint works as expected and does not produce warnings:

eslint --no-ignore scripts app test *.js

Copied from original issue: Microsoft/vscode#20198

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
dmytrokyrychukcommented, May 11, 2017

I just noticed that vscode-eslint extension does not emit the “Expression expected” message!

selection_297

As a workaround I can suggest to disable JavaScript validation by putting the following into your user or workspace config:

"javascript.validate.enable": true

I think vscode uses TypeScript for JS (because the javascript.validate.enable option is listed under TypeScript section in settings). If this is true, JS validation may be enabled back once Microsoft/TypeScript/issues/3508 is resolved.

3reactions
dbaeumercommented, Mar 1, 2017

@pronebird I am able to reproduce but I have no idea why this is happening. The ESLint extension actually uses the eslint npm module to do the actual validation. I don’t know why it behaves different when running outside from the command line version inside VS Code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is linting and how can it save you time? - freeCodeCamp
Simply put, a linter is a tool that programmatically scans your code with the goal of finding issues that can lead to bugs...
Read more >
What is "Linting"? - Stack Overflow
Linting is a process by a linter program that analyzes source code in a particular programming language and flag potential problems like ...
Read more >
Linting - Developer Experience Knowledge Base
Lint, or a Linter, is a very useful tool for automated analyzing of your source code to look for bugs and stylistic errors....
Read more >
Lint Code: What Is Linting + When To Use Lint Tools - Perforce
Linting is the process of checking code for programmatic and stylistic errors. Learn how to easily use lint programming and lint tools (also ......
Read more >
Linting tools to identify and fix code mistakes - IBM
Linting is the process of performing static analysis on source code to flag patterns that might cause errors or other problems. As an...
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