diff --git a/.babelrc b/.babelrc index 53f2ae9..15d27ad 100644 --- a/.babelrc +++ b/.babelrc @@ -1,4 +1,4 @@ { "stage": 0, "loose": "all" -} \ No newline at end of file +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..88f6888 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +# editorconfig.org +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 2 +insert_final_newline = true +indent_style = space +max_line_length = 0 +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +# The indent size used in the `package.json` file cannot be changed +# https://github.com/npm/npm/pull/3180#issuecomment-16336516 +# The other files are added for parity. +[{.bowerrc,.travis.yml,bower.json,package.json}] +indent_size = 2 +indent_style = space diff --git a/.npmignore b/.npmignore index a8b6d49..739feac 100644 --- a/.npmignore +++ b/.npmignore @@ -4,4 +4,4 @@ examples .DS_Store *.log *.tgs -*.yml \ No newline at end of file +*.yml diff --git a/.travis.yml b/.travis.yml index d99c2e7..c42701f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,3 @@ language: node_js node_js: - - "iojs" \ No newline at end of file + - "iojs" diff --git a/examples/counter/actions/counter.js b/examples/counter/actions/counter.js index 798231a..214092e 100644 --- a/examples/counter/actions/counter.js +++ b/examples/counter/actions/counter.js @@ -31,4 +31,4 @@ export function incrementAsync(delay = 1000) { dispatch(increment()); }, delay); }; -} \ No newline at end of file +} diff --git a/examples/counter/components/counter.html b/examples/counter/components/counter.html index 416e431..08b541f 100644 --- a/examples/counter/components/counter.html +++ b/examples/counter/components/counter.html @@ -1,6 +1,5 @@

Clicked: {{counter.value}} times

- diff --git a/examples/counter/components/counter.js b/examples/counter/components/counter.js index 26e537b..0ddd1e6 100644 --- a/examples/counter/components/counter.js +++ b/examples/counter/components/counter.js @@ -23,4 +23,4 @@ class CounterController { value: state.counter }; } -} \ No newline at end of file +} diff --git a/examples/counter/index.html b/examples/counter/index.html index f548f84..aaf7f9a 100644 --- a/examples/counter/index.html +++ b/examples/counter/index.html @@ -10,4 +10,4 @@
- \ No newline at end of file + diff --git a/examples/counter/reducers/counter.js b/examples/counter/reducers/counter.js index 7e05b66..84e9615 100644 --- a/examples/counter/reducers/counter.js +++ b/examples/counter/reducers/counter.js @@ -9,4 +9,4 @@ export default function counter(state = 0, action) { default: return state; } -} \ No newline at end of file +} diff --git a/examples/counter/reducers/index.js b/examples/counter/reducers/index.js index 41aac18..9817109 100644 --- a/examples/counter/reducers/index.js +++ b/examples/counter/reducers/index.js @@ -5,4 +5,4 @@ const rootReducer = combineReducers({ counter }); -export default rootReducer; \ No newline at end of file +export default rootReducer; diff --git a/index.d.ts b/index.d.ts index 18d3255..3ee3b78 100644 --- a/index.d.ts +++ b/index.d.ts @@ -32,4 +32,4 @@ export interface INgReduxProvider { } export var ngRedux: string; -export default ngRedux; \ No newline at end of file +export default ngRedux; diff --git a/src/components/connector.js b/src/components/connector.js index 9de4b16..37ab861 100644 --- a/src/components/connector.js +++ b/src/components/connector.js @@ -74,4 +74,4 @@ function getStateSlice(state, mapStateToScope) { ); return slice; -} \ No newline at end of file +} diff --git a/src/components/ngRedux.js b/src/components/ngRedux.js index 5d7a4cd..a86ed02 100644 --- a/src/components/ngRedux.js +++ b/src/components/ngRedux.js @@ -12,33 +12,33 @@ export default function ngReduxProvider() { let _storeEnhancers = undefined; this.createStoreWith = (reducer, middlewares, storeEnhancers) => { - invariant( - isFunction(reducer), - 'The reducer parameter passed to createStoreWith must be a Function. Instead received %s.', - typeof reducer - ); - - invariant( - !storeEnhancers || isArray(storeEnhancers), - 'The storeEnhancers parameter passed to createStoreWith must be an Array. Instead received %s.', - typeof storeEnhancers - ); - - _reducer = reducer; - _storeEnhancers = storeEnhancers - _middlewares = middlewares || []; + invariant( + isFunction(reducer), + 'The reducer parameter passed to createStoreWith must be a Function. Instead received %s.', + typeof reducer + ); + + invariant( + !storeEnhancers || isArray(storeEnhancers), + 'The storeEnhancers parameter passed to createStoreWith must be an Array. Instead received %s.', + typeof storeEnhancers + ); + + _reducer = reducer; + _storeEnhancers = storeEnhancers + _middlewares = middlewares || []; }; this.$get = ($injector) => { - let store, resolvedMiddleware = []; + let store, resolvedMiddleware = []; - for(let middleware of _middlewares) { - if(typeof middleware === 'string') { - resolvedMiddleware.push($injector.get(middleware)); - } else { - resolvedMiddleware.push(middleware); - } - } + for(let middleware of _middlewares) { + if(typeof middleware === 'string') { + resolvedMiddleware.push($injector.get(middleware)); + } else { + resolvedMiddleware.push(middleware); + } + } let finalCreateStore = _storeEnhancers ? compose(..._storeEnhancers)(createStore) : createStore; @@ -47,11 +47,11 @@ export default function ngReduxProvider() { store = applyMiddleware(...resolvedMiddleware)(finalCreateStore)(_reducer); - return { + return { ...store, connect: Connector(store) }; - } + }; this.$get.$inject = ['$injector']; } diff --git a/test/components/connector.spec.js b/test/components/connector.spec.js index 0b084aa..d849aef 100644 --- a/test/components/connector.spec.js +++ b/test/components/connector.spec.js @@ -22,15 +22,13 @@ describe('Connector', () => { connect = Connector(store); }); - it('Should throw when target is not a Function or a plain object', () => { - expect(connect(() => ({})).bind(connect, 15)).toThrow(); - expect(connect(() => ({})).bind(connect, undefined)).toThrow(); - expect(connect(() => ({})).bind(connect, 'test')).toThrow(); - - expect(connect(() => ({})).bind(connect, {})).toNotThrow(); + it('Should throw when target is not a Function or a plain object', () => { + expect(connect(() => ({})).bind(connect, 15)).toThrow(); + expect(connect(() => ({})).bind(connect, undefined)).toThrow(); + expect(connect(() => ({})).bind(connect, 'test')).toThrow(); + expect(connect(() => ({})).bind(connect, {})).toNotThrow(); expect(connect(() => ({})).bind(connect, () => {})).toNotThrow(); - - }); + }); it('Should throw when selector does not return a plain object', () => { expect(connect.bind(connect, state => state.foo)).toThrow(); @@ -61,7 +59,7 @@ describe('Connector', () => { targetObj.baz = 0; - //this should not replace our mutation, since the state didn't change + //this should not replace our mutation, since the state didn't change store.dispatch({ type: 'ACTION', payload: 5 }); expect(targetObj.baz).toBe(0); @@ -94,4 +92,4 @@ describe('Connector', () => { expect(receivedDispatch).toBe(store.dispatch); }); -}); \ No newline at end of file +}); diff --git a/test/utils/wrapActionCreators.spec.js b/test/utils/wrapActionCreators.spec.js index 11fbad9..af31ce4 100644 --- a/test/utils/wrapActionCreators.spec.js +++ b/test/utils/wrapActionCreators.spec.js @@ -28,4 +28,4 @@ describe('Utils', () => { }); }); -}); \ No newline at end of file +});