Lint your CoffeeScript/CJSX using gulp and CoffeeLint
npm install gulp-coffeelint-cjsx> CoffeeLint plugin for [gulp][gulp] 3.
First, install gulp-coffeelint-cjsx as a development dependency:
``shell`
npm install --save-dev gulp-coffeelint-cjsx
Then, add it to your gulpfile.js:
`javascript
var gulp = require('gulp');
var coffeelint = require('gulp-coffeelint-cjsx');
gulp.task('lint', function () {
gulp.src('./src/*.coffee')
.pipe(coffeelint())
.pipe(coffeelint.reporter())
});
`
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). Also, .litcoffee and .coffee.md files will be treated as Literate CoffeeScript.$3
Type: StringAbsolute path of a
json file containing [options][coffeelint-options] for coffeelint.$3
Type: Object[Options][coffeelint-options] you wish to send to
coffeelint. If optFile is given, this will be ignored.$3
Type: BooleanAre we dealing with Literate CoffeeScript?
$3
Type: Array[Function]
Default: []Add custom rules to
coffeelint.$3
Type: Booleancoffeelint-cjsx instead of coffeelint?Results
Adds the following properties to the
file object:
`javascript
file.coffeelint.success = true; // if no errors were found, false otherwise
file.coffeelint.errorCount = 0; // number of errors returned 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 used by coffeelint
file.coffeelint.literate = false; // you guessed it
`Reporters
$3
Assuming you would like to make use of those pretty results we have after piping through coffeelint() there are some bundled reporters at your service.$3
Type: String
Default: 'default'
Possible Values: 'default', 'fail', 'failOnWarning'* The
'default' reporter uses coffeelint-stylish to output a pretty report to the console. See usage example above.* If you would like your stream to
emit an error (e.g. to fail the build on a CI server) when errors are found, use the 'fail' reporter.* If you want it to throw an error on both warnings and errors, use the
'failOnWarning' reporterThis example will log errors and warnings using the coffeelint-stylish reporter, then fail if
coffeelint was not a success.`
.pipe(coffeelint())
.pipe(coffeelint.reporter())
.pipe(coffeelint.reporter('fail'))
``[gulp]: http://gulpjs.com/
[coffeelint-options]: http://www.coffeelint.org/#options
[npm-url]: https://npmjs.org/package/gulp-coffeelint
[npm-image]: http://img.shields.io/npm/v/gulp-coffeelint.svg
[travis-url]: http://travis-ci.org/janraasch/gulp-coffeelint
[travis-image]: https://travis-ci.org/janraasch/gulp-coffeelint.svg?branch=master
[coveralls-url]: https://coveralls.io/r/janraasch/gulp-coffeelint
[coveralls-image]: https://img.shields.io/coveralls/janraasch/gulp-coffeelint.svg
[depstat-url]: https://david-dm.org/janraasch/gulp-coffeelint
[depstat-image]: https://david-dm.org/janraasch/gulp-coffeelint.svg
[devdepstat-url]: https://david-dm.org/janraasch/gulp-coffeelint#info=devDependencies
[devdepstat-image]: https://david-dm.org/janraasch/gulp-coffeelint/dev-status.svg