cilint
Commit lint for Git
Last updated 3 years ago by imweb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install cilint 
SYNC missed versions from official npm registry.

NPM version

CILint

CILint是一个团队开发代码检查工具,进行检查时只关注新增行.

  • 使用ESLint检查javascript的语法
  • 使用Git的Hook在团队中推行

Installation and Usage

可以本地安装和全局安装

本地安装

npm install cilint --save-dev

初始化配置:

./node_modules/.bin/cilint --init

初始化配置的工作包括:

  • 生成.cilintrc.js
  • 生成.eslintrc.js
  • .git/hooks注入pre-commit的钩子

之后你可以对任意文件或者目录运行CILint:

./node_modules/.bin/cilint yourfile.js

git commit.git/hooks/pre-commit将自动执行, 存在error时将阻止本次提交并提示错误

全局安装

如果你希望在多个项目中使用,我们推荐你使用全局安装:

npm install -g cilint

生成配置文件:

cilint --init

运行CILint:

cilint yourfile.js

团队规范执行

1、在package.json中声明CILint的依赖:

{
  "devDependencies": {
    "cilint": "*"
  }
}

2、在构建文件webpack.config.jsgulpfile.jsfis-conf.js中引入如下代码执行init:

// 等同于`cilint --init`
require('cilint').initializer({
    // override: true,
    // cilintrcUrl: 'https://raw.githubusercontent.com/feix760/cilint/master/conf/cilintrc.js',
    // eslintrcUrl: 'https://raw.githubusercontent.com/feix760/cilint/master/conf/eslintrc.js',
    // editorconfigUrl: 'https://raw.githubusercontent.com/feix760/cilint/master/conf/editorconfig',
});

Configuring

.cilintrc.js配置

  • stopCommit Boolean default true 存在error时是否阻止commit
  • ignore Array.<String> default [] 代码检查忽略列表

.eslintrc.js配置

参考http://eslint.org/docs/user-guide/configuring

API

cilint.initializer(options)

初始化执行函数

Arguments

  • options Object
  • options.override Boolean 可选 default false 是否覆盖.cilintrc.js,.eslintrc.js等文件
  • options.cilintrc Object 可选 cilintrc配置项
  • options.cilintrcUrl String 可选 从指定url拉取cilintrc配置项, 可以结合override = true使用
  • options.eslintrc Object 可选 eslintrc配置项
  • options.eslintrcUrl String 可选 从指定url拉取eslintrc配置项
  • options.editorconfigUrl String 可选 从指定url拉取editorconfig配置项

ESLint Rules

FAQ

CILint如何选择ESLint的?

CILint首先会以项目根目录require ESLint, 这有可能会require到项目下的node_modules/eslint或者全局的eslint, 如果没有将使用CILint/node_modules/ESLint

注意:

  • ESLint和它的插件必须在同级node_modules下, 例如如果使用了全局的ESLint所有插件也必须全局安装
  • 如果使用CILint下的ESLint部分插件并没有在CILint下

[CHANGELOG](CHANGELOG.md) [LICENSE](LICENSE)

Current Tags

  • 0.0.21                                ...           latest (3 years ago)

21 Versions

  • 0.0.21                                ...           3 years ago
  • 0.0.20                                ...           3 years ago
  • 0.0.19                                ...           3 years ago
  • 0.0.18                                ...           3 years ago
  • 0.0.17                                ...           3 years ago
  • 0.0.16                                ...           3 years ago
  • 0.0.15                                ...           3 years ago
  • 0.0.14                                ...           3 years ago
  • 0.0.13                                ...           3 years ago
  • 0.0.12                                ...           4 years ago
  • 0.0.11                                ...           4 years ago
  • 0.0.10                                ...           4 years ago
  • 0.0.9                                ...           4 years ago
  • 0.0.8                                ...           4 years ago
  • 0.0.7                                ...           4 years ago
  • 0.0.6                                ...           4 years ago
  • 0.0.5                                ...           4 years ago
  • 0.0.4                                ...           4 years ago
  • 0.0.3                                ...           4 years ago
  • 0.0.2                                ...           4 years ago
  • 0.0.1                                ...           4 years ago
Maintainers (2)
Downloads
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 2
Dependencies (15)
Dev Dependencies (4)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |