Skip to content

Commit 71243db

Browse files
authored
chore: correct lint errors in CI (#10370)
* fix(eslint-plugin): [no-floating-promises]: remove unsued `output` variable * fix(typescript-estree): fix `no-else-return` lint errors
1 parent cdbc669 commit 71243db

File tree

7 files changed

+49
-29
lines changed

7 files changed

+49
-29
lines changed

packages/eslint-plugin/src/rules/no-floating-promises.ts

-2
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,6 @@ export default createRule<Options, MessageId>({
335335
return { isUnhandled: false };
336336
}
337337

338-
let output = { isUnhandled: true };
339-
340338
if (node.type === AST_NODE_TYPES.CallExpression) {
341339
// If the outer expression is a call, a `.catch()` or `.then()` with
342340
// rejection handler handles the promise.

packages/typescript-estree/src/convert.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1765,7 +1765,9 @@ export class Converter {
17651765
right: this.convertChild(node.initializer),
17661766
typeAnnotation: undefined,
17671767
});
1768-
} else if (node.dotDotDotToken) {
1768+
}
1769+
1770+
if (node.dotDotDotToken) {
17691771
return this.createNode<TSESTree.RestElement>(node, {
17701772
type: AST_NODE_TYPES.RestElement,
17711773
argument: arrayItem,

packages/typescript-estree/src/node-utils.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,16 @@ export function getBinaryExpressionType(operator: ts.BinaryOperatorToken):
199199
type: AST_NODE_TYPES.AssignmentExpression,
200200
operator: getTextForTokenKind(operator.kind),
201201
};
202-
} else if (isLogicalOperator(operator)) {
202+
}
203+
204+
if (isLogicalOperator(operator)) {
203205
return {
204206
type: AST_NODE_TYPES.LogicalExpression,
205207
operator: getTextForTokenKind(operator.kind),
206208
};
207-
} else if (isESTreeBinaryOperator(operator)) {
209+
}
210+
211+
if (isESTreeBinaryOperator(operator)) {
208212
return {
209213
type: AST_NODE_TYPES.BinaryExpression,
210214
operator: getTextForTokenKind(operator.kind),
@@ -483,7 +487,8 @@ export function getTokenType(
483487
if (keywordKind) {
484488
if (keywordKind === SyntaxKind.NullKeyword) {
485489
return AST_TOKEN_TYPES.Null;
486-
} else if (
490+
}
491+
if (
487492
keywordKind >= SyntaxKind.FirstFutureReservedWord &&
488493
keywordKind <= SyntaxKind.LastKeyword
489494
) {

packages/website/src/components/ast/PropertyValue.tsx

+12-6
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,38 @@ function getSimpleModel(data: unknown): SimpleModel {
2222
shortValue: value.length > 250 ? value.substring(0, 200) : undefined,
2323
value,
2424
};
25-
} else if (typeof data === 'number') {
25+
}
26+
if (typeof data === 'number') {
2627
return {
2728
className: styles.propNumber,
2829
value: String(data),
2930
};
30-
} else if (typeof data === 'bigint') {
31+
}
32+
if (typeof data === 'bigint') {
3133
return {
3234
className: styles.propNumber,
3335
value: `${data}n`,
3436
};
35-
} else if (data instanceof RegExp) {
37+
}
38+
if (data instanceof RegExp) {
3639
return {
3740
className: styles.propRegExp,
3841
value: String(data),
3942
};
40-
} else if (data == null) {
43+
}
44+
if (data == null) {
4145
return {
4246
className: styles.propEmpty,
4347
value: String(data),
4448
};
45-
} else if (typeof data === 'boolean') {
49+
}
50+
if (typeof data === 'boolean') {
4651
return {
4752
className: styles.propBoolean,
4853
value: data ? 'true' : 'false',
4954
};
50-
} else if (data instanceof Error) {
55+
}
56+
if (data instanceof Error) {
5157
return {
5258
className: styles.propError,
5359
value: `Error: ${data.message}`,

packages/website/src/components/ast/selectedRange.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ function isIterable(key: string, value: unknown): boolean {
2121
function getRangeFromNode(value: object): [number, number] | null {
2222
if (isESNode(value)) {
2323
return value.range;
24-
} else if (isTSNode(value)) {
24+
}
25+
if (isTSNode(value)) {
2526
return [value.pos, value.end];
2627
}
2728
return null;

packages/website/src/components/ast/utils.ts

+20-14
Original file line numberDiff line numberDiff line change
@@ -29,36 +29,41 @@ export function getNodeType(value: unknown): ParentNodeType {
2929
if (Boolean(value) && isRecord(value)) {
3030
if (isESNode(value)) {
3131
return 'esNode';
32-
} else if ('$id' in value && 'childScopes' in value && 'type' in value) {
32+
}
33+
if ('$id' in value && 'childScopes' in value && 'type' in value) {
3334
return 'scope';
34-
} else if (
35+
}
36+
if (
3537
'scopes' in value &&
3638
'nodeToScope' in value &&
3739
'declaredVariables' in value
3840
) {
3941
return 'scopeManager';
40-
} else if (
41-
'references' in value &&
42-
'identifiers' in value &&
43-
'name' in value
44-
) {
42+
}
43+
if ('references' in value && 'identifiers' in value && 'name' in value) {
4544
return 'scopeVariable';
46-
} else if ('$id' in value && 'type' in value && 'node' in value) {
45+
}
46+
if ('$id' in value && 'type' in value && 'node' in value) {
4747
return 'scopeDefinition';
48-
} else if (
48+
}
49+
if (
4950
'$id' in value &&
5051
'resolved' in value &&
5152
'identifier' in value &&
5253
'from' in value
5354
) {
5455
return 'scopeReference';
55-
} else if ('kind' in value && 'pos' in value && 'flags' in value) {
56+
}
57+
if ('kind' in value && 'pos' in value && 'flags' in value) {
5658
return 'tsNode';
57-
} else if ('getSymbol' in value) {
59+
}
60+
if ('getSymbol' in value) {
5861
return 'tsType';
59-
} else if ('getDeclarations' in value && value.getDeclarations != null) {
62+
}
63+
if ('getDeclarations' in value && value.getDeclarations != null) {
6064
return 'tsSymbol';
61-
} else if ('getParameters' in value && value.getParameters != null) {
65+
}
66+
if ('getParameters' in value && value.getParameters != null) {
6267
return 'tsSignature';
6368
}
6469
}
@@ -137,7 +142,8 @@ export function getTooltipLabel(
137142
case 'tsType':
138143
if (propName === 'flags') {
139144
return tsEnumFlagToString('TypeFlags', value);
140-
} else if (propName === 'objectFlags') {
145+
}
146+
if (propName === 'objectFlags') {
141147
return tsEnumFlagToString('ObjectFlags', value);
142148
}
143149
break;

tools/scripts/generate-lib.mts

+4-2
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,11 @@ async function main(): Promise<void> {
219219
const importName = ((): BASE_CONFIG_EXPORT_NAMES => {
220220
if (variable.isTypeVariable && variable.isValueVariable) {
221221
return BASE_CONFIG_EXPORT_NAMES.TYPE_AND_VALUE;
222-
} else if (variable.isTypeVariable) {
222+
}
223+
if (variable.isTypeVariable) {
223224
return BASE_CONFIG_EXPORT_NAMES.TYPE;
224-
} else if (variable.isValueVariable) {
225+
}
226+
if (variable.isValueVariable) {
225227
return BASE_CONFIG_EXPORT_NAMES.VALUE;
226228
}
227229
// shouldn't happen

0 commit comments

Comments
 (0)