This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR checklist
walk
function instead of extending AbstractRule in our new-rule templates #586Includes tests(no tests for new rule template)Documentation update(not required)Overview of change:
I've changed the new rule template to use a
walk
function instead of a class extendingRuleWalker
.When you use a
walk
function, there's a bit of a difference between a rule with options and one without options (compared to using aRuleWalker
), so I've added an additional prompt to ask you if the rule will have options (defaulting to false, because most rules don't have options). The answer to this prompt will change the generated rule slightly.When the rule has options:
Options
interface is defined, ready to be filled in.options
andoptionsDescription
metadata properties are added with TODO comments.optionExamples
metadata property is included.applyWithFunction
function is called with the rule's options.WalkContext
is defined asWalkContext<Options>
.When the rule does not have options:
options
andoptionsDescription
metadata properties are added with blank values and do not need to be changed.optionExamples
metadata property is excluded.applyWithFunction
function is called without the rule's options.WalkContext
is defined asWalkContext<void>
.Since this required a few conditional sections in the template, I've changed the template to use EJS. instead of just being an interpolated string (docs for EJS can be found here).
Is there anything you'd like reviewers to focus on?
Nope.