custom rules docs #201
-
Hello, Could anybody give us some basic instructions how to write and use custom rules? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello. I fully intended to write some docs for you tonight but I realized all the docs committed reflected things from the 0.4 series while The rules built in are a decent starting place to investigate the future. There is some cruft in there to support back compat but for a new rule you basically just need to export a class. An easy example would be https://github.com/monorepolint/monorepolint/blob/main/packages/rules/src/alphabeticalDependencies.ts You would need to implement The check function does all the work. The most important thing in there is to use the context for everything, including file io. On a large monorepo it can get very expensive to keep reading/writing json files and the context has cached methods on it under Here is an example of a fixer on an error: https://github.com/monorepolint/monorepolint/blob/main/packages/rules/src/packageEntry.ts#L54-L65 HOpe this helps. |
Beta Was this translation helpful? Give feedback.
Hello.
I fully intended to write some docs for you tonight but I realized all the docs committed reflected things from the 0.4 series while
main
is tracking the 0.5.0 series (which you can get on NPM btw). And I decided to fix that first. See #200The rules built in are a decent starting place to investigate the future. There is some cruft in there to support back compat but for a new rule you basically just need to export a class.
An easy example would be https://github.com/monorepolint/monorepolint/blob/main/packages/rules/src/alphabeticalDependencies.ts
You would need to implement
NewRuleModule
from@monorepolint/config
: https://github.com/monorepolint/monorepolint/blob/main/packages/c…