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

Commit a5048f3

Browse files
committed
Add typescript-eslint rules
1 parent a00f1e3 commit a5048f3

12 files changed

+426
-988
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Option.
5+
*/
6+
export interface ClassMethodsUseThisOption {
7+
/**
8+
* Allows specified method names to be ignored with this rule
9+
*/
10+
exceptMethods?: string[];
11+
/**
12+
* Enforces that functions used as instance field initializers utilize `this`
13+
*/
14+
enforceForClassFields?: boolean;
15+
/**
16+
* Ingore members marked with the `override` modifier
17+
*/
18+
ignoreOverrideMethods?: boolean;
19+
/**
20+
* Ignore classes that specifically implement some interface
21+
*/
22+
ignoreClassesThatImplementAnInterface?: boolean;
23+
}
24+
25+
/**
26+
* Options.
27+
*/
28+
export type ClassMethodsUseThisOptions = [ClassMethodsUseThisOption?];
29+
30+
/**
31+
* Enforce that class methods utilize `this`.
32+
*
33+
* @see [class-methods-use-this](https://typescript-eslint.io/rules/class-methods-use-this)
34+
*/
35+
export type ClassMethodsUseThisRuleConfig =
36+
RuleConfig<ClassMethodsUseThisOptions>;
37+
38+
/**
39+
* Enforce that class methods utilize `this`.
40+
*
41+
* @see [class-methods-use-this](https://typescript-eslint.io/rules/class-methods-use-this)
42+
*/
43+
export interface ClassMethodsUseThisRule {
44+
/**
45+
* Enforce that class methods utilize `this`.
46+
*
47+
* @see [class-methods-use-this](https://typescript-eslint.io/rules/class-methods-use-this)
48+
*/
49+
'@typescript-eslint/class-methods-use-this': ClassMethodsUseThisRuleConfig;
50+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type { BanTypesRule } from './ban-types';
77
import type { BlockSpacingRule } from './block-spacing';
88
import type { BraceStyleRule } from './brace-style';
99
import type { ClassLiteralPropertyStyleRule } from './class-literal-property-style';
10+
import type { ClassMethodsUseThisRule } from './class-methods-use-this';
1011
import type { CommaDangleRule } from './comma-dangle';
1112
import type { CommaSpacingRule } from './comma-spacing';
1213
import type { ConsistentGenericConstructorsRule } from './consistent-generic-constructors';
@@ -147,6 +148,7 @@ export type TypeScriptRules = AdjacentOverloadSignaturesRule &
147148
BlockSpacingRule &
148149
BraceStyleRule &
149150
ClassLiteralPropertyStyleRule &
151+
ClassMethodsUseThisRule &
150152
CommaDangleRule &
151153
CommaSpacingRule &
152154
ConsistentGenericConstructorsRule &

src/rules/typescript-eslint/lines-around-comment.d.ts

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,35 @@ import type { RuleConfig } from '../rule-config';
33
/**
44
* Option.
55
*/
6-
export type LinesAroundCommentOption =
7-
| []
8-
| [
9-
{
10-
beforeBlockComment?: boolean;
11-
afterBlockComment?: boolean;
12-
beforeLineComment?: boolean;
13-
afterLineComment?: boolean;
14-
allowBlockStart?: boolean;
15-
allowBlockEnd?: boolean;
16-
allowClassStart?: boolean;
17-
allowClassEnd?: boolean;
18-
allowObjectStart?: boolean;
19-
allowObjectEnd?: boolean;
20-
allowArrayStart?: boolean;
21-
allowArrayEnd?: boolean;
22-
allowInterfaceStart?: boolean;
23-
allowInterfaceEnd?: boolean;
24-
allowTypeStart?: boolean;
25-
allowTypeEnd?: boolean;
26-
allowEnumStart?: boolean;
27-
allowEnumEnd?: boolean;
28-
allowModuleStart?: boolean;
29-
allowModuleEnd?: boolean;
30-
ignorePattern?: string;
31-
applyDefaultIgnorePatterns?: boolean;
32-
},
33-
];
6+
export interface LinesAroundCommentOption {
7+
beforeBlockComment?: boolean;
8+
afterBlockComment?: boolean;
9+
beforeLineComment?: boolean;
10+
afterLineComment?: boolean;
11+
allowBlockStart?: boolean;
12+
allowBlockEnd?: boolean;
13+
allowClassStart?: boolean;
14+
allowClassEnd?: boolean;
15+
allowObjectStart?: boolean;
16+
allowObjectEnd?: boolean;
17+
allowArrayStart?: boolean;
18+
allowArrayEnd?: boolean;
19+
allowInterfaceStart?: boolean;
20+
allowInterfaceEnd?: boolean;
21+
allowTypeStart?: boolean;
22+
allowTypeEnd?: boolean;
23+
allowEnumStart?: boolean;
24+
allowEnumEnd?: boolean;
25+
allowModuleStart?: boolean;
26+
allowModuleEnd?: boolean;
27+
ignorePattern?: string;
28+
applyDefaultIgnorePatterns?: boolean;
29+
}
3430

3531
/**
3632
* Options.
3733
*/
38-
export type LinesAroundCommentOptions = LinesAroundCommentOption;
34+
export type LinesAroundCommentOptions = [LinesAroundCommentOption?];
3935

4036
/**
4137
* Require empty lines around comments.

src/rules/typescript-eslint/lines-between-class-members.d.ts

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,36 @@
1-
import type {
2-
LinesBetweenClassMembersConfig as BaseConfig,
3-
LinesBetweenClassMembersOption,
4-
} from '../eslint/lines-between-class-members';
51
import type { RuleConfig } from '../rule-config';
62

73
/**
84
* Config.
95
*/
10-
export interface LinesBetweenClassMembersConfig extends BaseConfig {
6+
export interface LinesBetweenClassMembersConfig {
7+
exceptAfterSingleLine?: boolean;
118
exceptAfterOverload?: boolean;
129
}
1310

11+
/**
12+
* Option.
13+
*/
14+
export type LinesBetweenClassMembersOption =
15+
| {
16+
/**
17+
* @minItems 1
18+
*/
19+
enforce: [
20+
{
21+
blankLine: 'always' | 'never';
22+
prev: 'method' | 'field' | '*';
23+
next: 'method' | 'field' | '*';
24+
},
25+
...{
26+
blankLine: 'always' | 'never';
27+
prev: 'method' | 'field' | '*';
28+
next: 'method' | 'field' | '*';
29+
}[],
30+
];
31+
}
32+
| ('always' | 'never');
33+
1434
/**
1535
* Options.
1636
*/

0 commit comments

Comments
 (0)