de6ugger

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

  •  
  •   de6ugger · Aug 28, 2017 · 3861 views
    This topic created in 3180 days ago, the information mentioned may be changed or developed.
    import {App, App2} from './app.vue';

    被格式化了

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

    看来只能选中部分进行单独格式化了,心好累。
    7 replies    2017-08-29 16:51:56 +08:00
    de6ugger
        1
    de6ugger  
    OP
       Aug 28, 2017
    待会还需要配 ESLint, 用了 airbnb 的规则, 一看代码我要崩溃了。
    de6ugger
        2
    de6ugger  
    OP
       Aug 28, 2017
    `-- 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  
       Aug 28, 2017   ❤️ 1
    EditorConfig 不会帮你格式化代码 你是不是有其他的格式话插件
    把你的插件列一下看看
    de6ugger
        4
    de6ugger  
    OP
       Aug 28, 2017
    @lanceli 谢谢大佬。
    果然是其他插件引起的问题,用了 beautify 导致的。VS Code 插件好多,我都凌乱了。


    貌似 EditorConfig 会处理空格的问题,也算是格式化代码的一种吧?
    qq641016547
        5
    qq641016547  
       Aug 28, 2017   ❤️ 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  
       Aug 28, 2017
    ps: EditorConfig 插件会影响编辑器默认格式化插件的行为
    de6ugger
        7
    de6ugger  
    OP
       Aug 29, 2017
    @qq641016547 谢谢大佬
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5579 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 06:52 · PVG 14:52 · LAX 23:52 · JFK 02:52
    ♥ Do have faith in what you're doing.