8000 no-unreachable-loop · abrahamguo/typescript-eslint@0d0e907 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0d0e907

Browse files
committed
no-unreachable-loop
1 parent d9dba42 commit 0d0e907

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ export default tseslint.config(
206206
'error',
207207
{ commentPattern: '.*intentional fallthrough.*' },
208208
],
209+
'no-unreachable-loop': 'error',
209210
'one-var': ['error', 'never'],
210211

211212
//

packages/eslint-plugin/src/rules/no-mixed-enums.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -170,18 +170,15 @@ export default createRule({
170170
.getSymbolAtLocation(tsNode)!
171171
.getDeclarations()!;
172172

173-
for (const declaration of declarations) {
174-
for (const member of (declaration as ts.EnumDeclaration).members) {
175-
return member.initializer
176-
? tsutils.isTypeFlagSet(
177-
typeChecker.getTypeAtLocation(member.initializer),
178-
ts.TypeFlags.StringLike,
179-
)
180-
? AllowedType.String
181-
: AllowedType.Number
182-
: AllowedType.Number;
183-
}
184-
}
173+
const [{ initializer }] = (declarations[0] as ts.EnumDeclaration)
174+
.members;
175+
return initializer &&
176+
tsutils.isTypeFlagSet(
177+
typeChecker.getTypeAtLocation(initializer),
178+
ts.TypeFlags.StringLike,
179+
)
180+
? AllowedType.String
181+
: AllowedType.Number;
185182
}
186183

187184
// Finally, we default to the type of the first enum member

packages/eslint-plugin/src/rules/no-unsafe-return.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ export default createRule({
166166
});
167167
}
168168

169-
for (const signature of functionType.getCallSignatures()) {
169+
const signature = functionType.getCallSignatures().at(0);
170+
if (signature) {
170171
const functionReturnType = signature.getReturnType();
171172
const result = isUnsafeAssignment(
172173
returnNodeType,

0 commit comments

Comments
 (0)
0