@@ -73,10 +73,10 @@ module.exports = {
73
73
messages : {
74
74
restrictedObjectProperty :
75
75
// 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}}" ,
77
77
restrictedProperty :
78
78
// 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}}" ,
80
80
} ,
81
81
} ,
82
82
@@ -155,6 +155,10 @@ module.exports = {
155
155
const message = matchedObjectProperty . message
156
156
? ` ${ matchedObjectProperty . message } `
157
157
: "" ;
158
+ const allowedPropertiesMessage =
159
+ matchedObjectProperty . allowProperties
160
+ ? ` Only these properties are allowed: ${ matchedObjectProperty . allowProperties . join ( ", " ) } .`
161
+ : "" ;
158
162
159
163
context . report ( {
160
164
node,
@@ -163,6 +167,7 @@ module.exports = {
163
167
objectName,
164
168
propertyName,
165
169
message,
170
+ allowedPropertiesMessage,
166
171
} ,
167
172
} ) ;
168
173
} else if (
@@ -172,13 +177,17 @@ module.exports = {
172
177
const message = globalMatchedProperty . message
173
178
? ` ${ globalMatchedProperty . message } `
174
179
: "" ;
180
+ const allowedObjectsMessage = globalMatchedProperty . allowObjects
181
+ ? ` Property '${ propertyName } ' is only allowed on these objects: ${ globalMatchedProperty . allowObjects . join ( ", " ) } .`
182
+ : "" ;
175
183
176
184
context . report ( {
177
185
node,
178
186
messageId : "restrictedProperty" ,
179
187
data : {
180
188
propertyName,
181
189
message,
190
+ allowedObjectsMessage,
182
191
} ,
183
192
} ) ;
184
193
}
0 commit comments