tslint-loader
Advanced tools
Comparing version
@@ -0,0 +0,0 @@ var Lint = require("tslint/lib/lint"); |
45
index.js
@@ -15,2 +15,3 @@ /* | ||
var rimraf = require("rimraf"); | ||
var objectAssign = require("object-assign"); | ||
@@ -54,8 +55,10 @@ | ||
if(this.options.tslint) { | ||
merge(options, this.options.tslint); | ||
objectAssign(options, this.options.tslint); | ||
} | ||
var bailEnabled = (this.options.bail === true); | ||
//Override options in tslint.json by those passed to the loader as a query string | ||
var query = loaderUtils.parseQuery(this.query); | ||
merge(options, query); | ||
objectAssign(options, query); | ||
@@ -66,6 +69,6 @@ var linter = new Linter(this.resourcePath, input, options); | ||
report(result, emitter, options.failOnHint, options.fileOutput); | ||
report(result, emitter, options.failOnHint, options.fileOutput, this.resourcePath, bailEnabled); | ||
} | ||
function report(result, emitter, failOnHint, fileOutputOpts) { | ||
function report(result, emitter, failOnHint, fileOutputOpts, filename, bailEnabled) { | ||
if(result.failureCount === 0) return; | ||
@@ -78,4 +81,8 @@ emitter(result.output); | ||
if(failOnHint) { | ||
throw new Error("Compilation failed due to tslint errors."); | ||
if(failOnHint) { | ||
var messages = ""; | ||
if (bailEnabled){ | ||
messages = "\n\n" + filename + "\n" + result.output; | ||
} | ||
throw new Error("Compilation failed due to tslint errors." + messages); | ||
} | ||
@@ -118,28 +125,2 @@ } | ||
/* Merges two (or more) objects, | ||
giving the last one precedence */ | ||
function merge(target, source) { | ||
if ( typeof target !== 'object' ) { | ||
target = {}; | ||
} | ||
for (var property in source) { | ||
if ( source.hasOwnProperty(property) ) { | ||
var sourceProperty = source[ property ]; | ||
if ( typeof sourceProperty === 'object' ) { | ||
target[ property ] = merge( target[ property ], sourceProperty ); | ||
continue; | ||
} | ||
target[ property ] = sourceProperty; | ||
} | ||
} | ||
for (var a = 2, l = arguments.length; a < l; a++) { | ||
merge(target, arguments[a]); | ||
} | ||
return target; | ||
} | ||
module.exports = function(input, map) { | ||
@@ -146,0 +127,0 @@ this.cacheable && this.cacheable(); |
{ | ||
"name": "tslint-loader", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "tslint loader for webpack", | ||
@@ -32,2 +32,3 @@ "main": "index.js", | ||
"mkdirp": "^0.5.1", | ||
"object-assign": "^4.0.1", | ||
"rimraf": "^2.4.4", | ||
@@ -34,0 +35,0 @@ "strip-json-comments": "^1.0.2" |
@@ -0,0 +0,0 @@ # tslint loader for webpack |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
7929
-7.65%6
20%126
-10.64%+ Added