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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: | ||
|
||
* `"newIsCap": true` (default) requires all `new` operators to be called with uppercase-started functions. | ||
* `"newIsCap": false` allows `new` operators to be called with lowercase-started or uppercase-started functions. | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
```js | ||
/*eslint new-cap: ["error", { "capIsNewExceptionPattern": "^Person\.." }]*/ | ||
/*eslint new-cap: ["error", { "capIsNewExceptionPattern": "^person\.." }]*/ | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. There should be a blank line after |
||
|
||
```js | ||
/*eslint new-cap: ["error", { "capIsNewExceptionPattern": "\.Bar$" }]*/ | ||
|
||
foo.Bar(); // Lint-Free! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no need for Also, can we please add a similar example for |
||
``` | ||
|
||
### properties | ||
|
||
|
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 the previous version was correct. "object option" means that the option is an object. In some other rules options are strings, numbers, etc..
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()
ornew C()
.Maybe we should revert this here, and provide a similar explanation in the
### capIsNewExceptionPattern
section.