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

Commit 3745a67

Browse files
committed
Add rule @typescript-eslint/prefer-optional-chain
1 parent 519cc46 commit 3745a67

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type { NoParameterPropertiesRule } from './no-parameter-properties';
88
import type { NoUnsafeAssignmentRule } from './no-unsafe-assignment';
99
import type { NoUnusedVarsRule } from './no-unused-vars';
1010
import type { PreferNullishCoalescingRule } from './prefer-nullish-coalescing';
11+
import type { PreferOptionalChainRule } from './prefer-optional-chain';
1112

1213
/**
1314
* All @typescript-eslint rules.
@@ -21,4 +22,5 @@ export type TypeScriptEslintRules = BanTsCommentRule &
2122
NoParameterPropertiesRule &
2223
NoUnsafeAssignmentRule &
2324
NoUnusedVarsRule &
24-
PreferNullishCoalescingRule;
25+
PreferNullishCoalescingRule &
26+
PreferOptionalChainRule;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Prefer using concise optional chain expressions instead of chained logical ands.
5+
*
6+
* @see [prefer-optional-chain](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-optional-chain.md)
7+
*/
8+
export type PreferOptionalChainRuleConfig = RuleConfig<[]>;
9+
10+
/**
11+
* Prefer using concise optional chain expressions instead of chained logical ands.
12+
*
13+
* @see [prefer-optional-chain](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-optional-chain.md)
14+
*/
15+
export interface PreferOptionalChainRule {
16+
/**
17+
* Prefer using concise optional chain expressions instead of chained logical ands.
18+
*
19+
* @see [prefer-optional-chain](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-optional-chain.md)
20+
*/
21+
'@typescript-eslint/prefer-optional-chain': PreferOptionalChainRuleConfig;
22+
}

0 commit comments

Comments
 (0)