Skip to content

Linter: Access rule type from class instead of instance#1298

Merged
marcoroth merged 3 commits into
mainfrom
refactor-linter-rule-class-access
Mar 5, 2026
Merged

Linter: Access rule type from class instead of instance#1298
marcoroth merged 3 commits into
mainfrom
refactor-linter-rule-class-access

Conversation

@marcoroth

@marcoroth marcoroth commented Mar 4, 2026

Copy link
Copy Markdown
Owner

This pull request refactors the linter by accessing the static type field directly on rule classes instead of instantiating rules and reading it from rule.constructor.

The instance-level type guards (isLexerRule, isSourceRule, isParserRule) are replaced with class-level equivalents (isLexerRuleClass, isSourceRuleClass, isParserRuleClass) that take a ruleClass rather than a Rule instance.

It also extracts a findRuleClass(ruleName) helper to deduplicate the six occurrences of this.rules.find(rule => rule.ruleName === ...), and renames RuleClass local variables to ruleClass to follow camelCase conventions for non-type identifiers.

Follow up on #1268

@marcoroth marcoroth changed the title Linter: Access rule type from class instead of instance Linter: Access rule type from class instead of instance Mar 4, 2026
@pkg-pr-new

pkg-pr-new Bot commented Mar 5, 2026

Copy link
Copy Markdown
npx https://pkg.pr.new/@herb-tools/formatter@1298
npx https://pkg.pr.new/@herb-tools/language-server@1298
npx https://pkg.pr.new/@herb-tools/linter@1298

commit: 4145710

@github-actions

github-actions Bot commented Mar 5, 2026

Copy link
Copy Markdown

🌿 Interactive Playground and Documentation Preview

A preview deployment has been built for this pull request. Try out the changes live in the interactive playground:


🌱 Grown from commit 4145710


✅ Preview deployment has been cleaned up.

@marcoroth marcoroth merged commit de93dd0 into main Mar 5, 2026
20 checks passed
@marcoroth marcoroth deleted the refactor-linter-rule-class-access branch March 5, 2026 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant