8000 Docs: fix and add more examples for new-cap rule (fixes #12874) (#14725) · eslint/eslint@278813a · GitHub
[go: up one dir, main page]

Skip to content

Commit 278813a

Browse files
Docs: fix and add more examples for new-cap rule (fixes #12874) (#14725)
* Docs: fix and add more examples for `new-cap` rule * Docs: update * Docs: update * Docs: update * Docs: Update docs/rules/new-cap.md Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com> Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
1 parent ed1da5d commit 278813a

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

docs/rules/new-cap.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,24 @@ var emitter = new events();
112112

113113
### newIsCapExceptionPattern
114114

115-
Examples of additional **correct** code for this rule with the `{ "newIsCapExceptionPattern": "^person\.." }` option:
115+
Examples of additional **correct** code for this rule with the `{ "newIsCapExceptionPattern": "^person\\.." }` option:
116116

117117
```js
118-
/*eslint new-cap: ["error", { "newIsCapExceptionPattern": "^person\.." }]*/
118+
/*eslint new-cap: ["error", { "newIsCapExceptionPattern": "^person\\.." }]*/
119119

120120
var friend = new person.acquaintance();
121+
121122
var bestFriend = new person.friend();
122123
```
123124

125+
Examples of additional **correct** code for this rule with the `{ "newIsCapExceptionPattern": "\\.bar$" }` option:
126+
127+
```js
128+
/*eslint new-cap: ["error", { "newIsCapExceptionPattern": "\\.bar$" }]*/
129+
130+
var friend = new person.bar();
131+
```
132+
124133
### capIsNewExceptions
125134

126135
Examples of additional **correct** code for this rule with the `{ "capIsNewExceptions": ["Person"] }` option:
@@ -135,15 +144,35 @@ function foo(arg) {
135144

136145
### capIsNewExceptionPattern
137146

138-
Examples of additional **correct** code for this rule with the `{ "capIsNewExceptionPattern": "^Person\.." }` option:
147+
Examples of additional **correct** code for this rule with the `{ "capIsNewExceptionPattern": "^person\\.." }` option:
139148

140149
```js
141-
/*eslint new-cap: ["error", { "capIsNewExceptionPattern": "^Person\.." }]*/
150+
/*eslint new-cap: ["error", { "capIsNewExceptionPattern": "^person\\.." }]*/
142151

143152
var friend = person.Acquaintance();
144153
var bestFriend = person.Friend();
145154
```
146155

156+
Examples of additional **correct** code for this rule with the `{ "capIsNewExceptionPattern": "\\.Bar$" }` option:
157+
158+
```js
159+
/*eslint new-cap: ["error", { "capIsNewExceptionPattern": "\\.Bar$" }]*/
160+
161+
foo.Bar();
162+
```
163+
164+
Examples of additional **correct** code for this rule with the `{ "capIsNewExceptionPattern": "^Foo" }` option:
165+
166+
```js
167+
/*eslint new-cap: ["error", { "capIsNewExceptionPattern": "^Foo" }]*/
168+
169+
var x = Foo(42);
170+
171+
var y = Foobar(42);
172+
173+
var z = Foo.Bar(42);
174+
```
175+
147176
### properties
148177

149178
Examples of **incorrect** code for this rule with the default `{ "properties": true }` option:

0 commit comments

Comments
 (0)
0