gulp-coffeelint
Advanced tools
Comparing version 0.1.2 to 0.2.0
62
index.js
@@ -1,2 +0,3 @@ | ||
var PluginError, coffeelint, coffeelintPlugin, configfinder, createPluginError, formatOutput, fs, stylish, through2; | ||
'use strict'; | ||
var Args, PluginError, coffeelint, coffeelintPlugin, configfinder, createPluginError, formatOutput, fs, isLiterate, params, stylish, through2; | ||
@@ -7,2 +8,4 @@ fs = require('fs'); | ||
Args = require('args-js/Args'); | ||
coffeelint = require('coffeelint'); | ||
@@ -16,2 +19,6 @@ | ||
isLiterate = function(file) { | ||
return /\.(litcoffee|coffee\.md)$/.test(file); | ||
}; | ||
createPluginError = function(message) { | ||
@@ -45,12 +52,26 @@ return new PluginError('gulp-coffeelint', message); | ||
coffeelintPlugin = function(opt, literate, rules) { | ||
var e; | ||
if (opt == null) { | ||
opt = null; | ||
params = [ | ||
{ | ||
optFile: Args.STRING | Args.Optional | ||
}, { | ||
opt: Args.OBJECT | Args.Optional | ||
}, { | ||
literate: Args.BOOL | Args.Optional | ||
}, { | ||
rules: Args.ARRAY | Args.Optional, | ||
_default: [] | ||
} | ||
if (literate == null) { | ||
literate = false; | ||
]; | ||
coffeelintPlugin = function() { | ||
var e, literate, opt, optFile, rules, _ref; | ||
try { | ||
_ref = Args(params, arguments), opt = _ref.opt, optFile = _ref.optFile, literate = _ref.literate, rules = _ref.rules; | ||
} catch (_error) { | ||
e = _error; | ||
throw createPluginError(e); | ||
} | ||
if (rules == null) { | ||
rules = []; | ||
if (Array.isArray(opt)) { | ||
rules = opt; | ||
opt = void 0; | ||
} | ||
@@ -63,5 +84,5 @@ rules.map(function(rule) { | ||
}); | ||
if (typeof opt === 'string') { | ||
if (toString.call(optFile) === '[object String]') { | ||
try { | ||
opt = JSON.parse(fs.readFileSync(opt).toString()); | ||
opt = JSON.parse(fs.readFileSync(optFile).toString()); | ||
} catch (_error) { | ||
@@ -73,3 +94,7 @@ e = _error; | ||
return through2.obj(function(file, enc, cb) { | ||
var output, results; | ||
var fileLiterate, fileOpt, output, results; | ||
fileOpt = opt; | ||
fileLiterate = literate; | ||
results = null; | ||
output = null; | ||
if (file.isNull()) { | ||
@@ -83,9 +108,10 @@ this.push(file); | ||
} | ||
if (!opt) { | ||
opt = configfinder.getConfig(file.path); | ||
if (fileOpt === void 0) { | ||
fileOpt = configfinder.getConfig(file.path); | ||
} | ||
results = null; | ||
output = null; | ||
results = coffeelint.lint(file.contents.toString(enc), opt, literate); | ||
output = formatOutput(results, opt, literate); | ||
if (fileLiterate === void 0) { | ||
fileLiterate = isLiterate(file.path); | ||
} | ||
results = coffeelint.lint(file.contents.toString(), fileOpt, fileLiterate); | ||
output = formatOutput(results, fileOpt, fileLiterate); | ||
file.coffeelint = output; | ||
@@ -92,0 +118,0 @@ this.push(file); |
{ | ||
"name": "gulp-coffeelint", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"description": "Lint your CoffeeScript using gulp and CoffeeLint", | ||
@@ -25,3 +25,4 @@ "keywords": [ | ||
"prepublish": "gulp coffee --require coffee-script", | ||
"test": "mocha ./test/*.coffee --require coffee-script --reporter spec && coffeelint gulpfile.coffee index.coffee test -f ./coffeelint.json" | ||
"test": "coffeelint gulpfile.coffee index.coffee test -f ./coffeelint.json && istanbul test _mocha --report lcovonly -- ./test/*.coffee --require coffee-script --reporter spec", | ||
"coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js" | ||
}, | ||
@@ -32,3 +33,4 @@ "dependencies": { | ||
"gulp-util": "~2.2.5", | ||
"through2": "~0.4.0" | ||
"through2": "~0.4.0", | ||
"args-js": "~0.8.0" | ||
}, | ||
@@ -38,7 +40,10 @@ "devDependencies": { | ||
"mocha": "~1.17.0", | ||
"should": "~2.1.0", | ||
"gulp": "~3.3.2", | ||
"gulp-coffee": "~1.2.2", | ||
"istanbul": "~0.2.3", | ||
"should": "~3.1.0", | ||
"sinon": "~1.7.3", | ||
"coveralls": "~2.6.1", | ||
"gulp": "~3.4.0", | ||
"gulp-coffee": "~1.3.0", | ||
"gulp-clean": "~0.2.2", | ||
"sinon": "~1.7.3" | ||
"conventional-changelog": "0.0.6" | ||
}, | ||
@@ -45,0 +50,0 @@ "engines": { |
@@ -1,5 +0,5 @@ | ||
# gulp-coffeelint [![Build Status][travis-image]][travis-url] [![NPM version][npm-image]][npm-url] | ||
# gulp-coffeelint [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![NPM version][npm-image]][npm-url] | ||
[![Dependency Status][depstat-image]][depstat-url] [![devDependency Status][devdepstat-image]][devdepstat-url] | ||
> [CoffeeLint](http://www.coffeelint.org/) plugin for [gulp](https://github.com/wearefractal/gulp) 3. | ||
> [CoffeeLint](http://www.coffeelint.org/) plugin for [gulp][gulp] 3. | ||
@@ -27,15 +27,21 @@ ## Usage | ||
## Options `coffeelint(opt, literate, rules)` | ||
## API | ||
### `coffeelint([optFile,] [opt,] [literate,] [rules])` | ||
All arguments are optional. By default `gulp-coffeelint` will walk up the directory tree looking for a `coffeelint.json` (per file, i.e. dirname) or a `package.json` that has a `coffeelintConfig` object ([as the cli does](http://www.coffeelint.org/#usage)). Also, `.litcoffee` and `.coffee.md` files will be treated as Literate CoffeeScript. | ||
### optFile | ||
Type: `String` | ||
Absolute path of a `json` file containing [options][coffeelint-options] for `coffeelint`. | ||
### opt | ||
Type: `String` or `Object` | ||
Default: `null` | ||
Type: `Object` | ||
By default it will walk up the directory tree looking for a `coffeelint.json` (per file, i.e. dirname) or a `package.json` that has a `coffeelintConfig` object ([as the cli does](http://www.coffeelint.org/#usage)). You may also pass in options you wish to send to `coffeelint` (see [http://www.coffeelint.org/#options](http://www.coffeelint.org/#options)) directly **or** you may enter the **absolute path** of a `.json` file containing such a configuration object. | ||
[Options][coffeelint-options] you wish to send to `coffeelint`. If `optFile` is given, this will be ignored. | ||
### literate | ||
Type: `Boolean` | ||
Default: `false` | ||
Are we dealing with literate CoffeeScript here? | ||
Are we dealing with Literate CoffeeScript? | ||
@@ -54,8 +60,11 @@ ### rules | ||
file.coffeelint.errorCount = 0; // number of errors returned by `coffeelint` | ||
file.coffeelint.warningCount = 0; // number of warnings returns by `coffeelint` | ||
file.coffeelint.warningCount = 0; // number of warnings returned by `coffeelint` | ||
file.coffeelint.results = []; // `coffeelint` results, see http://www.coffeelint.org/#api | ||
file.coffeelint.opt = {}; // The options you passed to `coffeelint` | ||
file.coffeelint.literate = false; // Again, this is your doing... | ||
file.coffeelint.opt = {}; // the options use by `coffeelint` | ||
file.coffeelint.literate = false; // you guessed it | ||
``` | ||
## Contributing | ||
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [gulp][gulp] and [npm-test](https://npmjs.org/doc/test.html). Plus, make sure to adhere to these [commit message conventions](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#heading=h.uyo6cb12dt6w). | ||
## License | ||
@@ -65,2 +74,5 @@ | ||
[gulp]: http://gulpjs.com/ | ||
[coffeelint-options]: http://www.coffeelint.org/#options | ||
[npm-url]: https://npmjs.org/package/gulp-coffeelint | ||
@@ -72,2 +84,5 @@ [npm-image]: https://badge.fury.io/js/gulp-coffeelint.png | ||
[coveralls-url]: https://coveralls.io/r/janraasch/gulp-coffeelint | ||
[coveralls-image]: https://coveralls.io/repos/janraasch/gulp-coffeelint/badge.png | ||
[depstat-url]: https://david-dm.org/janraasch/gulp-coffeelint | ||
@@ -74,0 +89,0 @@ [depstat-image]: https://david-dm.org/janraasch/gulp-coffeelint.png |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8046
117
89
5
10
+ Addedargs-js@~0.8.0
+ Addedargs-js@0.8.0(transitive)