-
Notifications
You must be signed in to change notification settings - Fork 18
Inconsistent indentation checking #297
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
Comments
Hello @Bartheleway, thanks for your feedback. Did you tried to use the |
@schorfES, I wasn't aware of this option. I tried it today and result is pretty good. I see at least one issue of using it. It seems to ignore all checks between comment boundaries which is not what I am trying to achieve. For example (with explicit indent / EOL): /**<lf>
<space><space>some bad stuff * could be bad line ending<cr><lf>
<tab><space><space>whatever
*/<lf> This would pass regardless of line ending and indentation settings. In my use case I only want to accept the extra whitespace in front of the /**<lf>
<space>* Some comments<lf>
<space>*/<lf> I see that my PR is only handling js comment style so it needs to be improved. The good thing is it only add acceptance for that extra front space before the I know that it is only my use case (following VS Code / js doc / java doc / ... convention) and that other projects might want to fully ignore what is between comment boundaries so I think both system should coexist. Happy to discuss it further and to improve my PR accordingly 😄 |
I was confused around the |
I’m a bit confused as well, but as far as I remember, EOL is always validated when the option is turned on, regardless of any ignores affecting the line (see README). Indentation, however, is disabled by ignores specifically for cases where comments have “incorrect” indentation. So, I believe the new options might not be necessary. I’ll need to double-check this... |
@Bartheleway I checked all the options. Here’s a list showing which ones respect ignores 👍 and which do not 👎:
As you can see, most of the options respect ignores, except for these two options. The end of line option does not consider ignored lines and always validates line endings, as it’s generally undesirable to mix line endings, whether in code or comments. I think this aligns with what you expect. So from my current perspective, I don’t see a need for the two new settings, eolToIgnores and indentationToIgnores. Hope I didn’t misunderstand you. |
Yes I agree, I don't really understand how I got no report about EOL inside comment as reading the code, it should raise it ... The only remaining "issue" is that indentation option respect too much the ignore option to my taste 😄 I would expect to still validate the indentation on comment lines in front of Maybe this is just my edge case and I am the only one concerned about comments like: class MyClass {
/**
Weird stuff
*/
function myMethodWithBadComment () {
// Some code
}
/**
* Weird stuff
*/
function myMethodWithGoodComment () {
// Some code
}
} |
Hi @Bartheleway, thank you for double-checking. If you still encounter a case where EOL is not working as expected, please consider opening a PR with a test case so we can address it. Regarding indentation for ignored lines, this primarily relates to the scope of this project. To fulfill your request, Lintspaces would need to become a syntax parser utilizing an AST, similar to ESLint and similar tools. However, Lintspaces is designed to be language-agnostic, focusing on rules that apply to any text (or source code) file rather than specific language syntax. While the multiline comment style with a vertical line of For this reason, I believe adding built-in support for this type of comment exceeds the scope of the project. However, we can explore solutions that maintain the project’s language-agnostic nature. One idea is to introduce hooks to Lintspaces, which would allow users to extend the linting process with custom code for extra validations or modifications to the report. In this case, a hook could be used to add a regular expression to check whether the What do you think of this approach? |
Interesting approach. Going this way would probably means that we will see in a near future some "node-lintspaces-js", "node-lintspaces-java", ...
Another approach would be to get all these language specific constraints in the current package. It will certainly alter a bit the agnostic current nature of the package which for me is fine as long as we don't break it (only linting specific language). As you said, vertical aligned comments comes from java and are now used in other languages. This can be seen as this type of comment is now language agnostic it is just a style of comment which can be then supported by a language agnostic linter 😉 in the same matter the package already implement language specific ignore pattern and this doesn't break the agnostic nature of the package. Technically speaking, I don't know yet how to implement it correctly but I will definitely explore this path. |
I would not expect separate packages for different languages, as the style of these comments is the same across languages. Technically, "node-lintspaces-js" and "node-lintspaces-java" would have nearly identical code. Instead, I can think of shipping these hooks or plugins directly with lintspaces and importing them as needed. For example: import Validator from 'lintspaces';
import DocStringHook from 'lintspaces/plugins/docstring';
const validator = new Validator({
hooks: [DocStringHook],
});
validator.validate('/path/to/file.ext');
validator.validate('/path/to/other/file.ext');
const results = validator.getInvalidFiles(); I assume, this approach would address your point as well:
|
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 usingindent_style = tab
(editorconfig). Same applies forindent_style = space
with the error "INDENTATION_SPACES_AMOUNT"Example code
Tests
I made my test using lintspaces-cli which might be the source of issue as well.
* @description ...
* @description ...
Possible solution
I see two solutions for this:
<space>*<space>
, this could create false negative (not detecting wrong indentation)I feel this is a language specific behavior so complex solution will probably be more robust approach.
The text was updated successfully, but these errors were encountered: