GithubHelp home page GithubHelp logo

sindresorhus / gulp-jsvalidate Goto Github PK

View Code? Open in Web Editor NEW
23.0 6.0 4.0 27 KB

Validate JavaScript code and report possible syntax errors

License: MIT License

JavaScript 100.00%
gulp-plugin javascript nodejs validate-js

gulp-jsvalidate's Introduction

gulp-jsvalidate

Validate JavaScript code and report possible syntax errors

The earlier you find syntax errors, the earlier you can fix them.

Install

npm install --save-dev gulp-jsvalidate

Usage

import gulp from 'gulp';
import jsValidate from 'gulp-jsvalidate';

export default () => (
	gulp.src('app.js')
		.pipe(jsValidate())
);

API

gulpJsValidate(options?)

options

Type: object

module

Type: boolean
Default: true

Parse the JavaScript code as a ES2015 module instead of a script.

gulp-jsvalidate's People

Contributors

sindresorhus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gulp-jsvalidate's Issues

Show file path and/or filename?

Great plugin overall! I like that the line number from the invalid file is listed in the error.

However, is there anyway to also show the path and or name of the file that the validation failed on?

Shows @import statements as error

I was trying to use gulp-jsvalidate to find errors in my js files. Although, I found that when I use @import statements, it recognize that statement as error.

As soon as I comment out that statement it works fine.
May be I don't know some settings.
Can you please help me out on this.

Can't pipe jsvalidate with other plugins?

I've tried to do that:

module.exports = function() {

 return require('gulp').src( files )
  .pipe( require('gulp-jsvalidate')() )
  .pipe( require('gulp-jscs')() )
  .pipe( jshint('.jshintrc') )
  .pipe( jshint.reporter('jshint-stylish') 
}

but if jsvalidate finds an error, it breaks everything.

I was able to do that though:

module.exports = function() {

 return require('gulp').src( files )
  .pipe( require('gulp-jscs')() )
  .pipe( jshint('.jshintrc') )
  .pipe( jshint.reporter('jshint-stylish') 
}

And this is what I do now:

var files = ['app.js', 'lib.js']

module.exports = {

  jsvalidate: function() {
    return require('gulp').src( files )
      .pipe( require('gulp-jsvalidate')() )
  },

  jscs: function() {
    return require('gulp').src( files )
      .pipe( require('gulp-jscs')() )
  },

  jshint: function() {
    var jshint = require('gulp-jshint')

    return require('gulp').src( files )
      .pipe( jshint('.jshintrc') )
      .pipe( jshint.reporter('jshint-stylish') )
  }

}

with

gulp.task('jshint', require(path + 'validate').jshint)
gulp.task('jsvalidate', require(path + 'validate').jsvalidate)
gulp.task('jscs', require(path + 'validate').jscs)
gulp.task('validate', ['jsvalidate', 'jshint', 'jscs'])

Any idea how to make my first try work?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.