node-lintspaces icon indicating copy to clipboard operation
node-lintspaces copied to clipboard

Inconsistent indentation checking

Open Bartheleway opened this issue 1 year ago • 9 comments

Issue

My team and I started using this very good package in our CI. We found out that multiline comments in javascript files (probably all languages recognizing this kind of comments /** */) are wrongly spotted as "INDENTATION_TABS" because we are using indent_style = tab (editorconfig). Same applies for indent_style = space with the error "INDENTATION_SPACES_AMOUNT"

Example code

class MyClass {
    /**
     * @ description Do something
     */
    function myFunction () {
        ...
    }
}

Tests

I made my test using lintspaces-cli which might be the source of issue as well.

.editorconfig value expected behavior result comment
indent_style = space ok ok? Please confirm this test, lintspaces-cli seems to set it to 0 instead of using the default 4
indent_style = space & indent_size = 4 ok ko Fails on the line with * @description ...
indent_style = tab ok ko Fails on the line with * @description ...

Possible solution

I see two solutions for this:

  • Simple: we make an exception when we find <space>*<space>, this could create false negative (not detecting wrong indentation)
  • Complex: we make an exception when we find a multiline comment, this oblige to find when it starts and when it ends

I feel this is a language specific behavior so complex solution will probably be more robust approach.

Bartheleway avatar Oct 14 '24 08:10 Bartheleway