• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

karimsa/gulp-jslint: JSLint for gulp.js.

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

karimsa/gulp-jslint

开源软件地址(OpenSource Url):

https://github.com/karimsa/gulp-jslint

开源编程语言(OpenSource Language):

JavaScript 100.0%

开源软件介绍(OpenSource Introduction):

gulp-jslint Build Status View on NPM code climate code coverage

It's JSLint for Gulp.js.

NPM

Supports node >= 0.10.x.

Table of Contents

Installation

Simply install with npm by running npm install gulp-jslint.

Usage

var gulp = require('gulp');
var jslint = require('gulp-jslint');

gulp.task('default', function () {
    return gulp.src(['source.js'])
            .pipe(jslint({ /* this object represents the JSLint directives being passed down */ }))
            .pipe(jslint.reporter( 'my-reporter' ));
});

If you would like to specify a custom jslint edition to use, set the property 'edition' in your directives object. These versions should follow what the package node-jslint expects or this property can be set to a pre-loaded jslint function.

Directives

All directives being passed to the jslint() function are standard JSLint directives (for a list of directives, see the official JSLint docs).

However, to supply a list of global variables for your code, use the directive 'predef' or 'global' like so ('global' is an alias of 'predef' but 'predef' will be prefered since it is the official JSLint standard):

gulp.task('default', function () {
    return gulp.src(['source.js'])
            .pipe(jslint({
                predef: [ 'a_global' ],
                global: [ 'a_global' ]
            }));
});

Please see gulpfile.js for a more extensive sample gulpfile.

Reporters

By default, two reporters are provided by gulp-jslint. The first is the default reporter (appropriately named 'default') and the second report is the popular 'jshint-stylish' (named 'stylish').

To use either of these reporters, provide the name of the reporter followed by whatever arguments they expect to the function jslint.reporter().

For example:

gulp.task('default', function () {
    return gulp.src(['source.js'])
            .pipe(jslint())
            .pipe(jslint.reporter('default', errorsOnly))
            .pipe(jslint.reporter('stylish', options));
});

It's probably a good idea to use something like path.basename() on the file property to avoid lots of garbage in the command-line (i.e. path.basename('/path/to/index.js') === 'index.js').

Custom Reporters

Custom reporters should be either be synchronous or streams. Either way, the reporter will receive a results object and can output its report onto the console/logfile the way it wishes.

The results object will contain the following properties:

  • filename: the absolute path to the file being linted.
  • success: a boolean value representing whether the linting passed.
  • errors: an array of JSLint errors. Each element will contain the properties:
    • name: the string 'JSLintError'.
    • column: the column number of the error.
    • line: the line number of the error.
    • code: a code relating to the error.
    • message: a message describing the error.

License

Licensed under MIT license.

Copyright © 2017 Karim Alibhai.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap