File tree 2 files changed +45
-0
lines changed
2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ 'use strict'
2
+
3
+ var chalk = require ( 'chalk' )
4
+
5
+ module . exports = {
6
+ pattern : / \b ( r o u t e r \s * ?\. \s * ?a l i a s ) \s * ?\( / ,
7
+ warning : function ( match , routerAlias ) {
8
+ return {
9
+ reason : 'Aliases have been moved to an option on route definitions to improve config organization' ,
10
+ fix : (
11
+ 'Replace ' + chalk . red ( routerAlias ) + ' with ' +
12
+ 'an alias option in a route definition (see link below for details)'
13
+ ) ,
14
+ docsHash : 'router-alias-deprecated'
15
+ }
16
+ }
17
+ }
Original file line number Diff line number Diff line change
1
+ 'use strict'
2
+
3
+ const check = createRuleChecker ( 'vue-router/router-alias' )
4
+
5
+ describe ( 'Rule: router-alias' , ( ) => {
6
+ it ( 'does not match an empty line' , ( ) => {
7
+ const warning = check ( '' )
8
+ expect ( warning ) . toBe ( null )
9
+ } )
10
+
11
+ it ( 'does not match "router"' , ( ) => {
12
+ const warning = check ( 'router' )
13
+ expect ( warning ) . toBe ( null )
14
+ } )
15
+
16
+ it ( 'does not match "alias"' , ( ) => {
17
+ const warning = check ( 'on' )
18
+ expect ( warning ) . toBe ( null )
19
+ } )
20
+
21
+ it ( 'matches "router.alias("' , ( ) => {
22
+ const warning = check ( `
23
+ router.alias(
24
+ ` )
25
+ expect ( warning ) . toBeTruthy ( )
26
+ expect ( warning . fix ) . toBe ( 'Replace router.alias with an alias option in a route definition (see link below for details)' )
27
+ } )
28
+ } )
You can’t perform that action at this time.
0 commit comments