Repository navigation
Conversation
Co-authored-by: pi <noreply@pi.dev> Agent-Model: openrouter/moonshotai/kimi-k3
Co-authored-by: pi <noreply@pi.dev> Agent-Model: openrouter/moonshotai/kimi-k3
Co-authored-by: pi <noreply@pi.dev> Agent-Model: openrouter/moonshotai/kimi-k3
Co-authored-by: pi <noreply@pi.dev> Agent-Model: openrouter/moonshotai/kimi-k3
Co-authored-by: pi <noreply@pi.dev> Agent-Model: openrouter/moonshotai/kimi-k3
Co-authored-by: pi <noreply@pi.dev> Agent-Model: openrouter/moonshotai/kimi-k3
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Proposal / Proof of Concept
This PR implements the foundation for per-rule custom linter configuration options, as proposed in #1204. It's framed as a PoC to settle the mechanism before rolling options out to more rules — feedback on the approach is very welcome.
Once the foundation is agreed upon, follow-up PRs can address the related use cases: #163, #2041, #1836, #550, plus the
erb-no-unused-expressionsside-effect-method list (see #1586) and an allow-list forerb-no-output-in-attribute-position(see #1204 comments).How it works
Option keys sit flat under the rule name, next to the built-in keys (
enabled,severity, …), matching the issue's example and erb_lint's layout:Rules declare their options with a type parameter, defaults, and an optional zod schema:
Design decisions
options:object), per the issue and erb_lint precedent.enabled,severity,frameworks,autoCorrect,include,only,exclude,environmentskeep their built-in meaning and are never passed to rules. A dev-time test asserts no rule'sdefaultOptionscollides with them.static optionsSchema, user options are validated when the rule is instantiated. Invalid options are a hard error in the CLI (one line per error, exit 1) and a warning in the language server; either way the rule falls back to its defaults for that run, so a bad config never crashes a lint. Strict schemas mean a typo likeallowdTypesis reported instead of silently ignored.failLevel/indentWidth.allpseudo rule are ignored.html-allowed-script-typeis the pilot rule (it had hardcoded constants with a note referencing Linter: Support per-rule custom configuration options #1204); its defaults are unchanged, so behavior without user config is identical.Implementation notes
@herb-tools/config:RuleConfigBaseSchemais now az.looseObject(unknown keys pass validation),Config.getRuleOptions(ruleName)returns a rule's config minus the reserved keys,BUILT_IN_RULE_CONFIG_KEYSlives in the browser-safe/schemasubpath.@herb-tools/linter:ParserRule/LexerRule/SourceRulegained a second genericTOptions(afterTAutofixContext, so existing rules compile unchanged),defaultOptions/options/resolveOptions/optionsErrors, andLinter.validateRuleOptions(config, rules). All rule-instantiation sites (lint loop, deferred rules, autofix paths) resolve options; registry constructor types are generic-agnostic so option-carrying rules can register..herb/rules/**/*.mjsget the same support via the base classes (schema optional); duck-typed rules without the base class are tolerated.FullRuleConfignow lists built-in keys explicitly (an index signature onRuleConfigwould collapse the previousOmit-based derivation).Validation
@herb-tools/configand@herb-tools/lintersuites green (~6,000 tests, including the browser vitest project),typecheckgreen.allignoring options, merge precedence and array replacement, schema-failure fallback,validateRuleOptionserror reporting (bad values + unknown keys), end-to-end linting with custom options, and pilot-rule behavior with customallowedTypes/allowBlank.configuration.mdand an "Options" section on the pilot rule's page (template for future rules).Known limitations / follow-ups
BrowserRule, live-DOM environment) don't support options yet — only Parser/Lexer/Source rules. Easy to add the same base-class treatment if the approach is accepted.Closes #1204 (pending feedback on the approach).