All Projects → rlaffers → eslint-plugin-xstate

rlaffers / eslint-plugin-xstate

Licence: MIT License
ESLint plugin to check for common mistakes and enforce good practices when using XState.

Programming Languages

javascript
184084 projects - #8 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to eslint-plugin-xstate

eslint-plugin-decorator-position
ESLint plugin for enforcing decorator position
Stars: ✭ 32 (+68.42%)
Mutual labels:  eslint-plugin
eslint-plugin-qunit
ESLint plugin containing rules useful for QUnit tests.
Stars: ✭ 26 (+36.84%)
Mutual labels:  eslint-plugin
eslint-plugin-ember-best-practices
Static analysis tools for enforcing best practices in Ember
Stars: ✭ 77 (+305.26%)
Mutual labels:  eslint-plugin
eslint-plugin-nestjs
POC. ESLint rules for nestjs framework
Stars: ✭ 30 (+57.89%)
Mutual labels:  eslint-plugin
eslint-plugin-expect-type
ESLint plugin with $ExpectType, $ExpectError, and $ExpectTypeSnapshot type assertions
Stars: ✭ 27 (+42.11%)
Mutual labels:  eslint-plugin
eslint-plugin
Enforcing best practices for Effector
Stars: ✭ 69 (+263.16%)
Mutual labels:  eslint-plugin
xstate-marionettist
Model based testing with Jest, XState and Puppeteer or Playwright made easy
Stars: ✭ 23 (+21.05%)
Mutual labels:  xstate
actus
A monorepo for a self learning command palette driven by a final state machine implemented in XState.
Stars: ✭ 43 (+126.32%)
Mutual labels:  xstate
eslint-plugin
😎 基于 @lint-md,提供 eslint-plugin,让 lint-md 玩家在 IDE 中得到愉悦的文档编写体验。
Stars: ✭ 22 (+15.79%)
Mutual labels:  eslint-plugin
eslint-config-get-off-my-lawn
A highly opinionated, sharable config of ESLint rules to produce beautiful, readable JavaScript.
Stars: ✭ 44 (+131.58%)
Mutual labels:  eslint-plugin
xstate-catalogue
Professionally designed, interactive state machines
Stars: ✭ 616 (+3142.11%)
Mutual labels:  xstate
xstate-cpp-generator
C++ State Machine generator for Xstate
Stars: ✭ 33 (+73.68%)
Mutual labels:  xstate
temporal-electronic-signature
Electronic signature demonstration built with Temporal and XState
Stars: ✭ 36 (+89.47%)
Mutual labels:  xstate
xstate-viz
Visualizer for XState machines
Stars: ✭ 274 (+1342.11%)
Mutual labels:  xstate
react-gizmo
🦎 React Gizmo - UI Finite State Machine for React
Stars: ✭ 39 (+105.26%)
Mutual labels:  xstate
eslint-plugin-strict-vue
Vue eslint plugin with rules to make you code stricter: enforce jsdoc, restrict rootGetters, rootState and more.
Stars: ✭ 28 (+47.37%)
Mutual labels:  eslint-plugin
eslint-plugin-sql
SQL linting rules for ESLint.
Stars: ✭ 56 (+194.74%)
Mutual labels:  eslint-plugin
eslint-plugin-clean-regex
An ESLint plugin for writing better regular expressions.
Stars: ✭ 280 (+1373.68%)
Mutual labels:  eslint-plugin
eslint-plugin-test-selectors
Enforces that data-test-id attributes are added to interactive DOM elements (JSX) to help with UI testing. JSX only.
Stars: ✭ 19 (+0%)
Mutual labels:  eslint-plugin
eslint-plugin-es5
ESLint plugin for ES5 users.
Stars: ✭ 52 (+173.68%)
Mutual labels:  eslint-plugin

eslint-plugin-xstate

ESLint plugin to check for common mistakes and enforce good practices when using XState library.

npm version code style: prettier PRs Welcome

Installation

You'll first need to install ESLint:

$ npm i eslint --save-dev

Next, install eslint-plugin-xstate:

$ npm install eslint-plugin-xstate --save-dev

Usage

Add xstate to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
  "plugins": ["xstate"]
}

Then configure the rules you want to use under the rules section.

{
  "rules": {
    "xstate/spawn-usage": "error",
    "xstate/no-infinite-loop": "error",
    "xstate/no-imperative-action": "error",
    "xstate/no-ondone-outside-compound-state": "error",
    "xstate/invoke-usage": "error",
    "xstate/entry-exit-action": "error",
    "xstate/prefer-always": "error",
    "xstate/no-misplaced-on-transition": "error",
    "xstate/no-invalid-transition-props": "error",
    "xstate/no-invalid-state-props": "error",
    "xstate/no-async-guard": "error",
    "xstate/event-names": ["warn", "macroCase"],
    "xstate/state-names": ["warn", "camelCase"],
    "xstate/no-inline-implementation": "warn",
    "xstate/no-auto-forward": "warn"
  }
}

Shareable Configurations

This plugin exports a recommended configuration which checks for common mistakes. To enable this configuration use the extends property in your .eslintrc.js config file:

{
  "extends": ["plugin:xstate/recommended"]
}

There is also an all configuration which includes every available rule. It enforces both correct usage and best XState practices.

{
  "extends": ["plugin:xstate/all"]
}

Supported Rules

Possible Errors

Rule Description Recommended
spawn-usage Enforce correct usage of spawn ✔️
no-infinite-loop Detect infinite loops with eventless transitions ✔️
no-imperative-action Forbid using action creators imperatively ✔️
no-ondone-outside-compound-state Forbid onDone transitions on atomic, history and final nodes ✔️
invoke-usage Enforce correct invocation of services ✔️
entry-exit-action Forbid invalid declarations of entry/exit actions ✔️
no-misplaced-on-transition Forbid invalid declarations of on transitions ✔️
no-invalid-transition-props Forbid invalid properties in transition declarations ✔️
no-invalid-state-props Forbid invalid properties in state node declarations ✔️
no-async-guard Forbid asynchronous guard functions ✔️

Best Practices

Rule Description Recommended
no-inline-implementation Suggest refactoring guards, actions and services into machine options
prefer-always Suggest using the always syntax for transient (eventless) transitions ✔️
no-auto-forward Forbid auto-forwarding events to invoked services or spawned actors

Stylistic Issues

Rule Description Recommended
event-names Suggest consistent formatting of event names
state-names Suggest consistent formatting of state names and prevent confusing names
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].