-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Breaking] Remove importOrderCaseInsensitive option (#64)
Ref #22 This removes the `importOrderGroupNamespaceSpecifiers` option in an effort to simplify the plugin and make it easier to understand and set up. There's no replacement currently, but if we hear from lots of folks who really want this, I think we could re-implement it using a special term in `importOrder`. I haven't done that here, as I would prefer to keep it simple.
- Loading branch information
Showing
14 changed files
with
6 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,7 @@ | ||
import { Import, ImportDeclaration } from '@babel/types'; | ||
import { ImportDeclaration } from '@babel/types'; | ||
|
||
import { naturalSort } from '../natural-sort'; | ||
import { PrettierOptions } from '../types'; | ||
|
||
export const getSortedNodesGroup = ( | ||
imports: ImportDeclaration[], | ||
options: Pick<PrettierOptions, 'importOrderGroupNamespaceSpecifiers'>, | ||
) => { | ||
return imports.sort((a, b) => { | ||
if (options.importOrderGroupNamespaceSpecifiers) { | ||
const diff = namespaceSpecifierSort(a, b); | ||
if (diff !== 0) return diff; | ||
} | ||
|
||
return naturalSort(a.source.value, b.source.value); | ||
}); | ||
export const getSortedNodesGroup = (imports: ImportDeclaration[]) => { | ||
return imports.sort((a, b) => naturalSort(a.source.value, b.source.value)); | ||
}; | ||
|
||
function namespaceSpecifierSort(a: ImportDeclaration, b: ImportDeclaration) { | ||
const aFirstSpecifier = a.specifiers.find( | ||
(s) => s.type === 'ImportNamespaceSpecifier', | ||
) | ||
? 1 | ||
: 0; | ||
const bFirstSpecifier = b.specifiers.find( | ||
(s) => s.type === 'ImportNamespaceSpecifier', | ||
) | ||
? 1 | ||
: 0; | ||
return bFirstSpecifier - aFirstSpecifier; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters