From: Eduardo San Martin Morote Date: Mon, 9 Dec 2019 10:33:38 +0000 (+0100) Subject: style: lint X-Git-Tag: v4.0.0-alpha.0~163 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=41e6aa729835c500adb6567dc1a8a18eec9282e9;p=thirdparty%2Fvuejs%2Frouter.git style: lint --- diff --git a/__tests__/matcher/ranking.spec.ts b/__tests__/matcher/ranking.spec.ts index c3600dd8..95665aeb 100644 --- a/__tests__/matcher/ranking.spec.ts +++ b/__tests__/matcher/ranking.spec.ts @@ -21,9 +21,9 @@ describe('createRouteRecordMatcher', () => { return [pathOrCombined, options] }) - const matchers: Array< - RouteRecordMatcher & { _options: RegExpOptions } - > = normalizedPaths + const matchers: Array = normalizedPaths .slice() // Because sorting order is conserved, allows to mismatch order on // routes with the same ranking diff --git a/e2e/browserstack-send-status.js b/e2e/browserstack-send-status.js index bc45fd87..0cb326fc 100644 --- a/e2e/browserstack-send-status.js +++ b/e2e/browserstack-send-status.js @@ -3,7 +3,7 @@ const axios = require('axios') const BS_USER = process.env.BS_USER const BS_KEY = process.env.BS_KEY -function getKey (client) { +function getKey(client) { // const { capabilities, currentTest } = client // originally i wanted to use this but it turns out the information changes // on the afterEach, making the key non valid. But because every environment @@ -17,7 +17,7 @@ function getKey (client) { return `${client.currentTest.module}: ${client.currentTest.name}` } -function shouldSkipBrowserstackReporting (client) { +function shouldSkipBrowserstackReporting(client) { return !BS_USER || !BS_KEY || client.options.selenium_port !== 80 } @@ -26,11 +26,11 @@ function shouldSkipBrowserstackReporting (client) { * to every test suite. It cannot be added globably because these must be * executed before each test (instead of each test suite as it does in globalModules) */ -module.exports = function sendStatus () { +module.exports = function sendStatus() { const sessionMap = Object.create(null) return { - beforeEach (browser, cb) { + beforeEach(browser, cb) { // avoid running if missing credentials if (shouldSkipBrowserstackReporting(this.client)) return cb() // retrieve the session and save it to the map @@ -41,7 +41,7 @@ module.exports = function sendStatus () { }) }, - afterEach (browser, cb) { + afterEach(browser, cb) { // avoid running if missing credentials if (shouldSkipBrowserstackReporting(this.client)) return cb() const key = getKey(this.client) @@ -63,13 +63,13 @@ module.exports = function sendStatus () { // change the name so it's easier to find name: key, status: 'failed', - reason + reason, }, { auth: { username: BS_USER, - password: BS_KEY - } + password: BS_KEY, + }, } ) .catch(err => { @@ -82,6 +82,6 @@ module.exports = function sendStatus () { } else { cb() } - } + }, } } diff --git a/package.json b/package.json index ad0a517c..7bc7bfbe 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "build": "yarn rollup -c rollup.config.js", "dev": "webpack-dev-server --mode=development", "dev:examples": "webpack-dev-server --mode=development --config examples/webpack.config.js", - "lint": "prettier --write --parser typescript \"src/**/*.ts?(x)\"", + "lint": "prettier -c --parser typescript \"{src,__tests__,e2e}/**/*.[jt]s?(x)\"", + "lint:fix": "yarn run lint --write", "test:types": "tsc --build tsconfig.json", "test:unit": "jest --coverage", "test": "yarn run test:types && yarn run test:unit && yarn build" diff --git a/src/router.ts b/src/router.ts index 26366196..8b7d9f03 100644 --- a/src/router.ts +++ b/src/router.ts @@ -82,12 +82,8 @@ export function createRouter({ ) const beforeGuards: NavigationGuard[] = [] const afterGuards: PostNavigationGuard[] = [] - let currentRoute: Readonly< - RouteLocationNormalized - > = START_LOCATION_NORMALIZED - let pendingLocation: Readonly< - RouteLocationNormalized - > = START_LOCATION_NORMALIZED + let currentRoute: Readonly = START_LOCATION_NORMALIZED + let pendingLocation: Readonly = START_LOCATION_NORMALIZED let onReadyCbs: OnReadyCallback[] = [] // TODO: should these be triggered before or after route.push().catch() let errorHandlers: ErrorHandler[] = [] diff --git a/src/types/index.ts b/src/types/index.ts index f0a8dc88..51bf0e02 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -38,9 +38,9 @@ interface RouteLocationOptions { // User level location export type RouteLocation = | string - | RouteQueryAndHash & LocationAsPath & RouteLocationOptions - | RouteQueryAndHash & LocationAsName & RouteLocationOptions - | RouteQueryAndHash & LocationAsRelative & RouteLocationOptions + | (RouteQueryAndHash & LocationAsPath & RouteLocationOptions) + | (RouteQueryAndHash & LocationAsName & RouteLocationOptions) + | (RouteQueryAndHash & LocationAsRelative & RouteLocationOptions) // A matched record cannot be a redirection and must contain // a normalized version of components with { default: Component } instead of `component`