Skip to content
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

Add (optional) rule to check consistency of indentation? #50

Open
alexdowad opened this issue Feb 25, 2022 · 8 comments
Open

Add (optional) rule to check consistency of indentation? #50

alexdowad opened this issue Feb 25, 2022 · 8 comments
Labels
enhancement New feature or request

Comments

@alexdowad
Copy link

Thank you for luacheck! It is a very nice tool.

Are you interested in adding a rule to check that indentation is consistent; for example, that only tabs or only spaces are used? Probably this would be disabled by default, to avoid breaking existing users.

If you like the idea, I would be happy to send a PR.

FYA @alerque

@alerque
Copy link
Member

alerque commented Feb 25, 2022

Personally I think this is the wrong tool for the job. Conceptually I think a language linter looking for coding errors should completely ignore anything remotely user-preference or style related. Any valid language syntax should be fair game. Separately a different tool (or possible completely different run time mode of a common tool) could look at the coding style and lint, suggest, or just outright format to taste. This would facilitate CI jobs where style vs. syntax and logic issues were treated differently, style was or was not enforced, etc. Also the kind of options that go into what to allow in a language are fundamentally different from what to allow for style (in my view).

Personally for things like enforcing indentation and checking for mixed space/tab usage I use editorconfig rules and editorconfig-checker for linting (other tools like eclint exist too).

That being said there is not another Lua specific tool (or mode) that handles style robustly at this time and there is precedent for whitespace handling rules mixed in the liter (e.g. https://github.com/lunarmodules/luacheck/blob/master/src/luacheck/stages/detect_bad_whitespace.lua) so I guess I don't have solid reason to object to that ruleset being expanded/improved.

@alerque alerque added the enhancement New feature or request label Feb 25, 2022
@alexdowad
Copy link
Author

Thanks for those thoughtful comments.

If the maintainers want this feature, I am available to help implement it; but if they don't want it, that is fine.

@alerque
Copy link
Member

alerque commented Feb 25, 2022

for example, that only tabs or only spaces are used?

Were you thinking this would be a line-wise, file-wise, or project-wise consistency check?

@alexdowad
Copy link
Author

I was thinking that if a user wants to use the check, they would put something in their configuration like:

indent = 'tabs'

...And then luacheck would perform the check on any file it scans.

@alexdowad
Copy link
Author

Or maybe the configuration might be something like this?

indent = { type='spaces', width=4 }

Or else:

indent_type = 'spaces'
indent_width = 4

@CppCXY
Copy link

CppCXY commented Mar 10, 2022

the EmmyLuaCodeStyle support this feature,it supports the use of language server, lua lib, and command-line tools in three ways

@alexdowad
Copy link
Author

the EmmyLuaCodeStyle support this feature,it supports the use of language server, lua lib, and command-line tools in three ways

Thanks for mentioning that.

@aloisdg aloisdg mentioned this issue Jul 28, 2022
3 tasks
@ParsaNobahari

This comment was marked as abuse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

4 participants