]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
chore: upgrade prettier
authorEduardo San Martin Morote <posva13@gmail.com>
Fri, 24 Apr 2020 12:19:59 +0000 (14:19 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Fri, 24 Apr 2020 12:19:59 +0000 (14:19 +0200)
v1 wasn't idempotent with return statements of expressions on multiple lines,
causing the CI to fail

12 files changed:
.prettierrc
__tests__/encoding.spec.ts
__tests__/guards/guardsContext.spec.ts
e2e/scroll-behavior/index.ts
e2e/specs/encoding.js
e2e/specs/hash.js
e2e/specs/modal.js
e2e/specs/scroll-behavior.js
e2e/specs/transitions.js
package.json
src/utils/encoding.ts
yarn.lock

index 9d313aa4a5b8453df4fb3fd305fb14f3d0aa4a04..12911d3ec48fcdc7ad21b16405d10a1a22439ff0 100644 (file)
@@ -1,5 +1,6 @@
 {
   "semi": false,
   "trailingComma": "es5",
-  "singleQuote": true
+  "singleQuote": true,
+  "arrowParens": "avoid"
 }
index 6d2049576023fc37a5073fc61bc331568419704d..19883e179de880304d77fad18d7c4fd775096380 100644 (file)
@@ -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('')
index 6f25d4d46c55ef5dadb575fc27161ef1c37264d4..a2ddc09df6d4834974c97161caff3f544a20e882 100644 (file)
@@ -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()
         }),
index 2acce8d5979183ec1c518830d13e69e23b89703c..dbafb0a21e3866afee7791759105b63997a020ec 100644 (file)
@@ -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) {
index 2b1d134f134628f72dc7b6ab9dbff4056b1fbc0d..ad288e4274c6e164d948848da6b0b3f8db94f989 100644 (file)
@@ -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 + '/')
index 1cbd70388c570ef84893e4bc43c0e25c74219194..0a8348220ca1bafec9b8df2a1a67c6d96b612f0e 100644 (file)
@@ -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
index 76cac67a8002378aaf9f1754ff29e9861e534815..236ac67e44c2231f44237de326b464bb1f12d5cf 100644 (file)
@@ -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)
index 1ecef744dca538e3f30f8d57b45580fcf01e85bb..5e7b53bd96911f351083cda12895fb7820233167 100644 (file)
@@ -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,
index 1a9af54e6d979ac982534d03193a72d5a491dff0..05d914630fae3738559e55f678eb2a3ec2b084ff 100644 (file)
@@ -5,7 +5,7 @@ module.exports = {
 
   '@tags': ['no-headless'],
 
-  transitions: function(browser) {
+  transitions: function (browser) {
     const TIMEOUT = 2000
 
     browser
index b40ab3c42e18e22ace5f453fa4adb3a8e7a0a568..17e64dbfd3c362dd0a811b653c531e98e417f432 100644 (file)
@@ -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",
index 62732f66c93896ac3a4a00c1997b53c5c7697f3e..2d87ecf2f139ecf61e55c6a09d79b6b28da0903e 100644 (file)
@@ -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')
 }
 
 /**
index dc7df66ea8e21191ee60c0d3bdea48bb521b510b..4ea6220cb3e5d461605c038188293efd395ca5ca 100644 (file)
--- 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"