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

"Nitpick" linters #1

Open
6 of 15 tasks
SquidDev opened this issue Nov 27, 2019 · 1 comment
Open
6 of 15 tasks

"Nitpick" linters #1

SquidDev opened this issue Nov 27, 2019 · 1 comment
Labels
area-linters Issues relating to linters and code fixers enhancement New feature or request

Comments

@SquidDev
Copy link
Owner

SquidDev commented Nov 27, 2019

It'd be really nice to have a series of linters which nitpick about minor formatting. For instance, ensuring spaces are in the correct places, enforcing a variable name convention, etc... Ideally many of these could have automatic fixers too, allowing for a form of automatic error correction.

  • Require spaces around binary operators, and assignments.
  • Require spaces after a comma, and forbid any before.
  • Enforce a consistent table separator (defaults to ,, but allow ;).
  • Require trailing ,/; on multi-line tables.
  • Complain about trailing whitespace. This may be a little harder, as it'd require providing a zipper-list of all tokens (or at least a "next token").
  • Misleading/inconsistent indentation.
  • Enforce variable naming conventions for locals and table keys/methods. It might be worth considering what we do with something like CC:T which uses camelCase for functions (even if local ones), and snake_case for variables.
  • Consistent spacing within parenthesis and {} (i.e. forbid {foo } but allow {foo} and { foo }).
  • Consistent table key names (forbid { ["foo"] = 1, bar = 2 }).
  • Convert string indexing into dot ones (x["foo"]x.foo). Might be nice to have a reverse refactoring too when we work that out.
  • String quotes (" vs ')
    • Allow "prefer " and prefer '". Prefer a kind of quote, but allow the other when you have strings like 'foo "bar"'.
  • Remove redundant =s in long strings.
    • And comments
  • Convert long string to quoted ones when nothing need be escaped. Might be nice to do the other way as a standard refactoring too.

One thing bearing in mind is how to handle alignment within tables and assignments. For instance, ideally we'd require a single spaces around tokens, but allow for cases such as follows, where people are trying to align expressions up:

vx = vx + 1
x  = x  + 1
@SquidDev SquidDev added the enhancement New feature or request label Nov 27, 2019
@SquidDev
Copy link
Owner Author

SquidDev commented Dec 6, 2019

We check trailing whitespace on commas on 1a7300d, but doing it generally is going to be harder. The token linter pass really needs a way to get the previous and next node, or at least their whitespace.

@SquidDev SquidDev added the area-linters Issues relating to linters and code fixers label Mar 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-linters Issues relating to linters and code fixers enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant