Rules & Presets
recommended preset
This preset is recommended for most projects, so we suggest enabling it by default.
ts
import effector from "eslint-plugin-effector"
const config = [
effector.flatConfigs.recommended,
]| Rule | Description |
|---|---|
| enforce-effect-naming-convention | Enforce Fx as a suffix for any Effector Effect |
| enforce-store-naming-convention | Enforce $ as a prefix/postfix for any Effector Store |
| keep-options-order | Enforce options order for Effector methods |
| no-ambiguity-target | Forbid ambiguous target in sample and guard |
| no-duplicate-on | Forbid duplicate .on calls on Stores |
| no-forward | Prefer sample over forward |
| no-getState | Forbid .getState calls on Effector stores |
| no-guard | Prefer sample over guard |
| no-unnecessary-combination | Forbid unnecessary combinations in clock and source |
| no-unnecessary-duplication | Forbid duplicate source and clock in sample and guard |
| no-useless-methods | Forbid useless calls of sample and guard |
| no-watch | Restrict usage of .watch on any Effector Unit |
patronum preset
This preset is recommended for projects that use patronum.
ts
import effector from "eslint-plugin-effector"
const config = [
effector.flatConfigs.patronum,
]| Rule | Description |
|---|---|
| no-patronum-debug | Disallow the use of patronum/debug |
react preset
This preset is recommended for projects that use React with Effector.
ts
import effector from "eslint-plugin-effector"
const config = [
effector.flatConfigs.react,
]| Rule | Description |
|---|---|
| enforce-gate-naming-convention | Enforce a Gate is named capitalized like a React Component |
| mandatory-scope-binding | Forbid Event and Effect usage without useUnit in React components |
| prefer-useUnit | Prefer useUnit over deprecated useStore and useEvent hooks |
scope preset
This preset is recommended for projects that use Fork API.
ts
import effector from "eslint-plugin-effector"
const config = [
effector.flatConfigs.scope,
]| Rule | Description |
|---|---|
| require-pickup-in-persist | Require every persist call of effector-storage to use pickup |
| strict-effect-handlers | Forbid mixing calls to both regular async functions and Effects in the same function |
future preset
Effector is evolving! Future-proof your code with this preset, which enforces best practices for future releases of Effector.
ts
import effector from "eslint-plugin-effector"
const config = [
effector.flatConfigs.future,
]| Rule | Description |
|---|---|
| no-domain-unit-creators | Disallow using Domain methods to create units |
Other Rules
Some ESLint rules are yet to be included in any preset but can be enabled individually if they suit your project's needs.
| Rule | Description |
|---|---|
| no-duplicate-clock-or-source-array-values | Forbid duplicate units in clock/source arrays |