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

New: no-restricted-properties rule (fixes #3218) #5872

Closed
wants to merge 1 commit into from

Conversation

willklein
Copy link

Fixes #3218.

Let me know if there's anything to address. Thanks!

@mention-bot
Copy link

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

@eslintbot
Copy link

LGTM

@@ -0,0 +1,73 @@
# Disallow certain object properties (no-restricted-properties)

Certain properties on objects may be disallowed in a codebase. This is useful for deprecating an API or restricting usage of a module's methods. This rule looks for accessing a given property key on a given object name, either when reading the property's value or invoking it as a function. You may specify an optional message to indicate an alternative API or a reason for the restriction.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give an example here to make this concrete? Like, location.href for example? (or something better?)

@nzakas
Copy link
Member

nzakas commented Apr 18, 2016

Overall looks good, just a few comments.

@@ -190,6 +190,7 @@ These rules are purely matters of style and are quite subjective.
* [no-nested-ternary](no-nested-ternary.md): disallow nested ternary expressions
* [no-new-object](no-new-object.md): disallow `Object` constructors
* [no-plusplus](no-plusplus.md): disallow the unary operators `++` and `--`
* [no-restricted-properties](no-restricted-properties.md) - disallow use of specified object properties
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disallow the use of specified object properties

After recent editing, most (but not quite all) occurrences of use are preceded by the.
Extra word :( but helps make clear it is a noun not a verb, especially if English is not first language of reader :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it, great input. I'll update this.

@pedrottimark
Copy link
Member

@willklein Thank you for investing the time and effort to research and follow existing precedents for the rule doc. Most of the line comments represent improvements we are in the middle of making, so by your extra effort right now, you level up with a rising tide, and save rework in the coming weeks. Thanks :)

@pedrottimark
Copy link
Member

pedrottimark commented Apr 18, 2016

@nzakas Good question about options. Although we are moving away from separate examples of json config, this is parallel with no-restricted-syntax, so let’s say it’s good to go for this PR.

As we edit rules with simpler options schema, we gain experience for the more complex schema.

@pedrottimark
Copy link
Member

Another thing that came to mind is reference to properties by object destructuring:

  • Simplest solution is make it clear enough under Rule Details that it is member expressions which are disallowed, so object destructuring becomes a mute point (pardon the pun :)
  • Alternative solution is a sentence under Rule Details like This rule does not apply to …

@nzakas
Copy link
Member

nzakas commented May 3, 2016

@willklein just checking in to see if you're still working on this?

@nzakas
Copy link
Member

nzakas commented May 4, 2016

@willklein when you get a chance, can you sign our new CLA? http://contribute.jquery.org/cla

@willklein
Copy link
Author

@nzakas, yes and yes.

@ilyavolodin
Copy link
Member

@willklein just checking to see if you are planning on finishing this up.

```json
{
"rules": {
"no-restricted-properties": [2, [{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be the wrong time to bring this up, but could the option syntax be simplified like so:

// ...
  "no-restricted-properties": [ "error", [ {
    "objectName": {
      "propertyName1": "Error message 1",
      "propertyName2": "Error message 2"
    },
    "anotherObjectName": {
       // ...
    }, // etc
  } ] ],

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add that feedback to the issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aubergine10 #3218

@nzakas
Copy link
Member

nzakas commented Jun 20, 2016

@willklein last ping, I promise. :) If you aren't able to finish this up, can you just sign the jQuery CLA? That way, someone can continue your work and finish it up.

@nzakas
Copy link
Member

nzakas commented Jun 28, 2016

Unfortunately, no response and without the CLA signed, we can't use the code. @willklein feel free to reopen if you'd like to continue.

@nzakas nzakas closed this Jun 28, 2016
@willklein
Copy link
Author

Sorry all, @nzakas. I signed the jQuery CLA so my code can be picked up. I had a baby, then started a new job, so this year has been crazy for me. Making open source a part of what we do @Crownpeak but I'm focused on building the Denver team instead of coding right now.

@alberto
Copy link
Member

alberto commented Jul 3, 2016

Thanks, @willklein, we understand, life happens :). @nzakas the bot didn't pick it. Maybe it is because the issue is closed? Is there any way we can confirm the CLA signature is ok?

@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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants