Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

缩进工具的一些建议 #4

Open
guileen opened this issue Apr 30, 2012 · 1 comment
Open

缩进工具的一些建议 #4

guileen opened this issue Apr 30, 2012 · 1 comment

Comments

@guileen
Copy link
Member

guileen commented Apr 30, 2012

作为一个vimer, 曾经一度使用google closure lint 的 fixjsstyle工具修复代码风格问题, 但在某些nodejs 异化风格上出现了问题, 就没再使用过了.

有几个js缩进问题, 困扰我许久. 虽然风格略显怪异, 但也是有不少使用者的, 以下是我的一些建议

  • 命令行工具
  • 工具需要用实际项目代码验证
  • 工具应提供一些选项, 如是缩进几个空格, 是否使用前置操作符, 大括号位置, 对齐风格等

一些怪异风格的需求

  • 操作符前置
var foo = foo
  , bar = bar

foo + bar 
  + bar
  + bar

foo.bar
  .bar
  .bar

{
    foo: foo
  , bar: bar
  , [{
        foo: foo
      , bar: bar
    }]
}
  • 对齐

虽然vim有插件做对齐的事情, 但若是配合fixstyle工具的话, 那这些对齐会被fixstyle工具重置掉, 所以所有风格的事情必须都由一个标准的fixstyle工具来完成, 才能解决

var a   = a
  , foo = foo
  , ba  = ba

{
    a   : a
  , foo : foo
  , ba  : ba
}
@michalliu
Copy link

试试jsflakes https://github.com/michalliu/jsflakes.vim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants