clutchski/coffeelint

Regression: version 1.16.0 fails with Undefined identifier of variables in for loops

Closed this issue · 4 comments

Hi.

Seems that there is a regression on latest release on for loops. The variable created in for x in something seems not to add the symbol to the scope. I'm using coffeescope2 but it has not been updated recently, plus the problem occurs as soon as coffeelint gets updated.

It is possible that the problem is being the two projects being out of sync.

With previous version:

image

image

With newest version

image

image

Workaround

in coffeelint.json configuring

check_scope: {
    undefined: false
}
swang commented

i can't really figure out anything without an actual code snippet that shows the problem but i'm guessing this is something coffeescope2 has to fix. i'm using 1.11.1 and a for x loop i still see x showing up in coffee-script as an identifier.

Here is an example that fails

for file in files
    do (file) ->
        console.log(file)

and here is the error:

./node_modules/.bin/coffeelint -f src/js/coffeelint.json test.coffee
  ✗ test.coffee
     ✗ #2: Undefined identifier "file".

✗ Lint! » 1 error and 0 warnings in 1 file

note that removing the do causes the error to go away... in that case.

swang commented

See: za-creature/coffeescope#29

This is most likely a coffeescope issue that they need to address with the new release of coffee-script. My suggestion is to pin to coffeelint 1.15.x until he fixes it.

coffeescope regression has been fixed and the tests pass, but there's probably heaps of other small incompatibilities that I've missed as the fix has been a bit too easy. Also, es6-style imports / exports aren't yet supported (though I'm working on them as we speak)

@swang feel free to @ me if you ever receive scope errors on this repo; I would've fixed this sooner, but github didn't notify me for the issue mention