@fimbul/wotan
Advanced tools
Comparing version 0.17.0-dev.20181217 to 0.17.0-dev.20181218
{ | ||
"name": "@fimbul/wotan", | ||
"version": "0.17.0-dev.20181217", | ||
"version": "0.17.0-dev.20181218", | ||
"description": "Pluggable TypeScript and JavaScript linter", | ||
@@ -47,4 +47,4 @@ "bin": "bin/main.js", | ||
"dependencies": { | ||
"@fimbul/mimir": "0.17.0-dev.20181217", | ||
"@fimbul/ymir": "0.17.0-dev.20181217", | ||
"@fimbul/mimir": "0.17.0-dev.20181218", | ||
"@fimbul/ymir": "0.17.0-dev.20181218", | ||
"bind-decorator": "^1.0.11", | ||
@@ -51,0 +51,0 @@ "chalk": "^2.3.0", |
@@ -42,2 +42,6 @@ # Wotan | ||
## Editor Integration | ||
For instructions how to integrate the linter into your editor, see the [documentation of the `@fimbul/mithotyn` package](https://github.com/fimbullinter/wotan/blob/master/packages/mimir/README.md). | ||
## Available Rules | ||
@@ -44,0 +48,0 @@ |
@@ -38,5 +38,2 @@ import { Linter } from './linter'; | ||
} | ||
interface SourceFile { | ||
parseDiagnostics: ts.DiagnosticWithLocation[]; | ||
} | ||
} |
@@ -201,28 +201,48 @@ "use strict"; | ||
for (const configFile of projects) { | ||
if (!utils_1.addUnique(seen, configFile)) | ||
if (configFile === undefined || !utils_1.addUnique(seen, typeof configFile === 'string' ? configFile : configFile.sourceFile.fileName)) | ||
continue; | ||
const config = ts.readConfigFile(configFile, (file) => host.readFile(file)); | ||
if (config.error !== undefined) { | ||
this.logger.warn(ts.formatDiagnostics([config.error], host)); | ||
config.config = {}; | ||
let commandLine; | ||
if (typeof configFile !== 'string') { | ||
({ commandLine } = configFile); | ||
} | ||
const parsed = ts.parseJsonConfigFileContent(config.config, utils_1.createParseConfigHost(host), path.dirname(configFile), { noEmit: true }, configFile); | ||
if (parsed.errors.length !== 0) { | ||
let { errors } = parsed; | ||
if (references && parsed.projectReferences !== undefined && parsed.projectReferences.length !== 0) | ||
else { | ||
const sourceFile = host.getSourceFile(configFile, ts.ScriptTarget.JSON); | ||
if (sourceFile === undefined) | ||
continue; | ||
commandLine = ts.parseJsonSourceFileConfigFileContent(sourceFile, utils_1.createParseConfigHost(host), path.dirname(configFile), { noEmit: true }, configFile); | ||
} | ||
if (commandLine.errors.length !== 0) { | ||
let { errors } = commandLine; | ||
if (commandLine.projectReferences !== undefined && commandLine.projectReferences.length !== 0) | ||
errors = errors.filter((e) => e.code !== 18002); | ||
if (errors.length !== 0) | ||
this.logger.warn(ts.formatDiagnostics(parsed.errors, host)); | ||
this.logger.warn(ts.formatDiagnostics(commandLine.errors, host)); | ||
} | ||
if (parsed.fileNames.length !== 0) { | ||
if (parsed.options.composite && !parsed.fileNames.some((file) => isFileIncluded(host.getFileSystemFile(file)))) { | ||
log("Project '%s' contains no file to lint", configFile); | ||
} | ||
else { | ||
if (commandLine.fileNames.length !== 0) { | ||
if (!commandLine.options.composite || commandLine.fileNames.some((file) => isFileIncluded(host.getFileSystemFile(file)))) { | ||
log("Using project '%s'", configFile); | ||
yield host.createProgram(parsed.fileNames, parsed.options, undefined, parsed.projectReferences); | ||
let program = host.createProgram(commandLine.fileNames, commandLine.options, undefined, commandLine.projectReferences); | ||
yield program; | ||
if (references) { | ||
const resolvedReferences = program.getResolvedProjectReferences === undefined | ||
? program.getProjectReferences() | ||
: program.getResolvedProjectReferences(); | ||
if (resolvedReferences !== undefined) { | ||
program = undefined; | ||
yield* this.createPrograms(resolvedReferences, host, seen, true, isFileIncluded); | ||
} | ||
} | ||
continue; | ||
} | ||
log("Project '%s' contains no file to lint", configFile); | ||
} | ||
if (references && parsed.projectReferences !== undefined) | ||
yield* this.createPrograms(parsed.projectReferences.map((ref) => this.checkConfigDirectory(ref.path)), host, seen, true, isFileIncluded); | ||
if (references) { | ||
if (typeof configFile !== 'string') { | ||
if (configFile.references !== undefined) | ||
yield* this.createPrograms(configFile.references, host, seen, true, isFileIncluded); | ||
} | ||
else if (commandLine.projectReferences !== undefined) { | ||
yield* this.createPrograms(commandLine.projectReferences.map((ref) => this.checkConfigDirectory(ref.path)), host, seen, true, isFileIncluded); | ||
} | ||
} | ||
} | ||
@@ -229,0 +249,0 @@ } |
@@ -42,3 +42,6 @@ "use strict"; | ||
if (this.typeRoots === undefined) | ||
this.typeRoots = ts.getEffectiveTypeRoots(this.options, this.host) || []; | ||
this.typeRoots = ts.getEffectiveTypeRoots(this.options, { | ||
directoryExists: (dir) => this.host.directoryExists(dir), | ||
getCurrentDirectory: () => this.program.getCurrentDirectory(), | ||
}) || []; | ||
return !this.typeRoots.every((typeRoot) => path.relative(typeRoot, fileName).startsWith('..' + path.sep)); | ||
@@ -45,0 +48,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
291202
109
3646
216
7
+ Added@fimbul/mimir@0.17.0-dev.20181218(transitive)
+ Added@fimbul/ymir@0.17.0-dev.20181218(transitive)
- Removed@fimbul/mimir@0.17.0-dev.20181217(transitive)
- Removed@fimbul/ymir@0.17.0-dev.20181217(transitive)