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
Copy file name to clipboardExpand all lines: README.md
+34-2Lines changed: 34 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -537,9 +537,11 @@ Current supported version of the standard is [SARIF-v2.1.0](https://docs.oasis-o
537
537
538
538
The tool can be extended with custom rules or formatters. This section contains additional information on how to implement such.
539
539
540
-
**To extend the linter with a custom rule or a formatter you'll have to push it to this repository or fork it**. This is due to the limited `-buildmode=plugin` support which [works only on Linux (with known issues)](https://golang.org/pkg/plugin/).
540
+
To extend the linter with a custom rule you can push it to this repository or use `revive` as a library (see below)
541
541
542
-
### Custom Rule
542
+
To add a custom formatter you'll have to push it to this repository or fork it. This is due to the limited `-buildmode=plugin` support which [works only on Linux (with known issues)](https://golang.org/pkg/plugin/).
543
+
544
+
### Writing a Custom Rule
543
545
544
546
Each rule needs to implement the `lint.Rule` interface:
545
547
@@ -568,6 +570,36 @@ With the snippet above we:
568
570
569
571
A sample rule implementation can be found [here](/rule/argument-limit.go).
570
572
573
+
#### Using `revive` as a library
574
+
If a rule is specific to your use case
575
+
(i.e. it is not a good candidate to be added to `revive`'s rule set) you can add it to your own linter using `revive` as linting engine.
576
+
577
+
The following code shows how to use `revive` in your own application.
578
+
In the example only one rule is added (`myRule`), of course, you can add as many as you need to.
579
+
Your rules can be configured programmatically or with the standard `revive` configuration file.
580
+
The full rule set of `revive` is also actionable by your application.
0 commit comments