Skip to content

Commit 7b2efaa

Browse files
committed
Fix lint warnings
1 parent 3ab6b9a commit 7b2efaa

File tree

10 files changed

+62
-70
lines changed

10 files changed

+62
-70
lines changed

lib/components/animated-outlet.js

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ export class AnimationHook {
2929
}
3030

3131
// code extracted from vue
32-
var raf = window.requestAnimationFrame
33-
var TRANSITION = 'transition'
34-
var ANIMATION = 'animation'
32+
const raf = window.requestAnimationFrame
33+
const TRANSITION = 'transition'
34+
const ANIMATION = 'animation'
3535

3636
// Transition property/event sniffing
37-
var transitionProp = 'transition'
38-
var transitionEndEvent = 'transitionend'
39-
var animationProp = 'animation'
40-
var animationEndEvent = 'animationend'
37+
const transitionProp = 'transition'
38+
const transitionEndEvent = 'transitionend'
39+
const animationProp = 'animation'
40+
const animationEndEvent = 'animationend'
4141

4242
function nextFrame (fn) {
4343
raf(function () {
@@ -49,18 +49,18 @@ function whenTransitionEnds (
4949
el,
5050
cb
5151
) {
52-
var ref = getTransitionInfo(el)
53-
var type = ref.type
54-
var timeout = ref.timeout
55-
var propCount = ref.propCount
52+
const ref = getTransitionInfo(el)
53+
const type = ref.type
54+
const timeout = ref.timeout
55+
const propCount = ref.propCount
5656
if (!type) { return cb() }
57-
var event = type === TRANSITION ? transitionEndEvent : animationEndEvent
58-
var ended = 0
59-
var end = function () {
57+
const event = type === TRANSITION ? transitionEndEvent : animationEndEvent
58+
let ended = 0
59+
const end = function () {
6060
el.removeEventListener(event, onEnd)
6161
cb()
6262
}
63-
var onEnd = function (e) {
63+
const onEnd = function (e) {
6464
if (e.target === el) {
6565
if (++ended >= propCount) {
6666
end()
@@ -76,29 +76,25 @@ function whenTransitionEnds (
7676
}
7777

7878
function getTransitionInfo (el) {
79-
var styles = window.getComputedStyle(el)
79+
const styles = window.getComputedStyle(el)
8080
// JSDOM may return undefined for transition properties
81-
var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ')
82-
var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ')
83-
var transitionTimeout = getTimeout(transitionDelays, transitionDurations)
84-
var animationDelays = (styles[animationProp + 'Delay'] || '').split(', ')
85-
var animationDurations = (styles[animationProp + 'Duration'] || '').split(', ')
86-
var animationTimeout = getTimeout(animationDelays, animationDurations)
87-
88-
var type
89-
var timeout = 0
90-
var propCount = 0
91-
92-
timeout = Math.max(transitionTimeout, animationTimeout)
93-
type = timeout > 0
81+
const transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ')
82+
const transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ')
83+
const transitionTimeout = getTimeout(transitionDelays, transitionDurations)
84+
const animationDelays = (styles[animationProp + 'Delay'] || '').split(', ')
85+
const animationDurations = (styles[animationProp + 'Duration'] || '').split(', ')
86+
const animationTimeout = getTimeout(animationDelays, animationDurations)
87+
88+
const timeout = Math.max(transitionTimeout, animationTimeout)
89+
const type = timeout > 0
9490
? transitionTimeout > animationTimeout
95-
? TRANSITION
96-
: ANIMATION
91+
? TRANSITION
92+
: ANIMATION
9793
: null
98-
propCount = type
94+
const propCount = type
9995
? type === TRANSITION
100-
? transitionDurations.length
101-
: animationDurations.length
96+
? transitionDurations.length
97+
: animationDurations.length
10298
: 0
10399

104100
return {

lib/function-dsl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable standard/no-callback-literal */
1+
/* eslint-disable node/no-callback-literal */
22
import invariant from './invariant'
33

44
export default function functionDsl (callback) {

lib/middlewares/router-links.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ let router
1515

1616
const delegate = function (el, eventName, selector, listener, context) {
1717
const handler = function (e) {
18-
var node = e.target
18+
let node = e.target
1919
for (; node && node !== el; node = node.parentNode) {
2020
if (node.matches && node.matches(selector)) {
2121
e.selectorTarget = node

lib/router.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable array-callback-return */
12
import { pick, clone, extend, isEqual, keys } from './utils'
23
import functionDsl from './function-dsl'
34
import arrayDsl from './array-dsl'

lib/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ export const keys = Object.keys
66
export const clone = obj =>
77
obj
88
? isArray(obj)
9-
? obj.slice(0)
10-
: extend({}, obj)
9+
? obj.slice(0)
10+
: extend({}, obj)
1111
: obj
1212

1313
export const pick = (obj, attrs) =>

tests/functional/nanodom.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Dom.prototype.html = function (content) {
2323
}
2424

2525
Dom.prototype.find = function (selector) {
26-
var result = new Dom()
26+
const result = new Dom()
2727
this.forEach(function (el) {
2828
[].slice.call(el.querySelectorAll(selector)).forEach(function (e) { result.push(e) })
2929
})
@@ -46,16 +46,16 @@ Dom.prototype.get = function (index) {
4646
return this[index]
4747
}
4848

49-
function domify (str) { var d = document.createElement('div'); d.innerHTML = str; return d.childNodes }
49+
function domify (str) { const d = document.createElement('div'); d.innerHTML = str; return d.childNodes }
5050

51-
var nanodom = function (selector) {
52-
var d
51+
const nanodom = function (selector) {
52+
let d
5353
if (selector instanceof Dom) return selector
5454
if (selector instanceof HTMLElement) { d = new Dom(); d.push(selector); return d }
5555
if (typeof selector !== 'string') return
5656
d = new Dom()
57-
var s; var c = (selector.indexOf('<') === 0)
58-
s = c ? domify(selector) : document.querySelectorAll(selector);
57+
const c = (selector.indexOf('<') === 0)
58+
const s = c ? domify(selector) : document.querySelectorAll(selector);
5959
[].slice.call(s).forEach(function (e) { d.push(e) })
6060
return d
6161
}

tests/functional/routerTest.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe('app', () => {
4242
it('cancelling and retrying transitions', async function () {
4343
await router.transitionTo('/posts/filter/foo')
4444
assert.equal(router.location.getURL(), '/posts/filter/foo')
45-
var transition = router.transitionTo('about')
45+
const transition = router.transitionTo('about')
4646
transition.cancel()
4747
await transition.catch(() => {})
4848
assert.equal(router.location.getURL(), '/posts/filter/foo')
@@ -52,22 +52,20 @@ describe('app', () => {
5252
})
5353

5454
it('transition.followRedirects resolves when all of the redirects have finished', async function () {
55-
var transition
56-
5755
await router.transitionTo('application')
5856
// initiate a transition
59-
transition = router.transitionTo('/posts/filter/foo')
57+
const transition = router.transitionTo('/posts/filter/foo')
6058
// and a redirect
6159
router.transitionTo('/about')
6260

6361
// if followRedirects is not used - the original transition is rejected
64-
var rejected = false
62+
let rejected = false
6563
await transition.catch(() => rejected = true)
6664
assert(rejected)
6765

6866
await router.transitionTo('application')
6967
// initiate a transition
70-
var t = router.transitionTo('/posts/filter/foo')
68+
const t = router.transitionTo('/posts/filter/foo')
7169
// and a redirect, this time using `redirectTo`
7270
t.redirectTo('/about')
7371

@@ -78,41 +76,37 @@ describe('app', () => {
7876
})
7977

8078
it('transition.followRedirects is rejected if transition fails', async function () {
81-
var transition
82-
8379
// silence the errors for the tests
8480
router.logError = () => {}
8581

8682
// initiate a transition
87-
transition = router.transitionTo('/posts/filter/foo')
83+
const transition = router.transitionTo('/posts/filter/foo')
8884
// install a breaking middleware
8985
router.use(() => {
9086
throw new Error('middleware error')
9187
})
9288
// and a redirect
9389
router.transitionTo('/about')
9490

95-
var rejected = false
91+
let rejected = false
9692
await transition.followRedirects().catch((err) => rejected = err.message)
9793
assert.equal(rejected, 'middleware error')
9894
})
9995

10096
it('transition.followRedirects is rejected if transition fails asynchronously', async function () {
101-
var transition
102-
10397
// silence the errors for the tests
10498
router.logError = () => {}
10599

106100
// initiate a transition
107-
transition = router.transitionTo('/posts/filter/foo')
101+
const transition = router.transitionTo('/posts/filter/foo')
108102
// install a breaking middleware
109103
router.use(() => {
110104
return Promise.reject(new Error('middleware promise error'))
111105
})
112106
// and a redirect
113107
router.transitionTo('/about')
114108

115-
var rejected = false
109+
let rejected = false
116110
await transition.followRedirects().catch((err) => rejected = err.message)
117111
assert.equal(rejected, 'middleware promise error')
118112
})
@@ -125,7 +119,7 @@ describe('app', () => {
125119
assert.equal(window.location.hash, '#posts/filter/foo')
126120

127121
// now attempt to transition to about and cancel
128-
var transition = router.transitionTo('/about')
122+
const transition = router.transitionTo('/about')
129123
transition.cancel()
130124
await transition.catch(() => {})
131125

tests/functional/testApp.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
/* eslint-disable array-callback-return */
12
import $ from './nanodom'
23
import { Router } from '../../lib/router'
34

45
export default function TestApp (options) {
56
options = options || {}
67

78
// create the router
8-
var router = this.router = new Router(options)
9+
const router = this.router = new Router(options)
910

1011
// provide the route map
1112
router.map(function (route) {
@@ -20,7 +21,7 @@ export default function TestApp (options) {
2021
})
2122
})
2223

23-
var handlers = {}
24+
const handlers = {}
2425

2526
handlers.application = {
2627
// this is a hook for 'performing'

tests/lib/fakeHistory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default function fakeHistory (location) {
22
const history = []
33

4-
var originalPushState = window.history.pushState
4+
const originalPushState = window.history.pushState
55
window.history.pushState = function (state, title, url) {
66
history.push(url)
77
}

tests/unit/routerTest.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable no-return-assign */
1+
/* eslint-disable no-return-assign,array-callback-return */
22
import BrowserLocation from '../../lib/locations/browser'
33
import { extend } from '../../lib/utils'
44
import { Router, interceptLinks } from '../../lib/router'
@@ -132,7 +132,7 @@ describe('Slick Router', () => {
132132

133133
it('#use middleware resolve and done hooks are called on successful transition', (done) => {
134134
router.map(routes)
135-
var m = {
135+
const m = {
136136
resolve: sinon.spy(),
137137
done: sinon.spy()
138138
}
@@ -148,7 +148,7 @@ describe('Slick Router', () => {
148148

149149
it('#use middleware error hook is called on failed transition', (done) => {
150150
router.map(routes)
151-
var m = {
151+
const m = {
152152
error: sinon.spy()
153153
}
154154
router.use(m)
@@ -162,7 +162,7 @@ describe('Slick Router', () => {
162162

163163
it('#use middleware cancel hook is called on cancelled transition', (done) => {
164164
router.map(routes)
165-
var m = {
165+
const m = {
166166
cancel: sinon.spy()
167167
}
168168
router.listen().then(() => {
@@ -177,7 +177,7 @@ describe('Slick Router', () => {
177177

178178
it('#use middleware cancel hook is called on redirected transition', (done) => {
179179
router.map(routes)
180-
var m = {
180+
const m = {
181181
cancel: sinon.spy()
182182
}
183183
router.listen().then(() => {
@@ -253,7 +253,7 @@ describe('Slick Router', () => {
253253

254254
it('#generate generates urls given route name and params as object', () => {
255255
router.map(routes).listen()
256-
var url = router.generate('status', { user: 'foo', id: 1 }, { withReplies: true })
256+
const url = router.generate('status', { user: 'foo', id: 1 }, { withReplies: true })
257257
assert.equal(url, '#application/foo/status/1?withReplies=true')
258258
})
259259

@@ -262,7 +262,7 @@ describe('Slick Router', () => {
262262
router.options.pushState = true
263263
router.options.root = '/foo/bar'
264264
router.map(routes).listen()
265-
var url = router.generate('status', { user: 'usr', id: 1 }, { withReplies: true })
265+
const url = router.generate('status', { user: 'usr', id: 1 }, { withReplies: true })
266266
assert.equal(url, '/foo/bar/application/usr/status/1?withReplies=true')
267267
})
268268
}
@@ -285,7 +285,7 @@ describe('Slick Router', () => {
285285
})
286286

287287
router.map(routes).listen()
288-
var url = router.generate('status', { user: 'usr', id: 1 }, { withReplies: true })
288+
const url = router.generate('status', { user: 'usr', id: 1 }, { withReplies: true })
289289
assert.equal(browserRedirectedTo, '/foo/bar/#different')
290290
assert.equal(url, '#application/usr/status/1?withReplies=true')
291291
})

0 commit comments

Comments
 (0)