Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rogeriopvl/gulp-jsonlint
🔍 jsonlint plugin for Gulp
https://github.com/rogeriopvl/gulp-jsonlint
gulp gulp-plugin javascript jsonlint
Last synced: 3 months ago
JSON representation
🔍 jsonlint plugin for Gulp
- Host: GitHub
- URL: https://github.com/rogeriopvl/gulp-jsonlint
- Owner: rogeriopvl
- License: mit
- Created: 2013-12-26T21:38:57.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T17:14:20.000Z (about 2 years ago)
- Last Synced: 2024-09-30T13:06:26.194Z (4 months ago)
- Topics: gulp, gulp-plugin, javascript, jsonlint
- Language: JavaScript
- Homepage:
- Size: 269 KB
- Stars: 26
- Watchers: 2
- Forks: 3
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gulp-jsonlint [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][depstat-image]][depstat-url]
> jsonlint plugin for [gulp](http://gulpjs.com/)
## Usage
First, install `gulp-jsonlint` as a development dependency:
```shell
npm install --save-dev gulp-jsonlint
```Then, add it to your `gulpfile.js`:
```javascript
var jsonlint = require("gulp-jsonlint");gulp.src("./src/*.json")
.pipe(jsonlint())
.pipe(jsonlint.reporter());
```Using a custom reporter:
```javascript
var jsonlint = require('gulp-jsonlint');
var log = require('fancy-log');var myCustomReporter = function (file) {
log('File ' + file.path + ' is not valid JSON.');
};gulp.src('./src/*.json')
.pipe(jsonlint())
.pipe(jsonlint.reporter(myCustomReporter));
```## API
### jsonlint(options)
For now, `options` are not supported yet.
### jsonlint.reporter(customReporter)
#### customReporter(file)
Type: `function`
You can pass a custom reporter function. If ommited then the default reporter will be used.
The `customReporter` function will be called with the argument `file`.
##### file
Type: `object`
This argument has the attribute `jsonlint` wich is an object that contains a `success` boolean attribute. If it's false you also have a `message` attribute containing the jsonlint error message.
### jsonlint.failOnError()
Stop a task/stream if an jsonlint error has been reported for any file.
```javascript
// Cause the stream to stop(/fail) before copying an invalid JS file to the output directory
gulp.src('**/*.js')
.pipe(jsonlint())
.pipe(jsonlint.failOnError())
.pipe(gulp.dest('../output'));
```### jsonlint.failAfterError()
Stop a task/stream if an jsonlint error has been reported for any file, but wait for all of them to be processed first.
## License
[MIT License](http://en.wikipedia.org/wiki/MIT_License)
[npm-url]: https://npmjs.org/package/gulp-jsonlint
[npm-image]: https://badge.fury.io/js/gulp-jsonlint.svg[travis-url]: http://travis-ci.org/rogeriopvl/gulp-jsonlint
[travis-image]: https://secure.travis-ci.org/rogeriopvl/gulp-jsonlint.svg?branch=master[depstat-url]: https://david-dm.org/rogeriopvl/gulp-jsonlint
[depstat-image]: https://david-dm.org/rogeriopvl/gulp-jsonlint.svg