diff --git a/rules/sort-named-exports.ts b/rules/sort-named-exports.ts index 5d64b873..4d36a58d 100644 --- a/rules/sort-named-exports.ts +++ b/rules/sort-named-exports.ts @@ -82,12 +82,20 @@ export default createEslintRule({ let sourceCode = getSourceCode(context) - let nodes: SortingNode[] = node.specifiers.map(specifier => ({ - size: rangeToDiff(specifier.range), - name: specifier.local.name, - node: specifier, - group: specifier.exportKind, - })) + let nodes: SortingNode[] = node.specifiers.map(specifier => { + let group: undefined | 'value' | 'type' + if (specifier.exportKind === 'type') { + group = 'type' + } else { + group = 'value' + } + return { + size: rangeToDiff(specifier.range), + name: specifier.local.name, + node: specifier, + group, + } + }) let shouldGroupByKind = options.groupKind !== 'mixed' let groupKindOrder = diff --git a/rules/sort-named-imports.ts b/rules/sort-named-imports.ts index 92d5e4c9..1ac2ce76 100644 --- a/rules/sort-named-imports.ts +++ b/rules/sort-named-imports.ts @@ -93,21 +93,27 @@ export default createEslintRule({ let sourceCode = getSourceCode(context) let nodes: SortingNode[] = specifiers.map(specifier => { - let group = 'unknown' + let group: undefined | 'value' | 'type' let { name } = specifier.local - if (specifier.type === 'ImportSpecifier') { - if (options.ignoreAlias) { - ;({ name } = specifier.imported) - } - group = specifier.importKind + if (specifier.type === 'ImportSpecifier' && options.ignoreAlias) { + ;({ name } = specifier.imported) + } + + if ( + specifier.type === 'ImportSpecifier' && + specifier.importKind === 'type' + ) { + group = 'type' + } else { + group = 'value' } return { size: rangeToDiff(specifier.range), node: specifier, - name, group, + name, } })