【问题标题】:How to add custom formatting in prettier (or es-lint)如何在更漂亮(或 eslint)中添加自定义格式
【发布时间】:2020-06-11 09:27:40
【问题描述】:

我的 React JS 项目中有一个脚本,允许重新排序三个特定类别的导入:

  1. 从依赖库导入
  2. 从内部组件导入
  3. 从样式文件导入

一切正常,使用命令npm run order-imports

现在,我有兴趣直接在 VS Code 中运行此脚本,例如,当我编写代码时,我想做 Crt+S 并运行此脚本来重新排序我的导入。

提前感谢您的建议。

【问题讨论】:

    标签: visual-studio-code eslint prettier


    【解决方案1】:

    在您的 settings.json 中,对于您的工作区或 vscode 全局,

    添加这个

    
        "editor.codeActionsOnSave": {
            "source.organizeImports": true, // This will organize all your imports 
            "source.fixAll.eslint": true // if  you want to fix other fixable inting errors
         },
    
    

    【讨论】:

    • 感谢您提供的信息,这不是我想要的。
    猜你喜欢
    • 2021-08-31
    • 2020-10-19
    • 2021-06-02
    • 2021-04-08
    • 2021-04-06
    • 2020-02-13
    • 2019-01-23
    • 2021-11-21
    • 2018-05-13
    相关资源
    最近更新 更多