File tree 3 files changed +35
-2
lines changed
3 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,12 @@ module.exports = {
43
43
state [ group ] . disableRules . delete ( rule )
44
44
}
45
45
break
46
+ case 'clear' :
47
+ state . block . disableAll = false
48
+ state . block . disableRules . clear ( )
49
+ state . line . disableAll = false
50
+ state . line . disableRules . clear ( )
51
+ break
46
52
}
47
53
return false
48
54
} else {
Original file line number Diff line number Diff line change @@ -107,11 +107,21 @@ function processLine (context, comment) {
107
107
function create ( context ) {
108
108
return {
109
109
Program ( node ) {
110
- const comments = ( node . templateBody && node . templateBody . comments ) || [ ]
111
- for ( const comment of comments ) {
110
+ if ( ! node . templateBody ) {
111
+ return
112
+ }
113
+
114
+ // Send directives to the post-process.
115
+ for ( const comment of node . templateBody . comments ) {
112
116
processBlock ( context , comment )
113
117
processLine ( context , comment )
114
118
}
119
+
120
+ // Send a clear mark to the post-process.
121
+ context . report ( {
122
+ loc : node . templateBody . loc . end ,
123
+ message : 'clear'
124
+ } )
115
125
}
116
126
}
117
127
}
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ const linter = new eslint.CLIEngine({
26
26
} ,
27
27
plugins : [ 'vue' ] ,
28
28
rules : {
29
+ 'no-unused-vars' : 'error' ,
29
30
'vue/comment-directive' : 'error' ,
30
31
'vue/no-parsing-error' : 'error' ,
31
32
'vue/no-duplicate-attributes' : 'error'
@@ -108,6 +109,22 @@ describe('comment-directive', () => {
108
109
assert . deepEqual ( messages [ 0 ] . ruleId , 'vue/no-duplicate-attributes' )
109
110
assert . deepEqual ( messages [ 0 ] . line , 6 )
110
111
} )
112
+
113
+ it ( 'should not affect to the code in <script>.' , ( ) => {
114
+ const code = `
115
+ <template>
116
+ <!-- eslint-disable -->
117
+ <div id id="a">Hello</div>
118
+ </template>
119
+ <script>
120
+ var a
121
+ </script>
122
+ `
123
+ const messages = linter . executeOnText ( code , 'test.vue' ) . results [ 0 ] . messages
124
+
125
+ assert . strictEqual ( messages . length , 1 )
126
+ assert . strictEqual ( messages [ 0 ] . ruleId , 'no-unused-vars' )
127
+ } )
111
128
} )
112
129
113
130
describe ( 'eslint-disable-line' , ( ) => {
You can’t perform that action at this time.
0 commit comments