Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSHint Gulp to error window VS2015

How can I get the output from JSHint to show up in my Error List in Visual Studio 2015 when using Gulp, rather than just output to the Task Runner?

I've tried this package but that doesn't seem to do anything except format the Gulp output slightly differently.

This is my gulpfile.js:

gulp.task('default', function () {     gulp.src(["Scripts/**/*.js"])         .pipe(jshint(".jshintrc"))         .pipe(jshint.reporter("jshint-visual-studio")); }); 

Actual output (in Task Runner Window):

Actual output

Preferred output (in Error List):

Preferred output

Please Note: I'm using Visual Studio 2015, so Web Essentials is no longer an option for JSHint as the functionality has been removed.

like image 990
CodingIntrigue Avatar asked May 27 '15 07:05

CodingIntrigue


People also ask

How do I run Gulpfile in Visual Studio?

Run a Gulp Task in Visual Studio CodeType "Run Task" and select it, which will bring up a list of tasks configured in Gulp. Choose the Gulp Task you want to run! Most of your Gulp Tasks will probably be automated using gulp watch, but manual Gulp Tasks can easily be run within Visual Studio Code.

What is gulp Gulpfile?

Gulpfile explained A gulpfile is a file in your project directory titled gulpfile. js (or capitalized as Gulpfile. js , like Makefile), that automatically loads when you run the gulp command.


2 Answers

I managed to get an official word on this from Mads Kristensen in this conversation on Twitter:

Tweet

So in VS2015RC (and RTM too), there is no way to get messages to go to the output window. The task runner only outputs to the error window if the Gulp task returns a failure - but honestly, I haven't managed to get this working either.

He did also confirm that this kind of functionality will be coming post-RTM.

Thanks to Eonasdan for pointing this out!

like image 64
CodingIntrigue Avatar answered Oct 05 '22 09:10

CodingIntrigue


Source code of your package (jshint-visual-studio) just add errors to errors array and log it to console. The code can't do anything to change console output, you must do it by yourself.

You can use this plugin.

Once the plugin is installed, open the Task Runner Explorer from the View –> Other Windows –> Task Runner Explorer menu.

This window will show you all the tasks in the gulp file and allow you to bind those tasks to certain Visual Studio events. This way, we don’t need to remember to run the gulp tasks from the command line. The IDE can handle it for us.

What I like to do is bind the watch task to the Solution Load event and bind the scripts task to the Before Build event.

enter image description here

With these bindings, we can make sure that all.min.js is correctly generated when we build the application and also regenerated anytime I make changes to the js files.

The Task Runner Explorer also shows the output of any running tasks. Here you can see the output from the watch task, which is always running in the background in this configuration.

enter image description here

From this article.

like image 25
Pinal Avatar answered Oct 05 '22 09:10

Pinal