Skip to content

Add .editorconfig #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"stage": 0,
"loose": "all"
}
}
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ examples
.DS_Store
*.log
*.tgs
*.yml
*.yml
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
language: node_js
node_js:
- "iojs"
- "iojs"
2 changes: 1 addition & 1 deletion examples/counter/actions/counter.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ export function incrementAsync(delay = 1000) {
dispatch(increment());
}, delay);
};
}
}
1 change: 0 additions & 1 deletion examples/counter/components/counter.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<div>
<p>Clicked: {{counter.value}} times </p>

<button ng-click='counter.increment()'>+</button>
<button ng-click='counter.decrement()'>-</button>
<button ng-click='counter.incrementIfOdd()'>Increment if odd</button>
Expand Down
2 changes: 1 addition & 1 deletion examples/counter/components/counter.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ class CounterController {
value: state.counter
};
}
}
}
2 changes: 1 addition & 1 deletion examples/counter/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
</div>
<div id="devTools"></div>
</body>
</html>
</html>
2 changes: 1 addition & 1 deletion examples/counter/reducers/counter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export default function counter(state = 0, action) {
default:
return state;
}
}
}
2 changes: 1 addition & 1 deletion examples/counter/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ const rootReducer = combineReducers({
counter
});

export default rootReducer;
export default rootReducer;
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ export interface INgReduxProvider {
}

export var ngRedux: string;
export default ngRedux;
export default ngRedux;
2 changes: 1 addition & 1 deletion src/components/connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ function getStateSlice(state, mapStateToScope) {
);

return slice;
}
}
50 changes: 25 additions & 25 deletions src/components/ngRedux.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -47,11 +47,11 @@ export default function ngReduxProvider() {

store = applyMiddleware(...resolvedMiddleware)(finalCreateStore)(_reducer);

return {
return {
...store,
connect: Connector(store)
};
}
};

this.$get.$inject = ['$injector'];
}
18 changes: 8 additions & 10 deletions test/components/connector.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -94,4 +92,4 @@ describe('Connector', () => {
expect(receivedDispatch).toBe(store.dispatch);
});

});
});
2 changes: 1 addition & 1 deletion test/utils/wrapActionCreators.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ describe('Utils', () => {

});
});
});
});