Skip to content

Commit 2bb478c

Browse files
committedApr 24, 2020
chore: upgrade prettier
v1 wasn't idempotent with return statements of expressions on multiple lines, causing the CI to fail
1 parent d0a08a5 commit 2bb478c

File tree

12 files changed

+51
-58
lines changed

12 files changed

+51
-58
lines changed
 

‎.prettierrc

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

‎__tests__/encoding.spec.ts

+3-12
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ describe('Encoding', () => {
3030
const encodedToEncode = toEncode
3131
.split('')
3232
.map(c => {
33-
const hex = c
34-
.charCodeAt(0)
35-
.toString(16)
36-
.toUpperCase()
33+
const hex = c.charCodeAt(0).toString(16).toUpperCase()
3734
return '%' + (hex.length > 1 ? hex : '0' + hex)
3835
})
3936
.join('')
@@ -65,10 +62,7 @@ describe('Encoding', () => {
6562
const encodedToEncode = toEncode
6663
.split('')
6764
.map(c => {
68-
const hex = c
69-
.charCodeAt(0)
70-
.toString(16)
71-
.toUpperCase()
65+
const hex = c.charCodeAt(0).toString(16).toUpperCase()
7266
return '%' + (hex.length > 1 ? hex : '0' + hex)
7367
})
7468
.join('')
@@ -102,10 +96,7 @@ describe('Encoding', () => {
10296
const encodedToEncode = toEncode
10397
.split('')
10498
.map(c => {
105-
const hex = c
106-
.charCodeAt(0)
107-
.toString(16)
108-
.toUpperCase()
99+
const hex = c.charCodeAt(0).toString(16).toUpperCase()
109100
return '%' + (hex.length > 1 ? hex : '0' + hex)
110101
})
111102
.join('')

‎__tests__/guards/guardsContext.spec.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('beforeRouteLeave', () => {
1313
expect.assertions(2)
1414
const spy = jest
1515
.fn()
16-
.mockImplementationOnce(function(this: any, to, from, next) {
16+
.mockImplementationOnce(function (this: any, to, from, next) {
1717
expect(typeof this.counter).toBe('number')
1818
next()
1919
})
@@ -55,7 +55,7 @@ describe('beforeRouteLeave', () => {
5555
data: () => ({ counter: 0 }),
5656
beforeRouteLeave: jest
5757
.fn()
58-
.mockImplementationOnce(function(this: any, to, from, next) {
58+
.mockImplementationOnce(function (this: any, to, from, next) {
5959
expect(typeof this.counter).toBe('number')
6060
next()
6161
}),
@@ -66,7 +66,7 @@ describe('beforeRouteLeave', () => {
6666
data: () => ({ counter: 0 }),
6767
beforeRouteLeave: jest
6868
.fn()
69-
.mockImplementationOnce(function(this: any, to, from, next) {
69+
.mockImplementationOnce(function (this: any, to, from, next) {
7070
expect(typeof this.counter).toBe('number')
7171
next()
7272
}),
@@ -109,7 +109,7 @@ describe('beforeRouteLeave', () => {
109109
data: () => ({ counter: 0 }),
110110
beforeRouteLeave: jest
111111
.fn()
112-
.mockImplementationOnce(function(this: any, to, from, next) {
112+
.mockImplementationOnce(function (this: any, to, from, next) {
113113
expect(typeof this.counter).toBe('number')
114114
next()
115115
}),
@@ -120,7 +120,7 @@ describe('beforeRouteLeave', () => {
120120
data: () => ({ counter: 0 }),
121121
beforeRouteLeave: jest
122122
.fn()
123-
.mockImplementationOnce(function(this: any, to, from, next) {
123+
.mockImplementationOnce(function (this: any, to, from, next) {
124124
expect(typeof this.counter).toBe('number')
125125
next()
126126
}),
@@ -168,7 +168,7 @@ describe('beforeRouteLeave', () => {
168168
data: () => ({ counter: 0 }),
169169
beforeRouteLeave: jest
170170
.fn()
171-
.mockImplementationOnce(function(this: any, to, from, next) {
171+
.mockImplementationOnce(function (this: any, to, from, next) {
172172
expect(typeof this.counter).toBe('number')
173173
next()
174174
}),
@@ -179,7 +179,7 @@ describe('beforeRouteLeave', () => {
179179
data: () => ({ counter: 0 }),
180180
beforeRouteLeave: jest
181181
.fn()
182-
.mockImplementationOnce(function(this: any, to, from, next) {
182+
.mockImplementationOnce(function (this: any, to, from, next) {
183183
expect(typeof this.counter).toBe('number')
184184
next()
185185
}),
@@ -190,7 +190,7 @@ describe('beforeRouteLeave', () => {
190190
data: () => ({ counter: 0 }),
191191
beforeRouteLeave: jest
192192
.fn()
193-
.mockImplementationOnce(function(this: any, to, from, next) {
193+
.mockImplementationOnce(function (this: any, to, from, next) {
194194
expect(typeof this.counter).toBe('number')
195195
next()
196196
}),

‎e2e/scroll-behavior/index.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ const Bar: RouteComponent = {
2121
// - only available in html5 history mode
2222
// - defaults to no scroll behavior
2323
// - return false to prevent scroll
24-
const scrollBehavior: ScrollBehavior = async function(to, from, savedPosition) {
24+
const scrollBehavior: ScrollBehavior = async function (
25+
to,
26+
from,
27+
savedPosition
28+
) {
2529
await scrollWaiter.promise
2630

2731
if (savedPosition) {

‎e2e/specs/encoding.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = {
88
'@tags': ['history', 'encoding'],
99

1010
/** @type {import('nightwatch').NightwatchTest} */
11-
'encodes values': function(browser) {
11+
'encodes values': function (browser) {
1212
browser
1313
.url(baseURL)
1414
.assert.urlEquals(baseURL + '/')

‎e2e/specs/hash.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = {
88
'@tags': ['hash', 'encoding'],
99

1010
/** @type {import('nightwatch').NightwatchTest} */
11-
'navigating to links': function(browser) {
11+
'navigating to links': function (browser) {
1212
browser
1313
.url(baseURL)
1414
.waitForElementPresent('#app > *', 1000)
@@ -42,7 +42,7 @@ module.exports = {
4242
},
4343

4444
/** @type {import('nightwatch').NightwatchTest} */
45-
'encoding on initial navigation': function(browser) {
45+
'encoding on initial navigation': function (browser) {
4646
browser
4747
.url(baseURL + '/unicode/%C3%A9')
4848
// navigation to unencoded value

‎e2e/specs/modal.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = {
88
'@tags': ['history'],
99

1010
/** @type {import('nightwatch').NightwatchTest} */
11-
'changes the url': function(browser) {
11+
'changes the url': function (browser) {
1212
browser
1313
.url(baseURL)
1414
.waitForElementPresent('#app > *', 1000)

‎e2e/specs/scroll-behavior.js

+22-23
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = {
66
'@tags': ['history'],
77

88
/** @type {import('nightwatch').NightwatchTest} */
9-
'scroll behavior': function(browser) {
9+
'scroll behavior': function (browser) {
1010
const TIMEOUT = 2000
1111

1212
browser
@@ -15,48 +15,48 @@ module.exports = {
1515
.assert.count('li a', 6)
1616
.assert.containsText('.view', 'home')
1717

18-
.execute(function() {
18+
.execute(function () {
1919
window.scrollTo(0, 100)
2020
})
2121
.click('li:nth-child(2) a')
2222
.waitForElementPresent('.view.foo', TIMEOUT)
2323
.assert.containsText('.view', 'foo')
24-
.execute(function() {
24+
.execute(function () {
2525
window.scrollTo(0, 200)
2626
window.history.back()
2727
})
2828
.waitForElementPresent('.view.home', TIMEOUT)
2929
.assert.containsText('.view', 'home')
3030
.assert.evaluate(
31-
function() {
31+
function () {
3232
return window.pageYOffset === 100
3333
},
3434
null,
3535
'restore scroll position on back'
3636
)
3737

3838
// scroll on a popped entry
39-
.execute(function() {
39+
.execute(function () {
4040
window.scrollTo(0, 50)
4141
window.history.forward()
4242
})
4343
.waitForElementPresent('.view.foo', TIMEOUT)
4444
.assert.containsText('.view', 'foo')
4545
.assert.evaluate(
46-
function() {
46+
function () {
4747
return window.pageYOffset === 200
4848
},
4949
null,
5050
'restore scroll position on forward'
5151
)
5252

53-
.execute(function() {
53+
.execute(function () {
5454
window.history.back()
5555
})
5656
.waitForElementPresent('.view.home', TIMEOUT)
5757
.assert.containsText('.view', 'home')
5858
.assert.evaluate(
59-
function() {
59+
function () {
6060
return window.pageYOffset === 50
6161
},
6262
null,
@@ -66,7 +66,7 @@ module.exports = {
6666
.click('li:nth-child(3) a')
6767
.waitForElementPresent('.view.bar', TIMEOUT)
6868
.assert.evaluate(
69-
function() {
69+
function () {
7070
return window.pageYOffset === 0
7171
},
7272
null,
@@ -75,9 +75,9 @@ module.exports = {
7575

7676
.click('li:nth-child(4) a')
7777
.assert.evaluate(
78-
function() {
78+
function () {
7979
return (
80-
(document.getElementById('anchor').getBoundingClientRect().top < 1)
80+
document.getElementById('anchor').getBoundingClientRect().top < 1
8181
)
8282
},
8383
null,
@@ -86,22 +86,21 @@ module.exports = {
8686

8787
.click('li:nth-child(5) a')
8888
.assert.evaluate(
89-
function() {
89+
function () {
9090
return (
91-
(document.getElementById('anchor2').getBoundingClientRect().top <
92-
101)
91+
document.getElementById('anchor2').getBoundingClientRect().top < 101
9392
)
9493
},
9594
null,
9695
'scroll to anchor with offset'
9796
)
98-
.execute(function() {
97+
.execute(function () {
9998
document.querySelector('li:nth-child(6) a').click()
10099
})
101100
.assert.evaluate(
102-
function() {
101+
function () {
103102
return (
104-
(document.getElementById('1number').getBoundingClientRect().top < 1)
103+
document.getElementById('1number').getBoundingClientRect().top < 1
105104
)
106105
},
107106
null,
@@ -111,18 +110,18 @@ module.exports = {
111110
// go to /foo first
112111
.click('li:nth-child(2) a')
113112
.waitForElementPresent('.view.foo', TIMEOUT)
114-
.execute(function() {
113+
.execute(function () {
115114
window.scrollTo(0, 150)
116115
})
117116
// revisiting the same hash should scroll again
118117
.click('li:nth-child(4) a')
119118
.waitForElementPresent('.view.bar', TIMEOUT)
120-
.execute(function() {
119+
.execute(function () {
121120
window.scrollTo(0, 50)
122121
})
123122
.click('li:nth-child(4) a')
124123
.assert.evaluate(
125-
function() {
124+
function () {
126125
// TODO: change implementation to use `afterEach`
127126
return true
128127
// return (
@@ -132,12 +131,12 @@ module.exports = {
132131
null,
133132
'scroll to anchor when the route is the same'
134133
)
135-
.execute(function() {
134+
.execute(function () {
136135
history.back()
137136
})
138137
.waitForElementPresent('.view.foo', TIMEOUT)
139138
.assert.evaluate(
140-
function() {
139+
function () {
141140
return window.pageYOffset === 150
142141
},
143142
null,
@@ -146,7 +145,7 @@ module.exports = {
146145
.refresh()
147146
.waitForElementPresent('.view.foo', TIMEOUT)
148147
.assert.evaluate(
149-
function() {
148+
function () {
150149
return window.pageYOffset === 150
151150
},
152151
null,

‎e2e/specs/transitions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = {
55

66
'@tags': ['no-headless'],
77

8-
transitions: function(browser) {
8+
transitions: function (browser) {
99
const TIMEOUT = 2000
1010

1111
browser

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"lint-staged": "^10.1.6",
7474
"nightwatch": "^1.3.4",
7575
"nightwatch-helpers": "^1.2.0",
76-
"prettier": "^1.19.1",
76+
"prettier": "^2.0.5",
7777
"rollup": "^1.0.0",
7878
"rollup-plugin-terser": "^5.3.0",
7979
"rollup-plugin-typescript2": "^0.27.0",

‎src/utils/encoding.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ export function encodeQueryProperty(text: string | number): string {
8585
* @returns encoded string
8686
*/
8787
export function encodePath(text: string): string {
88-
return commonEncode(text)
89-
.replace(HASH_RE, '%23')
90-
.replace(IM_RE, '%3F')
88+
return commonEncode(text).replace(HASH_RE, '%23').replace(IM_RE, '%3F')
9189
}
9290

9391
/**

‎yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -7033,10 +7033,10 @@ prelude-ls@~1.1.2:
70337033
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
70347034
integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=
70357035

7036-
prettier@^1.19.1:
7037-
version "1.19.1"
7038-
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb"
7039-
integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==
7036+
prettier@^2.0.5:
7037+
version "2.0.5"
7038+
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.5.tgz#d6d56282455243f2f92cc1716692c08aa31522d4"
7039+
integrity sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==
70407040

70417041
pretty-error@^2.1.1:
70427042
version "2.1.1"

0 commit comments

Comments
 (0)
Please sign in to comment.