Skip to content

Commit

Permalink
Style: force spacing inside braces
Browse files Browse the repository at this point in the history
  • Loading branch information
llh911001 committed Sep 16, 2017
1 parent 32753d5 commit eee6de2
Show file tree
Hide file tree
Showing 17 changed files with 72 additions and 71 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"semi": [2, "never"],
"space-before-blocks": 2,
"spaced-comment": [2, "always"],
"object-curly-spacing": [2, "always"],
},
"plugins": [
"react"
Expand Down
4 changes: 2 additions & 2 deletions src/actions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {dispatch} from './middleware'
import {options} from './defaults'
import { dispatch } from './middleware'
import { options } from './defaults'

const SEP = '/'

Expand Down
2 changes: 1 addition & 1 deletion src/defaults.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {effects, addEffect} from './effects'
import { effects, addEffect } from './effects'

export const options = {
// global initial state
Expand Down
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Route, Redirect, Switch, Prompt, withRouter} from 'react-router'
import {Link, NavLink} from 'react-router-dom'
import {connect} from 'react-redux'
import { Route, Redirect, Switch, Prompt, withRouter } from 'react-router'
import { Link, NavLink } from 'react-router-dom'
import { connect } from 'react-redux'
import model from './model'
import {actions} from './actions'
import { actions } from './actions'
import render from './render'
import hook from './hook'
import Router from './router'
Expand Down
4 changes: 2 additions & 2 deletions src/middleware.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {effects} from './effects'
import {hooks} from './hook'
import { effects } from './effects'
import { hooks } from './hook'

function warning() {
throw new Error(
Expand Down
2 changes: 1 addition & 1 deletion src/model.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {resolveReducers, addActions} from './actions'
import { resolveReducers, addActions } from './actions'

export const models = []

Expand Down
10 changes: 5 additions & 5 deletions src/render.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import React from 'react'
import ReactDOM from 'react-dom'
import {Provider} from 'react-redux'
import { Provider } from 'react-redux'

import {options} from './defaults'
import {models} from './model'
import {store, createStore, replaceReducer} from './store'
import { options } from './defaults'
import { models } from './model'
import { store, createStore, replaceReducer } from './store'

let started = false
let Root

export default function render(component, container, callback) {

const {initialState, middlewares, reducers} = options
const { initialState, middlewares, reducers } = options

if (started) {

Expand Down
12 changes: 6 additions & 6 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import PropTypes from 'prop-types'
import createBrowserHistory from 'history/createBrowserHistory'
import createHashHistory from 'history/createHashHistory'
import createMemoryHistory from 'history/createMemoryHistory'
import {ConnectedRouter, routerActions} from 'react-router-redux'
import { ConnectedRouter, routerActions } from 'react-router-redux'

import {options} from './defaults'
import {dispatch} from './middleware'
import {actions} from './actions'
import { options } from './defaults'
import { dispatch } from './middleware'
import { actions } from './actions'

let history

export default function Router({history = getHistory(), children}) {
export default function Router({ history = getHistory(), children }) {

// Add `push`, `replace`, `go`, `goForward` and `goBack` methods to actions.routing,
// when called, will dispatch the crresponding action provided by react-router-redux.
Expand Down Expand Up @@ -41,7 +41,7 @@ export function getHistory() {
return history
}

const {historyMode} = options
const { historyMode } = options

const historyModes = {
browser: createBrowserHistory,
Expand Down
4 changes: 2 additions & 2 deletions src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import {
combineReducers,
compose
} from 'redux'
import {routerMiddleware, routerReducer} from 'react-router-redux'
import { routerMiddleware, routerReducer } from 'react-router-redux'

import createMiddleware from './middleware'
import {getHistory} from './router'
import { getHistory } from './router'

export let store

Expand Down
32 changes: 16 additions & 16 deletions test/actions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ jest.useFakeTimers()
describe('global actions', () => {

it('actions should be an empty object', () => {
const {actions} = require('index')
const { actions } = require('index')
expect(actions).toEqual({})
})

it('addActions should add action', () => {
const {actions} = require('index')
const {addActions} = require('actions')
const { actions } = require('index')
const { addActions } = require('actions')

addActions('app', {
add(state, data) {
return {...state, count: state.count + data}
return { ...state, count: state.count + data }
}
})

Expand All @@ -29,7 +29,7 @@ describe('global actions', () => {

it('mirror.model should add action', () => {
const mirror = require('index')
const {actions} = mirror
const { actions } = mirror

mirror.model({
name: 'app',
Expand All @@ -38,7 +38,7 @@ describe('global actions', () => {
},
reducers: {
add(state, data) {
return {...state, count: state.count + data}
return { ...state, count: state.count + data }
}
}
})
Expand All @@ -50,7 +50,7 @@ describe('global actions', () => {

it('throws if call actions without creating store', () => {
const mirror = require('index')
const {actions} = mirror
const { actions } = mirror

mirror.model({
name: 'app',
Expand All @@ -69,8 +69,8 @@ describe('global actions', () => {

it('call actions should dispatch action', () => {
const mirror = require('index')
const {actions} = mirror
const {createStore} = require('store')
const { actions } = mirror
const { createStore } = require('store')

const model = mirror.model({
name: 'app',
Expand All @@ -96,7 +96,7 @@ describe('global actions', () => {

it('should register to global effects object', () => {
const mirror = require('index')
const {effects} = require('effects')
const { effects } = require('effects')

mirror.model({
name: 'app',
Expand All @@ -113,7 +113,7 @@ describe('global actions', () => {

it('should add action by specifying effects', () => {
const mirror = require('index')
const {actions} = mirror
const { actions } = mirror

mirror.model({
name: 'app',
Expand All @@ -136,8 +136,8 @@ describe('global actions', () => {

it('async/await style effect actions', async () => {
const mirror = require('index')
const {actions} = mirror
const {createStore} = require('store')
const { actions } = mirror
const { createStore } = require('store')

const model = mirror.model({
name: 'app',
Expand All @@ -149,7 +149,7 @@ describe('global actions', () => {
},
effects: {
async myEffect(data, getState) {
const {app} = getState()
const { app } = getState()
const res = await Promise.resolve(app + data)
// calls the pure reducer
actions.app.add(res)
Expand All @@ -170,8 +170,8 @@ describe('global actions', () => {

it('callback style effect actions', () => {
const mirror = require('index')
const {actions} = mirror
const {createStore} = require('store')
const { actions } = mirror
const { createStore } = require('store')

const fn = jest.fn()

Expand Down
2 changes: 1 addition & 1 deletion test/defaults.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import defaults, {options} from 'defaults'
import defaults, { options } from 'defaults'

describe('mirror.defaults', () => {

Expand Down
12 changes: 6 additions & 6 deletions test/hook.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ beforeEach(() => {
describe('the hook method', () => {

it('hooks should be an array', () => {
const {hooks} = require('hook')
const { hooks } = require('hook')

expect(hooks).toEqual([])
})
Expand All @@ -24,7 +24,7 @@ describe('the hook method', () => {

it('mirror.hook should add hook', () => {
const mirror = require('index')
const {hooks} = require('hook')
const { hooks } = require('hook')

const fn = jest.fn()

Expand All @@ -35,8 +35,8 @@ describe('the hook method', () => {

it('dispatch action should call hook', () => {
const mirror = require('index')
const {createStore} = require('store')
const {actions} = mirror
const { createStore } = require('store')
const { actions } = mirror

const fn = jest.fn()

Expand Down Expand Up @@ -66,8 +66,8 @@ describe('the hook method', () => {

it('call function returned by hook should remove hook', () => {
const mirror = require('index')
const {createStore} = require('store')
const {actions} = mirror
const { createStore } = require('store')
const { actions } = mirror

let log = []
let state
Expand Down
10 changes: 5 additions & 5 deletions test/middleware.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {createStore, applyMiddleware} from 'redux'
import createMiddleware, {dispatch} from 'middleware'
import {effects, addEffect} from 'effects'
import { createStore, applyMiddleware } from 'redux'
import createMiddleware, { dispatch } from 'middleware'
import { effects, addEffect } from 'effects'

describe('the middleware', () => {

Expand All @@ -24,13 +24,13 @@ describe('the middleware', () => {

expect(dispatch).toBeDefined()

dispatch({type: 'add', data: 1})
dispatch({ type: 'add', data: 1 })

expect(store.getState()).toEqual(1)

expect(fn).not.toBeCalled()

dispatch({type: 'myEffect'})
dispatch({ type: 'myEffect' })

expect(fn).toBeCalled()
})
Expand Down
6 changes: 3 additions & 3 deletions test/model.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('mirror.model', () => {

it('models should be an array', () => {
const mirror = require('index')
const {models} = require('model')
const { models } = require('model')

expect(models).toBeInstanceOf(Array)

Expand Down Expand Up @@ -133,7 +133,7 @@ describe('mirror.model', () => {

it('do not add actions if reducers and effects are empty', () => {
const mirror = require('index')
const {actions} = mirror
const { actions } = mirror

mirror.model({
name: 'model1'
Expand Down Expand Up @@ -184,7 +184,7 @@ describe('mirror.model', () => {

it('should ignore non-function entries in reducers and effects', () => {
const mirror = require('index')
const {actions} = mirror
const { actions } = mirror

const fn = () => {}

Expand Down
16 changes: 8 additions & 8 deletions test/render.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import mirror, {actions, render, connect} from 'index'
import {store} from 'store'
import mirror, { actions, render, connect } from 'index'
import { store } from 'store'


describe('the render function', () => {
Expand All @@ -20,7 +20,7 @@ describe('the render function', () => {

expect(store).toBeDefined()
expect(store.getState).toBeInstanceOf(Function)
expect(store.getState().foo).toEqual({count: 0})
expect(store.getState().foo).toEqual({ count: 0 })
})

it('should connect and render', () => {
Expand All @@ -34,15 +34,15 @@ describe('the render function', () => {
},
reducers: {
increment(state) {
return {...state, count: state.count + 1}
return { ...state, count: state.count + 1 }
}
}
})

/* eslint react/prop-types: 0 */
const Comp = props => <div id="app" onClick={actions.app.increment}>{props.count}</div>

const App = connect(({app}) => app)(Comp)
const App = connect(({ app }) => app)(Comp)

render(<App/>, container)

Expand All @@ -69,7 +69,7 @@ describe('the render function', () => {

render(<div/>, container)

expect(store.getState().model1).toEqual({count: 0})
expect(store.getState().model1).toEqual({ count: 0 })

// create another model
mirror.model({
Expand All @@ -82,7 +82,7 @@ describe('the render function', () => {
// re-render
render()

expect(store.getState().model1).toEqual({count: 0})
expect(store.getState().model2).toEqual({foo: 'foo'})
expect(store.getState().model1).toEqual({ count: 0 })
expect(store.getState().model2).toEqual({ foo: 'foo' })
})
})
Loading

0 comments on commit eee6de2

Please sign in to comment.