Created
October 4, 2018 11:19
-
-
Save ialarmedalien/952a9d110563eae58e4d5d13a7dde1aa to your computer and use it in GitHub Desktop.
Revisions
-
ialarmedalien created this gist
Oct 4, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,56 @@ // output eslint results in TSV format module.exports = function ( results = [] ) { const sep = "\t" , severity = [ '', 'warning', 'error' ] , path = require( 'path' ) , eslint = require( 'eslint' ) , cwd = process.cwd() , header = function () { console.log( [ 'file', 'line', 'column', 'severity', 'fixable', 'code', 'description' ].join( sep ) ); } , lintfree = function () { console.log( 'All files lint free!' ); } , fixable = {} , linter = new eslint.Linter() ; let found = false , rules = linter.getRules() ; rules.forEach( ( val, key ) => { if ( val.meta.fixable ) { fixable[key] = true; } }); results.forEach( r => { if ( r.messages.length > 0 ) { if ( !found ) { header(); found = true; } const file = path.relative( cwd, r.filePath ); r.messages.forEach( m => { console.log( [ file , m.line , m.column , severity[ m.severity ] , m.ruleId && fixable.hasOwnProperty(m.ruleId) ? 'true' : 'false' , ( m.ruleId ? m.ruleId : m.message.indexOf('Parsing error') !== -1 ? 'parse-error' : '-' ) , m.message ].join( sep ) ); }); } }); if ( !found ) { lintfree(); } };