File tree Expand file tree Collapse file tree 2 files changed +64
-7
lines changed Expand file tree Collapse file tree 2 files changed +64
-7
lines changed Original file line number Diff line number Diff line change @@ -49,8 +49,23 @@ function main(context) {
49
49
context . report ( {
50
50
'node' : null ,
51
51
'message' : 'Empty comments are not allowed' ,
52
- 'loc' : comment . loc
52
+ 'loc' : comment . loc ,
53
+ 'fix' : fix
53
54
} ) ;
55
+
56
+ /**
57
+ * Fixes the lint error.
58
+ *
59
+ * @private
60
+ * @param {Function } fixer - ESLint fixer
61
+ * @returns {(Object|null) } fix or null
62
+ */
63
+ function fix ( fixer ) {
64
+ if ( comment . type === 'Block' || comment . type === 'Line' ) {
65
+ return fixer . removeRange ( comment . range ) ;
66
+ }
67
+ return null ;
68
+ }
54
69
}
55
70
56
71
/**
@@ -98,11 +113,12 @@ function main(context) {
98
113
99
114
rule = {
100
115
'meta' : {
116
+ 'type' : 'layout' ,
101
117
'docs' : {
102
118
'description' : 'enforce that comments are not empty'
103
119
} ,
104
- 'schema ' : [ ] ,
105
- 'fixable ' : null
120
+ 'fixable ' : 'code' ,
121
+ 'schema ' : [ ]
106
122
} ,
107
123
'create' : main
108
124
} ;
Original file line number Diff line number Diff line change @@ -33,7 +33,13 @@ test = {
33
33
'message' : 'Empty comments are not allowed' ,
34
34
'type' : null
35
35
}
36
- ]
36
+ ] ,
37
+ 'output' : [
38
+ 'function pow2( x ) {' ,
39
+ ' ' ,
40
+ ' return x*x;' ,
41
+ '}'
42
+ ] . join ( '\n' )
37
43
} ;
38
44
invalid . push ( test ) ;
39
45
@@ -55,7 +61,19 @@ test = {
55
61
'message' : 'Empty comments are not allowed' ,
56
62
'type' : null
57
63
}
58
- ]
64
+ ] ,
65
+ 'output' : [
66
+ 'function fizzBuzz() {' ,
67
+ ' var out;' ,
68
+ ' var i;' ,
69
+ '' ,
70
+ ' for ( i = 1; i <= 100; i++ ) {' ,
71
+ ' out = ( i % 5 === 0 ) ? "Buzz" : ( i % 3 === 0 ) ? "Fizz" : i;' ,
72
+ ' ' ,
73
+ ' console.log( out );' ,
74
+ ' }' ,
75
+ '}'
76
+ ] . join ( '\n' )
59
77
} ;
60
78
invalid . push ( test ) ;
61
79
@@ -81,7 +99,19 @@ test = {
81
99
'message' : 'Empty comments are not allowed' ,
82
100
'type' : null
83
101
}
84
- ]
102
+ ] ,
103
+ 'output' : [
104
+ 'function makePerson() {' ,
105
+ ' var person = {' ,
106
+ ' ' ,
107
+ ' \'title\': \'engineer\',' ,
108
+ '' ,
109
+ ' ' ,
110
+ ' \'name\': \'Susan\'' ,
111
+ ' };' ,
112
+ ' return person;' ,
113
+ '}'
114
+ ] . join ( '\n' )
85
115
} ;
86
116
invalid . push ( test ) ;
87
117
@@ -102,7 +132,18 @@ test = {
102
132
'message' : 'Empty comments are not allowed' ,
103
133
'type' : null
104
134
}
105
- ]
135
+ ] ,
136
+ 'output' : [
137
+ 'function square( x ) {' ,
138
+ ' var out;' ,
139
+ ' var x;' ,
140
+ '' ,
141
+ ' out = x*x;' ,
142
+ ' ' ,
143
+ '' ,
144
+ ' return out;' ,
145
+ '}'
146
+ ] . join ( '\n' )
106
147
} ;
107
148
invalid . push ( test ) ;
108
149
You can’t perform that action at this time.
0 commit comments