Skip to content

Commit

Permalink
added eslint and fixed lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
3LOK committed Jan 16, 2017
1 parent 61e62b6 commit f0480e5
Show file tree
Hide file tree
Showing 4 changed files with 226 additions and 174 deletions.
55 changes: 55 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"parser": "babel-eslint",
"parserOptions": {
"ecmaFeatures": {
"modules": true,
"jsx": true
}
},
"env": {
"browser": true,
"node": true,
"es6": true
},
"extends": ["eslint:recommended"],
"globals": {
"mapboxgl": true,
"Q": true,
"_": true,
"google": true,
"FB": true,
"goog": true,
"$": true,
"moment": true,
"dispatch": true,
"connect": true,
"React": true,
"ReactDOM": true,
"spiceProduction": true,
"ReactBootstrap": true,
"Wix": true,
"If": true,
"For": true,
"Else": true,
"define": true,
"olark": true,
"Reflux": true,
"uniqueId": true,
"describe": false,
"it":false,
"beforeEach":false,
"spiceVer": false,
"prodLocaleFile": true,
"prodAppFile": true,
},
"rules": {
"strict": 0,
"no-console": 0,
"no-underscore-dangle": 0,
"no-trailing-spaces": 2,
"no-unused-vars": 2,
"no-undef": 2,
"semi": 2,
"indent": ["error", 4]
}
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"description": "Full redux environment testing helper for redux-saga",
"main": "dist/SagaTester.js",
"scripts": {
"lint": "eslint './src/**/*.js' './test/**/*.js'",
"prepublish": "npm test && npm run compile",
"test": "mocha --compilers js:babel-register",
"test": "mocha --compilers js:babel-register && npm run lint",
"compile": "babel -d dist/ src/",
"build": ":",
"release": "npm install @wix/wnpm-ci && wnpm-release -- --no-shrinkwrap"
Expand All @@ -27,13 +28,15 @@
"devDependencies": {
"babel": "^6.5.2",
"babel-cli": "^6.14.0",
"babel-eslint": "^7.1.1",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-preset-es2015": "^6.14.0",
"babel-preset-stage-2": "^6.13.0",
"babel-register": "^6.14.0",
"babel-runtime": "^6.11.6",
"chai": "^3.5.0",
"chai-as-promised": "^5.3.0",
"eslint": "^3.13.1",
"mocha": "^3.0.2",
"redux": "^3.6.0",
"redux-saga": "^0.11.1"
Expand Down
23 changes: 8 additions & 15 deletions src/SagaTester.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,7 @@ import createSagaMiddleware from 'redux-saga';
import { combineReducers as reduxCombineReducers, createStore, applyMiddleware } from 'redux';

const RESET_TESTER_ACTION_TYPE = '@@RESET_TESTER';
const makeResettable = (reducer, initialStateSlice) => (state, action) => {
switch (action.type) {
case RESET_TESTER_ACTION_TYPE:
return reducer(initialStateSlice, action);
default:
return reducer(state, action);
}
};

export const resetAction = { type : RESET_TESTER_ACTION_TYPE };

export default class SagaIntegrationTester {
Expand All @@ -19,21 +12,21 @@ export default class SagaIntegrationTester {
this.actionLookups = {};
this.sagaMiddleware = createSagaMiddleware();

const reducerFn = typeof reducers === 'object' ? combineReducers(reducers) : reducers
const reducerFn = typeof reducers === 'object' ? combineReducers(reducers) : reducers;

const finalReducer = (state, action) => {
// reset state if requested
if (action.type === RESET_TESTER_ACTION_TYPE) return initialState;
if (action.type === RESET_TESTER_ACTION_TYPE) return initialState;

// supply identity reducer as default
if (!reducerFn) return initialState;
if (!reducerFn) return initialState;

// otherwise use the provided reducer
return reducerFn(state, action);
return reducerFn(state, action);
};

// Middleware to store the actions and create promises
const testerMiddleware = store => next => action => {
const testerMiddleware = () => next => action => {
if (ignoreReduxActions && action.type.startsWith('@@redux')) {
// Don't monitor redux actions
} else {
Expand All @@ -43,7 +36,7 @@ export default class SagaIntegrationTester {
actionObj.callback(action);
}
return next(action);
}
};

const allMiddlewares = [
...middlewares,
Expand All @@ -61,7 +54,7 @@ export default class SagaIntegrationTester {
let action = this.actionLookups[actionType];
if (!action || futureOnly) {
action = { count : 0 };
action.promise = new Promise((resolve, reject) => action.callback = resolve);
action.promise = new Promise((resolve) => action.callback = resolve);
this.actionLookups[actionType] = action;
}
return action;
Expand Down
Loading

0 comments on commit f0480e5

Please sign in to comment.