Skip to content

Commit

Permalink
Resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
joutvhu committed Dec 11, 2024
1 parent 9f38e42 commit 213ca7a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/utils/get-sorted-nodes-by-import-order.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { clone } from 'lodash';

import { THIRD_PARTY_MODULES_SPECIAL_WORD, newLineNode } from '../constants';
import { THIRD_PARTY_MODULES_SPECIAL_WORD, newLineNode, SEPARATOR_SPECIAL_WORD } from '../constants';
import { naturalSort } from '../natural-sort';
import { GetSortedNodes, ImportGroups, ImportOrLine } from '../types';
import { getImportNodesMatchedGroup } from './get-import-nodes-matched-group';
Expand Down Expand Up @@ -40,7 +40,7 @@ export const getSortedNodesByImportOrder: GetSortedNodes = (nodes, options) => {
);

const importOrderWithOutThirdPartyPlaceholder = importOrder.filter(
(group) => group !== THIRD_PARTY_MODULES_SPECIAL_WORD,
(group) => group !== THIRD_PARTY_MODULES_SPECIAL_WORD && group !== SEPARATOR_SPECIAL_WORD,
);

for (const node of originalNodes) {
Expand All @@ -52,6 +52,16 @@ export const getSortedNodesByImportOrder: GetSortedNodes = (nodes, options) => {
}

for (const group of importOrder) {
if (group === SEPARATOR_SPECIAL_WORD) {
if (
finalNodes.length !== 0 &&
finalNodes[finalNodes.length - 1] !== newLineNode
) {
finalNodes.push(newLineNode);
}
continue;
}

const groupNodes = importOrderGroups[group];

if (groupNodes.length === 0) continue;
Expand Down

0 comments on commit 213ca7a

Please sign in to comment.