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
Allow for Boolean Prop Naming Custom Message #1588
Conversation
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.
Thanks, this is a great addition!
lib/rules/boolean-prop-naming.js
Outdated
@@ -35,6 +35,10 @@ module.exports = { | |||
default: '^(is|has)[A-Z]([A-Za-z0-9]?)+', | |||
minLength: 1, | |||
type: 'string' | |||
}, | |||
message: { | |||
default: '', |
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.
I don't think eslint pays attention to default
here, fwiw.
Also, could we add minLength: 1
? nobody should need to configure an empty string
@ljharb Did you mean to request changes on this PR. From your comment, it looks like you meant to approve. |
@rapheld if you click on "show outdated" you'll see the change i requested. |
lib/rules/boolean-prop-naming.js
Outdated
@@ -131,7 +135,7 @@ module.exports = { | |||
const propName = getPropName(propNode); | |||
context.report({ | |||
node: propNode, | |||
message: `Prop name (${propName}) doesn't match rule (${config.rule})`, | |||
message: config.message || `Prop name (${propName}) doesn't match rule (${config.rule})`, |
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.
I think if we're making this configurable, then instead of using a template literal to interpolate propName
and config.rule
, we should use eslint's built-in string templating - that way the configurable message can use placeholders for those two things.
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.
Adding now.
I had tried that, but for whatever reason, it wasn’t displaying a comment. Worked this time though. |
@ljharb String templating added! |
@ljharb Glad to see this merged! This is my first contribution to this project, and I'm trying to determine how I should bring this into my own project. What's the timeline for publication of this enhancement? (P.S. will delete this branch soon) |
@louisscruz once merged, you're welcome to delete your branch whenever you like, or keep it forever :-) For this project, only @yannickcr can do a release, so it'll be released when they get a chance to do so (I can't speak to their timeline). |
@yannickcr Any plans for publication? |
The default message for boolean-prop-naming does not make it clear why the rule is being flagged. I'd like my organization to be able to immediately know what the issue is without them having to parse the Regex.
This PR introduces functionality such that the following configuration:
displays the custom message of
Boolean prop names must begin with either 'is' or 'has'.
.