From 30993cd9a2f70c4f6c53b954ec62dd65c1458f61 Mon Sep 17 00:00:00 2001 From: Michal Dziekonski Date: Mon, 10 Aug 2020 01:00:03 +0200 Subject: [PATCH] docs: document additional allow options in no-empty-function (#2379) --- .../docs/rules/no-empty-function.md | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/packages/eslint-plugin/docs/rules/no-empty-function.md b/packages/eslint-plugin/docs/rules/no-empty-function.md index 43dcf5375b0..071584e9906 100644 --- a/packages/eslint-plugin/docs/rules/no-empty-function.md +++ b/packages/eslint-plugin/docs/rules/no-empty-function.md @@ -20,5 +20,59 @@ One example of valid TypeScript specific code that would otherwise trigger the ` ## Options See [`eslint/no-empty-function` options](https://eslint.org/docs/rules/no-empty-function#options). +This rule adds the following options: + +```ts +type AdditionalAllowOptionEntries = + | 'private-constructors' + | 'protected-constructors' + | 'decoratedFunctions'; + +type AllowOptionEntries = + | BaseNoEmptyFunctionAllowOptionEntries + | AdditionalAllowOptionEntries; + +interface Options extends BaseNoEmptyFunctionOptions { + allow?: Array; +} +const defaultOptions: Options = { + ...baseNoEmptyFunctionDefaultOptions, + allow: [], +}; +``` + +### allow: `private-constructors` + +Examples of correct code for the `{ "allow": ["private-constructors"] }` option: + +```ts +class Foo { + private constructor() {} +} +``` + +### allow: `protected-constructors` + +Examples of correct code for the `{ "allow": ["protected-constructors"] }` option: + +```ts +class Foo { + protected constructor() {} +} +``` + +### allow: `decoratedFunctions` + +Examples of correct code for the `{ "allow": ["decoratedFunctions"] }` option: + +```ts +@decorator() +function foo() {} + +class Foo { + @decorator() + foo() {} +} +``` Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/master/docs/rules/no-empty-function.md)