Skip to content

Commit

Permalink
chore: correct lint errors in CI (#10370)
Browse files Browse the repository at this point in the history
* fix(eslint-plugin): [no-floating-promises]: remove unsued `output` variable

* fix(typescript-estree): fix `no-else-return` lint errors
  • Loading branch information
marcalexiei authored Nov 22, 2024
1 parent cdbc669 commit 71243db
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 29 deletions.
2 changes: 0 additions & 2 deletions packages/eslint-plugin/src/rules/no-floating-promises.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,6 @@ export default createRule<Options, MessageId>({
return { isUnhandled: false };
}

let output = { isUnhandled: true };

if (node.type === AST_NODE_TYPES.CallExpression) {
// If the outer expression is a call, a `.catch()` or `.then()` with
// rejection handler handles the promise.
Expand Down
4 changes: 3 additions & 1 deletion packages/typescript-estree/src/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1765,7 +1765,9 @@ export class Converter {
right: this.convertChild(node.initializer),
typeAnnotation: undefined,
});
} else if (node.dotDotDotToken) {
}

if (node.dotDotDotToken) {
return this.createNode<TSESTree.RestElement>(node, {
type: AST_NODE_TYPES.RestElement,
argument: arrayItem,
Expand Down
11 changes: 8 additions & 3 deletions packages/typescript-estree/src/node-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,16 @@ export function getBinaryExpressionType(operator: ts.BinaryOperatorToken):
type: AST_NODE_TYPES.AssignmentExpression,
operator: getTextForTokenKind(operator.kind),
};
} else if (isLogicalOperator(operator)) {
}

if (isLogicalOperator(operator)) {
return {
type: AST_NODE_TYPES.LogicalExpression,
operator: getTextForTokenKind(operator.kind),
};
} else if (isESTreeBinaryOperator(operator)) {
}

if (isESTreeBinaryOperator(operator)) {
return {
type: AST_NODE_TYPES.BinaryExpression,
operator: getTextForTokenKind(operator.kind),
Expand Down Expand Up @@ -483,7 +487,8 @@ export function getTokenType(
if (keywordKind) {
if (keywordKind === SyntaxKind.NullKeyword) {
return AST_TOKEN_TYPES.Null;
} else if (
}
if (
keywordKind >= SyntaxKind.FirstFutureReservedWord &&
keywordKind <= SyntaxKind.LastKeyword
) {
Expand Down
18 changes: 12 additions & 6 deletions packages/website/src/components/ast/PropertyValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,38 @@ function getSimpleModel(data: unknown): SimpleModel {
shortValue: value.length > 250 ? value.substring(0, 200) : undefined,
value,
};
} else if (typeof data === 'number') {
}
if (typeof data === 'number') {
return {
className: styles.propNumber,
value: String(data),
};
} else if (typeof data === 'bigint') {
}
if (typeof data === 'bigint') {
return {
className: styles.propNumber,
value: `${data}n`,
};
} else if (data instanceof RegExp) {
}
if (data instanceof RegExp) {
return {
className: styles.propRegExp,
value: String(data),
};
} else if (data == null) {
}
if (data == null) {
return {
className: styles.propEmpty,
value: String(data),
};
} else if (typeof data === 'boolean') {
}
if (typeof data === 'boolean') {
return {
className: styles.propBoolean,
value: data ? 'true' : 'false',
};
} else if (data instanceof Error) {
}
if (data instanceof Error) {
return {
className: styles.propError,
value: `Error: ${data.message}`,
Expand Down
3 changes: 2 additions & 1 deletion packages/website/src/components/ast/selectedRange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ function isIterable(key: string, value: unknown): boolean {
function getRangeFromNode(value: object): [number, number] | null {
if (isESNode(value)) {
return value.range;
} else if (isTSNode(value)) {
}
if (isTSNode(value)) {
return [value.pos, value.end];
}
return null;
Expand Down
34 changes: 20 additions & 14 deletions packages/website/src/components/ast/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,36 +29,41 @@ export function getNodeType(value: unknown): ParentNodeType {
if (Boolean(value) && isRecord(value)) {
if (isESNode(value)) {
return 'esNode';
} else if ('$id' in value && 'childScopes' in value && 'type' in value) {
}
if ('$id' in value && 'childScopes' in value && 'type' in value) {
return 'scope';
} else if (
}
if (
'scopes' in value &&
'nodeToScope' in value &&
'declaredVariables' in value
) {
return 'scopeManager';
} else if (
'references' in value &&
'identifiers' in value &&
'name' in value
) {
}
if ('references' in value && 'identifiers' in value && 'name' in value) {
return 'scopeVariable';
} else if ('$id' in value && 'type' in value && 'node' in value) {
}
if ('$id' in value && 'type' in value && 'node' in value) {
return 'scopeDefinition';
} else if (
}
if (
'$id' in value &&
'resolved' in value &&
'identifier' in value &&
'from' in value
) {
return 'scopeReference';
} else if ('kind' in value && 'pos' in value && 'flags' in value) {
}
if ('kind' in value && 'pos' in value && 'flags' in value) {
return 'tsNode';
} else if ('getSymbol' in value) {
}
if ('getSymbol' in value) {
return 'tsType';
} else if ('getDeclarations' in value && value.getDeclarations != null) {
}
if ('getDeclarations' in value && value.getDeclarations != null) {
return 'tsSymbol';
} else if ('getParameters' in value && value.getParameters != null) {
}
if ('getParameters' in value && value.getParameters != null) {
return 'tsSignature';
}
}
Expand Down Expand Up @@ -137,7 +142,8 @@ export function getTooltipLabel(
case 'tsType':
if (propName === 'flags') {
return tsEnumFlagToString('TypeFlags', value);
} else if (propName === 'objectFlags') {
}
if (propName === 'objectFlags') {
return tsEnumFlagToString('ObjectFlags', value);
}
break;
Expand Down
6 changes: 4 additions & 2 deletions tools/scripts/generate-lib.mts
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,11 @@ async function main(): Promise<void> {
const importName = ((): BASE_CONFIG_EXPORT_NAMES => {
if (variable.isTypeVariable && variable.isValueVariable) {
return BASE_CONFIG_EXPORT_NAMES.TYPE_AND_VALUE;
} else if (variable.isTypeVariable) {
}
if (variable.isTypeVariable) {
return BASE_CONFIG_EXPORT_NAMES.TYPE;
} else if (variable.isValueVariable) {
}
if (variable.isValueVariable) {
return BASE_CONFIG_EXPORT_NAMES.VALUE;
}
// shouldn't happen
Expand Down

0 comments on commit 71243db

Please sign in to comment.