Skip to content

Commit 9e2b680

Browse files
committed
catch v-link-active
1 parent 5b562d7 commit 9e2b680

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

rules/vue-router/v-link-active.js

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: /\bv-link-active\b/,
7+
warning: function (match) {
8+
return {
9+
reason: 'Active route classes are now handled through the <router-link> component',
10+
fix: (
11+
'Replace ' + chalk.red(match) + ' with the new <router-link> component with a custom tag (see link below for details)'
12+
),
13+
docsHash: 'v-link-active-deprecated'
14+
}
15+
}
16+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict'
2+
3+
const check = createRuleChecker('vue-router/v-link-active')
4+
5+
describe('Rule: v-link-active', () => {
6+
it('does not match an empty line', () => {
7+
const warning = check('')
8+
expect(warning).toBe(null)
9+
})
10+
11+
it('matches a simple v-link-active', () => {
12+
const warning = check(`
13+
<li v-link-active>
14+
`)
15+
expect(warning).toBeTruthy()
16+
expect(warning.fix).toBe('Replace v-link-active with the new <router-link> component with a custom tag (see link below for details)')
17+
})
18+
19+
it('matches a v-link-active with other attributes', () => {
20+
const warning = check(`
21+
<li data-foo="bar" v-link-active class="baz">
22+
`)
23+
expect(warning).toBeTruthy()
24+
expect(warning.fix).toBe('Replace v-link-active with the new <router-link> component with a custom tag (see link below for details)')
25+
})
26+
})

rules/vue-router/v-link.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = {
66
pattern: /\bv-link=(?:'[^']+'|"[^"]+")/,
77
warning: function (match) {
88
return {
9-
reason: 'The v-link attribute has been replaced with the new <router-link> component',
9+
reason: 'The v-link directive has been replaced with the new <router-link> component',
1010
fix: (
1111
'Replace ' + chalk.red(match) + ' with the new <router-link> component (see link below for details)'
1212
),

0 commit comments

Comments
 (0)