Skip to content

Commit 101b2a2

Browse files
committed
catch saveScrollPosition
1 parent 6313953 commit 101b2a2

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict'
2+
3+
var chalk = require('chalk')
4+
5+
module.exports = {
6+
pattern: /\bsaveScrollPosition\b/,
7+
warning: function (match) {
8+
return {
9+
reason: 'The binary nature of saveScrollPosition wasn\'t sufficient for many use cases, but the new scrollBehavior option allows scroll behavior to be fully customized',
10+
fix: (
11+
'Replace ' + chalk.red('saveScrollPosition') + ' with the new ' +
12+
chalk.green('scrollBehavior') + ' option, which takes a function (see the link below for examples)'
13+
),
14+
docsHash: 'saveScrollPosition-deprecated'
15+
}
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use strict'
2+
3+
const check = createRuleChecker('vue-router/save-scroll-position')
4+
5+
describe('Rule: save-scroll-position', () => {
6+
it('does not match an empty line', () => {
7+
const warning = check('')
8+
expect(warning).toBe(null)
9+
})
10+
11+
it('does not match "save scroll position"', () => {
12+
const warning = check('save scroll position')
13+
expect(warning).toBe(null)
14+
})
15+
16+
it('matches "saveScrollPosition"', () => {
17+
const warning = check('saveScrollPosition')
18+
expect(warning).toBeTruthy()
19+
expect(warning.fix).toBe('Replace saveScrollPosition with the new scrollBehavior option, which takes a function (see the link below for examples)')
20+
})
21+
22+
it('matches "saveScrollPosition:"', () => {
23+
const warning = check(`
24+
saveScrollPosition:
25+
`)
26+
expect(warning).toBeTruthy()
27+
expect(warning.fix).toBe('Replace saveScrollPosition with the new scrollBehavior option, which takes a function (see the link below for examples)')
28+
})
29+
30+
it('matches "saveScrollPosition :"', () => {
31+
const warning = check(`
32+
saveScrollPosition :
33+
`)
34+
expect(warning).toBeTruthy()
35+
expect(warning.fix).toBe('Replace saveScrollPosition with the new scrollBehavior option, which takes a function (see the link below for examples)')
36+
})
37+
})

0 commit comments

Comments
 (0)