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

Check for whitespace around operators #19

Open
AiyionPrime opened this issue Jul 11, 2021 · 1 comment
Open

Check for whitespace around operators #19

AiyionPrime opened this issue Jul 11, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@AiyionPrime
Copy link

I'm looking for an option to check for whitespaces around operators, but cannot find it, yet.
I did find a mention of this feature not being implemented yet, from 2016 though.

examples would be

  • too less/many spaces around operator:
i=  3
  • no spaces after ,
for var_1,···,var_n in explist do body end

I realize its not an easy to implement check, due to its context sensitivity, but would like to state I'm missing this feature.
Maybe someone comes along feels the same, and leaves a 👍.

This project is really nice to have around, thanks!

[...]
Ideally luacheck would also check for correct amount of whitespace around operators, parens, etc., but that would require more cooperation with the parser, and also it will be more complex to support customization. The warnings you suggested don't seem to need any options.

I haven't touched luacheck code in a while, and contributions are most welcome! I think that the way to do this would be to modify the lexer to consider whitespace a token, with exactly one whitespace token between each two consecutive normal tokens. Then the parser can call a function provided by the checker on each token. That function would check whitespace tokens and issue warnings.

Originally posted by @mpeterv in mpeterv#79 (comment)

I was just made aware of his passing away and hope this repo is the right place to follow up on this.

@alerque alerque changed the title whitespaces aroumd operators Check for whitespace around operators Oct 7, 2021
@alerque alerque added the enhancement New feature or request label Oct 7, 2021
@appgurueu
Copy link

I think this is out of scope for Luacheck and should rather be a formatter's job to fix and/or check. Luacheck is supposed to check likely semantic issues rather than formatting issues. The only warning where Luacheck checks formatting is with mixed indentation, which is severe and universal enough that it seems reasonable.

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

3 participants