@fimbul/wotan
Advanced tools
Comparing version 0.11.0-dev.20180610 to 0.11.0-dev.20180611
{ | ||
"name": "@fimbul/wotan", | ||
"version": "0.11.0-dev.20180610", | ||
"version": "0.11.0-dev.20180611", | ||
"description": "Pluggable TypeScript and JavaScript linter", | ||
@@ -5,0 +5,0 @@ "bin": "bin/main.js", |
@@ -36,2 +36,5 @@ import { Linter } from './linter'; | ||
} | ||
interface SourceFile { | ||
parseDiagnostics: ts.DiagnosticWithLocation[]; | ||
} | ||
} |
@@ -16,2 +16,4 @@ "use strict"; | ||
const project_host_1 = require("./project-host"); | ||
const debug = require("debug"); | ||
const log = debug('wotan:runner'); | ||
let Runner = class Runner { | ||
@@ -46,7 +48,8 @@ constructor(fs, configManager, linter, processorLoader, directories, logger) { | ||
let summary; | ||
if (options.fix) { | ||
const fix = shouldFix(sourceFile, options, originalName); | ||
if (fix) { | ||
summary = this.linter.lintAndFix(sourceFile, originalContent, effectiveConfig, (content, range) => { | ||
({ sourceFile, program } = processorHost.updateSourceFile(sourceFile, program, content, range)); | ||
return { program, file: sourceFile }; | ||
}, options.fix === true ? undefined : options.fix, program, mapped === undefined ? undefined : mapped.processor); | ||
}, fix === true ? undefined : fix, program, mapped === undefined ? undefined : mapped.processor); | ||
} | ||
@@ -107,8 +110,9 @@ else { | ||
let sourceFile = ts.createSourceFile(name, content, ts.ScriptTarget.ESNext, true); | ||
const fix = shouldFix(sourceFile, options, file); | ||
let summary; | ||
if (options.fix) { | ||
if (fix) { | ||
summary = this.linter.lintAndFix(sourceFile, originalContent, effectiveConfig, (newContent, range) => { | ||
sourceFile = ts.updateSourceFile(sourceFile, newContent, range); | ||
return { file: sourceFile }; | ||
}, options.fix === true ? undefined : options.fix, undefined, processor); | ||
}, fix === true ? undefined : fix, undefined, processor); | ||
} | ||
@@ -243,2 +247,12 @@ else { | ||
} | ||
function hasParseErrors(sourceFile) { | ||
return sourceFile.parseDiagnostics.length !== 0; | ||
} | ||
function shouldFix(sourceFile, options, originalName) { | ||
if (options.fix && hasParseErrors(sourceFile)) { | ||
log("Not fixing '%s' because of parse errors.", originalName); | ||
return false; | ||
} | ||
return options.fix; | ||
} | ||
function createParseConfigHost(host) { | ||
@@ -245,0 +259,0 @@ return { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
247292
3145