@@ -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,14 +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
111
suggest : isUsingOptions ? [ ] : [
112
112
{
113
113
messageId : 'addEmptySchema' ,
114
- fix ( fixer ) {
115
- return utils . insertProperty ( fixer , metaNode , 'schema: []' , sourceCode ) ;
116
- } ,
114
+ fix : metaNode && metaNode . type === 'ObjectExpression' ?
115
+ fixer => {
116
+ return utils . insertProperty ( fixer , metaNode , 'schema: []' , sourceCode ) ;
117
+ } :
118
+ undefined ,
117
119
} ,
118
120
] ,
119
121
} ) ;
@@ -130,7 +132,7 @@ module.exports = {
130
132
node . property . name === 'options'
131
133
) {
132
134
isUsingOptions = true ;
133
- context . report ( { node : schemaNode || metaNode , messageId : 'foundOptionsUsage' } ) ;
135
+ context . report ( { node : schemaNode || metaNode || info . create , messageId : 'foundOptionsUsage' } ) ;
134
136
}
135
137
} ,
136
138
} ;
0 commit comments