From c73d22ad55b7ec00ed1a99fc85e973fd0325fb9c Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 19 Jun 2021 08:51:13 +0530 Subject: [PATCH 1/5] Docs: fix and add more examples for `new-cap` rule --- docs/rules/new-cap.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/docs/rules/new-cap.md b/docs/rules/new-cap.md index 22ac57729dc..25a969efca9 100644 --- a/docs/rules/new-cap.md +++ b/docs/rules/new-cap.md @@ -135,15 +135,31 @@ 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: ```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: + +```js +/*eslint new-cap: ["error", { "capIsNewExceptionPattern": "\.Bar$" }]*/ + +foo.Bar(); +``` + +Examples of additional **correct** code for this rule with the `{ "capIsNewExceptionPattern": "^Foo" }` option: + +```js +/*eslint new-cap: ["error", { "capIsNewExceptionPattern": "^Foo" }]*/ + +var x = Foo(42) +``` + ### properties Examples of **incorrect** code for this rule with the default `{ "properties": true }` option: From bd280abcf0b08cf7e6df8bc9b499d0fdeb368c85 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Thu, 24 Jun 2021 10:21:45 +0530 Subject: [PATCH 2/5] Docs: update --- docs/rules/new-cap.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/rules/new-cap.md b/docs/rules/new-cap.md index 25a969efca9..b60e19dbc10 100644 --- a/docs/rules/new-cap.md +++ b/docs/rules/new-cap.md @@ -112,10 +112,10 @@ var emitter = new events(); ### newIsCapExceptionPattern -Examples of additional **correct** code for this rule with the `{ "newIsCapExceptionPattern": "^person\.." }` option: +Examples of additional **correct** code for this rule with the `{ "newIsCapExceptionPattern": "^person\\.." }` option: ```js -/*eslint new-cap: ["error", { "newIsCapExceptionPattern": "^person\.." }]*/ +/*eslint new-cap: ["error", { "newIsCapExceptionPattern": "^person\\.." }]*/ var friend = new person.acquaintance(); var bestFriend = new person.friend(); @@ -135,19 +135,19 @@ 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: ```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: +Examples of additional **correct** code for this rule with the `{ "capIsNewExceptionPattern": "\\.Bar$" }` option: ```js -/*eslint new-cap: ["error", { "capIsNewExceptionPattern": "\.Bar$" }]*/ +/*eslint new-cap: ["error", { "capIsNewExceptionPattern": "\\.Bar$" }]*/ foo.Bar(); ``` From e1d3c220fe0477746b2018a1ee99328e1c164453 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 26 Jun 2021 08:56:35 +0530 Subject: [PATCH 3/5] Docs: update --- docs/rules/new-cap.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/rules/new-cap.md b/docs/rules/new-cap.md index b60e19dbc10..07c1d25f1e4 100644 --- a/docs/rules/new-cap.md +++ b/docs/rules/new-cap.md @@ -118,9 +118,18 @@ Examples of additional **correct** code for this rule with the `{ "newIsCapExcep /*eslint new-cap: ["error", { "newIsCapExceptionPattern": "^person\\.." }]*/ var friend = new person.acquaintance(); + var bestFriend = new person.friend(); ``` +Examples of additional **correct** code for this rule with the `{ "capIsNewExceptionPattern": "\\.Bar$" }` option: + +```js +/*eslint new-cap: ["error", { "newIsCapExceptionPattern": "\\.Bar$" }]*/ + +var friend = new person.bar(); +``` + ### capIsNewExceptions Examples of additional **correct** code for this rule with the `{ "capIsNewExceptions": ["Person"] }` option: @@ -157,7 +166,11 @@ Examples of additional **correct** code for this rule with the `{ "capIsNewExcep ```js /*eslint new-cap: ["error", { "capIsNewExceptionPattern": "^Foo" }]*/ -var x = Foo(42) +var x = Foo(42); + +var y = Foobar(42); + +var z = Foo.Bar(42); ``` ### properties From 9db763613cbc892719db0322c7ef1b3c973976cd Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 26 Jun 2021 08:57:04 +0530 Subject: [PATCH 4/5] Docs: update --- docs/rules/new-cap.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/rules/new-cap.md b/docs/rules/new-cap.md index 07c1d25f1e4..abccfba5877 100644 --- a/docs/rules/new-cap.md +++ b/docs/rules/new-cap.md @@ -122,7 +122,7 @@ var friend = new person.acquaintance(); var bestFriend = new person.friend(); ``` -Examples of additional **correct** code for this rule with the `{ "capIsNewExceptionPattern": "\\.Bar$" }` option: +Examples of additional **correct** code for this rule with the `{ "newIsCapExceptionPattern": "\\.Bar$" }` option: ```js /*eslint new-cap: ["error", { "newIsCapExceptionPattern": "\\.Bar$" }]*/ From a83c53268038e96144590380d5d4b3347a8d15e4 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 26 Jun 2021 18:25:11 +0530 Subject: [PATCH 5/5] Docs: Update docs/rules/new-cap.md Co-authored-by: Milos Djermanovic --- docs/rules/new-cap.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/rules/new-cap.md b/docs/rules/new-cap.md index abccfba5877..ef8c61508c6 100644 --- a/docs/rules/new-cap.md +++ b/docs/rules/new-cap.md @@ -122,10 +122,10 @@ var friend = new person.acquaintance(); var bestFriend = new person.friend(); ``` -Examples of additional **correct** code for this rule with the `{ "newIsCapExceptionPattern": "\\.Bar$" }` option: +Examples of additional **correct** code for this rule with the `{ "newIsCapExceptionPattern": "\\.bar$" }` option: ```js -/*eslint new-cap: ["error", { "newIsCapExceptionPattern": "\\.Bar$" }]*/ +/*eslint new-cap: ["error", { "newIsCapExceptionPattern": "\\.bar$" }]*/ var friend = new person.bar(); ```