From 4bf827f2511d85f44671df5b94de0c83c456ad6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dzieko=C5=84ski?= Date: Mon, 10 Aug 2020 00:41:27 +0200 Subject: [PATCH] docs: document additional allow options in no-empty-function --- .../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 43dcf5375b0b..071584e99069 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)