如何使用Vim按字母顺序对JS es6导入进行排序

时间:2018-10-05 12:49:41

标签: vim eslint tslint

我将vim项目的IDE用作typescript

import { FlightInfo } from './FlightInfo'                                                                               
import { InfoBlockProps, InfoRowProps, INavigationFlightOfferDataProps } from './interfaces'                            
import { getDiscountData, formatDataByServicesType, selectAdministrationFee } from './functions'

此外,我使用ts-lint规则进行支票排序:

 ...
 ordered-imports": [                                                                                                
      true,                                                                                                             
      {                                                                                                                 
        "import-sources-order": "lowercase-first",                                                                      
        "named-imports-order": "lowercase-first"                                                                        
      }                                                                                                                 
    ],
 ...  

并得到错误:

ERROR: 11:1   ordered-imports  Import sources within a group must be alphabetized.
ERROR: 11:10  ordered-imports  Named imports must be alphabetized.
ERROR: 12:1   ordered-imports  Import sources within a group must be alphabetized.
ERROR: 12:10  ordered-imports  Named imports must be alphabetized.

我正在搜索解决此排序错误的解决方案或插件。

1 个答案:

答案 0 :(得分:0)

在这种情况下,对我来说,ts-lint --fix -c ./ts-congig.json my-file.ts命令非常有效。