@@ -151,6 +151,16 @@ function checkMetaValidity(context, exportsNode, ruleIsFixable) {
151
151
}
152
152
}
153
153
154
+ /**
155
+ * Whether this node is the correct format for a rule definition or not.
156
+ *
157
+ * @param {ASTNode } node node that the rule exports.
158
+ * @returns {boolean } `true` if the exported node is the correct format for a rule definition
159
+ */
160
+ function isCorrectExportsFormat ( node ) {
161
+ return node . type === "ObjectExpression" ;
162
+ }
163
+
154
164
//------------------------------------------------------------------------------
155
165
// Rule Definition
156
166
//------------------------------------------------------------------------------
@@ -167,7 +177,7 @@ module.exports = {
167
177
} ,
168
178
169
179
create : function ( context ) {
170
- let metaExportsValue ;
180
+ let exportsNode ;
171
181
let ruleIsFixable = false ;
172
182
173
183
return {
@@ -178,7 +188,7 @@ module.exports = {
178
188
node . left . object . name === "module" &&
179
189
node . left . property . name === "exports" ) {
180
190
181
- metaExportsValue = node . right ;
191
+ exportsNode = node . right ;
182
192
}
183
193
} ,
184
194
@@ -205,7 +215,12 @@ module.exports = {
205
215
} ,
206
216
207
217
"Program:exit" : function ( ) {
208
- checkMetaValidity ( context , metaExportsValue , ruleIsFixable ) ;
218
+ if ( ! isCorrectExportsFormat ( exportsNode ) ) {
219
+ context . report ( exportsNode , "Rule does not export an Object. Make sure the rule follows the new rule format." ) ;
220
+ return ;
221
+ }
222
+
223
+ checkMetaValidity ( context , exportsNode , ruleIsFixable ) ;
209
224
}
210
225
} ;
211
226
}
0 commit comments