Socket
Socket
Sign inDemoInstall

gulp-json-lint

Package Overview
Dependencies
58
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    gulp-json-lint

JSON linter Gulp plugin


Version published
Weekly downloads
515
increased by4.25%
Maintainers
1
Install size
1.09 MB
Created
Weekly downloads
 

Readme

Source

gulp-json-lint

JSON linter plugin for Gulp.

First install gulp-json-lint

npm install --save-dev gulp-json-lint

Usage:

var jsonlint = require('gulp-json-lint');

gulp.task('jsonlint', function(){
      gulp.src('source.json')
        .pipe(jsonlint())
        .pipe(jsonlint.report('verbose'));
});

The output is added to file.jsonlint. You can output the errors by using reporters. There are two default reporters:

  • 'json' prints stringified JSON to console.log.
  • 'verbose' prints longer human-readable failures to console.log.

Reporters are executed only if there is an error.

You can use your own reporter by supplying a function.

/* Output is in the following form:
 * {
 *   "error": "Unknown Character 'a', expecting a string for key statement.",
 *   "line": 2,
 *   "character": 5
 * }
 */
var testReporter = function (lint, file) {
    console.log(file.path + ': ' + lint.error);
};

gulp.task('invalid', function(){
      gulp.src('invalid.json')
        .pipe(jsonlint())
        .pipe(jsonlint.report(testReporter));
});

gulp-json-lint only has one option, which specifies if comments are allowed. By default, they're not.

gulp.task('comments-valid', function(){
      gulp.src('comments.json')
        .pipe(jsonlint({
          comments: true
        }))
        .pipe(jsonlint.report('verbose'));
});

Development

Fork this repository, run npm install and send pull requests.

Keywords

FAQs

Last updated on 14 Feb 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc