Skip to content

Commit

Permalink
chore(deps): update dependency prettier to v2 (#304)
Browse files Browse the repository at this point in the history
* chore(deps): update dependency prettier to v2

* format

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Jimmy Jia <tesrin@gmail.com>
  • Loading branch information
3 people authored Mar 22, 2020
1 parent a7708e2 commit 081aae1
Show file tree
Hide file tree
Showing 18 changed files with 51 additions and 55 deletions.
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const webpack = require('webpack'); // eslint-disable-line import/no-extraneous-dependencies

module.exports = config => {
module.exports = (config) => {
const { env } = process;

config.set({
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"karma-webpack": "^4.0.2",
"lint-staged": "^10.0.8",
"mocha": "^7.1.0",
"prettier": "^1.19.1",
"prettier": "^2.0.1",
"sinon": "^9.0.1",
"sinon-chai": "^3.5.0",
"webpack": "^4.42.0"
Expand Down
6 changes: 3 additions & 3 deletions src/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ export default {
type: ActionTypes.INIT,
}),

push: location => ({
push: (location) => ({
type: ActionTypes.PUSH,
payload: location,
}),

replace: location => ({
replace: (location) => ({
type: ActionTypes.REPLACE,
payload: location,
}),

go: delta => ({
go: (delta) => ({
type: ActionTypes.GO,
payload: delta,
}),
Expand Down
4 changes: 1 addition & 3 deletions src/BrowserProtocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import createPath from './utils/createPath';

export default class BrowserProtocol {
constructor() {
this._keyPrefix = Math.random()
.toString(36)
.slice(2, 8);
this._keyPrefix = Math.random().toString(36).slice(2, 8);
this._keyIndex = 0;

this._index = null;
Expand Down
4 changes: 1 addition & 3 deletions src/MemoryProtocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ export default class MemoryProtocol {
this._index = 0;
}

this._keyPrefix = Math.random()
.toString(36)
.slice(2, 8);
this._keyPrefix = Math.random().toString(36).slice(2, 8);
this._keyIndex = 0;

this._listener = null;
Expand Down
6 changes: 3 additions & 3 deletions src/createBasenameMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import createLocationMiddleware from './createLocationMiddleware';
export default function createBasenameMiddleware({ basename }) {
if (!basename || basename === '/') {
// Fast path in case basename is trivial.
return () => next => next;
return () => (next) => next;
}

// Normalize away trailing slash on basename.
const pathnamePrefix =
basename.slice(-1) === '/' ? basename.slice(0, -1) : basename;

return createLocationMiddleware({
makeLocationDescriptor: location => ({
makeLocationDescriptor: (location) => ({
...location,
pathname: `${pathnamePrefix}${location.pathname}`,
}),
makeLocation: location => ({
makeLocation: (location) => ({
...location,
pathname:
location.pathname.indexOf(pathnamePrefix) === 0
Expand Down
2 changes: 1 addition & 1 deletion src/createHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export default function createHistory(options) {
const store = createStore(locationReducer, createHistoryEnhancer(options));
store.dispatch(Actions.init());

return createStoreHistory(store, location => location);
return createStoreHistory(store, (location) => location);
}
6 changes: 3 additions & 3 deletions src/createHistoryMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ function updateLocation(location) {

export default function createHistoryMiddleware(protocol) {
return function historyMiddleware() {
return next => {
const dispose = protocol.subscribe(location => {
return (next) => {
const dispose = protocol.subscribe((location) => {
next(updateLocation(location));
});

return action => {
return (action) => {
const { type, payload } = action;

switch (type) {
Expand Down
2 changes: 1 addition & 1 deletion src/createLocationMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function createLocationMiddleware({
makeLocation,
}) {
return function locationMiddleware() {
return next => action => {
return (next) => (action) => {
const { type, payload } = action;

switch (type) {
Expand Down
22 changes: 11 additions & 11 deletions src/createTransitionHookMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function runHook(hook, location, callback) {
}

result
.catch(e => {
.catch((e) => {
warning(
false,
'Ignoring transition hook `%s` that failed with `%s`.',
Expand All @@ -44,7 +44,7 @@ function runHooks(hooks, location, callback) {
return callback(true);
}

return runHook(hooks[0], location, result =>
return runHook(hooks[0], location, (result) =>
result != null
? callback(result)
: runHooks(hooks.slice(1), location, callback),
Expand All @@ -60,7 +60,7 @@ function maybeConfirm(result) {
}

function runAllowTransition(hooks, location, callback) {
return runHooks(hooks, location, result => callback(maybeConfirm(result)));
return runHooks(hooks, location, (result) => callback(maybeConfirm(result)));
}

export default function createTransitionHookMiddleware({
Expand All @@ -73,14 +73,14 @@ export default function createTransitionHookMiddleware({
hooks.push(hook);

return () => {
hooks = hooks.filter(item => item !== hook);
hooks = hooks.filter((item) => item !== hook);
};
}

let onBeforeUnload = null;

function transitionHookMiddleware({ dispatch }) {
return next => action => {
return (next) => (action) => {
const { type, payload } = action;

if (nextStep && type === ActionTypes.UPDATE_LOCATION) {
Expand All @@ -94,8 +94,8 @@ export default function createTransitionHookMiddleware({
// Only attach this listener once.
if (useBeforeUnload && !onBeforeUnload) {
/* istanbul ignore next: not testable with Karma */
onBeforeUnload = event => {
const syncResult = runHooks(hooks, null, result => result);
onBeforeUnload = (event) => {
const syncResult = runHooks(hooks, null, (result) => result);

if (syncResult === true || syncResult === undefined) {
// An asynchronous transition hook usually means there will be
Expand All @@ -118,7 +118,7 @@ export default function createTransitionHookMiddleware({

return next(action);
case ActionTypes.TRANSITION:
return runAllowTransition(hooks, payload, allowTransition => {
return runAllowTransition(hooks, payload, (allowTransition) => {
if (!allowTransition) {
return null;
}
Expand All @@ -142,12 +142,12 @@ export default function createTransitionHookMiddleware({

// Without delta, we can't restore the location.
if (payload.delta == null) {
return runAllowTransition(hooks, payload, allowTransition =>
return runAllowTransition(hooks, payload, (allowTransition) =>
allowTransition ? next(action) : null,
);
}

const finishRunAllowTransition = result => {
const finishRunAllowTransition = (result) => {
if (!maybeConfirm(result)) {
return null;
}
Expand All @@ -164,7 +164,7 @@ export default function createTransitionHookMiddleware({
let sync = true;
let rewindDone = false;

const syncResult = runHooks(hooks, payload, result => {
const syncResult = runHooks(hooks, payload, (result) => {
if (sync) {
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ensureLocationMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ActionTypes from './ActionTypes';
import ensureLocation from './utils/ensureLocation';

export default function ensureLocationMiddleware() {
return next => action => {
return (next) => (action) => {
const { type, payload } = action;

switch (type) {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/maybePromisify.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function maybePromisify(hook, syncLength) {

let resolvePromise;

hook(...args, result => {
hook(...args, (result) => {
if (resolvePromise) {
resolvePromise(result);
return;
Expand All @@ -20,7 +20,7 @@ export default function maybePromisify(hook, syncLength) {
});

if (!hasSyncResult) {
return new Promise(resolve => {
return new Promise((resolve) => {
resolvePromise = resolve;
});
}
Expand Down
2 changes: 1 addition & 1 deletion test/createHistory.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe('createHistory', () => {
it('should support async transition hooks', async () => {
let resolveHook;
history.listenBefore(async (location, cb) => {
const result = await new Promise(resolve => {
const result = await new Promise((resolve) => {
resolveHook = resolve;
});

Expand Down
6 changes: 3 additions & 3 deletions test/createLocationMiddleware.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import createLocationMiddleware from '../src/createLocationMiddleware';

describe('createLocationMiddleware', () => {
const middleware = createLocationMiddleware({
makeLocationDescriptor: descriptor => ({ descriptor }),
makeLocation: location => ({ location }),
makeLocationDescriptor: (descriptor) => ({ descriptor }),
makeLocation: (location) => ({ location }),
});

const dispatch = middleware()(action => action.payload);
const dispatch = middleware()((action) => action.payload);

it('should handle location descriptors for TRANSITION', () => {
expect(
Expand Down
22 changes: 11 additions & 11 deletions test/createTransitionHookMiddleware.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ describe('createTransitionHookMiddleware', () => {
let resolveHook;
store.farce.addTransitionHook(
() =>
new Promise(resolve => {
new Promise((resolve) => {
resolveHook = resolve;
}),
);
Expand All @@ -144,7 +144,7 @@ describe('createTransitionHookMiddleware', () => {
let resolveHook;
store.farce.addTransitionHook(
() =>
new Promise(resolve => {
new Promise((resolve) => {
resolveHook = resolve;
}),
);
Expand All @@ -164,13 +164,13 @@ describe('createTransitionHookMiddleware', () => {

store.farce.addTransitionHook(
() =>
new Promise(resolve => {
new Promise((resolve) => {
resolveHook1 = resolve;
}),
);
store.farce.addTransitionHook(
() =>
new Promise(resolve => {
new Promise((resolve) => {
resolveHook2 = resolve;
}),
);
Expand Down Expand Up @@ -252,7 +252,7 @@ describe('createTransitionHookMiddleware', () => {
let resolveHook;
store.farce.addTransitionHook(
() =>
new Promise(resolve => {
new Promise((resolve) => {
resolveHook = resolve;
}),
);
Expand All @@ -270,7 +270,7 @@ describe('createTransitionHookMiddleware', () => {
let resolveHook;
store.farce.addTransitionHook(
() =>
new Promise(resolve => {
new Promise((resolve) => {
resolveHook = resolve;
}),
);
Expand Down Expand Up @@ -319,8 +319,8 @@ describe('createTransitionHookMiddleware', () => {
let resolveListener;

// eslint-disable-next-line no-underscore-dangle
protocol._listener = async location => {
await new Promise(resolve => {
protocol._listener = async (location) => {
await new Promise((resolve) => {
resolveListener = resolve;
});

Expand All @@ -330,7 +330,7 @@ describe('createTransitionHookMiddleware', () => {
let resolveHook;
store.farce.addTransitionHook(
() =>
new Promise(resolve => {
new Promise((resolve) => {
resolveHook = resolve;
}),
);
Expand Down Expand Up @@ -370,7 +370,7 @@ describe('createTransitionHookMiddleware', () => {
let resolveHook;
store.farce.addTransitionHook(
() =>
new Promise(resolve => {
new Promise((resolve) => {
resolveHook = resolve;
}),
);
Expand All @@ -395,7 +395,7 @@ describe('createTransitionHookMiddleware', () => {
let resolveHook;
store.farce.addTransitionHook(
() =>
new Promise(resolve => {
new Promise((resolve) => {
resolveHook = resolve;
}),
);
Expand Down
2 changes: 1 addition & 1 deletion test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function invokeMakeLocation(middleware, location) {
}

export function timeout(delay) {
return new Promise(resolve => {
return new Promise((resolve) => {
setTimeout(resolve, delay);
});
}
4 changes: 2 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ testsContext.keys().forEach(testsContext);

beforeEach(() => {
/* eslint-disable no-console */
sinon.stub(console, 'error').callsFake(message => {
sinon.stub(console, 'error').callsFake((message) => {
let expected = false;

console.error.expected.forEach(about => {
console.error.expected.forEach((about) => {
if (message.includes(about)) {
console.error.warned[about] = true;
expected = true;
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5328,10 +5328,10 @@ prettier-linter-helpers@^1.0.0:
dependencies:
fast-diff "^1.1.2"

prettier@^1.19.1:
version "1.19.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb"
integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==
prettier@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.1.tgz#3f00ac71263be34684b2b2c8d7e7f63737592dac"
integrity sha512-piXGBcY1zoFOG0MvHpNE5reAGseLmaCRifQ/fmfF49BcYkInEs/naD/unxGNAeOKFA5+JxVrPyMvMlpzcd20UA==

private@^0.1.6:
version "0.1.8"
Expand Down

0 comments on commit 081aae1

Please sign in to comment.