-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
fix: update error message for no-restricted-properties
#19855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for docs-eslint canceled.
|
Hi @Tanujkanti4441, could you take a look at the CI failure? The formatting is currently causing an error. |
@@ -155,6 +155,10 @@ module.exports = { | |||
const message = matchedObjectProperty.message | |||
? ` ${matchedObjectProperty.message}` | |||
: ""; | |||
const allowedPropertiesMessage = | |||
matchedObjectProperty.allowProperties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we clean this up a bit?
matchedObjectProperty.allowProperties | |
? ` Only these properties are allowed: ${matchedObjectProperty.allowProperties.join(", ")}.` |
@@ -172,13 +177,17 @@ module.exports = { | |||
const message = globalMatchedProperty.message | |||
? ` ${globalMatchedProperty.message}` | |||
: ""; | |||
const allowedObjectsMessage = globalMatchedProperty.allowObjects | |||
? ` It can be used only in allowed objects - ${globalMatchedProperty.allowObjects.join(", ")}.` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For clarity.
? ` It can be used only in allowed objects - ${globalMatchedProperty.allowObjects.join(", ")}.` | |
? ` Property ${propertyName} is only allowed on these objects: ${globalMatchedProperty.allowObjects.join(", ")}.` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! also added quotes around propertyName
.
no-restricted-properties
no-restricted-properties
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -73,10 +73,10 @@ module.exports = { | |||
messages: { | |||
restrictedObjectProperty: | |||
// eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period | |||
"'{{objectName}}.{{propertyName}}' is restricted from being used.{{message}}", | |||
"'{{objectName}}.{{propertyName}}' is restricted from being used.{{allowedPropertiesMessage}}{{message}}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just want to double-check, do we need a space here?
"'{{objectName}}.{{propertyName}}' is restricted from being used.{{allowedPropertiesMessage}}{{message}}", | |
"'{{objectName}}.{{propertyName}}' is restricted from being used.{{allowedPropertiesMessage}} {{message}}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const message = matchedObjectProperty.message
? ` ${matchedObjectProperty.message}`
: "";
There is already a space before the message, so we don't need space here.
restrictedProperty: | ||
// eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period | ||
"'{{propertyName}}' is restricted from being used.{{message}}", | ||
"'{{propertyName}}' is restricted from being used.{{allowedObjectsMessage}}{{message}}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question.
"'{{propertyName}}' is restricted from being used.{{allowedObjectsMessage}}{{message}}", | |
"'{{propertyName}}' is restricted from being used.{{allowedObjectsMessage}} {{message}}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[x] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
What changes did you make? (Give an overview)
Updated the error message of
no-restricted-properties
for two new optionsallowObjects
andallowProperties
; now the error message will also show the property or objects names that are allowed.Now the error is -
'push' is restricted from being used. It can be used only in allowed objects - router.
Now the error is -
'config.apiKey' is restricted from being used. Only allowed properties can be used - settings, version.
Is there anything you'd like reviewers to focus on?