Skip to content

Commit 39f4874

Browse files
committed
catch
1 parent 036486d commit 39f4874

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-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: /\$loadingRouteData/,
7+
warning: function (match) {
8+
return {
9+
reason: 'The same results can now be achieved with normal reactive properties, so it\'s been deprecated',
10+
fix: (
11+
'Replace ' + chalk.red('$loadingRouteData') + ' with a reactive property that you define (see the link below for an example)'
12+
),
13+
docsHash: 'loadingRouteData-deprecated'
14+
}
15+
}
16+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
'use strict'
2+
3+
const check = createRuleChecker('vue-router/loading-route-data')
4+
5+
describe('Rule: loading-route-data', () => {
6+
it('does not match an empty line', () => {
7+
const warning = check('')
8+
expect(warning).toBe(null)
9+
})
10+
11+
it('does not match "loading route data"', () => {
12+
const warning = check('can reuse')
13+
expect(warning).toBe(null)
14+
})
15+
16+
it('does not match "loadingRouteData"', () => {
17+
const warning = check('loadingRouteData')
18+
expect(warning).toBe(null)
19+
})
20+
21+
it('matches "$loadingRouteData"', () => {
22+
const warning = check(`
23+
$loadingRouteData
24+
`)
25+
expect(warning).toBeTruthy()
26+
expect(warning.fix).toBe('Replace $loadingRouteData with a reactive property that you define (see the link below for an example)')
27+
})
28+
29+
it('matches "this.$loadingRouteData"', () => {
30+
const warning = check(`
31+
this.$loadingRouteData
32+
`)
33+
expect(warning).toBeTruthy()
34+
expect(warning.fix).toBe('Replace $loadingRouteData with a reactive property that you define (see the link below for an example)')
35+
})
36+
37+
it('matches "this.$loadingRouteData" surrounded by quotes', () => {
38+
const warning = check(`
39+
"$loadingRouteData"
40+
`)
41+
expect(warning).toBeTruthy()
42+
expect(warning.fix).toBe('Replace $loadingRouteData with a reactive property that you define (see the link below for an example)')
43+
})
44+
})

0 commit comments

Comments
 (0)