zoukankan      html  css  js  c++  java
  • sublime react jsx 格式化 插件 配置

     插件名是:

    SUBLIME JSFMT .

    github地址是:

    https://github.com/royriojas/esformatter-jsx/wiki/Usage-with-jsfmt

    设置Setting user:

    // add to your 
    {
      "autoformat": true,
      "extensions": [
        "js",
        "jsx",
        "sublime-settings"
      ],
      "options": {
        "plugins": [
          "esformatter-jsx",
        ],
        "jsx": {
          "formatJSX": true,
          // change these to your preferred values
          // refer to https://github.com/royriojas/esformatter-jsx#best-configuration for more options
          "attrsOnSameLineAsTag": false,
          "maxAttrsOnTag": 1,
          "firstAttributeOnSameLine": false,
          "alignWithFirstAttribute": true,
          "formatJSXExpressions": true
        }
      // other esformatter options
      }
    }

    默认设置是组件的属性如果换行,则会缩进至组件长度后,不是很美观,如下:

    修改 ~AppDataRoamingSublime Text 3Packagesjsfmt ode_modulesesformatter-jsxlibformat-jsx.js

    将原代码

    var alignWith = me.jsxOptions.alignWithFirstAttribute ? first.loc.start.column : node.loc.start.column + indentSize;

    修改为

    var attrLen = first.parent.name.name.length;
    var alignWith = me.jsxOptions.alignWithFirstAttribute ? (first.loc.start.column - attrLen) : node.loc.start.column - attrLen + indentSize;

    如图

  • 相关阅读:
    汇总博客-Alpha
    Beta冲刺总结
    用户调查报告
    Beta成果测试总结
    Beta 冲刺 (9/9)
    Beta 冲刺 (8/9)
    Beta 冲刺 (7/9)
    Beta 冲刺 (6/9)
    Beta 冲刺 (5/9)
    Beta 冲刺 (4/9)
  • 原文地址:https://www.cnblogs.com/ignacio/p/7520364.html
Copyright © 2011-2022 走看看