How to order imports with tslint's import-ordering rule

后端 未结 3 832
情歌与酒
情歌与酒 2021-02-05 00:07

On my project tslint\'s \"import-ordering\" rule is used

import CopyLensModal from \'./CopyLensModal\';
import FetchStatus from \'../../../../../state/generic/mo         


        
3条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-05 01:03

    This error also happens if there is not empty new line added as separation between groups of imports.

    import * as fs from 'fs';
    import * as os from 'os';
    
    import * as bar from './bar';
    import * as foo from './foo';
    

    Also notice if the error says like this:

    ***(5,1): Import sources within a group must be alphabetized.***
    

    This means in the specified file go to line #5 and press enter to add a new empty line there as separator.

    I did that and this resolved my problem. For more reference about this issue review this page

提交回复
热议问题