@@ -73,10 +73,10 @@ module.exports = {
7373 messages : {
7474 restrictedObjectProperty :
7575 // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
76- "'{{objectName}}.{{propertyName}}' is restricted from being used.{{message}}" ,
76+ "'{{objectName}}.{{propertyName}}' is restricted from being used.{{allowedPropertiesMessage}}{{ message}}" ,
7777 restrictedProperty :
7878 // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
79- "'{{propertyName}}' is restricted from being used.{{message}}" ,
79+ "'{{propertyName}}' is restricted from being used.{{allowedObjectsMessage}}{{ message}}" ,
8080 } ,
8181 } ,
8282
@@ -155,6 +155,10 @@ module.exports = {
155155 const message = matchedObjectProperty . message
156156 ? ` ${ matchedObjectProperty . message } `
157157 : "" ;
158+ const allowedPropertiesMessage =
159+ matchedObjectProperty . allowProperties
160+ ? ` Only these properties are allowed: ${ matchedObjectProperty . allowProperties . join ( ", " ) } .`
161+ : "" ;
158162
159163 context . report ( {
160164 node,
@@ -163,6 +167,7 @@ module.exports = {
163167 objectName,
164168 propertyName,
165169 message,
170+ allowedPropertiesMessage,
166171 } ,
167172 } ) ;
168173 } else if (
@@ -172,13 +177,17 @@ module.exports = {
172177 const message = globalMatchedProperty . message
173178 ? ` ${ globalMatchedProperty . message } `
174179 : "" ;
180+ const allowedObjectsMessage = globalMatchedProperty . allowObjects
181+ ? ` Property '${ propertyName } ' is only allowed on these objects: ${ globalMatchedProperty . allowObjects . join ( ", " ) } .`
182+ : "" ;
175183
176184 context . report ( {
177185 node,
178186 messageId : "restrictedProperty" ,
179187 data : {
180188 propertyName,
181189 message,
190+ allowedObjectsMessage,
182191 } ,
183192 } ) ;
184193 }
0 commit comments