Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including redux-fsa-linter with all npm packages installed. Try it out:

var reduxFsaLinter = require("redux-fsa-linter")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

redux-fsa-linter v2.0.0

Redux middleware to lint for Flux Standard Actions

redux-fsa-linter

npm package build status

Redux middleware that validates incoming actions with Flux Standard Action.

linting

Installation

npm install redux-fsa-linter --save-dev

Usage

import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import createLinter from 'redux-fsa-linter';

const linter = createLinter();

const createStoreWithMiddleware = applyMiddleware(
  thunk,
  linter
)(createStore);

The middleware will ignore anything passing through it that is not a plain object.

By default, the linter will alert the user of non-compliant actions by way of console warnings. Passing {strict: true} to the createLinter function will result in non-compliant actions throwing errors.

createLinter can also take an ignore function on the options object. This predicate is handed the incoming action, and the linter will ignore the action if the function returns a truthy value:

const ignore = ({ type }) => type === 'IGNORE_ME'

const createLinter({ ignore })

This may be useful if you are using third-party libraries that may dispatch non-FSA actions.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free