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

Commit 3f2c773

Browse files
committed
Add rule no-constant-condition
1 parent d557a34 commit 3f2c773

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

src/rules/eslint/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { LinebreakStyleRule } from './linebreak-style';
55
import type { MaxClassesPerFileRule } from './max-classes-per-file';
66
import type { MaxLenRule } from './max-len';
77
import type { NoCaseDeclarationsRule } from './no-case-declarations';
8+
import type { NoConstantConditionRule } from './no-constant-condition';
89
import type { NoDebuggerRule } from './no-debugger';
910
import type { QuotesRule } from './quotes';
1011
import type { SemiRule } from './semi';
@@ -19,6 +20,7 @@ export type EslintRules = CommaDangleRule &
1920
MaxClassesPerFileRule &
2021
MaxLenRule &
2122
NoCaseDeclarationsRule &
23+
NoConstantConditionRule &
2224
NoDebuggerRule &
2325
QuotesRule &
2426
SemiRule;
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Option.
5+
*/
6+
export type NoConstantConditionOption = {
7+
/**
8+
* Setting this option to `false` allows constant expressions in loops.
9+
*
10+
* @default true
11+
*
12+
* @see [checkLoops](https://eslint.org/docs/rules/no-constant-condition#checkloops)
13+
*/
14+
checkLoops?: boolean;
15+
};
16+
17+
/**
18+
* Options.
19+
*/
20+
export type NoConstantConditionOptions = [NoConstantConditionOption?];
21+
22+
/**
23+
* Disallow constant expressions in conditions.
24+
*
25+
* @see [no-constant-condition](https://eslint.org/docs/rules/no-constant-condition)
26+
*/
27+
export type NoConstantConditionRuleConfig = RuleConfig<NoConstantConditionOptions>;
28+
29+
/**
30+
* Disallow constant expressions in conditions.
31+
*
32+
* @see [no-constant-condition](https://eslint.org/docs/rules/no-constant-condition)
33+
*/
34+
export interface NoConstantConditionRule {
35+
/**
36+
* Disallow constant expressions in conditions.
37+
*
38+
* @see [no-constant-condition](https://eslint.org/docs/rules/no-constant-condition)
39+
*/
40+
'no-constant-condition': NoConstantConditionRuleConfig;
41+
}

0 commit comments

Comments
 (0)