You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 }).
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+1x=x+1
The text was updated successfully, but these errors were encountered:
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.
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.
,
, but allow;
).,
/;
on multi-line tables.camelCase
for functions (even if local ones), andsnake_case
for variables.{}
(i.e. forbid{foo }
but allow{foo}
and{ foo }
).{ ["foo"] = 1, bar = 2 }
).x["foo"]
→x.foo
). Might be nice to have a reverse refactoring too when we work that out."
vs'
)"
and prefer'
". Prefer a kind of quote, but allow the other when you have strings like'foo "bar"'
.=
s in long strings.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:
The text was updated successfully, but these errors were encountered: