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
Fix: Replaced explanation of option object; corrected first example f… #13037
Conversation
…or capIsNewExceptionPattern; included additional correct case (fixes #12874)
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 for the PR! I left a couple of notes.
@@ -33,7 +33,7 @@ function foo(arg) { | |||
|
|||
## Options | |||
|
|||
This rule has an object option: | |||
This rule has an object, `option`. This object can be used to define exceptions by property name, object name, or even both at the same time. Here are the properties one can define on the `option` object: |
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.
This rule has an object option
I think the previous version was correct. "object option" means that the option is an object. In some other rules options are strings, numbers, etc..
This object can be used to define exceptions by property name, object name, or even both at the same time. Here are the properties one can define on the
option
object
This might be confusing at this point because this rule doesn't apply only to member expressions (object.property
). It also works with "simple" function/constructor calls where it's on an identifier, e.g., f()
or new C()
.
Maybe we should revert this here, and provide a similar explanation in the ### capIsNewExceptionPattern
section.
|
||
var friend = person.Acquaintance(); | ||
var bestFriend = person.Friend(); | ||
``` | ||
Examples of additional **correct** code for this rule with the `{ "capIsNewExceptionPattern": "\.Bar$" }` option: |
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.
There should be a blank line after ```
, this produces the linting error.
@@ -135,14 +135,21 @@ function foo(arg) { | |||
|
|||
### capIsNewExceptionPattern | |||
|
|||
Examples of additional **correct** code for this rule with the `{ "capIsNewExceptionPattern": "^Person\.." }` option: | |||
Examples of additional **correct** code for this rule with the `{ "capIsNewExceptionPattern": "^person\.." }` option: |
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.
👍
```js | ||
/*eslint new-cap: ["error", { "capIsNewExceptionPattern": "\.Bar$" }]*/ | ||
|
||
foo.Bar(); // Lint-Free! |
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.
There is no need for // Lint-Free!
, this is already an example of correct code.
Also, can we please add a similar example for newIsCapExceptionPattern
?
@jordanmoore753 are you still working on this? |
Hi @nzakas! Yes I'm still on this, sorry for the delay. I've had a lot of work lately and haven't had the chance to address this. I'll work on it this week. |
No worries, the world is crazy at the moment. Just didn’t want to hand this off if you were still going to work on it. |
@jordanmoore753 just one more check to see if you're still working on this. We completely understand if you can't finish this up, we'd just like to know if we should get someone else to finish this up. Thanks! |
Closing due to inactivity and in favor of #14725. |
…or capIsNewExceptionPattern; included additional correct case (fixes #12874)
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[X ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
What changes did you make? (Give an overview)
I corrected the first correct example for the
capIsNewExceptionPattern
section, in addition to adding a second correct example. I also updated the Options section at the top with a more descriptive summary of what theoption
object can be used for.Is there anything you'd like reviewers to focus on?