https://github.com/maxmechanic/redux-fsa-linter
Redux middleware to lint for Flux Standard Actions
https://github.com/maxmechanic/redux-fsa-linter
Last synced: 25 days ago
JSON representation
Redux middleware to lint for Flux Standard Actions
- Host: GitHub
- URL: https://github.com/maxmechanic/redux-fsa-linter
- Owner: maxmechanic
- License: mit
- Created: 2015-10-26T02:06:01.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-08-11T23:39:15.000Z (almost 9 years ago)
- Last Synced: 2025-04-09T04:48:42.996Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# redux-fsa-linter
[](https://www.npmjs.org/package/redux-fsa-linter)
[](https://travis-ci.org/maxmechanic/redux-fsa-linter)Redux middleware that validates incoming actions with [Flux Standard Action](https://github.com/acdlite/flux-standard-action).

## Installation
```
npm install redux-fsa-linter --save-dev
```## Usage
```js
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:
```js
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.