Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

const inside switch case statement is a syntax error #1805

Closed
dmnd opened this issue Feb 8, 2015 · 11 comments
Closed

const inside switch case statement is a syntax error #1805

dmnd opened this issue Feb 8, 2015 · 11 comments
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion blocked This change can't be completed until another issue is resolved bug ESLint is working incorrectly core Relates to ESLint's core APIs and features

Comments

@dmnd
Copy link

dmnd commented Feb 8, 2015

Maybe a bug with ES 6 block bindings?

$ eslint -v
v0.14.1


$ eslint -c .eslintrc test.js 

test.js
  4:7  error  Unexpected token const

✖ 1 problem (1 error, 0 warnings)


$ cat test.js 
function fn(foo) {
  switch (foo) {
    case "foo":
      const bar = "bar";
      break;
  }
}


$ cat .eslintrc 
env:
  browser: true,
  node: true

ecmaFeatures:
  blockBindings: true
@nzakas nzakas added accepted There is consensus among the team that this change meets the criteria for inclusion blocked This change can't be completed until another issue is resolved bug ESLint is working incorrectly core Relates to ESLint's core APIs and features labels Feb 8, 2015
@nzakas
Copy link
Member

nzakas commented Feb 8, 2015

This is a parser error, would you mind filing this at https://github.com/eslint/Espree/issues

@steelbrain
Copy link

@nzakas I am still getting this error, here's some minimal repro code

module.exports = function(a){
  a.somethin = function(){
    let c = ""
  }
}

@michaelficarra
Copy link
Member

@steelbrain What? Your code doesn't include const or switch.

@steelbrain
Copy link

@michaelficarra it does include a let I was referred to this issue from #1834

@michaelficarra
Copy link
Member

The original error was

Unexpected token const

Is that the error you see? The error was also triggered by interaction with switch. Do you have a switch?

@steelbrain
Copy link

The error I see is Unexpected token let, You can find out more using the repro example above.

@WA9ACE
Copy link

WA9ACE commented Aug 3, 2015

I just had this error as well.

screen shot 2015-08-02 at 11 33 59 pm

@ilyavolodin
Copy link
Member

@C0deMaver1ck Can you share your .eslintrc file please?

@WA9ACE
Copy link

WA9ACE commented Aug 3, 2015

The previous screenshot was without one. When I used this:

env:
  browser: true,
  node: true

ecmaFeatures:
  blockBindings: true

I got

src/main.js
  3:27  error  Unexpected token >

✖ 1 problem (1 error, 0 warnings)

@IanVS
Copy link
Member

IanVS commented Aug 3, 2015

What version are you using? If you're on 1.0.0, there is likely an .eslintrc file somewhere up the directory structure, or possibly in your ~/. Without some kind of eslint configuration, ESLint will do nothing in version 1.0.0.

@mysticatea
Copy link
Member

@C0deMaver1ck You are using arrow functions, so need arrowFunctions: true in ecmaFeatures section. Or...

env:
  browser: true
  node: true
  es6: true

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 7, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion blocked This change can't be completed until another issue is resolved bug ESLint is working incorrectly core Relates to ESLint's core APIs and features
Projects
None yet
Development

No branches or pull requests

8 participants