#linter #rules #rs-lint #linting #parallel #source #file

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

#706 in Development tools

Download history 47/week @ 2024-06-10 51/week @ 2024-06-17 3/week @ 2024-06-24 4/week @ 2024-07-01 48/week @ 2024-07-08 13/week @ 2024-07-15 27/week @ 2024-07-22 116/week @ 2024-07-29 24/week @ 2024-08-26 46/week @ 2024-09-23

56 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–15MB
~131K SLoC