Skip to content

Commit a0208ac

Browse files
committed
fix: fix export and import kind default value
1 parent 2e08f03 commit a0208ac

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

rules/sort-named-exports.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,20 @@ export default createEslintRule<Options, MESSAGE_ID>({
8282

8383
let sourceCode = getSourceCode(context)
8484

85-
let nodes: SortingNode[] = node.specifiers.map(specifier => ({
86-
size: rangeToDiff(specifier.range),
87-
name: specifier.local.name,
88-
node: specifier,
89-
group: specifier.exportKind,
90-
}))
85+
let nodes: SortingNode[] = node.specifiers.map(specifier => {
86+
let group: undefined | 'value' | 'type'
87+
if (specifier.exportKind === 'type') {
88+
group = 'type'
89+
} else {
90+
group = 'value'
91+
}
92+
return {
93+
size: rangeToDiff(specifier.range),
94+
name: specifier.local.name,
95+
node: specifier,
96+
group,
97+
}
98+
})
9199

92100
let shouldGroupByKind = options.groupKind !== 'mixed'
93101
let groupKindOrder =

rules/sort-named-imports.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,27 @@ export default createEslintRule<Options, MESSAGE_ID>({
9393
let sourceCode = getSourceCode(context)
9494

9595
let nodes: SortingNode[] = specifiers.map(specifier => {
96-
let group = 'unknown'
96+
let group: undefined | 'value' | 'type'
9797
let { name } = specifier.local
9898

99-
if (specifier.type === 'ImportSpecifier') {
100-
if (options.ignoreAlias) {
101-
;({ name } = specifier.imported)
102-
}
103-
group = specifier.importKind
99+
if (specifier.type === 'ImportSpecifier' && options.ignoreAlias) {
100+
;({ name } = specifier.imported)
101+
}
102+
103+
if (
104+
specifier.type === 'ImportSpecifier' &&
105+
specifier.importKind === 'type'
106+
) {
107+
group = 'type'
108+
} else {
109+
group = 'value'
104110
}
105111

106112
return {
107113
size: rangeToDiff(specifier.range),
108114
node: specifier,
109-
name,
110115
group,
116+
name,
111117
}
112118
})
113119

0 commit comments

Comments
 (0)