From 2de8c920caef249f8a068418c1df9faf3da2b477 Mon Sep 17 00:00:00 2001 From: stephengrider Date: Fri, 16 Jun 2017 10:01:00 -0700 Subject: [PATCH] prettier codebase --- blog/src/actions/index.js | 22 +++++++------ blog/src/components/posts_index.js | 10 +++--- blog/src/components/posts_new.js | 32 ++++++++----------- blog/src/components/posts_show.js | 10 +++--- blog/src/index.js | 25 ++++++++------- blog/src/reducers/index.js | 6 ++-- blog/src/reducers/reducer_posts.js | 20 ++++++------ blog/test/components/app_test.js | 8 ++--- blog/test/test_helper.js | 26 +++++++-------- blog/webpack.config.js | 26 +++++++-------- book_list/src/actions/index.js | 2 +- book_list/src/components/app.js | 8 ++--- book_list/src/containers/book-detail.js | 4 +-- book_list/src/containers/book-list.js | 15 +++++---- book_list/src/index.js | 17 +++++----- book_list/src/reducers/index.js | 6 ++-- book_list/src/reducers/reducer_active_book.js | 6 ++-- book_list/src/reducers/reducer_books.js | 8 ++--- book_list/webpack.config.js | 22 ++++++------- video_browser/src/components/search_bar.js | 9 +++--- video_browser/src/components/video_detail.js | 6 ++-- video_browser/src/components/video_list.js | 11 ++++--- .../src/components/video_list_item.js | 4 +-- video_browser/src/index.js | 31 ++++++++++-------- video_browser/webpack.config.js | 22 ++++++------- weather/src/actions/index.js | 6 ++-- weather/src/components/app.js | 8 ++--- weather/src/components/chart.js | 16 ++++++---- weather/src/components/google_map.js | 2 +- weather/src/containers/search_bar.js | 15 +++++---- weather/src/containers/weather_list.js | 8 ++--- weather/src/index.js | 19 +++++------ weather/src/reducers/index.js | 4 +-- weather/src/reducers/reducer_weather.js | 6 ++-- weather/webpack.config.js | 22 ++++++------- 35 files changed, 236 insertions(+), 226 deletions(-) diff --git a/blog/src/actions/index.js b/blog/src/actions/index.js index 0edf9e98..0e2440fe 100644 --- a/blog/src/actions/index.js +++ b/blog/src/actions/index.js @@ -1,12 +1,12 @@ -import axios from 'axios'; +import axios from "axios"; -export const FETCH_POSTS = 'fetch_posts'; -export const FETCH_POST = 'fetch_post'; -export const CREATE_POST = 'create_post'; -export const DELETE_POST = 'delete_post'; +export const FETCH_POSTS = "fetch_posts"; +export const FETCH_POST = "fetch_post"; +export const CREATE_POST = "create_post"; +export const DELETE_POST = "delete_post"; -const ROOT_URL = 'http://reduxblog.herokuapp.com/api'; -const API_KEY = '?key=PAPERCLIP1234'; +const ROOT_URL = "http://reduxblog.herokuapp.com/api"; +const API_KEY = "?key=PAPERCLIP1234"; export function fetchPosts() { const request = axios.get(`${ROOT_URL}/posts${API_KEY}`); @@ -18,7 +18,8 @@ export function fetchPosts() { } export function createPost(values, callback) { - const request = axios.post(`${ROOT_URL}/posts${API_KEY}`, values) + const request = axios + .post(`${ROOT_URL}/posts${API_KEY}`, values) .then(() => callback()); return { @@ -37,11 +38,12 @@ export function fetchPost(id) { } export function deletePost(id, callback) { - const request = axios.delete(`${ROOT_URL}/posts/${id}${API_KEY}`) + const request = axios + .delete(`${ROOT_URL}/posts/${id}${API_KEY}`) .then(() => callback()); return { type: DELETE_POST, payload: id - } + }; } diff --git a/blog/src/components/posts_index.js b/blog/src/components/posts_index.js index dd2aeda5..f8d6c264 100644 --- a/blog/src/components/posts_index.js +++ b/blog/src/components/posts_index.js @@ -1,8 +1,8 @@ -import _ from 'lodash'; -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { Link } from 'react-router-dom'; -import { fetchPosts } from '../actions'; +import _ from "lodash"; +import React, { Component } from "react"; +import { connect } from "react-redux"; +import { Link } from "react-router-dom"; +import { fetchPosts } from "../actions"; class PostsIndex extends Component { componentDidMount() { diff --git a/blog/src/components/posts_new.js b/blog/src/components/posts_new.js index 95158b27..ce9bd401 100644 --- a/blog/src/components/posts_new.js +++ b/blog/src/components/posts_new.js @@ -1,24 +1,20 @@ -import React, { Component } from 'react'; -import { Field, reduxForm } from 'redux-form'; -import { Link } from 'react-router-dom'; -import { connect } from 'react-redux'; -import { createPost } from '../actions'; +import React, { Component } from "react"; +import { Field, reduxForm } from "redux-form"; +import { Link } from "react-router-dom"; +import { connect } from "react-redux"; +import { createPost } from "../actions"; class PostsNew extends Component { renderField(field) { const { meta: { touched, error } } = field; - const className = `form-group ${touched && error ? 'has-danger' : ''}`; + const className = `form-group ${touched && error ? "has-danger" : ""}`; return (
- +
- {touched ? error : ''} + {touched ? error : ""}
); @@ -26,7 +22,7 @@ class PostsNew extends Component { onSubmit(values) { this.props.createPost(values, () => { - this.props.history.push('/'); + this.props.history.push("/"); }); } @@ -66,10 +62,10 @@ function validate(values) { errors.title = "Enter a title"; } if (!values.categories) { - errors.categories = 'Enter some categories'; + errors.categories = "Enter some categories"; } if (!values.content) { - errors.content = 'Enter some content please'; + errors.content = "Enter some content please"; } // If errors is empty, the form is fine to submit @@ -79,7 +75,5 @@ function validate(values) { export default reduxForm({ validate, - form: 'PostsNewForm' -})( - connect(null,{ createPost })(PostsNew) -); + form: "PostsNewForm" +})(connect(null, { createPost })(PostsNew)); diff --git a/blog/src/components/posts_show.js b/blog/src/components/posts_show.js index 54185589..41538c1d 100644 --- a/blog/src/components/posts_show.js +++ b/blog/src/components/posts_show.js @@ -1,7 +1,7 @@ -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { Link } from 'react-router-dom'; -import { fetchPost, deletePost } from '../actions'; +import React, { Component } from "react"; +import { connect } from "react-redux"; +import { Link } from "react-router-dom"; +import { fetchPost, deletePost } from "../actions"; class PostsShow extends Component { componentDidMount() { @@ -13,7 +13,7 @@ class PostsShow extends Component { const { id } = this.props.match.params; this.props.deletePost(id, () => { - this.props.history.push('/'); + this.props.history.push("/"); }); } diff --git a/blog/src/index.js b/blog/src/index.js index 37fcbe3a..80091582 100644 --- a/blog/src/index.js +++ b/blog/src/index.js @@ -1,14 +1,14 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; -import { Provider } from 'react-redux'; -import { createStore, applyMiddleware } from 'redux'; -import { BrowserRouter, Route, Switch } from 'react-router-dom'; -import promise from 'redux-promise'; +import React from "react"; +import ReactDOM from "react-dom"; +import { Provider } from "react-redux"; +import { createStore, applyMiddleware } from "redux"; +import { BrowserRouter, Route, Switch } from "react-router-dom"; +import promise from "redux-promise"; -import reducers from './reducers'; -import PostsIndex from './components/posts_index'; -import PostsNew from './components/posts_new'; -import PostsShow from './components/posts_show'; +import reducers from "./reducers"; +import PostsIndex from "./components/posts_index"; +import PostsNew from "./components/posts_new"; +import PostsShow from "./components/posts_show"; const createStoreWithMiddleware = applyMiddleware(promise)(createStore); @@ -23,5 +23,6 @@ ReactDOM.render( - - , document.querySelector('.container')); + , + document.querySelector(".container") +); diff --git a/blog/src/reducers/index.js b/blog/src/reducers/index.js index 72be3f44..340301b1 100644 --- a/blog/src/reducers/index.js +++ b/blog/src/reducers/index.js @@ -1,6 +1,6 @@ -import { combineReducers } from 'redux'; -import { reducer as formReducer } from 'redux-form'; -import PostsReducer from './reducer_posts'; +import { combineReducers } from "redux"; +import { reducer as formReducer } from "redux-form"; +import PostsReducer from "./reducer_posts"; const rootReducer = combineReducers({ posts: PostsReducer, diff --git a/blog/src/reducers/reducer_posts.js b/blog/src/reducers/reducer_posts.js index 8b8dc772..415e1c96 100644 --- a/blog/src/reducers/reducer_posts.js +++ b/blog/src/reducers/reducer_posts.js @@ -1,15 +1,15 @@ -import _ from 'lodash'; -import { FETCH_POSTS, FETCH_POST, DELETE_POST } from '../actions'; +import _ from "lodash"; +import { FETCH_POSTS, FETCH_POST, DELETE_POST } from "../actions"; export default function(state = {}, action) { switch (action.type) { - case DELETE_POST: - return _.omit(state, action.payload); - case FETCH_POST: - return { ...state, [action.payload.data.id]: action.payload.data }; - case FETCH_POSTS: - return _.mapKeys(action.payload.data, 'id'); - default: - return state; + case DELETE_POST: + return _.omit(state, action.payload); + case FETCH_POST: + return { ...state, [action.payload.data.id]: action.payload.data }; + case FETCH_POSTS: + return _.mapKeys(action.payload.data, "id"); + default: + return state; } } diff --git a/blog/test/components/app_test.js b/blog/test/components/app_test.js index d7a17a59..665a1174 100644 --- a/blog/test/components/app_test.js +++ b/blog/test/components/app_test.js @@ -1,14 +1,14 @@ -import { renderComponent , expect } from '../test_helper'; -import App from '../../src/components/app'; +import { renderComponent, expect } from "../test_helper"; +import App from "../../src/components/app"; -describe('App' , () => { +describe("App", () => { let component; beforeEach(() => { component = renderComponent(App); }); - it('renders something', () => { + it("renders something", () => { expect(component).to.exist; }); }); diff --git a/blog/test/test_helper.js b/blog/test/test_helper.js index e4d00a0c..d67fad76 100644 --- a/blog/test/test_helper.js +++ b/blog/test/test_helper.js @@ -1,15 +1,15 @@ -import _$ from 'jquery'; -import React from 'react'; -import ReactDOM from 'react-dom'; -import TestUtils from 'react-addons-test-utils'; -import jsdom from 'jsdom'; -import chai, { expect } from 'chai'; -import chaiJquery from 'chai-jquery'; -import { Provider } from 'react-redux'; -import { createStore } from 'redux'; -import reducers from '../src/reducers'; +import _$ from "jquery"; +import React from "react"; +import ReactDOM from "react-dom"; +import TestUtils from "react-addons-test-utils"; +import jsdom from "jsdom"; +import chai, { expect } from "chai"; +import chaiJquery from "chai-jquery"; +import { Provider } from "react-redux"; +import { createStore } from "redux"; +import reducers from "../src/reducers"; -global.document = jsdom.jsdom(''); +global.document = jsdom.jsdom(""); global.window = global.document.defaultView; global.navigator = global.window.navigator; const $ = _$(window); @@ -17,7 +17,7 @@ const $ = _$(window); chaiJquery(chai, chai.util, $); function renderComponent(ComponentClass, props = {}, state = {}) { - const componentInstance = TestUtils.renderIntoDocument( + const componentInstance = TestUtils.renderIntoDocument( @@ -33,4 +33,4 @@ $.fn.simulate = function(eventName, value) { TestUtils.Simulate[eventName](this[0]); }; -export {renderComponent, expect}; +export { renderComponent, expect }; diff --git a/blog/webpack.config.js b/blog/webpack.config.js index 31d865c2..24827dcb 100644 --- a/blog/webpack.config.js +++ b/blog/webpack.config.js @@ -1,26 +1,26 @@ module.exports = { - entry: [ - './src/index.js' - ], + entry: ["./src/index.js"], output: { path: __dirname, - publicPath: '/', - filename: 'bundle.js' + publicPath: "/", + filename: "bundle.js" }, module: { - loaders: [{ - exclude: /node_modules/, - loader: 'babel', - query: { - presets: ['react', 'es2015', 'stage-1'] + loaders: [ + { + exclude: /node_modules/, + loader: "babel", + query: { + presets: ["react", "es2015", "stage-1"] + } } - }] + ] }, resolve: { - extensions: ['', '.js', '.jsx'] + extensions: ["", ".js", ".jsx"] }, devServer: { historyApiFallback: true, - contentBase: './' + contentBase: "./" } }; diff --git a/book_list/src/actions/index.js b/book_list/src/actions/index.js index 95dba608..ad38f4d1 100644 --- a/book_list/src/actions/index.js +++ b/book_list/src/actions/index.js @@ -2,7 +2,7 @@ export function selectBook(book) { // selectBook is an ActionCreator, it needs to return an action, // an object with a type property. return { - type: 'BOOK_SELECTED', + type: "BOOK_SELECTED", payload: book }; } diff --git a/book_list/src/components/app.js b/book_list/src/components/app.js index a855184c..c1eb0f04 100644 --- a/book_list/src/components/app.js +++ b/book_list/src/components/app.js @@ -1,8 +1,8 @@ -import React from 'react'; -import { Component } from 'react'; +import React from "react"; +import { Component } from "react"; -import BookList from '../containers/book-list'; -import BookDetail from '../containers/book-detail'; +import BookList from "../containers/book-list"; +import BookDetail from "../containers/book-detail"; export default class App extends Component { render() { diff --git a/book_list/src/containers/book-detail.js b/book_list/src/containers/book-detail.js index e8455057..c9ff4ef4 100644 --- a/book_list/src/containers/book-detail.js +++ b/book_list/src/containers/book-detail.js @@ -1,5 +1,5 @@ -import React, { Component } from 'react'; -import { connect } from 'react-redux'; +import React, { Component } from "react"; +import { connect } from "react-redux"; class BookDetail extends Component { render() { diff --git a/book_list/src/containers/book-list.js b/book_list/src/containers/book-list.js index 6683a4f4..9c1335b5 100644 --- a/book_list/src/containers/book-list.js +++ b/book_list/src/containers/book-list.js @@ -1,16 +1,17 @@ -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { selectBook } from '../actions/index'; -import { bindActionCreators } from 'redux'; +import React, { Component } from "react"; +import { connect } from "react-redux"; +import { selectBook } from "../actions/index"; +import { bindActionCreators } from "redux"; class BookList extends Component { renderList() { - return this.props.books.map((book) => { + return this.props.books.map(book => { return (
  • this.props.selectBook(book)} - className="list-group-item"> + className="list-group-item" + > {book.title}
  • ); @@ -22,7 +23,7 @@ class BookList extends Component { - ) + ); } } diff --git a/book_list/src/index.js b/book_list/src/index.js index 86f25006..08031483 100644 --- a/book_list/src/index.js +++ b/book_list/src/index.js @@ -1,13 +1,14 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; -import { Provider } from 'react-redux'; -import { createStore } from 'redux'; +import React from "react"; +import ReactDOM from "react-dom"; +import { Provider } from "react-redux"; +import { createStore } from "redux"; -import App from './components/app'; -import reducers from './reducers'; +import App from "./components/app"; +import reducers from "./reducers"; ReactDOM.render( - - , document.querySelector('.container')); + , + document.querySelector(".container") +); diff --git a/book_list/src/reducers/index.js b/book_list/src/reducers/index.js index be181637..b630e1a7 100644 --- a/book_list/src/reducers/index.js +++ b/book_list/src/reducers/index.js @@ -1,6 +1,6 @@ -import { combineReducers } from 'redux'; -import BooksReducer from './reducer_books'; -import ActiveBook from './reducer_active_book'; +import { combineReducers } from "redux"; +import BooksReducer from "./reducer_books"; +import ActiveBook from "./reducer_active_book"; const rootReducer = combineReducers({ books: BooksReducer, diff --git a/book_list/src/reducers/reducer_active_book.js b/book_list/src/reducers/reducer_active_book.js index 89d2a823..702886af 100644 --- a/book_list/src/reducers/reducer_active_book.js +++ b/book_list/src/reducers/reducer_active_book.js @@ -1,9 +1,9 @@ // State argument is not application state, only the state // this reducer is responsible for export default function(state = null, action) { - switch(action.type) { - case 'BOOK_SELECTED': - return action.payload; + switch (action.type) { + case "BOOK_SELECTED": + return action.payload; } return state; diff --git a/book_list/src/reducers/reducer_books.js b/book_list/src/reducers/reducer_books.js index 12a2d2cf..46a0a224 100644 --- a/book_list/src/reducers/reducer_books.js +++ b/book_list/src/reducers/reducer_books.js @@ -1,8 +1,8 @@ export default function() { return [ - { title: 'Javascript: The Good Parts', pages: 101 }, - { title: 'Harry Potter', pages: 39 }, - { title: 'The Dark Tower', pages: 85 }, - { title: 'Eloquent Ruby', pages: 1 } + { title: "Javascript: The Good Parts", pages: 101 }, + { title: "Harry Potter", pages: 39 }, + { title: "The Dark Tower", pages: 85 }, + { title: "Eloquent Ruby", pages: 1 } ]; } diff --git a/book_list/webpack.config.js b/book_list/webpack.config.js index fbefc734..4fc8af18 100644 --- a/book_list/webpack.config.js +++ b/book_list/webpack.config.js @@ -1,22 +1,22 @@ module.exports = { - entry: [ - './src/index.js' - ], + entry: ["./src/index.js"], output: { path: __dirname, - publicPath: '/', - filename: 'bundle.js' + publicPath: "/", + filename: "bundle.js" }, module: { - loaders: [{ - exclude: /node_modules/, - loader: 'babel' - }] + loaders: [ + { + exclude: /node_modules/, + loader: "babel" + } + ] }, resolve: { - extensions: ['', '.js', '.jsx'] + extensions: ["", ".js", ".jsx"] }, devServer: { - contentBase: './' + contentBase: "./" } }; diff --git a/video_browser/src/components/search_bar.js b/video_browser/src/components/search_bar.js index 8eb40136..9839b27b 100644 --- a/video_browser/src/components/search_bar.js +++ b/video_browser/src/components/search_bar.js @@ -1,10 +1,10 @@ -import React, { Component } from 'react'; +import React, { Component } from "react"; class SearchBar extends Component { constructor(props) { super(props); - this.state = { term: '' }; + this.state = { term: "" }; } render() { @@ -12,13 +12,14 @@ class SearchBar extends Component {
    this.onInputChange(event.target.value)} /> + onChange={event => this.onInputChange(event.target.value)} + />
    ); } onInputChange(term) { - this.setState({term}); + this.setState({ term }); this.props.onSearchTermChange(term); } } diff --git a/video_browser/src/components/video_detail.js b/video_browser/src/components/video_detail.js index 04344eef..cb767d50 100644 --- a/video_browser/src/components/video_detail.js +++ b/video_browser/src/components/video_detail.js @@ -1,6 +1,6 @@ -import React from 'react'; +import React from "react"; -const VideoDetail = ({video}) => { +const VideoDetail = ({ video }) => { if (!video) { return
    Loading...
    ; } @@ -11,7 +11,7 @@ const VideoDetail = ({video}) => { return (
    - +