ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Baidu FE Code Style

by leeight ALL

Baidu FE Code Style Sublime(2,3) Plugin

Details

  • 0.0.2
  • github.​com
  • github.​com
  • 10 years ago
  • 57 minutes ago
  • 10 years ago

Installs

  • Total 1K
  • Win 736
  • Mac 371
  • Linux 78
Oct 24 Oct 23 Oct 22 Oct 21 Oct 20 Oct 19 Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7 Oct 6 Oct 5 Oct 4 Oct 3 Oct 2 Oct 1 Sep 30 Sep 29 Sep 28 Sep 27 Sep 26 Sep 25 Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10
Windows 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 2 0 0 0 0 0 0 0
Mac 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

Baidu-FE-Code-Style

Baidu FE Code Style 是一个基于fecs开发的 Sublime Text 2/3 和 WebStorm 插件,目的是方便的验证所写的代码是否符合 百度前端编码规范 的要求

Sublime Text 2/3

安装

手工安装

  1. git clone https://github.com/leeight/Baidu-FE-Code-Style.git
  2. 把 'Baidu FE Code Style' 目录放到
    1. OS X: ~/Library/Application Support/Sublime Text 2/Packages
    2. Windows: %APPDATA%\Sublime Text 2\Packages
    3. Linux: ~/.config/sublime-text-2/Packages

通过Package Control安装

输入Baidu FE Code Style来进行查询,查询之后安装即可

配置

安装完毕之后,因为 Sublime 无法读取系统的PATH环境变量,所以初次使用需要配置一下相关的路径:

fecs-config.png

主要配置的内容如下(按照自己系统上的路径填写即可):

{
  "env": {
    "fecs_bin": "/usr/local/bin/fecs",
    "node_bin": "/usr/local/bin/node"
  }
}

使用

当打开一个js文件开始编辑,保存之后会自动调用fecs对当前的文件进行验证,如果有 warning 的话,会显示在左侧:

fecs-show.png

点击圆点之后,具体的 warning 信息会显示在底部的状态栏,如果错误信息太多,状态栏显示不全的话,可以通过Ctrl + ~调用 Sublime Text 的 Console,里面有更详细的信息。

WebStorm

安装

WebStorm默认集成了jscs的插件,我们只需要修改一下配置即可使用,首先需要通过npm i -g fecs来确保系统中已经安装了fecs,然后修改jscs的配置:

webstorm-config.png

主要是修改JSCS Package的路径。另外Configuration fileCode style preset可以随便选择,我们是用不到的(直接忽略了)

使用

配置之后就可以直接使用了,保存之后就会自动验证,效果如下:

webstorm-result.png