InvalidRuleError
The Cause
Section titled “The Cause”A loaded rule declares one or more executable types (static, analytics, or test) but has no execution function for at least one of them. Such a rule would register but silently never run. This can happen when:
- a rule object is constructed by hand (without the
httpRulebuilder) and misses thelintRule,analyzeRule, ortestRulefunction for a declared type, or - the
typeoverride for a rule in your Thymian config file points at a type the rule has no execution function for, or - a rule combines the
informationaltype with executable types —informationalmust be the only type of a rule, or - a rule’s
meta.typeis malformed: missing, not an array, empty, or containing unknown rule types.
The Solution
Section titled “The Solution”Make sure every declared executable type has a matching execution function:
import { httpRule } from '@thymian/core';
// ✅ .rule() provides the execution function for every declared typeexport default httpRule('my-rule') .severity('warn') .type('static', 'analytics') .rule((context, options, logger) => { /* rule logic */ }) .done();If the rule is documentation-only, declare it as informational instead — informational rules are the only rules without execution functions:
export default httpRule('my-informational-rule') .severity('warn') .type('informational') // informational rules never execute .description('Documented requirement that cannot be checked automatically.') .done();If the error points at a type override in your Thymian config file, restrict the override to types the rule actually implements, or set the rule’s type to ['informational'] to stop executing it.
If the broken rule comes from a package you do not control, disable it by setting its severity to off in your Thymian config file — a disabled rule is filtered out before this validation runs — or downgrade it to ['informational'] via the type override.