File tree 1 file changed +25
-3
lines changed
1 file changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -157,8 +157,12 @@ function isPlainImportModule(node) {
157
157
return node . type === 'ImportDeclaration' && node . specifiers != null && node . specifiers . length > 0
158
158
}
159
159
160
+ function isPlainImportEquals ( node ) {
161
+ return node . type === 'TSImportEqualsDeclaration' && node . moduleReference . expression
162
+ }
163
+
160
164
function canCrossNodeWhileReorder ( node ) {
161
- return isPlainRequireModule ( node ) || isPlainImportModule ( node )
165
+ return isPlainRequireModule ( node ) || isPlainImportModule ( node ) || isPlainImportEquals ( node )
162
166
}
163
167
164
168
function canReorderItems ( firstNode , secondNode ) {
@@ -247,10 +251,10 @@ function getSorter(ascending) {
247
251
return function importsSorter ( importA , importB ) {
248
252
let result
249
253
250
- if ( importA < importB ) {
254
+ if ( ( importA < importB ) || importB === null ) {
251
255
result = - 1
252
256
}
253
- else if ( importA > importB ) {
257
+ else if ( ( importA > importB ) || importA === null ) {
254
258
result = 1
255
259
}
256
260
else {
@@ -603,6 +607,24 @@ module.exports = {
603
607
)
604
608
}
605
609
} ,
610
+ TSImportEqualsDeclaration : function handleImports ( node ) {
611
+ let name
612
+ if ( node . moduleReference . type === 'TSExternalModuleReference' ) {
613
+ name = node . moduleReference . expression . value
614
+ }
615
+ else {
616
+ name = null
617
+ }
618
+ registerNode (
619
+ context ,
620
+ node ,
621
+ name ,
622
+ 'import' ,
623
+ ranks ,
624
+ imported ,
625
+ pathGroupsExcludedImportTypes
626
+ )
627
+ } ,
606
628
CallExpression : function handleRequires ( node ) {
607
629
if ( level !== 0 || ! isStaticRequire ( node ) || ! isInVariableDeclarator ( node . parent ) ) {
608
630
return
You can’t perform that action at this time.
0 commit comments