Ⅰ. 插件描述
Lint your CoffeeScript.Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'clutchski/coffeelint'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'clutchski/coffeelint'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'clutchski/coffeelint'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/clutchski/coffeelint
Ⅳ. 文档说明
CoffeeLint
CoffeeLint is a style checker that helps keep CoffeeScript code
clean and consistent.
For guides on installing, using and configuring CoffeeLint, head over
here.
To suggest a feature, report a bug, or general discussion, head over
here.
Team
Current:
Past:
Contributing
- New rules should be set to a
warnlevel. Developers will expect new changes to NOT break their existing workflow, so unless your change is extremely usefull, default towarn. Expect discussion if you choose to useerror. - Look at existing rules and test structures when deciding how to name your rule.
no_foo.coffeeis used for many tests designed to catch specific errors, whereasfoo.coffeeis used for tests that are designed to enforce formatting and syntax.
Steps
- Fork the repo locally.
- Run
npm installto get dependencies. - Create your rule in a single file as
src/rules/your_rule_here.coffee, using the existing
rules as a guide.
You may examine the AST and tokens using
http://asaayers.github.io/clfiddle/.
- Add your test file
my_test.coffeeto thetestdirectory. - Register your rule in
src/coffeelint.coffee. - Run your test using
npm run testrule test/your_test_here.coffee. - Run the whole tests suite using
npm test. - Check that your rule's documentation is generated properly (see _Updating documentation when
- a new rule_ below).
- Squash all commits into a single commit when done.
- Submit a pull request.
Updating documentation when adding a new rule
When adding a new rule, its documentation is specified by setting adescription property within its rule property:
module.exports = class NoComment
rule:
name: 'no_comment'
level: 'ignore'
message: 'No comment'
description: '''
Disallows any comment in the code
'''
tokens: ['#', '###']
lintToken : (token, tokenApi) ->
return {context: "Found '#{token[0]}'"}The description property is a string that can embed HTML code:
description: '''
Disallows any comment in the code. This code would not pass:
<pre>
<code>### Some code with comments
foo = ->
# some other comments
bar()
</code>
</pre>
'''Coffeelint's website generates each
rule's documentation based on this description property.
When adding a new rule, it is suggested that you check that the documentation
for your new rule is generated correctly. In order to do that, you should
follow these steps:
- Checkout the branch that contains the changes adding the new rule.
- Run
npm run compile. - Checkout the
gh-pagesbranch:git checkout origin/gh-pages. - Run
cp lib/coffeelint.js js/coffeelint.js. - Regenerate the HTML documentation:
rake updatehtml. Note that you will
- need to install rake.
- Open the
index.htmlfile with your favorite browser and make sure that your
rule's documentation is generated properly.