clutchski/coffeelint

Problem with linting indentation between v0.11.0 and v0.12.1

Closed this issue · 7 comments

egel commented

I'm building a commercial app in coffee (using gulp, and gulp-coffeelint plugin) and during this week I've noticed that some linting problems occurred with indentation, which cause problem of building a whole project. I wish to emphasize that those lines are mark as wrong isn't changed since ;)

I mean time I've figured out that that is not a problem of gulp plugin (gulp-coffeelint) due to the fact that its version isn't changed only its dependency (version of coffeelint)

To temporary solve this problem I need to add peerDependency section to my package.json file like this presented below:

"peerDependency": {
    "coffeelint": "^1.11.0"
},

Below I paste few lines of error log section from gulp for further maintenance. The strange thing is that the indentation is negative with enormous numbers like -28,-39,-44, ...

app/app.coffee
  ✖  line 291  Line contains inconsistent indentation  Expected 2 got -28

✖ 1 error

[13:36:35] Finished 'copy-assets' after 5.46 s

[13:36:38] Finished 'build-styles' after 7.65 s

app/forgot-password/request/remind-request.coffee
  ✖  line 28  Line contains inconsistent indentation  Expected 2 got -39

✖ 1 error


app/forgot-password/reset/reset.coffee
  ✖  line 27  Line contains inconsistent indentation  Expected 2 got -44

✖ 1 error


app/industries/list/industries-list.coffee
  ✖  line 28  Line contains inconsistent indentation  Expected 2 got -39

✖ 1 error


app/profile/public/public-profile.coffee
  ✖  line 44  Line contains inconsistent indentation  Expected 2 got 1

Hope it helps.

+1

The Grunt and Gulp plugins must be specifying the dev dependency with auto upgrade.

swang commented

Hi, sorry about that. Can you paste the actual code where those errors are being generated? Or have a minimum use case that shows the problem?

+1

For me, this error appears often around multiline strings. Here is one example

func = ->
  """
    multiline string
     .looksLikeAFunc 'but its just a string, man!'
  """
func()
.length

The last line .length gives a lint error that the indentation is wrong. It acts as though the indentation level is tracked through that multiline string, and it expects the chained function call to be at the same level.

You can change the number of spaces preceeding the line ".looksLikeAFunc" and the error will give an different value for the incorrect indentation amount. It only gives an error if this number is odd.

swang commented

I've made PR #506, to fix the issue @balihoo-acobb was addressing. @egel if you could post some samples of code that is erroring out for you I can figure out if #506 fixes it or if I need another PR for that.

Hi @swang. Thanks for looking into this. Here is a code-fragment which you can test against.

I only encounter such errors for empty catch blocks. For example, the following code gives the error

Line contains inconsistent indentation Expected 2 got -4

This error goes away once I uncomment console.error

execFunc = () ->
  if element._masonry?
    try
      if element.children.length > 0
        element._masonry.reload()
    catch err
      #console.error err
  else
    element._masonry = new Masonry element, conf
swang commented

@akshat1 I cannot reproduce the error you are seeing. Please make sure you are updated to the latest version of coffeelint and try running it again. If you continue to see errors, please open up a new issue.

@swang I get this with the latest version of coffeelint (1.12.1). I checkout out the source, and the changes from your PR but the error still occurs. I'll go ahead and log another bug as you advised. Thanks!