Skip to content

Commit

Permalink
fix(eslint-plugin): [space-infix-ops] regression fix for type aliases (
Browse files Browse the repository at this point in the history
  • Loading branch information
armano2 committed Jun 4, 2022
1 parent 8dc1f92 commit 4e13deb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/eslint-plugin/src/rules/space-infix-ops.ts
Expand Up @@ -174,10 +174,8 @@ export default util.createRule<Options, MessageIds>({
function checkForTypeAliasAssignment(
node: TSESTree.TSTypeAliasDeclaration,
): void {
const leftNode = sourceCode.getTokenByRangeStart(node.id.range[0])!;
const rightNode = sourceCode.getTokenByRangeStart(
node.typeAnnotation.range[0],
);
const leftNode = sourceCode.getLastToken(node.typeParameters ?? node.id)!;
const rightNode = sourceCode.getFirstToken(node.typeAnnotation);

checkAndReportAssignmentSpace(node, leftNode, rightNode);
}
Expand Down
3 changes: 3 additions & 0 deletions packages/eslint-plugin/tests/rules/space-infix-ops.test.ts
Expand Up @@ -244,6 +244,9 @@ ruleTester.run('space-infix-ops', rule, {
{
code: 'type Baz<T> = T extends (bar: string) => void ? { x: string } : { y: string }',
},
{
code: 'type Foo<T extends (...args: any[]) => any> = T;',
},
{
code: `
interface Test {
Expand Down

0 comments on commit 4e13deb

Please sign in to comment.