Skip to content

Commit 311279d

Browse files
committed
Prettier 2.0
1 parent cffad3c commit 311279d

10 files changed

+26
-31
lines changed

.prettierrc.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"semi": false,
33
"singleQuote": true,
4-
"tabWidth": 2
4+
"tabWidth": 2,
5+
"trailingComma": "none",
6+
"arrowParens": "avoid"
57
}

docs/advanced/AsyncActions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ export function fetchPosts(subreddit) {
357357
// It passes the dispatch method as an argument to the function,
358358
// thus making it able to dispatch actions itself.
359359

360-
return function(dispatch) {
360+
return function (dispatch) {
361361
// First dispatch: the app state is updated to inform
362362
// that the API call is starting.
363363

docs/api/applyMiddleware.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function makeASandwichWithSecretSauce(forPerson) {
109109
// Invert control!
110110
// Return a function that accepts `dispatch` so we can dispatch later.
111111
// Thunk middleware knows how to turn thunk async actions into actions.
112-
return function(dispatch) {
112+
return function (dispatch) {
113113
return fetchSecretSauce().then(
114114
sauce => dispatch(makeASandwich(forPerson, sauce)),
115115
error => dispatch(apologize('The Sandwich Shop', forPerson, error))
@@ -131,7 +131,7 @@ store.dispatch(makeASandwichWithSecretSauce('My wife')).then(() => {
131131
// actions and async actions from other action creators,
132132
// and I can build my control flow with Promises.
133133
function makeSandwichesForEverybody() {
134-
return function(dispatch, getState) {
134+
return function (dispatch, getState) {
135135
if (!getState().sandwiches.isShopOpen) {
136136
// You don't have to return Promises, but it's a handy convention
137137
// so the caller can always call .then() on async dispatch result.

docs/introduction/Ecosystem.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,7 @@ const newData = update(myData, {
365365
Simpler alternative to immutability-helpers and Immutable.js
366366
367367
```js
368-
const newObj = immutable(obj)
369-
.set('a.b', 'f')
370-
.del(['a', 'c', 0])
371-
.value()
368+
const newObj = immutable(obj).set('a.b', 'f').del(['a', 'c', 0]).value()
372369
```
373370
374371
**[debitoor/dot-prop-immutable](https://github.com/debitoor/dot-prop-immutable)** <br />

docs/recipes/ImplementingUndoHistory.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ A reducer enhancer that doesn't do anything looks like this:
267267

268268
```js
269269
function doNothingWith(reducer) {
270-
return function(state, action) {
270+
return function (state, action) {
271271
// Just call the passed reducer
272272
return reducer(state, action)
273273
}
@@ -278,7 +278,7 @@ A reducer enhancer that combines other reducers might look like this:
278278

279279
```js
280280
function combineReducers(reducers) {
281-
return function(state = {}, action) {
281+
return function (state = {}, action) {
282282
return Object.keys(reducers).reduce((nextState, key) => {
283283
// Call every reducer with the part of the state it manages
284284
nextState[key] = reducers[key](state[key], action)
@@ -302,7 +302,7 @@ function undoable(reducer) {
302302
}
303303

304304
// Return a reducer that handles undo and redo
305-
return function(state = initialState, action) {
305+
return function (state = initialState, action) {
306306
const { past, present, future } = state
307307

308308
switch (action.type) {

docs/recipes/ReducingBoilerplate.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function addTodoWithoutCheck(text) {
9292
export function addTodo(text) {
9393
// This form is allowed by Redux Thunk middleware
9494
// described below in “Async Action Creators” section.
95-
return function(dispatch, getState) {
95+
return function (dispatch, getState) {
9696
if (getState().todos.length === 3) {
9797
// Exit early
9898
return
@@ -138,7 +138,7 @@ You can always write a function that generates an action creator:
138138

139139
```js
140140
function makeActionCreator(type, ...argNames) {
141-
return function(...args) {
141+
return function (...args) {
142142
const action = { type }
143143
argNames.forEach((arg, index) => {
144144
action[argNames[index]] = args[index]
@@ -269,7 +269,7 @@ Consider the code above rewritten with [redux-thunk](https://github.com/gaearon/
269269
```js
270270
export function loadPosts(userId) {
271271
// Interpreted by the thunk middleware:
272-
return function(dispatch, getState) {
272+
return function (dispatch, getState) {
273273
const { posts } = getState()
274274
if (posts[userId]) {
275275
// There is cached data! Don't do anything.
@@ -473,7 +473,7 @@ const TodoStore = Object.assign({}, EventEmitter.prototype, {
473473
}
474474
})
475475

476-
AppDispatcher.register(function(action) {
476+
AppDispatcher.register(function (action) {
477477
switch (action.type) {
478478
case ActionTypes.ADD_TODO:
479479
const text = action.text.trim()

src/bindActionCreators.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function bindActionCreator<A extends AnyAction = AnyAction>(
99
actionCreator: ActionCreator<A>,
1010
dispatch: Dispatch
1111
) {
12-
return function(this: any, ...args: any[]) {
12+
return function (this: any, ...args: any[]) {
1313
return dispatch(actionCreator.apply(this, args))
1414
}
1515
}

src/utils/actionTypes.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66
*/
77

88
const randomString = () =>
9-
Math.random()
10-
.toString(36)
11-
.substring(7)
12-
.split('')
13-
.join('.')
9+
Math.random().toString(36).substring(7).split('').join('.')
1410

1511
const ActionTypes = {
1612
INIT: `@@redux/INIT${/* #__PURE__ */ randomString()}`,

test/combineReducers.spec.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,12 @@ describe('Utils', () => {
322322
console.error = preSpy
323323
})
324324

325-
describe('With Replace Reducers', function() {
325+
describe('With Replace Reducers', function () {
326326
const foo = (state = {}) => state
327327
const bar = (state = {}) => state
328328
const ACTION = { type: 'ACTION' }
329329

330-
it('should return an updated state when additional reducers are passed to combineReducers', function() {
330+
it('should return an updated state when additional reducers are passed to combineReducers', function () {
331331
const originalCompositeReducer = combineReducers({ foo })
332332
const store = createStore(originalCompositeReducer)
333333

@@ -342,7 +342,7 @@ describe('Utils', () => {
342342
expect(nextState).not.toBe(initialState)
343343
})
344344

345-
it('should return an updated state when reducers passed to combineReducers are changed', function() {
345+
it('should return an updated state when reducers passed to combineReducers are changed', function () {
346346
const baz = (state = {}) => state
347347

348348
const originalCompositeReducer = combineReducers({ foo, bar })
@@ -359,7 +359,7 @@ describe('Utils', () => {
359359
expect(nextState).not.toBe(initialState)
360360
})
361361

362-
it('should return the same state when reducers passed to combineReducers not changed', function() {
362+
it('should return the same state when reducers passed to combineReducers not changed', function () {
363363
const originalCompositeReducer = combineReducers({ foo, bar })
364364
const store = createStore(originalCompositeReducer)
365365

@@ -374,7 +374,7 @@ describe('Utils', () => {
374374
expect(nextState).toBe(initialState)
375375
})
376376

377-
it('should return an updated state when one of more reducers passed to the combineReducers are removed', function() {
377+
it('should return an updated state when one of more reducers passed to the combineReducers are removed', function () {
378378
const originalCompositeReducer = combineReducers({ foo, bar })
379379
const store = createStore(originalCompositeReducer)
380380

test/createStore.spec.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ describe('createStore', () => {
422422

423423
it('does not leak private listeners array', done => {
424424
const store = createStore(reducers.todos)
425-
store.subscribe(function() {
425+
store.subscribe(function () {
426426
expect(this).toBe(undefined)
427427
done()
428428
})
@@ -664,19 +664,19 @@ describe('createStore', () => {
664664
const store = createStore(() => {})
665665
const obs = store[$$observable]()
666666

667-
expect(function() {
667+
expect(function () {
668668
obs.subscribe()
669669
}).toThrowError(new TypeError('Expected the observer to be an object.'))
670670

671-
expect(function() {
671+
expect(function () {
672672
obs.subscribe(null)
673673
}).toThrowError(new TypeError('Expected the observer to be an object.'))
674674

675-
expect(function() {
675+
expect(function () {
676676
obs.subscribe(() => {})
677677
}).toThrowError(new TypeError('Expected the observer to be an object.'))
678678

679-
expect(function() {
679+
expect(function () {
680680
obs.subscribe({})
681681
}).not.toThrow()
682682
})

0 commit comments

Comments
 (0)