#rules #linter #parallel #source #linting #file #run

rslint_core

The core linter housing all of the rules for the rslint project

7 releases

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

#1378 in Development tools

Download history 62/week @ 2024-01-29 46/week @ 2024-02-05 25/week @ 2024-02-12 71/week @ 2024-02-19 65/week @ 2024-02-26 9/week @ 2024-03-04 38/week @ 2024-03-11 14/week @ 2024-03-18 9/week @ 2024-03-25 32/week @ 2024-04-01 19/week @ 2024-04-08 27/week @ 2024-04-15

87 downloads per month
Used in 2 crates

MIT license

1MB
31K 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

~4–14MB
~139K SLoC