recommended
Stable · since 0.1.0
Rules in
Section titled “Rules in recommended”
The default flat-config preset shipped by @triggery/eslint-plugin. Enables seven of the eight rules with severities that catch real problems without drowning the diff. prefer-named-hook is off in recommended — it’s a style nudge available in the stricter preset.
For projects that want maximum signal, see the strict preset, which raises everything to error level and adds tighter handler/port size caps.
Import
Section titled “Import”import triggery from '@triggery/eslint-plugin';
// or, named:
import { recommended } from '@triggery/eslint-plugin';
// eslint.config.js (flat config — ESLint 9.x)
import triggery from '@triggery/eslint-plugin';
export default [
// … your other configs
triggery.configs.recommended,
];Picking individual rules instead of spreading the preset also works:
// eslint.config.js
import triggery from '@triggery/eslint-plugin';
export default [
{
plugins: { '@triggery': triggery },
rules: {
'@triggery/no-dynamic-id': 'error',
'@triggery/hook-rules': 'error',
},
},
];Rules in recommended
Section titled “Rules in recommended”| Rule | Severity | What it catches |
|---|---|---|
@triggery/no-dynamic-id | error | createTrigger({ id: someVariable }) — id must be a string literal so static analysis (devtools, the triggery graph CLI) can resolve it. |
@triggery/no-event-cascade | error | A trigger handler that calls runtime.fire (or the firing helper) is forbidden; emit through actions.<name>?.(payload) instead, or accept that the cascade is intentional and disable per-line. |
@triggery/hook-rules | error | useEvent / useCondition / useAction / useInlineTrigger outside a React function — same intent as react-hooks/rules-of-hooks but applied to Triggery hooks. |
@triggery/exhaustive-conditions | warn | A condition listed in the schema but never registered on any reachable code path. Surfaces dead surface area. |
@triggery/exhaustive-required | warn | A condition declared in required is missing a default registration (and would always short-circuit). |
@triggery/max-handler-size | warn | Handler function body exceeds the threshold (default 50 lines). A nudge to extract the work into actions. |
@triggery/max-ports-per-trigger | warn | Trigger schema has too many events / conditions / total ports. A nudge to split into multiple triggers. |
The remaining rule, @triggery/prefer-named-hook, is not enabled in recommended — adopters generally prefer the universal useEvent(trigger, 'x') form until a port has more than a couple of call sites. Turn it on in the strict preset or per-rule.
Examples
Section titled “Examples”Override a single severity
Section titled “Override a single severity”// eslint.config.js
import triggery from '@triggery/eslint-plugin';
export default [
triggery.configs.recommended,
{
rules: {
'@triggery/exhaustive-conditions': 'error',
'@triggery/max-handler-size': ['error', { max: 40 }],
},
},
];Disable for legacy folders
Section titled “Disable for legacy folders”// eslint.config.js
import triggery from '@triggery/eslint-plugin';
export default [
triggery.configs.recommended,
{
files: ['legacy/**/*.ts'],
rules: {
'@triggery/no-dynamic-id': 'off',
'@triggery/hook-rules': 'off',
},
},
];Use the strict preset on top
Section titled “Use the strict preset on top”// eslint.config.js
import triggery from '@triggery/eslint-plugin';
export default [
triggery.configs.recommended,
triggery.configs.strict, // overrides previous severities with stricter values
];Related
Section titled “Related” createTrigger The constructor most rules analyse.
useEvent / useCondition / useAction The hooks `hook-rules` enforces.
createNamedHooks Enable `prefer-named-hook` when you adopt this helper.
Linting guide Editor integration, CI setup, ignore patterns.