7 releases

0.3.0 Sep 16, 2021
0.2.2 Oct 21, 2020
0.1.2 Oct 8, 2020

#756 in Development tools

Download history 8/week @ 2022-11-30 23/week @ 2022-12-07 7/week @ 2022-12-14 30/week @ 2022-12-21 17/week @ 2022-12-28 13/week @ 2023-01-04 14/week @ 2023-01-11 20/week @ 2023-01-18 23/week @ 2023-01-25 30/week @ 2023-02-01 23/week @ 2023-02-08 37/week @ 2023-02-15 17/week @ 2023-02-22 24/week @ 2023-03-01 16/week @ 2023-03-08 11/week @ 2023-03-15

78 downloads per month
Used in 2 crates

MIT license

1MB
28K SLoC

The core runner for RSLint responsible for the bulk of the linter's work.

The crate is not RSLint-specific and can be used from any project. The runner is responsible for taking a list of rules, and source code and running the linter on it. It is important to decouple the CLI work and the low level linting work from eachother to be able to reuse the linter facilities. Therefore, the core runner should never do anything rslint_cli-specific.

The structure at the core of the crate is the [CstRule] and [Rule] traits. CST rules run on a single file and its concrete syntax tree produced by [rslint_parser]. The rules have a couple of restrictions for clarity and speed, these include:

  • all cst rules must be Send and Sync so they can be run in parallel
  • rules may never rely on the results of other rules, this is impossible because rules are run in parallel
  • rules should never make any network or file requests

Using the runner

To run the runner you must first create a [CstRuleStore], which is the structure used for storing what rules to run. Then you can use [lint_file].

Running a single rule

To run a single rule you can find the rule you want in the groups module and submodules within. Then to run a rule in full on a syntax tree you can use [run_rule].

Rules can also be run on individual nodes using the functions on [CstRule]. ⚠️ note however that many rules rely on checking tokens or the root and running on single nodes may yield incorrect results, you should only do this if you know about the rule's implementation.

Dependencies

~4MB
~78K SLoC