With Squawk, we frequently add new linter rules. A quick way to do this is to duplicate an existing rule and modify it. This works, but we also want to add documentation, update imports for the new rule, and update our homepage. That’s tedious work.
A code generator makes adding a new rule easy.
With a code generator, we can:
- Generate a linter rule stub.
- Import and register the new rule.
- Add a documentation page stub.
- Add the rule to homepage
s/new-rule script makes it easy to start adding new rules to Squawk:
s/new-rule 'my new rule' ✔ ++ /linter/src/rules/my_new_rule.rs ✔ ++ /docs/docs/my-new-rule.md ✔ +- /linter/src/rules/mod.rs ✔ +- /linter/src/violations.rs ✔ +- /linter/src/lib.rs ✔ +- /linter/src/lib.rs ✔ +- /docs/sidebars.js ✔ +- /docs/src/pages/index.js
I think using a code generator like Plop can be useful for adding HTTP endpoints, queue workers, database models, UI components and more to a project.