-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
5187 new cap wildcard support #5484
Conversation
Thanks for the pull request, @diki! I took a look to make sure it's ready for merging and found some changes are needed:
Can you please update the pull request to address these? (More information can be found in our pull request guide.) |
Hi @diki, thanks for the pull request! Besides the comments left by @eslintbot, this PR also has two commits in it now. Per our pull request guide, we like to have one commit per pull request. Could you please squash your commits and force-push to your branch when you have cleaned up the other items? Thanks a lot! |
5b59317
to
b6853d9
Compare
@platinumazure this is my first PR ever, made the all changes necessary now watching excitedly :) |
No worries (and congrats on putting together your first PR!). Just one more thing: We're a little picky about the formatting of the issue number in the commit message (see Travis build result). All you need to do is edit the commit message and re-force push. git commit --amend -m "Update: Wildcard support for the new-cap rule (fixes #5187)"
git push -f origin 5187-new-cap-wildcard-support Uniform commit messages mean pretty auto-generated changelogs. 😄 Thanks so much for your patience! You're very nearly there, I promise. |
Does this rule currently only cover identifiers? In other words, |
b6853d9
to
1057037
Compare
@platinumazure done! @ljharb i made some modifications to support foo['Bar'] case. |
1057037
to
6a379ed
Compare
@diki i'm not sure you understood what I meant. Let's say I want it to warn on |
@ljharb you are right i got it wrong but at least now i can handle
It may be a noob question (sorry for that already) could you do that before or cannot do it after this patch? Current new-cap rule already does not deal with expressions like |
@diki that's a fair point - I'm certainly not claiming you're breaking an existing use case - but what you are doing is permanently preventing it from being supported. I wonder if it would be better, in the wildcard case, for the rule option to be in a different format? Either |
6a379ed
to
5a764c2
Compare
@ljharb agree. |
@@ -76,6 +88,14 @@ Array of uppercase-starting function names that are permitted to be used without | |||
|
|||
If provided, it must be an `Array`. The default values will continue to be excluded when `capIsNewExceptions` is provided. | |||
|
|||
### `newIsCapWildcardExceptions` | |||
|
|||
Array of lowercase library names where all child methods belong to are permitted to be used with `new` operator |
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 wonder if it would be a better API to allow this to be an array of RegExp source strings - ie, pass it into new RegExp()
and use the resulting regular expression to do the test.
That way things like ^
and $
and $
etc all work, and the plugin doesn't have to implement any of them :-)
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.
Is that level of granularity needed? The issue asked for wildcard support only.
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.
By granularity do you mean a separate option? my question here hopefully explains why I don't think it should be folded into the existing option.
As for the regex support - i don't think it's needed, but including it gets us a lot of functionality for free without having to implement anything special.
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.
Let's discuss back on the issue.
5a764c2
to
33d2c2b
Compare
@diki Looks like we lost track of this. Are you interested finishing this up? |
@diki one last ping. Can you let us know if you plan on finishing this? Thanks |
No response and without a signed CLA, we are unable to carry over this pull request, so closing. |
wildcard support for new-cap rule