@fimbul/wotan
Advanced tools
Comparing version 0.13.0-dev.20180807 to 0.13.0
{ | ||
"name": "@fimbul/wotan", | ||
"version": "0.13.0-dev.20180807", | ||
"version": "0.13.0", | ||
"description": "Pluggable TypeScript and JavaScript linter", | ||
@@ -37,3 +37,3 @@ "bin": "bin/main.js", | ||
"@types/js-yaml": "^3.10.1", | ||
"@types/json5": "0.0.29", | ||
"@types/json5": "0.0.30", | ||
"@types/minimatch": "^3.0.1", | ||
@@ -45,2 +45,3 @@ "@types/mkdirp": "^0.5.2", | ||
"@types/semver": "^5.4.0", | ||
"@types/to-absolute-glob": "^2.0.0", | ||
"escape-string-regexp": "^1.0.5", | ||
@@ -50,4 +51,4 @@ "rimraf": "^2.6.2" | ||
"dependencies": { | ||
"@fimbul/mimir": "0.13.0-dev.20180803", | ||
"@fimbul/ymir": "0.13.0-dev.20180802", | ||
"@fimbul/mimir": "^0.13.0", | ||
"@fimbul/ymir": "^0.13.0", | ||
"bind-decorator": "^1.0.11", | ||
@@ -62,3 +63,3 @@ "chalk": "^2.3.0", | ||
"js-yaml": "^3.10.0", | ||
"json5": "^1.0.0", | ||
"json5": "^2.0.0", | ||
"minimatch": "^3.0.4", | ||
@@ -68,2 +69,3 @@ "reflect-metadata": "^0.1.12", | ||
"semver": "^5.4.1", | ||
"to-absolute-glob": "^2.0.2", | ||
"tslib": "^1.8.1", | ||
@@ -73,4 +75,4 @@ "tsutils": "^3.0.0" | ||
"peerDependencies": { | ||
"typescript": ">= 2.7.1 || >= 3.0.0-dev || >= 3.0.0-insiders || 3.0.0-rc || >= 3.1.0-dev" | ||
"typescript": ">= 2.8.1 || >= 3.0.0-dev || >= 3.0.0-insiders || 3.0.0-rc || >= 3.1.0-dev" | ||
} | ||
} |
@@ -37,3 +37,3 @@ # Wotan | ||
wotan -p <path/to/tsconfig.json> # lint the whole project | ||
wotan "src/**/*.ts" -e "**/*.d.ts" # lint all typescript files excluding declaration files | ||
wotan 'src/**/*.ts' -e '**/*.d.ts' # lint all typescript files excluding declaration files | ||
wotan --fix # lint the whole project and fix all fixable errors | ||
@@ -146,2 +146,4 @@ ``` | ||
Note that all file paths are relative to the current working directory. Therefore `**/*.ts` doesn't match `../foo.ts`. | ||
### Examples | ||
@@ -148,0 +150,0 @@ |
@@ -11,3 +11,3 @@ "use strict"; | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
if (argv.length === 1 && /^(')?(?:-v|version)\1$/.test(argv[0])) | ||
if (argv.length === 1 && /^(')?-(?:v|-version)\1$/.test(argv[0])) | ||
return console.log(require('../package.json').version); | ||
@@ -14,0 +14,0 @@ try { |
@@ -17,2 +17,3 @@ "use strict"; | ||
const debug = require("debug"); | ||
const resolveGlob = require("to-absolute-glob"); | ||
const log = debug('wotan:runner'); | ||
@@ -30,5 +31,11 @@ let Runner = class Runner { | ||
const config = options.config !== undefined ? this.configManager.loadLocalOrResolved(options.config) : undefined; | ||
const resolveOptions = { cwd: this.directories.getCurrentDirectory() }; | ||
const files = options.files.map(resolve); | ||
const exclude = options.exclude.map(resolve); | ||
if (options.project === undefined && options.files.length !== 0) | ||
return this.lintFiles(options, config); | ||
return this.lintProject(options, config); | ||
return this.lintFiles(Object.assign({}, options, { files, exclude }), config); | ||
return this.lintProject(Object.assign({}, options, { files, exclude }), config); | ||
function resolve(pattern) { | ||
return resolveGlob(pattern, resolveOptions); | ||
} | ||
} | ||
@@ -146,22 +153,13 @@ *lintProject(options, config) { | ||
const ex = exclude.map((p) => new minimatch_1.Minimatch(p, { dot: true })); | ||
const typeRoots = ts.getEffectiveTypeRoots(program.getCompilerOptions(), host); | ||
outer: for (const sourceFile of program.getSourceFiles()) { | ||
const typeRoots = ts.getEffectiveTypeRoots(program.getCompilerOptions(), host) || []; | ||
for (const sourceFile of program.getSourceFiles()) { | ||
const { fileName } = sourceFile; | ||
if (fileName.startsWith(libDirectory) || | ||
fileName.endsWith('/node_modules/tslib/tslib.d.ts')) | ||
fileName.endsWith('/node_modules/tslib/tslib.d.ts') || | ||
program.isSourceFileFromExternalLibrary(sourceFile) || | ||
!typeRoots.every((typeRoot) => path.relative(typeRoot, fileName).startsWith('..' + path.sep))) | ||
continue; | ||
if (program.isSourceFileFromExternalLibrary(sourceFile)) | ||
const originalName = host.getFileSystemFile(fileName); | ||
if (include.length !== 0 && !include.some((e) => e.match(originalName)) || ex.some((e) => e.match(originalName))) | ||
continue; | ||
if (typeRoots !== undefined) { | ||
for (const typeRoot of typeRoots) { | ||
const relative = path.relative(typeRoot, fileName); | ||
if (!relative.startsWith('..' + path.sep)) | ||
continue outer; | ||
} | ||
} | ||
const originalName = path.relative(cwd, host.getFileSystemFile(fileName)); | ||
if (include.length !== 0 && !include.some((e) => e.match(originalName))) | ||
continue; | ||
if (ex.some((e) => e.match(originalName))) | ||
continue; | ||
files.push(fileName); | ||
@@ -168,0 +166,0 @@ originalNames.push(originalName); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
249578
208
20
16
3151
+ Addedto-absolute-glob@^2.0.2
+ Added@fimbul/mimir@0.13.0(transitive)
+ Added@fimbul/ymir@0.13.0(transitive)
+ Addedis-absolute@1.0.0(transitive)
+ Addedis-relative@1.0.0(transitive)
+ Addedis-unc-path@1.0.0(transitive)
+ Addedis-windows@1.0.2(transitive)
+ Addedjson5@2.2.3(transitive)
+ Addedto-absolute-glob@2.0.2(transitive)
+ Addedunc-path-regex@0.1.2(transitive)
- Removed@fimbul/mimir@0.13.0-dev.20180803(transitive)
- Removed@fimbul/ymir@0.13.0-dev.20180802(transitive)
- Removedjson5@1.0.2(transitive)
- Removedminimist@1.2.8(transitive)
Updated@fimbul/mimir@^0.13.0
Updated@fimbul/ymir@^0.13.0
Updatedjson5@^2.0.0