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

New linter #299

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

New linter #299

wants to merge 5 commits into from

Conversation

nilnor
Copy link
Contributor

@nilnor nilnor commented Oct 17, 2016

This replace the current linter with the new moonpick linter. The new linter works against the parse tree instead of piggybacking on the compile process. Similarly to the old linter it detects global accesses and declared but unused variables. When it comes to unused variables it handles a lot more constructs, detecting unused variables resulting from destructuring statements, imports, etc. It also detects unused variables resulting from unused parameter declarations as well loop variable declarations. Another form of detection lacking altogether in the current linter is shadowing declarations, where a variable declaration of some sort shadows an existing declaration in an outer scope.

This PR removes the current cmd.lint module, replacing it with a new lint module. It also adds a lint_config.moon and updates the current code to be lint clean for the new linter (two separate commits).

Things to consider / be aware of are:

  • What defaults should be used? Currently unused parameter detection is disabled by default, while unused loop variables and shadowing detections are enabled by default.
  • The old cmd.lint module is removed. This was never advertised as a public API (AFAIK), but nonetheless it might have been used by other downstream projects.
  • The new API isn't documented - perhaps it should be to allow for easier integration for anyone who wishes to use it programmatically.

The new linter is capable of detecting a lot more possible issues with
Moonscript compared to the current one. Similarly to the old linter, it
detects unused variables and undeclared global usages. It does however
detect unused declarations in a lot more contexts, such as import lists,
destructuring statements, for loops, parameter lists, etc.

The new linter also warns for shadowing declarations, i.e. a declaration
of a variable where a previous declaration already exists higher up in a
scope.
@nilnor
Copy link
Contributor Author

nilnor commented Jun 13, 2017

Just a note: This is now out of date with the standalone moonpick implementation, which has had more checks added since the opening of this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant