Skip to content

Commit 5b6d093

Browse files
committed
catch suppressTransitionError
1 parent 5223738 commit 5b6d093

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict'
2+
3+
var chalk = require('chalk')
4+
5+
module.exports = {
6+
pattern: /\bsuppressTransitionError\b/,
7+
warning: function (match) {
8+
return {
9+
reason: 'Removed due to hooks simplification - if you really must suppress transition errors, you can use JavaScript\'s try-catch instead',
10+
fix: (
11+
'Remove the ' + chalk.red('suppressTransitionError') + ' option'
12+
),
13+
docsHash: 'suppressTransitionError-deprecated'
14+
}
15+
}
16+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
'use strict'
2+
3+
const check = createRuleChecker('vue-router/suppress-transition-error')
4+
5+
describe('Rule: suppress-transition-error', () => {
6+
it('does not match an empty line', () => {
7+
const warning = check('')
8+
expect(warning).toBe(null)
9+
})
10+
11+
it('does not match "suppress transition error"', () => {
12+
const warning = check('suppress transition error')
13+
expect(warning).toBe(null)
14+
})
15+
16+
it('does not match "suppresstransitionerror"', () => {
17+
const warning = check('suppresstransitionerror')
18+
expect(warning).toBe(null)
19+
})
20+
21+
it('matches "suppressTransitionError"', () => {
22+
const warning = check('suppressTransitionError')
23+
expect(warning).toBeTruthy()
24+
expect(warning.fix).toBe('Remove the suppressTransitionError option')
25+
})
26+
27+
it('matches "suppressTransitionError:"', () => {
28+
const warning = check(`
29+
suppressTransitionError:
30+
`)
31+
expect(warning).toBeTruthy()
32+
expect(warning.fix).toBe('Remove the suppressTransitionError option')
33+
})
34+
35+
it('matches "suppressTransitionError :"', () => {
36+
const warning = check(`
37+
suppressTransitionError :
38+
`)
39+
expect(warning).toBeTruthy()
40+
expect(warning.fix).toBe('Remove the suppressTransitionError option')
41+
})
42+
})

0 commit comments

Comments
 (0)