Skip to content
GitHubXDiscord

recommended

Stable · since 0.1.0

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 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',
    },
  },
];
RuleSeverityWhat it catches
@triggery/no-dynamic-iderrorcreateTrigger({ id: someVariable }) — id must be a string literal so static analysis (devtools, the triggery graph CLI) can resolve it.
@triggery/no-event-cascadeerrorA 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-ruleserroruseEvent / useCondition / useAction / useInlineTrigger outside a React function — same intent as react-hooks/rules-of-hooks but applied to Triggery hooks.
@triggery/exhaustive-conditionswarnA condition listed in the schema but never registered on any reachable code path. Surfaces dead surface area.
@triggery/exhaustive-requiredwarnA condition declared in required is missing a default registration (and would always short-circuit).
@triggery/max-handler-sizewarnHandler function body exceeds the threshold (default 50 lines). A nudge to extract the work into actions.
@triggery/max-ports-per-triggerwarnTrigger 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.

// 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 }],
    },
  },
];
// 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',
    },
  },
];
// eslint.config.js
import triggery from '@triggery/eslint-plugin';

export default [
  triggery.configs.recommended,
  triggery.configs.strict, // overrides previous severities with stricter values
];