adametry / gulp-eslint

A Gulp plugin for identifying and reporting on patterns found in ECMAScript/JavaScript code.
MIT License
563 stars 118 forks source link

Cannot get eslint output to print to file #256

Closed jaydubb12 closed 3 years ago

jaydubb12 commented 3 years ago

Issue - User cannot get output to print to file for gulp-lint process

Documentation Reference It is observed in the documentation that a writeableStream is a valid configuration, but regrettably it does not denote or provide clarification on how to do this....and I have tried the solution below, along with others to no avail...so am seeking any insight / support that can be provided

Observations - other users had published guidance suggesting a stream similar to this, but when attempting this 2 things are observed....

  1. The IntelliJ IDE notes that the parameter "writable" should be updated to "writableStream"
  2. The build output generates the file, but the file is empty, therefore I am obviously missing something with respect to configuring / establishing the stream properly

Sample Code Block

'use strict';

const {src, task}          = require('gulp');
const eslint               = require('gulp-eslint');
const fs                     =require('fs');

task('lint', () => {
    return src(['**/*.js', '!**/node_modules/**', '!**/handlebars.runtime-v4.1.2.js', '!**/parsley.js', '!**/slick.js','!*SampleTests.js'])

                // Runs eslint
                .pipe(eslint())

                // Sets the format of the console
                .pipe(eslint.format('table',fs.createWriteStream('eslint-result.xml')))

                // To have the process exit with an error code (1) on lint error, return the stream and pipe to failAfterError last
                .pipe(eslint.failOnError()

                .pipe(eslint.results(results => {
                    // Called once for all ESLint results.
                    console.log(`Total Results: ${results.length}`);
                    console.log(`Total Warnings: ${results.warningCount}`);
                    console.log(`Total Errors: ${results.errorCount}`);
                }))
                )
});
jaydubb12 commented 3 years ago

Oddly, I ran a build again this morning, and the configuration worked. NO idea why it didnt work yesterday, but it worked today...closing as resolved