@fimbul/valtyr
Advanced tools
Comparing version
{ | ||
"name": "@fimbul/valtyr", | ||
"version": "0.21.0-dev.20190322", | ||
"version": "0.21.0-dev.20190328", | ||
"description": "Wotan plugin to behave almost like TSLint", | ||
@@ -33,3 +33,3 @@ "author": "Klaus Meinhardt", | ||
"peerDependencies": { | ||
"@fimbul/wotan": "0.21.0-dev.20190322", | ||
"@fimbul/wotan": "0.21.0-dev.20190328", | ||
"typescript": ">= 3.1.1 || >= 3.4.0-dev || >= 3.5.0-dev" | ||
@@ -36,0 +36,0 @@ }, |
@@ -8,2 +8,9 @@ "use strict"; | ||
const path = require("path"); | ||
/** | ||
* Number of .. until the containing node_modules. | ||
* __dirname -> src | ||
* .. -> project root | ||
* ../.. -> node_modules (or @scope) | ||
* ../../.. -> node_modules if @scoped package | ||
*/ | ||
const OFFSET_TO_NODE_MODULES = 3; | ||
@@ -26,4 +33,5 @@ let TslintConfigurationProvider = class TslintConfigurationProvider { | ||
if (result === undefined && !this.cache.has(fileName)) { | ||
result = TSLint.Configuration.findConfigurationPath(null, fileName); | ||
result = TSLint.Configuration.findConfigurationPath(null, fileName); // tslint:disable-line:no-null-keyword | ||
const { root } = path.parse(fileName); | ||
// prevent infinite loop when result is on different drive | ||
const configDirname = result === undefined || root !== path.parse(result).root ? root : path.dirname(result); | ||
@@ -30,0 +38,0 @@ this.cache.set(fileName, result); |
@@ -13,2 +13,3 @@ "use strict"; | ||
for (let match = re.exec(sourceFile.text); match !== null; match = re.exec(sourceFile.text)) { | ||
// not using `context.getCommentAtPosition` here is intentional, because it doesn't benefit from caching the converted AST | ||
const comment = tsutils_1.getCommentAtPosition(sourceFile, match.index); | ||
@@ -34,2 +35,3 @@ if (comment === undefined || comment.pos !== match.index) | ||
pos: lineStarts[line], | ||
// no need to switch back if there is no next line | ||
end: lineStarts.length === line + 1 ? undefined : lineStarts[line + 1], | ||
@@ -44,2 +46,3 @@ location: { pos: comment.pos, end: comment.end }, | ||
if (lineStarts.length === line) { | ||
// there is no next line, return an out-of-range switch that can be reported | ||
result.push({ | ||
@@ -57,2 +60,3 @@ rules, enable, | ||
pos: lineStarts[line], | ||
// no need to switch back if there is no next line | ||
end: lineStarts.length === line + 1 ? undefined : lineStarts[line + 1], | ||
@@ -93,3 +97,3 @@ location: { pos: comment.pos, end: comment.end }, | ||
pos = re.lastIndex; | ||
fixPos = match.index; | ||
fixPos = match.index; // fix always removes the preceeding comma | ||
} | ||
@@ -96,0 +100,0 @@ return result; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
43746
1.97%341
3.65%