Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

diki
Copy link
Contributor

@diki diki commented Mar 6, 2016

wildcard support for new-cap rule

@mention-bot
Copy link

By analyzing the blame information on this pull request, we identified @roadhump, @ljharb and @nzakas to be potential reviewers

@eslintbot
Copy link

Thanks for the pull request, @diki! I took a look to make sure it's ready for merging and found some changes are needed:

  • The commit summary needs to begin with a tag (such as Fix: or Update:). Please check out our guide for how to properly format your commit summary and update it on this pull request.
  • Pull requests with code require an issue to be mentioned at the end of the commit summary, such as (fixes #1234). Please update the commit summary with an issue (file a new issue if one doesn't already exist).

Can you please update the pull request to address these?

(More information can be found in our pull request guide.)

@platinumazure
Copy link
Member

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!

@diki diki force-pushed the 5187-new-cap-wildcard-support branch from 5b59317 to b6853d9 Compare March 6, 2016 01:43
@diki
Copy link
Contributor Author

diki commented Mar 6, 2016

@platinumazure this is my first PR ever, made the all changes necessary now watching excitedly :)

@platinumazure
Copy link
Member

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.

@ljharb
Copy link
Sponsor Contributor

ljharb commented Mar 6, 2016

Does this rule currently only cover identifiers? In other words, foo['Bar']() seems like it would error out also. If so, doesn't that mean that this wildcard support would break that? For example, what if I had a literal identifier Foo* I wanted an exception for?

@diki diki force-pushed the 5187-new-cap-wildcard-support branch from b6853d9 to 1057037 Compare March 6, 2016 19:52
@diki
Copy link
Contributor Author

diki commented Mar 6, 2016

@platinumazure done!

@ljharb i made some modifications to support foo['Bar'] case.

@diki diki force-pushed the 5187-new-cap-wildcard-support branch from 1057037 to 6a379ed Compare March 6, 2016 20:02
@ljharb
Copy link
Sponsor Contributor

ljharb commented Mar 6, 2016

@diki i'm not sure you understood what I meant. Let's say I want it to warn on var obj = {}; obj['Foo*'] = function () {}; obj['Foo*']() - how would I do that with your wildcard support?

@diki
Copy link
Contributor Author

diki commented Mar 6, 2016

@ljharb you are right i got it wrong but at least now i can handle obj['Foo'] type expressions.

Let's say I want it to warn on var obj = {}; obj['Foo*'] = function () {}; obj'Foo*' - how would I do that with your wildcard support?

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 obj['Foo'] or obj['Foo*'].

@ljharb
Copy link
Sponsor Contributor

ljharb commented Mar 6, 2016

@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 capIsNewWildcardExceptions (and the corresponding support for newIsCapWildcardExceptions), or instead of a string, an object with a "wildcard" property, or something similar?

@diki diki force-pushed the 5187-new-cap-wildcard-support branch from 6a379ed to 5a764c2 Compare March 6, 2016 22:40
@diki
Copy link
Contributor Author

diki commented Mar 6, 2016

@ljharb agree. capIsNewWildcardExceptions and newIsCapWildcardExceptions options fit much better. I updated the pull request accordingly, thanks for advice.

@@ -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
Copy link
Sponsor Contributor

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 :-)

Copy link
Member

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.

Copy link
Sponsor Contributor

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.

Copy link
Member

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.

@diki diki force-pushed the 5187-new-cap-wildcard-support branch from 5a764c2 to 33d2c2b Compare March 7, 2016 16:37
@nzakas nzakas added the do not merge This pull request should not be merged yet label Mar 25, 2016
@nzakas nzakas removed the cla found label Apr 29, 2016
@nzakas
Copy link
Member

nzakas commented May 24, 2016

@diki Looks like we lost track of this. Are you interested finishing this up?

@nzakas
Copy link
Member

nzakas commented Jun 3, 2016

@diki one last ping. Can you let us know if you plan on finishing this? Thanks

@nzakas
Copy link
Member

nzakas commented Jun 8, 2016

No response and without a signed CLA, we are unable to carry over this pull request, so closing.

@nzakas nzakas closed this Jun 8, 2016
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion do not merge This pull request should not be merged yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants