Skip to content

Commit

Permalink
fix: fix export and import kind default value
Browse files Browse the repository at this point in the history
  • Loading branch information
azat-io committed Jul 22, 2024
1 parent 2e08f03 commit a0208ac
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
20 changes: 14 additions & 6 deletions rules/sort-named-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,20 @@ export default createEslintRule<Options, MESSAGE_ID>({

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 =
Expand Down
20 changes: 13 additions & 7 deletions rules/sort-named-imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,27 @@ export default createEslintRule<Options, MESSAGE_ID>({
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,
}
})

Expand Down

0 comments on commit a0208ac

Please sign in to comment.