@boll/core
Advanced tools
Comparing version 1.5.1 to 1.5.2
@@ -5,3 +5,18 @@ { | ||
{ | ||
"date": "Fri, 20 Nov 2020 22:00:01 GMT", | ||
"date": "Tue, 01 Dec 2020 22:03:54 GMT", | ||
"tag": "@boll/core_v1.5.2", | ||
"version": "1.5.2", | ||
"comments": { | ||
"patch": [ | ||
{ | ||
"comment": "Adding boll disable next line rule", | ||
"author": "vipati@microsoft.com", | ||
"commit": "6dae75cd502b8982086bf0a38fca8a87966817f2", | ||
"package": "@boll/core" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"date": "Fri, 20 Nov 2020 22:01:01 GMT", | ||
"tag": "@boll/core_v1.5.1", | ||
@@ -8,0 +23,0 @@ "version": "1.5.1", |
# Change Log - @boll/core | ||
This log was last generated on Fri, 20 Nov 2020 22:00:01 GMT and should not be manually modified. | ||
This log was last generated on Tue, 01 Dec 2020 22:03:54 GMT and should not be manually modified. | ||
<!-- Start content --> | ||
## 1.5.2 | ||
Tue, 01 Dec 2020 22:03:54 GMT | ||
### Patches | ||
- Adding boll disable next line rule (vipati@microsoft.com) | ||
## 1.5.1 | ||
Fri, 20 Nov 2020 22:00:01 GMT | ||
Fri, 20 Nov 2020 22:01:01 GMT | ||
@@ -11,0 +19,0 @@ ### Patches |
@@ -12,5 +12,7 @@ import ts from "typescript"; | ||
private _parsedIgnoreChecks; | ||
private _parsedIgnoreChecksByLine; | ||
private _ignoredChecks; | ||
private _sourceFileLoaded; | ||
private _sourceFile?; | ||
private _ignoredChecksByLine; | ||
constructor(packageRoot: BollDirectory, packageContext: Package, filename: BollFile, content: string); | ||
@@ -21,2 +23,3 @@ get source(): ts.SourceFile; | ||
get ignoredChecks(): string[]; | ||
get ignoredChecksByLine(): Map<number, string[]>; | ||
get relativeFilename(): string; | ||
@@ -23,0 +26,0 @@ shouldSkip(r: PackageRule): boolean; |
@@ -55,5 +55,7 @@ "use strict"; | ||
this._parsedIgnoreChecks = false; | ||
this._parsedIgnoreChecksByLine = false; | ||
this._ignoredChecks = []; | ||
this._sourceFileLoaded = false; | ||
this._sourceFile = undefined; | ||
this._ignoredChecksByLine = new Map(); | ||
} | ||
@@ -106,2 +108,30 @@ Object.defineProperty(FileContext.prototype, "source", { | ||
}); | ||
Object.defineProperty(FileContext.prototype, "ignoredChecksByLine", { | ||
get: function () { | ||
var _this = this; | ||
if (this._parsedIgnoreChecksByLine) | ||
return this._ignoredChecksByLine; | ||
this.source.forEachChild(function (n) { | ||
var _a; | ||
var lineNumber = _this.source.getLineAndCharacterOfPosition(n.pos).line; | ||
var trimmedNodeText = n.getFullText().trim(); | ||
var ignoredChecks = []; | ||
(_a = trimmedNodeText.match(/boll-disable-next-line.*/g)) === null || _a === void 0 ? void 0 : _a.forEach(function (line) { | ||
var capture = line.match(/boll-disable-next-line\s([\w,\s-]*)/); | ||
if (capture && capture.length > 0 && capture[1]) { | ||
capture[1] | ||
.split(",") | ||
.map(function (x) { return x.trim(); }) | ||
.forEach(function (rule) { return ignoredChecks.push(rule); }); | ||
} | ||
}); | ||
if (ignoredChecks.length > 0) | ||
_this._ignoredChecksByLine.set(lineNumber, ignoredChecks); | ||
}); | ||
this._parsedIgnoreChecksByLine = true; | ||
return this._ignoredChecksByLine; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(FileContext.prototype, "relativeFilename", { | ||
@@ -108,0 +138,0 @@ get: function () { |
@@ -110,1 +110,48 @@ "use strict"; | ||
}); }); | ||
exports.test("should keep track of a disabled next line rules in a FileContext", function () { return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, test_internal_1.inFixtureDir("standalone-source-files", __dirname, function (cwd) { return __awaiter(void 0, void 0, void 0, function () { | ||
var sut, expectedResult; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, file_context_1.getSourceFile(cwd, "simple-disable-next-line.ts", new package_1.Package({}, {}))]; | ||
case 1: | ||
sut = _a.sent(); | ||
expectedResult = new Map(); | ||
expectedResult.set(1, ["MadeUpCheckName"]); | ||
assert.deepStrictEqual(sut.ignoredChecksByLine, expectedResult); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); })]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
exports.test("should keep track of a disabled next line rules in a FileContext", function () { return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, test_internal_1.inFixtureDir("standalone-source-files", __dirname, function (cwd) { return __awaiter(void 0, void 0, void 0, function () { | ||
var sut, expectedResult; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, file_context_1.getSourceFile(cwd, "multiple-disable-next-line.ts", new package_1.Package({}, {}))]; | ||
case 1: | ||
sut = _a.sent(); | ||
expectedResult = new Map(); | ||
expectedResult.set(0, ["MadeUpCheckName", "AlsoMadeUpName"]); | ||
expectedResult.set(2, ["MadeUpCheckName"]); | ||
assert.deepStrictEqual(sut.ignoredChecksByLine, expectedResult); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); })]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); |
@@ -48,3 +48,3 @@ { | ||
}, | ||
"version": "1.5.1" | ||
"version": "1.5.2" | ||
} |
170308
3717