From a6a76fb38d06a04fa38e46a133640273bb4a1011 Mon Sep 17 00:00:00 2001 From: tristen Date: Fri, 21 Aug 2015 20:00:29 -0400 Subject: [PATCH] Writing in ES6 is lovely --- .babelrc | 5 +++++ .eslintrc | 3 +++ package.json | 1 + src/components/shared/input.js | 1 - src/reducers/index.js | 32 ++++++++++++-------------------- 5 files changed, 21 insertions(+), 21 deletions(-) create mode 100644 .babelrc diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..166ed4e --- /dev/null +++ b/.babelrc @@ -0,0 +1,5 @@ +{ + "stage": 0, + "loose": "all", + "plugins": ["object-assign"] +} diff --git a/.eslintrc b/.eslintrc index efee512..0429caa 100644 --- a/.eslintrc +++ b/.eslintrc @@ -26,6 +26,9 @@ "comma-spacing": [0], "key-spacing": [0], "no-use-before-define": [0], + "react/jsx-uses-react": 2, + "react/jsx-uses-vars": 2, + "react/react-in-jsx-scope": 2, "react/no-multi-comp": 2, "react/prop-types": 2 } diff --git a/package.json b/package.json index 1a844f4..3c90ab3 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "babel-core": "^5.8.22", "babel-eslint": "^4.0.10", "babel-loader": "^5.3.2", + "babel-plugin-object-assign": "^1.2.1", "babelify": "^6.1.3", "browserify": "^11.0.1", "eslint": "^1.1.0", diff --git a/src/components/shared/input.js b/src/components/shared/input.js index baf5165..e86d5e6 100644 --- a/src/components/shared/input.js +++ b/src/components/shared/input.js @@ -33,7 +33,6 @@ export default class Input extends Component { render() { const { options } = this.props; - const inputAttributes = { placeholder: options.placeholder, onChange: this.onChange.bind(this) diff --git a/src/reducers/index.js b/src/reducers/index.js index b6b7707..10163b6 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -11,44 +11,36 @@ const initialState = { function inputs(state = initialState, action) { switch (action.type) { case types.ORIGIN_INPUT: - return { + return Object.assign({}, state, { originQuery: action.query, - originResults: action.results, - destinationResults: state.destinationResults, - destinationQuery: state.destinationQuery - }; + originResults: action.results + }); case types.DESTINATION_INPUT: - return { - originQuery: state.originQuery, - originResults: state.originResults, + return Object.assign({}, state, { destinationQuery: action.query, destinationResults: action.results - }; + }); case types.ORIGIN_CLEAR: - return { + return Object.assign({}, state, { originQuery: '', - originResults: [], - destinationResults: state.destinationResults, - destinationQuery: state.destinationQuery - }; + originResults: [] + }); case types.DESTINATION_CLEAR: - return { - originQuery: state.originQuery, - originResults: state.originResults, + return Object.assign({}, state, { destinationQuery: '', destinationResults: [] - }; + }); case types.REVERSE_INPUTS: - return { + return Object.assign({}, state, { originResults: state.destinationResults, originQuery: state.destinationQuery, destinationResults: state.originResults, destinationQuery: state.originQuery - }; + }); default: return state;