Skip to content

Commit 851bb90

Browse files
fix(eslint-plugin): [sort-type-union-intersection-members] Wrap the constructorType in parentheses (#4590)
Co-authored-by: Josh Goldberg <me@joshuakgoldberg.com>
1 parent 6afcaea commit 851bb90

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

‎packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ function getGroup(node: TSESTree.TypeNode): Group {
8585
}
8686

8787
function requiresParentheses(node: TSESTree.TypeNode): boolean {
88-
return node.type === AST_NODE_TYPES.TSFunctionType;
88+
return (
89+
node.type === AST_NODE_TYPES.TSFunctionType ||
90+
node.type === AST_NODE_TYPES.TSConstructorType
91+
);
8992
}
9093

9194
export type Options = [

‎packages/eslint-plugin/tests/rules/sort-type-union-intersection-members.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,15 @@ type T =
272272
},
273273
],
274274
},
275+
{
276+
code: `type Expected = (new (x: number) => boolean) ${operator} string;`,
277+
output: `type Expected = string ${operator} (new (x: number) => boolean);`,
278+
errors: [
279+
{
280+
messageId: 'notSortedNamed',
281+
},
282+
],
283+
},
275284
];
276285
};
277286

0 commit comments

Comments
 (0)