V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
de6ugger
V2EX  ›  Visual Studio Code

用了 EditorConfig for Visual Studio Code,格式化文件时, import {App, App2} from './app.vue'; 这样带{}的语句,都被格式化了,这个应该怎么破?

  •  
  •   de6ugger · 2017-08-28 11:14:23 +08:00 · 2915 次点击
    这是一个创建于 2405 天前的主题,其中的信息可能已经有所发展或是发生改变。
    import {App, App2} from './app.vue';

    被格式化了

    import {
    App,
    App2
    } from './app.vue';

    看来只能选中部分进行单独格式化了,心好累。
    7 条回复    2017-08-29 16:51:56 +08:00
    de6ugger
        1
    de6ugger  
    OP
       2017-08-28 11:16:27 +08:00
    待会还需要配 ESLint, 用了 airbnb 的规则, 一看代码我要崩溃了。
    de6ugger
        2
    de6ugger  
    OP
       2017-08-28 11:20:22 +08:00
    `-- UNMET PEER DEPENDENCY [email protected]

    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current:
    {"os":"win32","arch":"x64"})
    npm WARN [email protected] requires a peer of eslint-plugin-jsx-a11y@^5.1.1 but none was installed.
    npm ERR! code 1

    用 windows 搞前端开发的孩子上辈子都是折翼天使。
    lanceli
        3
    lanceli  
       2017-08-28 11:22:31 +08:00   ❤️ 1
    EditorConfig 不会帮你格式化代码 你是不是有其他的格式话插件
    把你的插件列一下看看
    de6ugger
        4
    de6ugger  
    OP
       2017-08-28 12:12:31 +08:00
    @lanceli 谢谢大佬。
    果然是其他插件引起的问题,用了 beautify 导致的。VS Code 插件好多,我都凌乱了。


    貌似 EditorConfig 会处理空格的问题,也算是格式化代码的一种吧?
    qq641016547
        5
    qq641016547  
       2017-08-28 14:24:34 +08:00   ❤️ 1
    https://marketplace.visualstudio.com/items?itemName=MadsKristensen.JavaScriptPrettier
    https://github.com/prettier/prettier
    https://atom.io/packages/prettier-atom
    以上参考,可根据 EditorConfig、.eslintrc.js 进行格式化,有优先级,一般来说可 EditorConfig 有配置的可覆盖.eslintrc.js

    我用 Atom

    atom 插件
    video: http://recordit.co/ZoLsrCfZIz
    gif: http://g.recordit.co/ZoLsrCfZIz.gif
    qq641016547
        6
    qq641016547  
       2017-08-28 14:25:35 +08:00
    ps: EditorConfig 插件会影响编辑器默认格式化插件的行为
    de6ugger
        7
    de6ugger  
    OP
       2017-08-29 16:51:56 +08:00
    @qq641016547 谢谢大佬
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2434 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 16:04 · PVG 00:04 · LAX 09:04 · JFK 12:04
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.