Skip to content

Commit 30993cd

Browse files
authored
docs: document additional allow options in no-empty-function (#2379)
1 parent 00d84ff commit 30993cd

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

packages/eslint-plugin/docs/rules/no-empty-function.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,59 @@ One example of valid TypeScript specific code that would otherwise trigger the `
2020
## Options
2121

2222
See [`eslint/no-empty-function` options](https://eslint.org/docs/rules/no-empty-function#options).
23+
This rule adds the following options:
24+
25+
```ts
26+
type AdditionalAllowOptionEntries =
27+
| 'private-constructors'
28+
| 'protected-constructors'
29+
| 'decoratedFunctions';
30+
31+
type AllowOptionEntries =
32+
| BaseNoEmptyFunctionAllowOptionEntries
33+
| AdditionalAllowOptionEntries;
34+
35+
interface Options extends BaseNoEmptyFunctionOptions {
36+
allow?: Array<AllowOptionEntries>;
37+
}
38+
const defaultOptions: Options = {
39+
...baseNoEmptyFunctionDefaultOptions,
40+
allow: [],
41+
};
42+
```
43+
44+
### allow: `private-constructors`
45+
46+
Examples of correct code for the `{ "allow": ["private-constructors"] }` option:
47+
48+
```ts
49+
class Foo {
50+
private constructor() {}
51+
}
52+
```
53+
54+
### allow: `protected-constructors`
55+
56+
Examples of correct code for the `{ "allow": ["protected-constructors"] }` option:
57+
58+
```ts
59+
class Foo {
60+
protected constructor() {}
61+
}
62+
```
63+
64+
### allow: `decoratedFunctions`
65+
66+
Examples of correct code for the `{ "allow": ["decoratedFunctions"] }` option:
67+
68+
```ts
69+
@decorator()
70+
function foo() {}
71+
72+
class Foo {
73+
@decorator()
74+
foo() {}
75+
}
76+
```
2377

2478
<sup>Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/master/docs/rules/no-empty-function.md)</sup>

0 commit comments

Comments
 (0)