@@ -34,11 +34,13 @@ Please set .textlinrc:
3434 let src = new StructuredSource ( text ) ;
3535 let makeChangeSet = config . makeChangeSet ( null , text ) ;
3636 makeChangeSet . forEach ( function ( changeSet ) {
37- // Avoid accidental match(ignore case, expected contain actual pattern)
38- var expectedQuery = new RegExp ( '^' + changeSet . expected ) ;
39- // | ----[match------|
37+ // | ----[match]------
4038 var slicedText = text . slice ( changeSet . index ) ;
41- if ( expectedQuery . test ( slicedText ) ) {
39+ // | ----[match------|
40+ var matchedText = slicedText . slice ( 0 , changeSet . matches [ 0 ] . length ) ;
41+ var expected = matchedText . replace ( changeSet . pattern , changeSet . expected ) ;
42+ // Avoid accidental match(ignore case, expected contain actual pattern)
43+ if ( slicedText . indexOf ( expected ) === 0 ) {
4244 return ;
4345 }
4446 /*
@@ -48,11 +50,9 @@ Please set .textlinrc:
4850 adjust position => line -1, column + 1
4951 */
5052 var position = src . indexToPosition ( changeSet . index ) ;
51- // | ----[match]------|
52- var matchedText = slicedText . slice ( 0 , changeSet . matches [ 0 ] . length ) ;
53- var expected = matchedText . replace ( changeSet . pattern , changeSet . expected ) ;
53+
5454 // line, column
55- context . report ( node , new context . RuleError ( changeSet . matches [ 0 ] + " => " + expected , {
55+ context . report ( node , new RuleError ( changeSet . matches [ 0 ] + " => " + expected , {
5656 line : position . line - 1 ,
5757 column : position . column + 1
5858 } ) ) ;
0 commit comments