ricardofbarros / linter-js-standard

Atom linter plugin for JavaScript, using JavaScript Standard Style
https://atom.io/packages/linter-js-standard
MIT License
99 stars 48 forks source link

Using for-await syntax with Babel's stage-3 preset causes a linter error (even if the line is ignored) #148

Closed Klathmon closed 8 years ago

Klathmon commented 8 years ago

The exact code from my codebase that can cause the problem:

export default async function parseFileToObjectNew (readableStream) {
  const fileArray = []
  // eslint-disable-next-line
  for await (const line of parseFile(readableStream)) {
    fileArray.push(line)
  }
  return fileArray
}

I'm using a babel preset which includes this plugin. Trying to use various eslint-disable comments doesn't help anything, and it's not throwing anything to the atom developer console.

All can see is that every time I save or change anything in the file, an error that says the following is shown in the atom notifications:

Something bad happened
Cannot read property '0' of undefined

It goes away if I disable the standard plugin, and it happens with only the default plugins + standard installed.

Arcanemagus commented 8 years ago

Does this work on the command line? It's unlikely this is the fault of this package and not eslint / babel parser / transform-async-generator-functions.

Klathmon commented 8 years ago

Babel is successfully compiling it to ES5 code when run from the command line, if that's what you mean.

Edit: i'm dumb. You mean using standard from the command line. Let me go check real quick...

Klathmon commented 8 years ago

It does work correctly using the standard command from the command line. One thing I forgot to mention is that i'm using a custom "parser" for standard in the package.json:

  "standard": {
    "parser": "babel-eslint",
    "globals": [
      "describe",
      "it",
      "before",
      "after",
      "beforeEach",
      "afterEach"
    ]
  },
ricardofbarros commented 8 years ago

@Klathmon do you have checkStyleDevDependencies option ticked?

Klathmon commented 8 years ago

Yup

ricardofbarros commented 8 years ago

It could be that it's somehow using babel-eslint from linter-js-standard (black magic) instead of your local custom parser.

Could you update linter-js-standard, I've just dropped an updated version that updates all deps.

Klathmon commented 8 years ago

just pulled in the new update and that seems to have fixed this specific issue!

let me know if you want me to do anything specific on my machine to try and figure out why it decided to use the bundled version.