Skip to content

Commit

Permalink
fix(ast-spec): add TSQualifiedName to TypeNode union (#5906)
Browse files Browse the repository at this point in the history
* fix(ast-spec): add TSQualifiedName to TypeNode union

* fix rule with missing type
  • Loading branch information
bradzacher committed Oct 31, 2022
1 parent 0520d53 commit 5c316c1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/ast-spec/src/unions/TypeNode.ts
Expand Up @@ -25,6 +25,7 @@ import type { TSOptionalType } from '../type/TSOptionalType/spec';
import type { TSPrivateKeyword } from '../type/TSPrivateKeyword/spec';
import type { TSProtectedKeyword } from '../type/TSProtectedKeyword/spec';
import type { TSPublicKeyword } from '../type/TSPublicKeyword/spec';
import type { TSQualifiedName } from '../type/TSQualifiedName/spec';
import type { TSReadonlyKeyword } from '../type/TSReadonlyKeyword/spec';
import type { TSRestType } from '../type/TSRestType/spec';
import type { TSStaticKeyword } from '../type/TSStaticKeyword/spec';
Expand Down Expand Up @@ -71,6 +72,7 @@ export type TypeNode =
| TSPrivateKeyword
| TSProtectedKeyword
| TSPublicKeyword
| TSQualifiedName
| TSReadonlyKeyword
| TSRestType
| TSStaticKeyword
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin/src/rules/sort-type-constituents.ts
Expand Up @@ -60,6 +60,7 @@ function getGroup(node: TSESTree.TypeNode): Group {
case AST_NODE_TYPES.TSIndexedAccessType:
case AST_NODE_TYPES.TSInferType:
case AST_NODE_TYPES.TSTypeReference:
case AST_NODE_TYPES.TSQualifiedName:
return Group.named;

case AST_NODE_TYPES.TSMappedType:
Expand Down
Expand Up @@ -60,6 +60,7 @@ function getGroup(node: TSESTree.TypeNode): Group {
case AST_NODE_TYPES.TSIndexedAccessType:
case AST_NODE_TYPES.TSInferType:
case AST_NODE_TYPES.TSTypeReference:
case AST_NODE_TYPES.TSQualifiedName:
return Group.named;

case AST_NODE_TYPES.TSMappedType:
Expand Down
Expand Up @@ -45,6 +45,8 @@ const valid = (operator: '|' | '&'): TSESLint.ValidTestCase<Options>[] => [
type T =
${operator} A
${operator} B
${operator} C.D
${operator} D.E
${operator} intrinsic
${operator} number[]
${operator} string[]
Expand Down Expand Up @@ -220,6 +222,8 @@ type T =
${operator} readonly number[]
${operator} string[]
${operator} number[]
${operator} D.E
${operator} C.D
${operator} B
${operator} A
${operator} undefined
Expand All @@ -229,7 +233,7 @@ type T =
`,
output: `
type T =
A ${operator} B ${operator} number[] ${operator} string[] ${operator} any ${operator} string ${operator} readonly number[] ${operator} readonly string[] ${operator} 'a' ${operator} 'b' ${operator} "a" ${operator} "b" ${operator} (() => string) ${operator} (() => void) ${operator} { a: string } ${operator} { b: string } ${operator} [1, 2, 3] ${operator} [1, 2, 4] ${operator} null ${operator} undefined;
A ${operator} B ${operator} C.D ${operator} D.E ${operator} number[] ${operator} string[] ${operator} any ${operator} string ${operator} readonly number[] ${operator} readonly string[] ${operator} 'a' ${operator} 'b' ${operator} "a" ${operator} "b" ${operator} (() => string) ${operator} (() => void) ${operator} { a: string } ${operator} { b: string } ${operator} [1, 2, 3] ${operator} [1, 2, 4] ${operator} null ${operator} undefined;
`,
errors: [
{
Expand Down
Expand Up @@ -45,6 +45,8 @@ const valid = (operator: '|' | '&'): TSESLint.ValidTestCase<Options>[] => [
type T =
${operator} A
${operator} B
${operator} C.D
${operator} D.E
${operator} intrinsic
${operator} number[]
${operator} string[]
Expand Down Expand Up @@ -220,6 +222,8 @@ type T =
${operator} readonly number[]
${operator} string[]
${operator} number[]
${operator} D.E
${operator} C.D
${operator} B
${operator} A
${operator} undefined
Expand All @@ -229,7 +233,7 @@ type T =
`,
output: `
type T =
A ${operator} B ${operator} number[] ${operator} string[] ${operator} any ${operator} string ${operator} readonly number[] ${operator} readonly string[] ${operator} 'a' ${operator} 'b' ${operator} "a" ${operator} "b" ${operator} (() => string) ${operator} (() => void) ${operator} { a: string } ${operator} { b: string } ${operator} [1, 2, 3] ${operator} [1, 2, 4] ${operator} null ${operator} undefined;
A ${operator} B ${operator} C.D ${operator} D.E ${operator} number[] ${operator} string[] ${operator} any ${operator} string ${operator} readonly number[] ${operator} readonly string[] ${operator} 'a' ${operator} 'b' ${operator} "a" ${operator} "b" ${operator} (() => string) ${operator} (() => void) ${operator} { a: string } ${operator} { b: string } ${operator} [1, 2, 3] ${operator} [1, 2, 4] ${operator} null ${operator} undefined;
`,
errors: [
{
Expand Down

0 comments on commit 5c316c1

Please sign in to comment.