Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit d8b0a34

Browse files
committed
Add rule no-empty-function
1 parent e44e098 commit d8b0a34

File tree

4 files changed

+107
-0
lines changed

4 files changed

+107
-0
lines changed

src/rules/eslint/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type { MaxLinesRule } from './max-lines';
1111
import type { NoCaseDeclarationsRule } from './no-case-declarations';
1212
import type { NoConstantConditionRule } from './no-constant-condition';
1313
import type { NoDebuggerRule } from './no-debugger';
14+
import type { NoEmptyFunctionRule } from './no-empty-function';
1415
import type { NoUnusedExpressionsRule } from './no-unused-expressions';
1516
import type { NoUselessConcatRule } from './no-useless-concat';
1617
import type { PreferTemplateRule } from './prefer-template';
@@ -34,6 +35,7 @@ export type EslintRules = CommaDangleRule &
3435
NoCaseDeclarationsRule &
3536
NoConstantConditionRule &
3637
NoDebuggerRule &
38+
NoEmptyFunctionRule &
3739
NoUnusedExpressionsRule &
3840
NoUselessConcatRule &
3941
PreferTemplateRule &
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/** Allow Option Entries. */
4+
export type AllowOptionEntries =
5+
| 'functions' // Normal functions.
6+
| 'arrowFunctions' // Arrow functions.
7+
| 'generatorFunctions' // Generator functions.
8+
| 'methods' // Class methods and method shorthands of object literals.
9+
| 'generatorMethods' // Class methods and method shorthands of object literals with generator.
10+
| 'getters' // Getters.
11+
| 'setters' // Setters.
12+
| 'constructors' // Class constructors.
13+
| 'asyncFunctions' // Async functions.
14+
| 'asyncMethods'; // Async class methods and method shorthands of object literals.
15+
16+
/**
17+
* Option.
18+
*/
19+
export type NoEmptyFunctionOption = {
20+
/**
21+
* Allow specific kinds of functions to be empty.
22+
*
23+
* @default []
24+
*
25+
* @see [allow](https://eslint.org/docs/rules/no-empty-function#options)
26+
*/
27+
allow?: AllowOptionEntries[];
28+
};
29+
30+
/**
31+
* Options.
32+
*/
33+
export type NoEmptyFunctionOptions = [NoEmptyFunctionOption?];
34+
35+
/**
36+
* Disallow empty functions.
37+
*
38+
* @see [no-empty-function](https://eslint.org/docs/rules/no-empty-function)
39+
*/
40+
export type NoEmptyFunctionRuleConfig = RuleConfig<NoEmptyFunctionOptions>;
41+
42+
/**
43+
* Disallow empty functions.
44+
*
45+
* @see [no-empty-function](https://eslint.org/docs/rules/no-empty-function)
46+
*/
47+
export interface NoEmptyFunctionRule {
48+
/**
49+
* Disallow empty functions.
50+
*
51+
* @see [no-empty-function](https://eslint.org/docs/rules/no-empty-function)
52+
*/
53+
'no-empty-function': NoEmptyFunctionRuleConfig;
54+
}

src/rules/typescript-eslint/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type { InterfaceNamePrefixRule } from './interface-name-prefix';
1313
import type { MemberDelimiterStyleRule } from './member-delimiter-style';
1414
import type { MemberOrderingRule } from './member-ordering';
1515
import type { NamingConventionRule } from './naming-convention';
16+
import type { NoEmptyFunctionRule } from './no-empty-function';
1617
import type { NoExplicitAnyRule } from './no-explicit-any';
1718
import type { NoInferrableTypesRule } from './no-inferrable-types';
1819
import type { NoParameterPropertiesRule } from './no-parameter-properties';
@@ -43,6 +44,7 @@ export type TypeScriptEslintRules = AdjacentOverloadSignaturesRule &
4344
MemberDelimiterStyleRule &
4445
MemberOrderingRule &
4546
NamingConventionRule &
47+
NoEmptyFunctionRule &
4648
NoExplicitAnyRule &
4749
NoInferrableTypesRule &
4850
NoParameterPropertiesRule &
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { AllowOptionEntries } from '../eslint/no-empty-function';
2+
import type { RuleConfig } from '../rule-config';
3+
4+
/** Additional Allow Option Entries. */
5+
export type AdditionalAllowOptionEntries =
6+
| AllowOptionEntries
7+
| 'private-constructors'
8+
| 'protected-constructors'
9+
| 'decoratedFunctions';
10+
11+
/**
12+
* Option.
13+
*/
14+
export type NoEmptyFunctionOption = {
15+
/**
16+
* Allow specific kinds of functions to be empty.
17+
*
18+
* @default []
19+
*
20+
* @see [allow](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-empty-function.md#options)
21+
*/
22+
allow?: AdditionalAllowOptionEntries[];
23+
};
24+
25+
/**
26+
* Options.
27+
*/
28+
export type NoEmptyFunctionOptions = [NoEmptyFunctionOption?];
29+
30+
/**
31+
* Disallow empty functions.
32+
*
33+
* @see [no-empty-function](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-empty-function.md)
34+
*/
35+
export type NoEmptyFunctionRuleConfig = RuleConfig<NoEmptyFunctionOptions>;
36+
37+
/**
38+
* Disallow empty functions.
39+
*
40+
* @see [no-empty-function](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-empty-function.md)
41+
*/
42+
export interface NoEmptyFunctionRule {
43+
/**
44+
* Disallow empty functions.
45+
*
46+
* @see [no-empty-function](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-empty-function.md)
47+
*/
48+
'@typescript-eslint/no-empty-function': NoEmptyFunctionRuleConfig;
49+
}

0 commit comments

Comments
 (0)