From: Eduardo San Martin Morote Date: Fri, 24 Apr 2020 12:19:59 +0000 (+0200) Subject: chore: upgrade prettier X-Git-Tag: v4.0.0-alpha.8~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2bb478ca790f40ea6bfbd4ee3042b48b6ac2caa8;p=thirdparty%2Fvuejs%2Frouter.git chore: upgrade prettier v1 wasn't idempotent with return statements of expressions on multiple lines, causing the CI to fail --- diff --git a/.prettierrc b/.prettierrc index 9d313aa4..12911d3e 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,5 +1,6 @@ { "semi": false, "trailingComma": "es5", - "singleQuote": true + "singleQuote": true, + "arrowParens": "avoid" } diff --git a/__tests__/encoding.spec.ts b/__tests__/encoding.spec.ts index 6d204957..19883e17 100644 --- a/__tests__/encoding.spec.ts +++ b/__tests__/encoding.spec.ts @@ -30,10 +30,7 @@ describe('Encoding', () => { const encodedToEncode = toEncode .split('') .map(c => { - const hex = c - .charCodeAt(0) - .toString(16) - .toUpperCase() + const hex = c.charCodeAt(0).toString(16).toUpperCase() return '%' + (hex.length > 1 ? hex : '0' + hex) }) .join('') @@ -65,10 +62,7 @@ describe('Encoding', () => { const encodedToEncode = toEncode .split('') .map(c => { - const hex = c - .charCodeAt(0) - .toString(16) - .toUpperCase() + const hex = c.charCodeAt(0).toString(16).toUpperCase() return '%' + (hex.length > 1 ? hex : '0' + hex) }) .join('') @@ -102,10 +96,7 @@ describe('Encoding', () => { const encodedToEncode = toEncode .split('') .map(c => { - const hex = c - .charCodeAt(0) - .toString(16) - .toUpperCase() + const hex = c.charCodeAt(0).toString(16).toUpperCase() return '%' + (hex.length > 1 ? hex : '0' + hex) }) .join('') diff --git a/__tests__/guards/guardsContext.spec.ts b/__tests__/guards/guardsContext.spec.ts index 6f25d4d4..a2ddc09d 100644 --- a/__tests__/guards/guardsContext.spec.ts +++ b/__tests__/guards/guardsContext.spec.ts @@ -13,7 +13,7 @@ describe('beforeRouteLeave', () => { expect.assertions(2) const spy = jest .fn() - .mockImplementationOnce(function(this: any, to, from, next) { + .mockImplementationOnce(function (this: any, to, from, next) { expect(typeof this.counter).toBe('number') next() }) @@ -55,7 +55,7 @@ describe('beforeRouteLeave', () => { data: () => ({ counter: 0 }), beforeRouteLeave: jest .fn() - .mockImplementationOnce(function(this: any, to, from, next) { + .mockImplementationOnce(function (this: any, to, from, next) { expect(typeof this.counter).toBe('number') next() }), @@ -66,7 +66,7 @@ describe('beforeRouteLeave', () => { data: () => ({ counter: 0 }), beforeRouteLeave: jest .fn() - .mockImplementationOnce(function(this: any, to, from, next) { + .mockImplementationOnce(function (this: any, to, from, next) { expect(typeof this.counter).toBe('number') next() }), @@ -109,7 +109,7 @@ describe('beforeRouteLeave', () => { data: () => ({ counter: 0 }), beforeRouteLeave: jest .fn() - .mockImplementationOnce(function(this: any, to, from, next) { + .mockImplementationOnce(function (this: any, to, from, next) { expect(typeof this.counter).toBe('number') next() }), @@ -120,7 +120,7 @@ describe('beforeRouteLeave', () => { data: () => ({ counter: 0 }), beforeRouteLeave: jest .fn() - .mockImplementationOnce(function(this: any, to, from, next) { + .mockImplementationOnce(function (this: any, to, from, next) { expect(typeof this.counter).toBe('number') next() }), @@ -168,7 +168,7 @@ describe('beforeRouteLeave', () => { data: () => ({ counter: 0 }), beforeRouteLeave: jest .fn() - .mockImplementationOnce(function(this: any, to, from, next) { + .mockImplementationOnce(function (this: any, to, from, next) { expect(typeof this.counter).toBe('number') next() }), @@ -179,7 +179,7 @@ describe('beforeRouteLeave', () => { data: () => ({ counter: 0 }), beforeRouteLeave: jest .fn() - .mockImplementationOnce(function(this: any, to, from, next) { + .mockImplementationOnce(function (this: any, to, from, next) { expect(typeof this.counter).toBe('number') next() }), @@ -190,7 +190,7 @@ describe('beforeRouteLeave', () => { data: () => ({ counter: 0 }), beforeRouteLeave: jest .fn() - .mockImplementationOnce(function(this: any, to, from, next) { + .mockImplementationOnce(function (this: any, to, from, next) { expect(typeof this.counter).toBe('number') next() }), diff --git a/e2e/scroll-behavior/index.ts b/e2e/scroll-behavior/index.ts index 2acce8d5..dbafb0a2 100644 --- a/e2e/scroll-behavior/index.ts +++ b/e2e/scroll-behavior/index.ts @@ -21,7 +21,11 @@ const Bar: RouteComponent = { // - only available in html5 history mode // - defaults to no scroll behavior // - return false to prevent scroll -const scrollBehavior: ScrollBehavior = async function(to, from, savedPosition) { +const scrollBehavior: ScrollBehavior = async function ( + to, + from, + savedPosition +) { await scrollWaiter.promise if (savedPosition) { diff --git a/e2e/specs/encoding.js b/e2e/specs/encoding.js index 2b1d134f..ad288e42 100644 --- a/e2e/specs/encoding.js +++ b/e2e/specs/encoding.js @@ -8,7 +8,7 @@ module.exports = { '@tags': ['history', 'encoding'], /** @type {import('nightwatch').NightwatchTest} */ - 'encodes values': function(browser) { + 'encodes values': function (browser) { browser .url(baseURL) .assert.urlEquals(baseURL + '/') diff --git a/e2e/specs/hash.js b/e2e/specs/hash.js index 1cbd7038..0a834822 100644 --- a/e2e/specs/hash.js +++ b/e2e/specs/hash.js @@ -8,7 +8,7 @@ module.exports = { '@tags': ['hash', 'encoding'], /** @type {import('nightwatch').NightwatchTest} */ - 'navigating to links': function(browser) { + 'navigating to links': function (browser) { browser .url(baseURL) .waitForElementPresent('#app > *', 1000) @@ -42,7 +42,7 @@ module.exports = { }, /** @type {import('nightwatch').NightwatchTest} */ - 'encoding on initial navigation': function(browser) { + 'encoding on initial navigation': function (browser) { browser .url(baseURL + '/unicode/%C3%A9') // navigation to unencoded value diff --git a/e2e/specs/modal.js b/e2e/specs/modal.js index 76cac67a..236ac67e 100644 --- a/e2e/specs/modal.js +++ b/e2e/specs/modal.js @@ -8,7 +8,7 @@ module.exports = { '@tags': ['history'], /** @type {import('nightwatch').NightwatchTest} */ - 'changes the url': function(browser) { + 'changes the url': function (browser) { browser .url(baseURL) .waitForElementPresent('#app > *', 1000) diff --git a/e2e/specs/scroll-behavior.js b/e2e/specs/scroll-behavior.js index 1ecef744..5e7b53bd 100644 --- a/e2e/specs/scroll-behavior.js +++ b/e2e/specs/scroll-behavior.js @@ -6,7 +6,7 @@ module.exports = { '@tags': ['history'], /** @type {import('nightwatch').NightwatchTest} */ - 'scroll behavior': function(browser) { + 'scroll behavior': function (browser) { const TIMEOUT = 2000 browser @@ -15,20 +15,20 @@ module.exports = { .assert.count('li a', 6) .assert.containsText('.view', 'home') - .execute(function() { + .execute(function () { window.scrollTo(0, 100) }) .click('li:nth-child(2) a') .waitForElementPresent('.view.foo', TIMEOUT) .assert.containsText('.view', 'foo') - .execute(function() { + .execute(function () { window.scrollTo(0, 200) window.history.back() }) .waitForElementPresent('.view.home', TIMEOUT) .assert.containsText('.view', 'home') .assert.evaluate( - function() { + function () { return window.pageYOffset === 100 }, null, @@ -36,27 +36,27 @@ module.exports = { ) // scroll on a popped entry - .execute(function() { + .execute(function () { window.scrollTo(0, 50) window.history.forward() }) .waitForElementPresent('.view.foo', TIMEOUT) .assert.containsText('.view', 'foo') .assert.evaluate( - function() { + function () { return window.pageYOffset === 200 }, null, 'restore scroll position on forward' ) - .execute(function() { + .execute(function () { window.history.back() }) .waitForElementPresent('.view.home', TIMEOUT) .assert.containsText('.view', 'home') .assert.evaluate( - function() { + function () { return window.pageYOffset === 50 }, null, @@ -66,7 +66,7 @@ module.exports = { .click('li:nth-child(3) a') .waitForElementPresent('.view.bar', TIMEOUT) .assert.evaluate( - function() { + function () { return window.pageYOffset === 0 }, null, @@ -75,9 +75,9 @@ module.exports = { .click('li:nth-child(4) a') .assert.evaluate( - function() { + function () { return ( - (document.getElementById('anchor').getBoundingClientRect().top < 1) + document.getElementById('anchor').getBoundingClientRect().top < 1 ) }, null, @@ -86,22 +86,21 @@ module.exports = { .click('li:nth-child(5) a') .assert.evaluate( - function() { + function () { return ( - (document.getElementById('anchor2').getBoundingClientRect().top < - 101) + document.getElementById('anchor2').getBoundingClientRect().top < 101 ) }, null, 'scroll to anchor with offset' ) - .execute(function() { + .execute(function () { document.querySelector('li:nth-child(6) a').click() }) .assert.evaluate( - function() { + function () { return ( - (document.getElementById('1number').getBoundingClientRect().top < 1) + document.getElementById('1number').getBoundingClientRect().top < 1 ) }, null, @@ -111,18 +110,18 @@ module.exports = { // go to /foo first .click('li:nth-child(2) a') .waitForElementPresent('.view.foo', TIMEOUT) - .execute(function() { + .execute(function () { window.scrollTo(0, 150) }) // revisiting the same hash should scroll again .click('li:nth-child(4) a') .waitForElementPresent('.view.bar', TIMEOUT) - .execute(function() { + .execute(function () { window.scrollTo(0, 50) }) .click('li:nth-child(4) a') .assert.evaluate( - function() { + function () { // TODO: change implementation to use `afterEach` return true // return ( @@ -132,12 +131,12 @@ module.exports = { null, 'scroll to anchor when the route is the same' ) - .execute(function() { + .execute(function () { history.back() }) .waitForElementPresent('.view.foo', TIMEOUT) .assert.evaluate( - function() { + function () { return window.pageYOffset === 150 }, null, @@ -146,7 +145,7 @@ module.exports = { .refresh() .waitForElementPresent('.view.foo', TIMEOUT) .assert.evaluate( - function() { + function () { return window.pageYOffset === 150 }, null, diff --git a/e2e/specs/transitions.js b/e2e/specs/transitions.js index 1a9af54e..05d91463 100644 --- a/e2e/specs/transitions.js +++ b/e2e/specs/transitions.js @@ -5,7 +5,7 @@ module.exports = { '@tags': ['no-headless'], - transitions: function(browser) { + transitions: function (browser) { const TIMEOUT = 2000 browser diff --git a/package.json b/package.json index b40ab3c4..17e64dbf 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,7 @@ "lint-staged": "^10.1.6", "nightwatch": "^1.3.4", "nightwatch-helpers": "^1.2.0", - "prettier": "^1.19.1", + "prettier": "^2.0.5", "rollup": "^1.0.0", "rollup-plugin-terser": "^5.3.0", "rollup-plugin-typescript2": "^0.27.0", diff --git a/src/utils/encoding.ts b/src/utils/encoding.ts index 62732f66..2d87ecf2 100644 --- a/src/utils/encoding.ts +++ b/src/utils/encoding.ts @@ -85,9 +85,7 @@ export function encodeQueryProperty(text: string | number): string { * @returns encoded string */ export function encodePath(text: string): string { - return commonEncode(text) - .replace(HASH_RE, '%23') - .replace(IM_RE, '%3F') + return commonEncode(text).replace(HASH_RE, '%23').replace(IM_RE, '%3F') } /** diff --git a/yarn.lock b/yarn.lock index dc7df66e..4ea6220c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7033,10 +7033,10 @@ prelude-ls@~1.1.2: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= -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.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.5.tgz#d6d56282455243f2f92cc1716692c08aa31522d4" + integrity sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg== pretty-error@^2.1.1: version "2.1.1"