Skip to content

Commit

Permalink
Prettier 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
timdorr committed Apr 27, 2020
1 parent cffad3c commit 311279d
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 31 deletions.
4 changes: 3 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"semi": false,
"singleQuote": true,
"tabWidth": 2
"tabWidth": 2,
"trailingComma": "none",
"arrowParens": "avoid"
}
2 changes: 1 addition & 1 deletion docs/advanced/AsyncActions.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ export function fetchPosts(subreddit) {
// It passes the dispatch method as an argument to the function,
// thus making it able to dispatch actions itself.

return function(dispatch) {
return function (dispatch) {
// First dispatch: the app state is updated to inform
// that the API call is starting.

Expand Down
4 changes: 2 additions & 2 deletions docs/api/applyMiddleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function makeASandwichWithSecretSauce(forPerson) {
// Invert control!
// Return a function that accepts `dispatch` so we can dispatch later.
// Thunk middleware knows how to turn thunk async actions into actions.
return function(dispatch) {
return function (dispatch) {
return fetchSecretSauce().then(
sauce => dispatch(makeASandwich(forPerson, sauce)),
error => dispatch(apologize('The Sandwich Shop', forPerson, error))
Expand All @@ -131,7 +131,7 @@ store.dispatch(makeASandwichWithSecretSauce('My wife')).then(() => {
// actions and async actions from other action creators,
// and I can build my control flow with Promises.
function makeSandwichesForEverybody() {
return function(dispatch, getState) {
return function (dispatch, getState) {
if (!getState().sandwiches.isShopOpen) {
// You don't have to return Promises, but it's a handy convention
// so the caller can always call .then() on async dispatch result.
Expand Down
5 changes: 1 addition & 4 deletions docs/introduction/Ecosystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,7 @@ const newData = update(myData, {
Simpler alternative to immutability-helpers and Immutable.js
```js
const newObj = immutable(obj)
.set('a.b', 'f')
.del(['a', 'c', 0])
.value()
const newObj = immutable(obj).set('a.b', 'f').del(['a', 'c', 0]).value()
```
**[debitoor/dot-prop-immutable](https://github.com/debitoor/dot-prop-immutable)** <br />
Expand Down
6 changes: 3 additions & 3 deletions docs/recipes/ImplementingUndoHistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ A reducer enhancer that doesn't do anything looks like this:

```js
function doNothingWith(reducer) {
return function(state, action) {
return function (state, action) {
// Just call the passed reducer
return reducer(state, action)
}
Expand All @@ -278,7 +278,7 @@ A reducer enhancer that combines other reducers might look like this:

```js
function combineReducers(reducers) {
return function(state = {}, action) {
return function (state = {}, action) {
return Object.keys(reducers).reduce((nextState, key) => {
// Call every reducer with the part of the state it manages
nextState[key] = reducers[key](state[key], action)
Expand All @@ -302,7 +302,7 @@ function undoable(reducer) {
}

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

switch (action.type) {
Expand Down
8 changes: 4 additions & 4 deletions docs/recipes/ReducingBoilerplate.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function addTodoWithoutCheck(text) {
export function addTodo(text) {
// This form is allowed by Redux Thunk middleware
// described below in “Async Action Creators” section.
return function(dispatch, getState) {
return function (dispatch, getState) {
if (getState().todos.length === 3) {
// Exit early
return
Expand Down Expand Up @@ -138,7 +138,7 @@ You can always write a function that generates an action creator:

```js
function makeActionCreator(type, ...argNames) {
return function(...args) {
return function (...args) {
const action = { type }
argNames.forEach((arg, index) => {
action[argNames[index]] = args[index]
Expand Down Expand Up @@ -269,7 +269,7 @@ Consider the code above rewritten with [redux-thunk](https://github.com/gaearon/
```js
export function loadPosts(userId) {
// Interpreted by the thunk middleware:
return function(dispatch, getState) {
return function (dispatch, getState) {
const { posts } = getState()
if (posts[userId]) {
// There is cached data! Don't do anything.
Expand Down Expand Up @@ -473,7 +473,7 @@ const TodoStore = Object.assign({}, EventEmitter.prototype, {
}
})

AppDispatcher.register(function(action) {
AppDispatcher.register(function (action) {
switch (action.type) {
case ActionTypes.ADD_TODO:
const text = action.text.trim()
Expand Down
2 changes: 1 addition & 1 deletion src/bindActionCreators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function bindActionCreator<A extends AnyAction = AnyAction>(
actionCreator: ActionCreator<A>,
dispatch: Dispatch
) {
return function(this: any, ...args: any[]) {
return function (this: any, ...args: any[]) {
return dispatch(actionCreator.apply(this, args))
}
}
Expand Down
6 changes: 1 addition & 5 deletions src/utils/actionTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
*/

const randomString = () =>
Math.random()
.toString(36)
.substring(7)
.split('')
.join('.')
Math.random().toString(36).substring(7).split('').join('.')

const ActionTypes = {
INIT: `@@redux/INIT${/* #__PURE__ */ randomString()}`,
Expand Down
10 changes: 5 additions & 5 deletions test/combineReducers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,12 @@ describe('Utils', () => {
console.error = preSpy
})

describe('With Replace Reducers', function() {
describe('With Replace Reducers', function () {
const foo = (state = {}) => state
const bar = (state = {}) => state
const ACTION = { type: 'ACTION' }

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

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

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

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

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

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

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

Expand Down
10 changes: 5 additions & 5 deletions test/createStore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ describe('createStore', () => {

it('does not leak private listeners array', done => {
const store = createStore(reducers.todos)
store.subscribe(function() {
store.subscribe(function () {
expect(this).toBe(undefined)
done()
})
Expand Down Expand Up @@ -664,19 +664,19 @@ describe('createStore', () => {
const store = createStore(() => {})
const obs = store[$$observable]()

expect(function() {
expect(function () {
obs.subscribe()
}).toThrowError(new TypeError('Expected the observer to be an object.'))

expect(function() {
expect(function () {
obs.subscribe(null)
}).toThrowError(new TypeError('Expected the observer to be an object.'))

expect(function() {
expect(function () {
obs.subscribe(() => {})
}).toThrowError(new TypeError('Expected the observer to be an object.'))

expect(function() {
expect(function () {
obs.subscribe({})
}).not.toThrow()
})
Expand Down

0 comments on commit 311279d

Please sign in to comment.