# gulp-jsonlint

> A jsonlint plugin for Gulp

Latest version **1.3.2** (published 2020-04-06) · 0 weekly downloads

## Install

```sh
npm install gulp-jsonlint
pnpm add gulp-jsonlint
yarn add gulp-jsonlint
bun add gulp-jsonlint
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.2 |
| Published | 2020-04-06 |
| First published | 2013-12-26 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 4 |
| Dependencies | 6 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 26 |
| Author | Rogério Vicente |
| Maintainers | rogeriopvl |
| Keywords | gulpplugin, jsonlint, json, lint |

## Links

- npm: https://www.npmjs.com/package/gulp-jsonlint
- Repository: https://github.com/rogeriopvl/gulp-jsonlint
- Issues: https://github.com/rogeriopvl/gulp-jsonlint/issues
- npm.io page: https://npm.io/package/gulp-jsonlint

## Dependencies (6)

- [jsonlint](https://npm.io/package/jsonlint.md) 1.6.3
- [through2](https://npm.io/package/through2.md) ^3.0.1
- [fancy-log](https://npm.io/package/fancy-log.md) ^1.3.3
- [map-stream](https://npm.io/package/map-stream.md) 0.0.7
- [ansi-colors](https://npm.io/package/ansi-colors.md) ^4.1.1
- [plugin-error](https://npm.io/package/plugin-error.md) 1.0.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.3.2 (latest) — 2020-04-06
- 1.3.1 — 2019-08-06
- 1.3.0 — 2019-02-22
- 1.2.2 — 2018-08-30
- 1.2.1 — 2017-12-30
- 1.2.0 — 2016-12-20
- 1.1.2 — 2016-02-16
- 1.1.1 — 2015-09-27
- 1.1.0 — 2015-06-03
- 1.0.2 — 2015-01-14
- 1.0.1 — 2014-10-24
- 1.0.0 — 2014-10-22
- 0.1.0 — 2014-08-23
- 0.0.3 — 2013-12-27
- 0.0.2 — 2013-12-27
- … 1 more at https://npm.io/package/gulp-jsonlint/versions

## 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

---
_Source: https://npm.io/package/gulp-jsonlint · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
