Coder Social home page Coder Social logo

Comments (12)

sindresorhus avatar sindresorhus commented on May 28, 2024

It was recently fixed in gulp. Please reinstall gulp globally and locally.

from gulp-jscs.

syamanaka avatar syamanaka commented on May 28, 2024

I'm running gulp 3.8.5

from gulp-jscs.

rikschennink avatar rikschennink commented on May 28, 2024

Now at 3.8.5, still not working, also updated node.

Commenting out / removing the this.push(file) statements fixes the issue, but as I'm not familiar with it's function I'm probably breaking something else.

from gulp-jscs.

jgrund avatar jgrund commented on May 28, 2024

I ran into this issue as well. The problem occurs when gulp-jscs is the last item in a stream, i.e. there is nothing to pipe to after that.

It hits the high water mark of 16 and just waits there.

Putting something, e.x. gulp-debug after gulp-jscs fixes the issue, although it obviously not an ideal fix.

from gulp-jscs.

dstroot avatar dstroot commented on May 28, 2024

Gahhh! I have been banging my head against the wall for days trying to figure this out - I think that somehow gulp-jscs ver 0.5.0 does not exhibit the behavior but 0.6.0 does. Need to test this out at home tonight.

from gulp-jscs.

dstroot avatar dstroot commented on May 28, 2024

OK - Using the latest gulp v3.8.6 and v0.6.0 of gulp-jscs I can verify that > 16 files still stops and never returns. This is definitely not fixed.

❯ gulp -v
[16:49:56] CLI version 3.8.6
[16:49:56] Local version 3.8.6

❯ node -v
v0.10.29

from gulp-jscs.

dstroot avatar dstroot commented on May 28, 2024

Test repo: https://github.com/dstroot/gulp-jscsTest

Environment:

gulp-jscsTest git/master  
❯ gulp -v
[17:42:22] CLI version 3.8.6
[17:42:22] Local version 3.8.6

gulp-jscsTest git/master  
❯ node -v
v0.10.29

Baseline:

If I have 16 or fewer files my gulpfile works great and gulp-jscs works and reports errors. In addition gulp.watch works and shows errors as I create them and removes the errors as I clean up the code. You can see this by opening any file and adding a comment with no space between the slashes and the comment:

//test, instead of
// test

If you fix it jscs is re-run and the error goes away. It looks like this:

gulp-jscsTest git/master  
❯ gulp
[17:29:27] Using gulpfile ~/Code/gulp-jscsTest/gulpfile.js
[17:29:27] Starting 'jscs'...
[17:29:27] Starting 'watch'...
[17:29:27] Finished 'watch' after 12 ms
[17:29:27] Finished 'jscs' after 325 ms
[17:29:27] Starting 'default'...
[17:29:27] Finished 'default' after 6.87 μs
[17:29:44] Starting 'jscs'...
[17:29:44] 'jscs' errored after 101 ms
[17:29:44] Error in plugin 'gulp-jscs'
Missing space after line comment at 01.js :
    13 |var passportConf  = require('../config/passport');
    14 |
    15 |//test
--------^
    16 |
    17 |/**
[17:29:52] Starting 'jscs'...
[17:29:52] Finished 'jscs' after 83 ms
^C% 

Greater than 16 files:

To test this copy file 17.js from files-staging to files. Run gulp - see that the jscs task never completes. We already know this is a problem… looks like this:

❯ gulp   
[17:44:16] Using gulpfile ~/Code/gulp-jscsTest/gulpfile.js
[17:44:16] Starting 'jscs'...
[17:44:16] Starting 'watch'...
[17:44:16] Finished 'watch' after 12 ms

Adding something to the stream after jscs:

‘jgrund’ commented that "Putting something, e.x. gulp-debug after gulp-jscs fixes the issue, although it obviously not an ideal fix.” This does indeed allow the task to complete. BUT jscs is not doing anything anymore - it is not reporting errors anymore! We can introduce the same error as we did above and we will see that it is not being picked up. So this is not a solution!

EDIT: if you don't use my "monkey business" to trap the errors then jscs will return the messages but it will crash gulp... which kind of defeats the purpose of my watch task.

HELP!

Background:

rvagg/through2#18

from gulp-jscs.

syamanaka avatar syamanaka commented on May 28, 2024

@dstroot I ended up doing this: .pipe(j).pipe(term()) where term looks like

return through2.obj(function(file, encoding, callback) {
  callback();
});

See through2.term rvagg/through2#9

from gulp-jscs.

dstroot avatar dstroot commented on May 28, 2024

@syamanaka - thanks! Not sure I fully understand but I'll look at your code. ;)

from gulp-jscs.

dstroot avatar dstroot commented on May 28, 2024

OK - Got it working due to @syamanaka's hint.

Why this is cool: jscs checks code style - it's not a linter. From my view a style checker should not blow up gulp, stopping my workflow. It should simply give me warning messages and keep on going so I can keep on coding...

Check it out:

'use strict';

var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var terminus = require("terminus");

/**
 * JSCS Task
 */

gulp.task('jscs', function () {
  // Monkey business to handle jscs errors without
  // stopping gulp, allowing gulp.watch to work
  // *and* with more than 16 files.  ;)
  var j = $.jscs();
  j.on('error', function (e) {
    $.util.log(e.message);
    j.end();
  });
  return gulp.src('files/*.js')
    .pipe(j)
    .pipe(terminus.devnull({ objectMode: true }));
});

/**
 * Default Task
 */

gulp.task('default', ['jscs'], function () {
  gulp.watch('files/*.js', ['jscs']);
});

from gulp-jscs.

dstroot avatar dstroot commented on May 28, 2024

Cleaner:

gulp.task('jscs', function () {
  return gulp.src(paths.lint)               // Read .js files
    .pipe($.jscs())                         // jscs .js files
    .on('error', function (e) {
      $.util.log(e.message);
      $.jscs().end();
    })
    .pipe(terminus.devnull({ objectMode: true }));
});

from gulp-jscs.

marcoslhc avatar marcoslhc commented on May 28, 2024

@dstroot In my environment, stoping on style errors is enforced. I think @sindresorhus is working (and wanting help) in a fail reporter a là gulp-jshint that makes the halting optional (#21).
the @syamanaka's solution worked like a charm thanks!.

from gulp-jscs.

Related Issues (20)

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.