From 1f54e1d0f9071d07207ef59461ce18c37a0c2f4a Mon Sep 17 00:00:00 2001 From: islandryu Date: Thu, 24 Feb 2022 17:32:57 +0900 Subject: [PATCH] fix(eslint-plugin): [sort-type-union-intersection-members] Wrap the constructorType in parentheses --- .../src/rules/sort-type-union-intersection-members.ts | 5 ++++- .../rules/sort-type-union-intersection-members.test.ts | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts b/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts index fcdaa00152de..fe7f698949c7 100644 --- a/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts +++ b/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts @@ -85,7 +85,10 @@ function getGroup(node: TSESTree.TypeNode): Group { } function requiresParentheses(node: TSESTree.TypeNode): boolean { - return node.type === AST_NODE_TYPES.TSFunctionType; + return ( + node.type === AST_NODE_TYPES.TSFunctionType || + node.type === AST_NODE_TYPES.TSConstructorType + ); } export type Options = [ diff --git a/packages/eslint-plugin/tests/rules/sort-type-union-intersection-members.test.ts b/packages/eslint-plugin/tests/rules/sort-type-union-intersection-members.test.ts index a5eeb2f2fa48..1d29a45ce610 100644 --- a/packages/eslint-plugin/tests/rules/sort-type-union-intersection-members.test.ts +++ b/packages/eslint-plugin/tests/rules/sort-type-union-intersection-members.test.ts @@ -272,6 +272,15 @@ type T = }, ], }, + { + code: `type Expected = (new (x: number) => boolean) ${operator} string;`, + output: `type Expected = string ${operator} (new (x: number) => boolean);`, + errors: [ + { + messageId: 'notSortedNamed', + }, + ], + }, ]; }; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy