@@ -41,7 +41,7 @@ module.exports = {
41
41
const sourceCode = context . getSourceCode ( ) ;
42
42
const { scopeManager } = sourceCode ;
43
43
const info = utils . getRuleInfo ( sourceCode ) ;
44
- if ( info === null || info . meta === null ) {
44
+ if ( info === null ) {
45
45
return { } ;
46
46
}
47
47
@@ -57,7 +57,7 @@ module.exports = {
57
57
58
58
return {
59
59
Program ( ast ) {
60
- contextIdentifiers = utils . getContextIdentifiers ( context , ast ) ;
60
+ contextIdentifiers = utils . getContextIdentifiers ( scopeManager , ast ) ;
61
61
62
62
schemaNode =
63
63
metaNode &&
@@ -106,16 +106,16 @@ module.exports = {
106
106
'Program:exit' ( ) {
107
107
if ( ! schemaNode && requireSchemaPropertyWhenOptionless ) {
108
108
context . report ( {
109
- node : metaNode ,
109
+ node : metaNode || info . create ,
110
110
messageId : 'missing' ,
111
- suggest : isUsingOptions ? [ ] : [
111
+ suggest : ! isUsingOptions && metaNode && metaNode . type === 'ObjectExpression' ? [
112
112
{
113
113
messageId : 'addEmptySchema' ,
114
114
fix ( fixer ) {
115
115
return utils . insertProperty ( fixer , metaNode , 'schema: []' , sourceCode ) ;
116
116
} ,
117
117
} ,
118
- ] ,
118
+ ] : [ ] ,
119
119
} ) ;
120
120
}
121
121
} ,
@@ -130,7 +130,7 @@ module.exports = {
130
130
node . property . name === 'options'
131
131
) {
132
132
isUsingOptions = true ;
133
- context . report ( { node : schemaNode || metaNode , messageId : 'foundOptionsUsage' } ) ;
133
+ context . report ( { node : schemaNode || metaNode || info . create , messageId : 'foundOptionsUsage' } ) ;
134
134
}
135
135
} ,
136
136
} ;
0 commit comments