Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@boll/core

Package Overview
Dependencies
Maintainers
3
Versions
1225
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@boll/core - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

2

dist/boll-directory.d.ts

@@ -1,4 +0,4 @@

export declare type BollDirectory = string & {
export type BollDirectory = string & {
__id: "BollDirectory";
};
export declare function asBollDirectory(dirPath: string): BollDirectory;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -17,3 +21,3 @@ if (k2 === undefined) k2 = k;

var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);

@@ -20,0 +24,0 @@ return result;

@@ -1,4 +0,4 @@

export declare type BollFile = string & {
export type BollFile = string & {
__id: "BollFile";
};
export declare function asBollFile(filePath: string): BollFile;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -17,3 +21,3 @@ if (k2 === undefined) k2 = k;

var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);

@@ -20,0 +24,0 @@ return result;

@@ -1,4 +0,4 @@

export declare type BollLineNumber = number & {
export type BollLineNumber = number & {
__id: "BollLineNumber";
};
export declare function asBollLineNumber(lineNumber: number): BollLineNumber;

@@ -14,3 +14,3 @@ "use strict";

if (this.registrations[name]) {
throw new Error("Already know about config \"" + name + "\", cannot redefine.");
throw new Error("Already know about config \"".concat(name, "\", cannot redefine."));
}

@@ -21,3 +21,3 @@ this.registrations[name] = config;

if (!this.registrations[name]) {
throw new Error("Don't know about config \"" + name + "\".");
throw new Error("Don't know about config \"".concat(name, "\"."));
}

@@ -24,0 +24,0 @@ return this.registrations[name];

@@ -18,4 +18,8 @@ import { ConfigDefinition } from "./types";

resolvedConfiguration(): ConfigDefinition;
loadExternalPlugin(fullPkgName: string): any;
loadBollPlugin(plugin: string): any;
requirePlugin(fullPkgName: string): any;
bootstrapPackages(): void;
resolveParentConfiguration(baseConfigName: string | null | undefined): ConfigDefinition;
private mergeConfigurations;
}

@@ -28,3 +28,3 @@ "use strict";

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -50,8 +50,10 @@ if (y = 0, t) op = [op[0] & 2, t.value];

};
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};

@@ -70,3 +72,3 @@ Object.defineProperty(exports, "__esModule", { value: true });

this.configuration = {};
this.ignoredFiles = new ignore_1.IgnoredFiles({ root: git_utils_1.getRepoRoot() });
this.ignoredFiles = new ignore_1.IgnoredFiles({ root: (0, git_utils_1.getRepoRoot)() });
}

@@ -108,3 +110,3 @@ Config.prototype.buildSuite = function () {

return [2 /*return*/, (config.ruleSets || []).map(function (ruleSetConfig) {
var exclude = __spreadArrays((ruleSetConfig.exclude || []), (config.exclude || []), gitIgnoredFiles);
var exclude = __spreadArray(__spreadArray(__spreadArray([], (ruleSetConfig.exclude || []), true), (config.exclude || []), true), gitIgnoredFiles, true);
if (ruleSetConfig.name &&

@@ -114,3 +116,3 @@ config.configuration &&

config.configuration.ruleSets[ruleSetConfig.name]) {
exclude = __spreadArrays(exclude, (config.configuration.ruleSets[ruleSetConfig.name].exclude || []));
exclude = __spreadArray(__spreadArray([], exclude, true), (config.configuration.ruleSets[ruleSetConfig.name].exclude || []), true);
}

@@ -123,4 +125,8 @@ var glob = ruleSetConfig.fileLocator;

var options = __assign(__assign({}, check.options), optionsFromConfig);
var rule = _this.ruleRegistry.get(check.rule)(_this.logger, options);
return new rule_set_1.InstantiatedPackageRule(rule.name, check.severity || "error", rule);
var fn = _this.ruleRegistry.get(check.rule);
if (typeof fn === "function") {
var rule = fn(_this.logger, options);
return new rule_set_1.InstantiatedPackageRule(rule.name, check.severity || "error", rule);
}
return new rule_set_1.InstantiatedPackageRule(fn.name, check.severity || "error", fn, options);
});

@@ -130,4 +136,8 @@ var metaChecks = ((ruleSetConfig.checks && ruleSetConfig.checks.meta) || []).map(function (check) {

var options = __assign(__assign({}, check.options), optionsFromConfig);
var rule = _this.ruleRegistry.get(check.rule)(_this.logger, options);
return new rule_set_1.InstantiatedPackageMetaRule(rule.name, check.severity || "error", rule);
var fn = _this.ruleRegistry.get(check.rule);
if (typeof fn === "function") {
var rule = fn(_this.logger, options);
return new rule_set_1.InstantiatedPackageMetaRule(rule.name, check.severity || "error", rule);
}
return new rule_set_1.InstantiatedPackageMetaRule(fn.name, check.severity || "error", fn, options);
});

@@ -144,2 +154,3 @@ return new rule_set_1.RuleSet(glob, fileChecks, metaChecks);

Config.prototype.resolvedConfiguration = function () {
this.bootstrapPackages();
var parentConfiguration = this.resolveParentConfiguration(this.configuration.extends);

@@ -149,2 +160,35 @@ var finalResult = this.mergeConfigurations(this.configuration, parentConfiguration);

};
Config.prototype.loadExternalPlugin = function (fullPkgName) {
return this.requirePlugin(fullPkgName);
};
Config.prototype.loadBollPlugin = function (plugin) {
var _a = plugin === null || plugin === void 0 ? void 0 : plugin.split("/"), base = _a[0], rest = _a.slice(1);
var fullPkgName = "@boll/".concat(plugin);
if (rest && rest.length >= 1) {
fullPkgName = "@boll/".concat(base, "/dist/").concat(__spreadArray([], rest, true).join("/"));
}
return this.requirePlugin(fullPkgName);
};
Config.prototype.requirePlugin = function (fullPkgName) {
try {
var pkg = require(fullPkgName);
return pkg;
}
catch (e) {
throw new Error("Could not load plugin ".concat(fullPkgName, "."));
}
};
Config.prototype.bootstrapPackages = function () {
if (this.configuration.extends) {
var _a = this.configuration.extends.split(":"), prefix = _a[0], pkg = _a[1];
var plugin = void 0;
if (prefix === "boll") {
plugin = this.loadBollPlugin(pkg);
}
else if (prefix === "plugin") {
plugin = this.loadExternalPlugin(pkg);
}
plugin === null || plugin === void 0 ? void 0 : plugin.bootstrap();
}
};
Config.prototype.resolveParentConfiguration = function (baseConfigName) {

@@ -168,4 +212,4 @@ if (!baseConfigName) {

}
obj.ruleSets = __spreadArrays((parentConfiguration.ruleSets || []), (childConfiguration.ruleSets || []));
obj.exclude = __spreadArrays((parentConfiguration.exclude || []), (childConfiguration.exclude || []));
obj.ruleSets = __spreadArray(__spreadArray([], (parentConfiguration.ruleSets || []), true), (childConfiguration.ruleSets || []), true);
obj.exclude = __spreadArray(__spreadArray([], (parentConfiguration.exclude || []), true), (childConfiguration.exclude || []), true);
if (parentConfiguration.configuration && parentConfiguration.configuration.ruleSets) {

@@ -172,0 +216,0 @@ Object.keys(parentConfiguration.configuration.ruleSets).forEach(function (k) {

import ts from "typescript";
import { BollDirectory } from "./boll-directory";
import { BollFile } from "./boll-file";
import { DependencyMap, Package } from "./package";
import { Package } from "./package";
import { Rule } from "./types";
export declare class FileContext {
packageRoot: BollDirectory;
packageContext: Package;
packageContext: Partial<Package>;
filename: BollFile;

@@ -17,6 +17,6 @@ content: string;

private _ignoredChecksByLine;
constructor(packageRoot: BollDirectory, packageContext: Package, filename: BollFile, content: string);
constructor(packageRoot: BollDirectory, packageContext: Partial<Package>, filename: BollFile, content: string);
get source(): ts.SourceFile;
get packageDependencies(): DependencyMap;
get packageDevDependencies(): DependencyMap;
get packageDependencies(): Package["dependencies"] | undefined;
get packageDevDependencies(): Package["devDependencies"] | undefined;
get ignoredChecks(): string[];

@@ -27,2 +27,2 @@ get ignoredChecksByLine(): Map<number, string[]>;

}
export declare function getSourceFile(projectRoot: BollDirectory, filename: string, packageContext: Package): Promise<FileContext>;
export declare function getSourceFile(projectRoot: BollDirectory, filename: string, packageContext: Partial<Package>): Promise<FileContext>;

@@ -17,3 +17,3 @@ "use strict";

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -48,3 +48,3 @@ if (y = 0, t) op = [op[0] & 2, t.value];

var boll_file_1 = require("./boll-file");
var readFileAsync = util_1.promisify(graceful_fs_1.default.readFile);
var readFileAsync = (0, util_1.promisify)(graceful_fs_1.default.readFile);
var FileContext = /** @class */ (function () {

@@ -156,3 +156,3 @@ function FileContext(packageRoot, packageContext, filename, content) {

case 0:
bollFile = boll_file_1.asBollFile(filename);
bollFile = (0, boll_file_1.asBollFile)(filename);
return [4 /*yield*/, readFileAsync(bollFile)];

@@ -159,0 +159,0 @@ case 1:

@@ -17,3 +17,3 @@ "use strict";

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -55,5 +55,3 @@ if (y = 0, t) op = [op[0] & 2, t.value];

try {
repoRoot = path_1.resolve(child_process_1.execSync("git rev-parse --show-toplevel")
.toString()
.trim());
repoRoot = (0, path_1.resolve)((0, child_process_1.execSync)("git rev-parse --show-toplevel").toString().trim());
return repoRoot;

@@ -81,3 +79,3 @@ }

_b = ignoreFileNameOrDefault;
return [4 /*yield*/, fast_glob_1.default("./**/" + ignoreFileNameOrDefault, {
return [4 /*yield*/, (0, fast_glob_1.default)("./**/".concat(ignoreFileNameOrDefault), {
cwd: cwdOrDefault,

@@ -87,3 +85,3 @@ ignore: ["./**/node_modules/**"]

case 1:
_a[_b] = (_c.sent()).map(function (p) { return path_1.resolve(cwdOrDefault, p); });
_a[_b] = (_c.sent()).map(function (p) { return (0, path_1.resolve)(cwdOrDefault, p); });
return [2 /*return*/, ignoreFiles[cwdOrDefault][ignoreFileNameOrDefault]];

@@ -90,0 +88,0 @@ }

@@ -15,1 +15,8 @@ import { BollFile } from "./boll-file";

}
export declare class WorkspacesGlob implements FileGlob {
exclude: string[];
include: string[];
cwd: string;
constructor(cwd?: string);
findFiles(): Promise<BollFile[]>;
}

@@ -17,3 +17,3 @@ "use strict";

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -39,8 +39,10 @@ if (y = 0, t) op = [op[0] & 2, t.value];

};
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};

@@ -51,5 +53,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {

Object.defineProperty(exports, "__esModule", { value: true });
exports.PackageJsonGlob = exports.TypescriptSourceGlob = void 0;
exports.WorkspacesGlob = exports.PackageJsonGlob = exports.TypescriptSourceGlob = void 0;
var fast_glob_1 = __importDefault(require("fast-glob"));
var boll_file_1 = require("./boll-file");
var workspace_tools_1 = require("workspace-tools");
function findFiles(pattern, include, exclude) {

@@ -60,6 +63,6 @@ return __awaiter(this, void 0, void 0, function () {

switch (_a.label) {
case 0: return [4 /*yield*/, fast_glob_1.default(pattern, { ignore: __spreadArrays(exclude, ["./**/node_modules/**"]) })];
case 0: return [4 /*yield*/, (0, fast_glob_1.default)(pattern, { ignore: __spreadArray(__spreadArray([], exclude, true), ["./**/node_modules/**"], false) })];
case 1:
paths = _a.sent();
return [4 /*yield*/, fast_glob_1.default(include)];
return [4 /*yield*/, (0, fast_glob_1.default)(include)];
case 2:

@@ -89,3 +92,3 @@ inclusions = _a.sent();

switch (_a.label) {
case 0: return [4 /*yield*/, findFiles("./**/*.ts?(x)", this.include, __spreadArrays(this.exclude, ["./**/*.d.ts"]))];
case 0: return [4 /*yield*/, findFiles("./**/*.ts?(x)", this.include, __spreadArray(__spreadArray([], this.exclude, true), ["./**/*.d.ts"], false))];
case 1: return [2 /*return*/, _a.sent()];

@@ -124,1 +127,18 @@ }

exports.PackageJsonGlob = PackageJsonGlob;
var WorkspacesGlob = /** @class */ (function () {
function WorkspacesGlob(cwd) {
if (cwd === void 0) { cwd = ""; }
this.exclude = [];
this.include = [];
this.cwd = cwd;
}
WorkspacesGlob.prototype.findFiles = function () {
var workspaces = (0, workspace_tools_1.getWorkspaces)(this.cwd || process.cwd()).map(function (_a) {
var path = _a.path;
return "".concat(path, "/package.json");
});
return Promise.resolve(workspaces.map(boll_file_1.asBollFile));
};
return WorkspacesGlob;
}());
exports.WorkspacesGlob = WorkspacesGlob;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -17,3 +21,3 @@ if (k2 === undefined) k2 = k;

var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);

@@ -37,3 +41,3 @@ return result;

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -103,8 +107,8 @@ if (y = 0, t) op = [op[0] & 2, t.value];

.split(path.sep)
.map(function (v, i, a) { return "./" + a.slice(0, i).join("/") + (i > 0 ? "/" : "") + "!(" + v + ")/**"; })
.map(function (v, i, a) { return "./".concat(a.slice(0, i).join("/")).concat(i > 0 ? "/" : "", "!(").concat(v, ")/**"); })
: [];
for (var _i = 0, _a = globsForIgnoreFile.globs; _i < _a.length; _i++) {
var glob = _a[_i];
ignoredFilesPromises.push(fast_glob_1.default(glob, { dot: true, cwd: globsForIgnoreFile.cwd, ignore: ignore }).then(function (files) {
var filesAsBollFiles = files.map(function (f) { return boll_file_1.asBollFile(path.resolve(globsForIgnoreFile.cwd, f)); });
for (var _e = 0, _f = globsForIgnoreFile.globs; _e < _f.length; _e++) {
var glob = _f[_e];
ignoredFilesPromises.push((0, fast_glob_1.default)(glob, { dot: true, cwd: globsForIgnoreFile.cwd, ignore: ignore }).then(function (files) {
var filesAsBollFiles = files.map(function (f) { return (0, boll_file_1.asBollFile)(path.resolve(globsForIgnoreFile.cwd, f)); });
ignoredFiles.push.apply(ignoredFiles, filesAsBollFiles);

@@ -131,3 +135,3 @@ }));

switch (_a.label) {
case 0: return [4 /*yield*/, git_utils_1.getIgnoreFiles(this.root, this.ignoreFileName)];
case 0: return [4 /*yield*/, (0, git_utils_1.getIgnoreFiles)(this.root, this.ignoreFileName)];
case 1: return [2 /*return*/, ((_a.sent())

@@ -144,3 +148,3 @@ // Only want ignore files that apply to the current working directory

return ignoreFiles.reduce(function (ignoreFileToIgnorePatterns, ignoreFile) {
ignoreFileToIgnorePatterns[ignoreFile] = parse_gitignore_1.default(fs_1.default.readFileSync(ignoreFile)).map(function (p) { return new IgnorePattern(p, ignoreFile); });
ignoreFileToIgnorePatterns[ignoreFile] = (0, parse_gitignore_1.default)(fs_1.default.readFileSync(ignoreFile)).map(function (p) { return new IgnorePattern(p, ignoreFile); });
return ignoreFileToIgnorePatterns;

@@ -189,6 +193,6 @@ }, {});

return ignorePattern.pattern.startsWith("/")
? ["." + ignorePattern.pattern + "**/*"]
? [".".concat(ignorePattern.pattern, "**/*")]
: ignorePattern.pattern.startsWith("./")
? [ignorePattern.pattern + "**/*"]
: ["./" + ignorePattern.pattern + "**/*"];
? ["".concat(ignorePattern.pattern, "**/*")]
: ["./".concat(ignorePattern.pattern, "**/*")];
}

@@ -198,22 +202,22 @@ else if (ignorePattern.isRelative && !ignorePattern.isDir) {

return ignorePattern.pattern.startsWith("/")
? ["." + ignorePattern.pattern]
? [".".concat(ignorePattern.pattern)]
: ignorePattern.pattern.startsWith("./")
? ["" + ignorePattern.pattern]
: ["./" + ignorePattern.pattern];
? ["".concat(ignorePattern.pattern)]
: ["./".concat(ignorePattern.pattern)];
}
else {
return ignorePattern.pattern.startsWith("/")
? ["." + ignorePattern.pattern + "/**/*", "." + ignorePattern.pattern]
? [".".concat(ignorePattern.pattern, "/**/*"), ".".concat(ignorePattern.pattern)]
: ignorePattern.pattern.startsWith("./")
? [ignorePattern.pattern + "/**/*", "" + ignorePattern.pattern]
: ["./" + ignorePattern.pattern + "/**/*", "./" + ignorePattern.pattern];
? ["".concat(ignorePattern.pattern, "/**/*"), "".concat(ignorePattern.pattern)]
: ["./".concat(ignorePattern.pattern, "/**/*"), "./".concat(ignorePattern.pattern)];
}
}
else if (!ignorePattern.isRelative && ignorePattern.isDir) {
return ["./**/" + ignorePattern.pattern + "**/*"];
return ["./**/".concat(ignorePattern.pattern, "**/*")];
}
else {
return ignorePattern.endsWithAsterisk
? ["./**/" + ignorePattern.pattern]
: ["./**/" + ignorePattern.pattern + "/**/*", "./**/" + ignorePattern.pattern];
? ["./**/".concat(ignorePattern.pattern)]
: ["./**/".concat(ignorePattern.pattern, "/**/*"), "./**/".concat(ignorePattern.pattern)];
}

@@ -220,0 +224,0 @@ };

@@ -12,4 +12,5 @@ export * from "./boll-directory";

export * from "./result-set";
export * from "./rule-set";
export * from "./rule-registry";
export * from "./suite";
export * from "./types";
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -10,3 +14,3 @@ if (k2 === undefined) k2 = k;

var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};

@@ -25,4 +29,5 @@ Object.defineProperty(exports, "__esModule", { value: true });

__exportStar(require("./result-set"), exports);
__exportStar(require("./rule-set"), exports);
__exportStar(require("./rule-registry"), exports);
__exportStar(require("./suite"), exports);
__exportStar(require("./types"), exports);

@@ -1,2 +0,2 @@

declare type MessagePrinter = (msg: string) => void;
type MessagePrinter = (msg: string) => void;
export declare class Logger {

@@ -3,0 +3,0 @@ private logPrinter;

@@ -1,10 +0,3 @@

import { BollFile } from "./boll-file";
export declare type DependencyMap = {
[depdencyName: string]: string;
};
export declare class Package {
dependencies: DependencyMap;
devDependencies: DependencyMap;
constructor(dependencies: DependencyMap, devDependencies: DependencyMap);
static parse(file: BollFile): Package;
}
import type { PackageInfo } from "workspace-tools";
export type { PackageInfo as Package };
export declare const parse: (fileContents: string) => PackageInfo;
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Package = void 0;
var fs_1 = require("fs");
var Package = /** @class */ (function () {
function Package(dependencies, devDependencies) {
this.dependencies = dependencies;
this.devDependencies = devDependencies;
exports.parse = void 0;
var parse = function (fileContents) {
try {
var json = JSON.parse(fileContents);
return __assign(__assign({}, json), { dependencies: json.dependencies || {}, devDependencies: json.devDependencies || {} });
}
Package.parse = function (file) {
try {
var fileContents = fs_1.readFileSync(file).toString();
var json = JSON.parse(fileContents);
return new Package(json["dependencies"] || {}, json["devDependencies"] || {});
}
catch (e) {
return new Package({}, {});
}
};
return Package;
}());
exports.Package = Package;
catch (e) {
console.log({ e: e });
return {};
}
};
exports.parse = parse;

@@ -18,3 +18,3 @@ "use strict";

get: function () {
return "[" + this.ruleName + "] Succeeded";
return "[".concat(this.ruleName, "] Succeeded");
},

@@ -43,3 +43,3 @@ enumerable: false,

get: function () {
return "[" + this.ruleName + "] " + this.filename + ":" + this.line + " " + this.text;
return "[".concat(this.ruleName, "] ").concat(this.filename, ":").concat(this.line, " ").concat(this.text);
},

@@ -46,0 +46,0 @@ enumerable: false,

import { Logger } from "./logger";
import { Rule } from "./types";
export declare type RuleDefinition<T extends Rule> = (logger: Logger, options?: {}) => T;
export type RuleDefinition<T extends Rule> = (logger: Logger, options?: {}) => T;
export declare class RuleRegistry {
registrations: {
[name: string]: RuleDefinition<Rule>;
[name: string]: RuleDefinition<Rule> | Rule;
};
register<T extends Rule>(name: string, factory: RuleDefinition<T>): void;
get<T extends Rule>(name: string): RuleDefinition<T>;
register<T extends Rule>(name: string, factory: RuleDefinition<T> | T): void;
get<T extends Rule>(name: string): RuleDefinition<T> | T;
}
export declare const addRule: <T extends Rule>(rule: T, instance?: RuleRegistry) => void;
export declare const RuleRegistryInstance: RuleRegistry;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RuleRegistryInstance = exports.RuleRegistry = void 0;
exports.RuleRegistryInstance = exports.addRule = exports.RuleRegistry = void 0;
var RuleRegistry = /** @class */ (function () {

@@ -10,3 +10,3 @@ function RuleRegistry() {

if (this.registrations[name]) {
throw new Error("Already know about rule \"" + name + "\", cannot redefine.");
throw new Error("Already know about rule \"".concat(name, "\", cannot redefine."));
}

@@ -17,3 +17,3 @@ this.registrations[name] = factory;

if (!this.registrations[name]) {
throw new Error("Don't know about rule \"" + name + "\".");
throw new Error("Don't know about rule \"".concat(name, "\"."));
}

@@ -25,2 +25,16 @@ return this.registrations[name];

exports.RuleRegistry = RuleRegistry;
/*
addRule("name", (logger, options) => {
return (files) => {};
});
addRule("name", (logger, options) => {
return ({ filename, content }) => {};
});
*/
var addRule = function (rule, instance) {
if (instance === void 0) { instance = exports.RuleRegistryInstance; }
instance.register(rule.name, rule);
};
exports.addRule = addRule;
exports.RuleRegistryInstance = new RuleRegistry();
import { FileContext } from "./file-context";
import { Result } from "./result-set";
import { CheckSeverity, FileGlob, PackageMetaRule, PackageRule } from "./types";
import { Logger } from "./logger";
export interface InstantiatedRule {

@@ -8,14 +9,17 @@ name: string;

}
export declare class InstantiatedPackageRule implements InstantiatedRule {
export interface RuleOptions {
logger: Logger;
[key: string]: string | Logger;
}
export declare class BasePackageRule<T> {
name: string;
severity: CheckSeverity;
rule: PackageRule;
constructor(name: string, severity: CheckSeverity, rule: PackageRule);
rule: T;
options?: RuleOptions | undefined;
constructor(name: string, severity: CheckSeverity, rule: T, options?: RuleOptions | undefined);
}
export declare class InstantiatedPackageRule extends BasePackageRule<PackageRule> implements InstantiatedRule {
check(file: FileContext): Promise<Result[]>;
}
export declare class InstantiatedPackageMetaRule implements InstantiatedRule {
name: string;
severity: CheckSeverity;
rule: PackageMetaRule;
constructor(name: string, severity: CheckSeverity, rule: PackageMetaRule);
export declare class InstantiatedPackageMetaRule extends BasePackageRule<PackageMetaRule> implements InstantiatedRule {
check(files: FileContext[]): Promise<Result[]>;

@@ -22,0 +26,0 @@ }

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.RuleSet = exports.InstantiatedPackageMetaRule = exports.InstantiatedPackageRule = void 0;
var InstantiatedPackageRule = /** @class */ (function () {
function InstantiatedPackageRule(name, severity, rule) {
exports.RuleSet = exports.InstantiatedPackageMetaRule = exports.InstantiatedPackageRule = exports.BasePackageRule = void 0;
var BasePackageRule = /** @class */ (function () {
function BasePackageRule(name, severity, rule, options) {
this.name = name;
this.severity = severity;
this.rule = rule;
this.options = options;
}
return BasePackageRule;
}());
exports.BasePackageRule = BasePackageRule;
var InstantiatedPackageRule = /** @class */ (function (_super) {
__extends(InstantiatedPackageRule, _super);
function InstantiatedPackageRule() {
return _super !== null && _super.apply(this, arguments) || this;
}
InstantiatedPackageRule.prototype.check = function (file) {
return this.rule.check(file);
return this.rule.check(file, this.options);
};
return InstantiatedPackageRule;
}());
}(BasePackageRule));
exports.InstantiatedPackageRule = InstantiatedPackageRule;
var InstantiatedPackageMetaRule = /** @class */ (function () {
function InstantiatedPackageMetaRule(name, severity, rule) {
this.name = name;
this.severity = severity;
this.rule = rule;
var InstantiatedPackageMetaRule = /** @class */ (function (_super) {
__extends(InstantiatedPackageMetaRule, _super);
function InstantiatedPackageMetaRule() {
return _super !== null && _super.apply(this, arguments) || this;
}
InstantiatedPackageMetaRule.prototype.check = function (files) {
return this.rule.check(files);
return this.rule.check(files, this.options);
};
return InstantiatedPackageMetaRule;
}());
}(BasePackageRule));
exports.InstantiatedPackageMetaRule = InstantiatedPackageMetaRule;

@@ -28,0 +51,0 @@ var RuleSet = /** @class */ (function () {

@@ -17,3 +17,3 @@ "use strict";

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -52,3 +52,3 @@ if (y = 0, t) op = [op[0] & 2, t.value];

var util_1 = require("util");
var readFileAsync = util_1.promisify(fs_1.default.readFile);
var readFileAsync = (0, util_1.promisify)(fs_1.default.readFile);
var Suite = /** @class */ (function () {

@@ -102,40 +102,52 @@ function Suite() {

sourceFilePaths = _a.sent();
projectRoot = boll_directory_1.asBollDirectory(process.cwd());
return [4 /*yield*/, Promise.all(sourceFilePaths.map(function (filename) { return file_context_1.getSourceFile(projectRoot, filename, packageContext); }))];
projectRoot = (0, boll_directory_1.asBollDirectory)(process.cwd());
return [4 /*yield*/, Promise.all(sourceFilePaths.map(function (filename) { return (0, file_context_1.getSourceFile)(projectRoot, filename, packageContext); }))];
case 3:
sourceFiles = _a.sent();
ruleSet.fileChecks.forEach(function (r) {
sourceFiles.forEach(function (s) { return __awaiter(_this, void 0, void 0, function () {
var results, filteredResults;
return [4 /*yield*/, Promise.all(ruleSet.fileChecks.map(function (r) { return __awaiter(_this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, Promise.all(sourceFiles.map(function (s) { return __awaiter(_this, void 0, void 0, function () {
var results, filteredResults;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (s.shouldSkip(r))
return [2 /*return*/];
return [4 /*yield*/, r.check(s)];
case 1:
results = _a.sent();
return [4 /*yield*/, this.filterIgnoredChecksByLine(results, s)];
case 2:
filteredResults = _a.sent();
this.addFailuresWithSeverity(r, filteredResults, resultSet);
return [2 /*return*/];
}
});
}); }))];
case 1:
_a.sent();
return [2 /*return*/];
}
});
}); }))];
case 4:
_a.sent();
return [4 /*yield*/, Promise.all(ruleSet.metaChecks.map(function (r) { return __awaiter(_this, void 0, void 0, function () {
var unskippedSourceFiles, results;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (s.shouldSkip(r))
return [2 /*return*/];
return [4 /*yield*/, r.check(s)];
unskippedSourceFiles = sourceFiles.filter(function (s) { return !s.shouldSkip(r); });
return [4 /*yield*/, r.check(unskippedSourceFiles)];
case 1:
results = _a.sent();
return [4 /*yield*/, this.filterIgnoredChecksByLine(results, s)];
case 2:
filteredResults = _a.sent();
this.addFailuresWithSeverity(r, filteredResults, resultSet);
this.addFailuresWithSeverity(r, results, resultSet);
return [2 /*return*/];
}
});
}); });
});
ruleSet.metaChecks.forEach(function (r) { return __awaiter(_this, void 0, void 0, function () {
var unskippedSourceFiles, results;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
unskippedSourceFiles = sourceFiles.filter(function (s) { return !s.shouldSkip(r); });
return [4 /*yield*/, r.check(unskippedSourceFiles)];
case 1:
results = _a.sent();
this.addFailuresWithSeverity(r, results, resultSet);
return [2 /*return*/];
}
});
}); });
}); }))];
case 5:
_a.sent();
return [2 /*return*/, true];

@@ -148,3 +160,3 @@ }

return __awaiter(this, void 0, void 0, function () {
var filename, packageBuffer, packageJson, packageContext, e_1;
var filename, packageBuffer, packageJson, e_1;
return __generator(this, function (_a) {

@@ -160,8 +172,7 @@ switch (_a.label) {

packageBuffer = _a.sent();
packageJson = JSON.parse(packageBuffer.toString("utf-8"));
packageContext = new package_1.Package(packageJson.dependencies || {}, packageJson.devDependencies || {});
return [2 /*return*/, packageContext];
packageJson = (0, package_1.parse)(packageBuffer.toString("utf-8"));
return [2 /*return*/, packageJson];
case 3:
e_1 = _a.sent();
logger.error("Error loading " + filename);
logger.error("Error loading ".concat(filename));
throw e_1;

@@ -184,3 +195,4 @@ case 4: return [2 /*return*/];

var skipLineNumber = failure.line - 1;
if (!(ignoredChecksByLine.has(skipLineNumber) && ((_a = ignoredChecksByLine.get(skipLineNumber)) === null || _a === void 0 ? void 0 : _a.includes(failure.ruleName)))) {
if (!(ignoredChecksByLine.has(skipLineNumber) &&
((_a = ignoredChecksByLine.get(skipLineNumber)) === null || _a === void 0 ? void 0 : _a.includes(failure.ruleName)))) {
filteredResults.push(l);

@@ -187,0 +199,0 @@ }

@@ -12,2 +12,2 @@ "use strict";

var suite_test_1 = require("./suite.test");
test_internal_1.suite(config_test_1.test, format_test_1.test, git_utils_test_1.test, glob_test_1.test, ignore_test_1.test, pragma_test_1.test, suite_test_1.test, result_test_1.test);
(0, test_internal_1.suite)(config_test_1.test, format_test_1.test, git_utils_test_1.test, glob_test_1.test, ignore_test_1.test, pragma_test_1.test, suite_test_1.test, result_test_1.test);
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -17,3 +21,3 @@ if (k2 === undefined) k2 = k;

var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);

@@ -37,3 +41,3 @@ return result;

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -70,3 +74,3 @@ if (y = 0, t) op = [op[0] & 2, t.value];

var rule_registry_1 = require("../rule-registry");
exports.test = baretest_1.default("Config");
exports.test = (0, baretest_1.default)("Config");
var FakeRule = /** @class */ (function () {

@@ -97,3 +101,3 @@ function FakeRule(options) {

}());
exports.test("should allow multi-level inheritance of configs", function () {
(0, exports.test)("should allow multi-level inheritance of configs", function () {
var configRegistry = new config_registry_1.ConfigRegistry();

@@ -118,3 +122,3 @@ var ruleRegistry = new rule_registry_1.RuleRegistry();

});
exports.test("should apply exclude/include across extended config", function () { return __awaiter(void 0, void 0, void 0, function () {
(0, exports.test)("should apply exclude/include across extended config", function () { return __awaiter(void 0, void 0, void 0, function () {
var configRegistry, ruleSets, config, suite;

@@ -137,3 +141,3 @@ return __generator(this, function (_a) {

}); });
exports.test("gives options to factory function", function () {
(0, exports.test)("gives options to factory function", function () {
var configRegistry = new config_registry_1.ConfigRegistry();

@@ -155,3 +159,33 @@ var ruleRegistry = new rule_registry_1.RuleRegistry();

});
exports.test("downstream rules configuration applies to rules", function () { return __awaiter(void 0, void 0, void 0, function () {
(0, exports.test)("addRule function can register and pass options", function () { return __awaiter(void 0, void 0, void 0, function () {
var configRegistry, ruleRegistry, config, ruleSets;
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
configRegistry = new config_registry_1.ConfigRegistry();
ruleRegistry = new rule_registry_1.RuleRegistry();
(0, rule_registry_1.addRule)({
name: "foo",
check: function (filename) { return __awaiter(void 0, void 0, void 0, function () {
var results;
return __generator(this, function (_a) {
results = [];
return [2 /*return*/, results];
});
}); }
}, ruleRegistry);
config = new config_1.Config(configRegistry, ruleRegistry, logger_1.NullLogger);
config.load({
ruleSets: [{ fileLocator: new FakeGlob(), checks: { file: [{ rule: "foo", options: { bar: "baz" } }] } }]
});
return [4 /*yield*/, config.buildSuite()];
case 1:
ruleSets = (_b.sent()).ruleSets;
assert.ok((_a = ruleSets[0].fileChecks[0].options) === null || _a === void 0 ? void 0 : _a.bar, "addRule should have been invoked with correct args when creating suite.");
return [2 /*return*/];
}
});
}); });
(0, exports.test)("downstream rules configuration applies to rules", function () { return __awaiter(void 0, void 0, void 0, function () {
var configRegistry, ruleRegistry, config, myConfig, suite, fakeRuleInstance;

@@ -189,3 +223,3 @@ return __generator(this, function (_a) {

}); });
exports.test("downstream ruleSet configuration applies to ruleSets", function () { return __awaiter(void 0, void 0, void 0, function () {
(0, exports.test)("downstream ruleSet configuration applies to ruleSets", function () { return __awaiter(void 0, void 0, void 0, function () {
var configRegistry, config, myConfig, suite, ruleSet;

@@ -223,3 +257,3 @@ return __generator(this, function (_a) {

}); });
exports.test("resolveConfiguration merges exclude", function () {
(0, exports.test)("resolveConfiguration merges exclude", function () {
var configRegistry = new config_registry_1.ConfigRegistry();

@@ -226,0 +260,0 @@ configRegistry.register({

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -17,3 +21,3 @@ if (k2 === undefined) k2 = k;

var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);

@@ -33,29 +37,29 @@ return result;

var result_set_1 = require("../result-set");
exports.test = baretest_1.default("Output formatter");
exports.test = (0, baretest_1.default)("Output formatter");
var assertContains = function (needle, haystack) {
var message = "Expected '" + haystack + "' to contain '" + needle + "'";
var message = "Expected '".concat(haystack, "' to contain '").concat(needle, "'");
assert.ok(haystack.includes(needle), message);
};
exports.test("includes the name of the source file", function () {
var sut = new result_set_1.Failure("ignore", boll_file_1.asBollFile("src/foo.tsx"), boll_line_number_1.asBollLineNumber(-1), "ignore");
(0, exports.test)("includes the name of the source file", function () {
var sut = new result_set_1.Failure("ignore", (0, boll_file_1.asBollFile)("src/foo.tsx"), (0, boll_line_number_1.asBollLineNumber)(-1), "ignore");
assertContains(path.normalize("src/foo.tsx"), sut.formattedMessage);
});
exports.test("includes the line of the offense", function () {
var sut = new result_set_1.Failure("ignore", boll_file_1.asBollFile("ignore"), boll_line_number_1.asBollLineNumber(3), "ignore");
(0, exports.test)("includes the line of the offense", function () {
var sut = new result_set_1.Failure("ignore", (0, boll_file_1.asBollFile)("ignore"), (0, boll_line_number_1.asBollLineNumber)(3), "ignore");
assertContains(":3", sut.formattedMessage);
});
exports.test("includes the name of the rule", function () {
var sut = new result_set_1.Failure("ExampleRule", boll_file_1.asBollFile("ignore"), boll_line_number_1.asBollLineNumber(-1), "ignore");
(0, exports.test)("includes the name of the rule", function () {
var sut = new result_set_1.Failure("ExampleRule", (0, boll_file_1.asBollFile)("ignore"), (0, boll_line_number_1.asBollLineNumber)(-1), "ignore");
assertContains("ExampleRule", sut.formattedMessage);
});
exports.test("includes descriptive text", function () {
var sut = new result_set_1.Failure("ignore", boll_file_1.asBollFile("ignore"), boll_line_number_1.asBollLineNumber(-1), "lorem ipsum dolor");
(0, exports.test)("includes descriptive text", function () {
var sut = new result_set_1.Failure("ignore", (0, boll_file_1.asBollFile)("ignore"), (0, boll_line_number_1.asBollLineNumber)(-1), "lorem ipsum dolor");
assertContains("lorem ipsum dolor", sut.formattedMessage);
});
exports.test("variations", function () {
var sut = new result_set_1.Failure("OtherRule", boll_file_1.asBollFile("src/bar.ts"), boll_line_number_1.asBollLineNumber(1), "ignore");
(0, exports.test)("variations", function () {
var sut = new result_set_1.Failure("OtherRule", (0, boll_file_1.asBollFile)("src/bar.ts"), (0, boll_line_number_1.asBollLineNumber)(1), "ignore");
assertContains("OtherRule", sut.formattedMessage);
assertContains(path.normalize("src/bar.ts") + ":1", sut.formattedMessage);
assertContains("".concat(path.normalize("src/bar.ts"), ":1"), sut.formattedMessage);
});
exports.test("success", function () {
(0, exports.test)("success", function () {
var sut = new result_set_1.Success("OtherRule");

@@ -62,0 +66,0 @@ assertContains("OtherRule", sut.formattedMessage);

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -17,3 +21,3 @@ if (k2 === undefined) k2 = k;

var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);

@@ -37,3 +41,3 @@ return result;

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -69,4 +73,4 @@ if (y = 0, t) op = [op[0] & 2, t.value];

var git_utils_1 = require("../git-utils");
exports.test = baretest_1.default("Git Utils");
exports.test("Should correctly parse repo root", function () { return __awaiter(void 0, void 0, void 0, function () {
exports.test = (0, baretest_1.default)("Git Utils");
(0, exports.test)("Should correctly parse repo root", function () { return __awaiter(void 0, void 0, void 0, function () {
var sut, result;

@@ -80,6 +84,6 @@ return __generator(this, function (_a) {

}); });
exports.test("Should correctly find specified ignore file", function () { return __awaiter(void 0, void 0, void 0, function () {
(0, exports.test)("Should correctly find specified ignore file", 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("git-utils", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
case 0: return [4 /*yield*/, (0, test_internal_1.inFixtureDir)("git-utils", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
var sut, result;

@@ -86,0 +90,0 @@ return __generator(this, function (_a) {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -17,3 +21,3 @@ if (k2 === undefined) k2 = k;

var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);

@@ -37,3 +41,3 @@ return result;

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -69,7 +73,7 @@ if (y = 0, t) op = [op[0] & 2, t.value];

var glob_1 = require("../glob");
exports.test = baretest_1.default("Glob");
exports.test("should find .ts source", function () { return __awaiter(void 0, void 0, void 0, function () {
exports.test = (0, baretest_1.default)("Glob");
(0, exports.test)("should find .ts source", 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("project-a", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
case 0: return [4 /*yield*/, (0, test_internal_1.inFixtureDir)("project-a", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
var glob, results;

@@ -83,3 +87,3 @@ return __generator(this, function (_a) {

results = _a.sent();
assert.ok(results.includes(boll_file_1.asBollFile("src/bad-import.ts")), "expected results to include bad-import.ts, but was " + results.join(", "));
assert.ok(results.includes((0, boll_file_1.asBollFile)("src/bad-import.ts")), "expected results to include bad-import.ts, but was ".concat(results.join(", ")));
return [2 /*return*/];

@@ -95,6 +99,6 @@ }

}); });
exports.test("should find .tsx source", function () { return __awaiter(void 0, void 0, void 0, function () {
(0, exports.test)("should find .tsx source", 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("project-a", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
case 0: return [4 /*yield*/, (0, test_internal_1.inFixtureDir)("project-a", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
var glob, results;

@@ -108,3 +112,3 @@ return __generator(this, function (_a) {

results = _a.sent();
assert.ok(results.includes(boll_file_1.asBollFile("src/foo.tsx")), "expected results to include foo.tsx, but was " + results.join(", "));
assert.ok(results.includes((0, boll_file_1.asBollFile)("src/foo.tsx")), "expected results to include foo.tsx, but was ".concat(results.join(", ")));
return [2 /*return*/];

@@ -120,6 +124,6 @@ }

}); });
exports.test("should not include .d.ts files", function () { return __awaiter(void 0, void 0, void 0, function () {
(0, exports.test)("should not include .d.ts files", 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("project-a", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
case 0: return [4 /*yield*/, (0, test_internal_1.inFixtureDir)("project-a", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
var glob, results;

@@ -133,3 +137,3 @@ return __generator(this, function (_a) {

results = _a.sent();
assert.ok(!results.includes(boll_file_1.asBollFile("src/some-thing.d.ts")), "expected results not to include some-thing.d.ts, but was " + results.join(", "));
assert.ok(!results.includes((0, boll_file_1.asBollFile)("src/some-thing.d.ts")), "expected results not to include some-thing.d.ts, but was ".concat(results.join(", ")));
return [2 /*return*/];

@@ -145,6 +149,6 @@ }

}); });
exports.test("should not return files explicitly excluded", function () { return __awaiter(void 0, void 0, void 0, function () {
(0, exports.test)("should not return files explicitly excluded", 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("glob", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
case 0: return [4 /*yield*/, (0, test_internal_1.inFixtureDir)("glob", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
var glob, results;

@@ -158,3 +162,3 @@ return __generator(this, function (_a) {

results = _a.sent();
assert.deepStrictEqual(results.sort(), [boll_file_1.asBollFile("a/a.ts")].sort());
assert.deepStrictEqual(results.sort(), [(0, boll_file_1.asBollFile)("a/a.ts")].sort());
return [2 /*return*/];

@@ -170,6 +174,6 @@ }

}); });
exports.test("should return files explicitly included", function () { return __awaiter(void 0, void 0, void 0, function () {
(0, exports.test)("should return files explicitly included", 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("glob", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
case 0: return [4 /*yield*/, (0, test_internal_1.inFixtureDir)("glob", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
var glob, results;

@@ -183,3 +187,3 @@ return __generator(this, function (_a) {

results = _a.sent();
assert.deepStrictEqual(results.sort(), [boll_file_1.asBollFile("a/a.ts"), boll_file_1.asBollFile("b/b.ts"), boll_file_1.asBollFile("c/c.someextension")].sort());
assert.deepStrictEqual(results.sort(), [(0, boll_file_1.asBollFile)("a/a.ts"), (0, boll_file_1.asBollFile)("b/b.ts"), (0, boll_file_1.asBollFile)("c/c.someextension")].sort());
return [2 /*return*/];

@@ -195,1 +199,30 @@ }

}); });
(0, exports.test)("should find packages in a monorepo", function () { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (0, test_internal_1.inFixtureDir)("monorepo", __dirname, function (fixtureDir) { return __awaiter(void 0, void 0, void 0, function () {
var glob, results;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
glob = new glob_1.WorkspacesGlob(fixtureDir);
return [4 /*yield*/, glob.findFiles()];
case 1:
results = _a.sent();
assert.deepStrictEqual(results.sort(), [
(0, boll_file_1.asBollFile)("packages/hip-glasses-smoke/package.json"),
(0, boll_file_1.asBollFile)("packages/large-worms-pull/package.json"),
(0, boll_file_1.asBollFile)("packages/lemon-foxes-exist/package.json"),
(0, boll_file_1.asBollFile)("packages/many-taxes-wash/package.json"),
(0, boll_file_1.asBollFile)("packages/yellow-hairs-film/package.json")
].sort());
return [2 /*return*/];
}
});
}); })];
case 1:
_a.sent();
return [2 /*return*/];
}
});
}); });
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -17,3 +21,3 @@ if (k2 === undefined) k2 = k;

var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);

@@ -37,3 +41,3 @@ return result;

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -69,3 +73,3 @@ if (y = 0, t) op = [op[0] & 2, t.value];

var ignore_1 = require("../ignore");
exports.test = baretest_1.default("Ignore files");
exports.test = (0, baretest_1.default)("Ignore files");
function assertArrayContentsEqual(actual, expected) {

@@ -76,3 +80,3 @@ actual.sort();

}
exports.test("Should produce a glob matching all files in ./a/b/ (relative to .gitignore)", function () {
(0, exports.test)("Should produce a glob matching all files in ./a/b/ (relative to .gitignore)", function () {
var sut = new ignore_1.GlobsForIgnorePattern(new ignore_1.IgnorePattern("a/b/", ".gitignored"));

@@ -82,3 +86,3 @@ var result = sut.globs;

});
exports.test("Should produce a glob matching all files with a path containing a/", function () {
(0, exports.test)("Should produce a glob matching all files with a path containing a/", function () {
var sut = new ignore_1.GlobsForIgnorePattern(new ignore_1.IgnorePattern("a/", ".gitignored"));

@@ -88,3 +92,3 @@ var result = sut.globs;

});
exports.test("Should produce a glob matching all files in directory /a or files named a (relative to .gitignore)", function () {
(0, exports.test)("Should produce a glob matching all files in directory /a or files named a (relative to .gitignore)", function () {
var sut = new ignore_1.GlobsForIgnorePattern(new ignore_1.IgnorePattern("/a", ".gitignored"));

@@ -94,3 +98,3 @@ var result = sut.globs;

});
exports.test("Should produce a glob matching all directories and files matching a", function () {
(0, exports.test)("Should produce a glob matching all directories and files matching a", function () {
var sut = new ignore_1.GlobsForIgnorePattern(new ignore_1.IgnorePattern("a", ".gitignored"));

@@ -100,3 +104,3 @@ var result = sut.globs;

});
exports.test("Should produce a glob matching all files matching pattern *.js and all files nested in a directory ending in the characters .js", function () {
(0, exports.test)("Should produce a glob matching all files matching pattern *.js and all files nested in a directory ending in the characters .js", function () {
var sut = new ignore_1.GlobsForIgnorePattern(new ignore_1.IgnorePattern("*.js", ".gitignored"));

@@ -106,3 +110,3 @@ var result = sut.globs;

});
exports.test("Should produce a glob matching all files in directory abc (relative to .gitignore file)", function () {
(0, exports.test)("Should produce a glob matching all files in directory abc (relative to .gitignore file)", function () {
var sut = new ignore_1.GlobsForIgnorePattern(new ignore_1.IgnorePattern("abc/**", ".gitignored"));

@@ -112,3 +116,3 @@ var result = sut.globs;

});
exports.test("Should match all files inside any directory b or files named b nested in directory a", function () {
(0, exports.test)("Should match all files inside any directory b or files named b nested in directory a", function () {
var sut = new ignore_1.GlobsForIgnorePattern(new ignore_1.IgnorePattern("a/**/b", ".gitignored"));

@@ -118,6 +122,6 @@ var result = sut.globs;

});
exports.test("Should match all files in directory a (relative to ignore file)", function () { return __awaiter(void 0, void 0, void 0, function () {
(0, exports.test)("Should match all files in directory a (relative to ignore file)", 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("ignore/ignore-directory", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
case 0: return [4 /*yield*/, (0, test_internal_1.inFixtureDir)("ignore/ignore-directory", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
var sut, result;

@@ -158,6 +162,6 @@ return __generator(this, function (_a) {

}); });
exports.test("Should match all files in directories named a and all files named a", function () { return __awaiter(void 0, void 0, void 0, function () {
(0, exports.test)("Should match all files in directories named a and all files named a", 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("ignore/ignore-file-or-directory", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
case 0: return [4 /*yield*/, (0, test_internal_1.inFixtureDir)("ignore/ignore-file-or-directory", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
var sut, result;

@@ -210,6 +214,6 @@ return __generator(this, function (_a) {

}); });
exports.test("Should match any files ending in .js and ignore any files in directories containing .js", function () { return __awaiter(void 0, void 0, void 0, function () {
(0, exports.test)("Should match any files ending in .js and ignore any files in directories containing .js", 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("ignore/ignore-file-type", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
case 0: return [4 /*yield*/, (0, test_internal_1.inFixtureDir)("ignore/ignore-file-type", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
var sut, result;

@@ -246,6 +250,6 @@ return __generator(this, function (_a) {

}); });
exports.test("Should match any files ending in .js in directory a (relative to ignore file)", function () { return __awaiter(void 0, void 0, void 0, function () {
(0, exports.test)("Should match any files ending in .js in directory a (relative to ignore file)", 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("ignore/ignore-file-type-in-directory", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
case 0: return [4 /*yield*/, (0, test_internal_1.inFixtureDir)("ignore/ignore-file-type-in-directory", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
var sut, result;

@@ -270,6 +274,6 @@ return __generator(this, function (_a) {

}); });
exports.test("Should match any files ending in .js in any directory b nested inside of directory a (relative to ignore file)", function () { return __awaiter(void 0, void 0, void 0, function () {
(0, exports.test)("Should match any files ending in .js in any directory b nested inside of directory a (relative to ignore file)", 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("ignore/ignore-file-type-in-nested-directory", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
case 0: return [4 /*yield*/, (0, test_internal_1.inFixtureDir)("ignore/ignore-file-type-in-nested-directory", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
var sut, result;

@@ -296,6 +300,6 @@ return __generator(this, function (_a) {

}); });
exports.test("Should match any files in directory b nested in directory a (relative to ignore file)", function () { return __awaiter(void 0, void 0, void 0, function () {
(0, exports.test)("Should match any files in directory b nested in directory a (relative to ignore file)", 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("ignore/ignore-nested-directory", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
case 0: return [4 /*yield*/, (0, test_internal_1.inFixtureDir)("ignore/ignore-nested-directory", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
var sut, result;

@@ -320,6 +324,6 @@ return __generator(this, function (_a) {

}); });
exports.test("Should match any files in directory b or any files named b nested in directory a (relative to ignore file)", function () { return __awaiter(void 0, void 0, void 0, function () {
(0, exports.test)("Should match any files in directory b or any files named b nested in directory a (relative to ignore file)", 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("ignore/ignore-nested-file-or-directory", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
case 0: return [4 /*yield*/, (0, test_internal_1.inFixtureDir)("ignore/ignore-nested-file-or-directory", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
var sut, result;

@@ -326,0 +330,0 @@ return __generator(this, function (_a) {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -17,3 +21,3 @@ if (k2 === undefined) k2 = k;

var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);

@@ -37,3 +41,3 @@ return result;

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -68,12 +72,11 @@ if (y = 0, t) op = [op[0] & 2, t.value];

var test_internal_1 = require("@boll/test-internal");
var package_1 = require("../package");
exports.test = baretest_1.default("Source detector");
exports.test("should keep track of a disabled rule in a FileContext", function () { return __awaiter(void 0, void 0, void 0, function () {
exports.test = (0, baretest_1.default)("Source detector");
(0, exports.test)("should keep track of a disabled rule 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 () {
case 0: return [4 /*yield*/, (0, test_internal_1.inFixtureDir)("standalone-source-files", __dirname, function (cwd) { return __awaiter(void 0, void 0, void 0, function () {
var sut;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, file_context_1.getSourceFile(cwd, "simple-disable.ts", new package_1.Package({}, {}))];
case 0: return [4 /*yield*/, (0, file_context_1.getSourceFile)(cwd, "simple-disable.ts", {})];
case 1:

@@ -92,10 +95,10 @@ sut = _a.sent();

}); });
exports.test("should keep track of multiple disabled rules in a FileContext", function () { return __awaiter(void 0, void 0, void 0, function () {
(0, exports.test)("should keep track of multiple disabled 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 () {
case 0: return [4 /*yield*/, (0, test_internal_1.inFixtureDir)("standalone-source-files", __dirname, function (cwd) { return __awaiter(void 0, void 0, void 0, function () {
var sut;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, file_context_1.getSourceFile(cwd, "multiple-disable.ts", new package_1.Package({}, {}))];
case 0: return [4 /*yield*/, (0, file_context_1.getSourceFile)(cwd, "multiple-disable.ts", {})];
case 1:

@@ -114,10 +117,10 @@ sut = _a.sent();

}); });
exports.test("should keep track of a disabled next line rule in a FileContext", function () { return __awaiter(void 0, void 0, void 0, function () {
(0, exports.test)("should keep track of a disabled next line rule 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 () {
case 0: return [4 /*yield*/, (0, 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 0: return [4 /*yield*/, (0, file_context_1.getSourceFile)(cwd, "simple-disable-next-line.ts", {})];
case 1:

@@ -138,10 +141,10 @@ sut = _a.sent();

}); });
exports.test("should keep track of a disabled next line rules in a FileContext", function () { return __awaiter(void 0, void 0, void 0, function () {
(0, 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 () {
case 0: return [4 /*yield*/, (0, 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 0: return [4 /*yield*/, (0, file_context_1.getSourceFile)(cwd, "multiple-disable-next-line.ts", {})];
case 1:

@@ -148,0 +151,0 @@ sut = _a.sent();

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -17,3 +21,3 @@ if (k2 === undefined) k2 = k;

var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);

@@ -37,3 +41,3 @@ return result;

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -74,3 +78,3 @@ if (y = 0, t) op = [op[0] & 2, t.value];

var glob_1 = require("../glob");
exports.test = baretest_1.default("Suite result");
exports.test = (0, baretest_1.default)("Suite result");
var FakeFile = /** @class */ (function () {

@@ -90,3 +94,3 @@ function FakeFile() {

return __generator(this, function (_a) {
return [2 /*return*/, [new result_set_1.Failure(this.name, file.filename, boll_line_number_1.asBollLineNumber(0), "Something went wrong.")]];
return [2 /*return*/, [new result_set_1.Failure(this.name, file.filename, (0, boll_line_number_1.asBollLineNumber)(0), "Something went wrong.")]];
});

@@ -97,6 +101,6 @@ });

}());
exports.test("should log a failure as an error by default", function () { return __awaiter(void 0, void 0, void 0, function () {
(0, exports.test)("should log a failure as an error by default", 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("project-a", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
case 0: return [4 /*yield*/, (0, test_internal_1.inFixtureDir)("project-a", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
var ruleRegistry, config, myConfig, suite, results;

@@ -140,6 +144,6 @@ return __generator(this, function (_a) {

}); });
exports.test("should log a failure as a warning if configured in the rule", function () { return __awaiter(void 0, void 0, void 0, function () {
(0, exports.test)("should log a failure as a warning if configured in the rule", 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("project-a", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
case 0: return [4 /*yield*/, (0, test_internal_1.inFixtureDir)("project-a", __dirname, function () { return __awaiter(void 0, void 0, void 0, function () {
var ruleRegistry, config, myConfig, suite, results;

@@ -146,0 +150,0 @@ return __generator(this, function (_a) {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -17,3 +21,3 @@ if (k2 === undefined) k2 = k;

var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);

@@ -37,3 +41,3 @@ return result;

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -68,15 +72,14 @@ if (y = 0, t) op = [op[0] & 2, t.value];

var test_internal_1 = require("@boll/test-internal");
var package_1 = require("../package");
var result_set_1 = require("../result-set");
var suite_1 = require("../suite");
var boll_line_number_1 = require("../boll-line-number");
exports.test = baretest_1.default("Source detector");
exports.test("should skip a single disabled next line rules in a FileContext", function () { return __awaiter(void 0, void 0, void 0, function () {
exports.test = (0, baretest_1.default)("Source detector");
(0, exports.test)("should skip a single 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 () {
case 0: return [4 /*yield*/, (0, test_internal_1.inFixtureDir)("standalone-source-files", __dirname, function (cwd) { return __awaiter(void 0, void 0, void 0, function () {
var sut, suite, results, failure1, filteredResult;
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 0: return [4 /*yield*/, (0, file_context_1.getSourceFile)(cwd, "simple-disable-next-line.ts", {})];
case 1:

@@ -86,3 +89,3 @@ sut = _a.sent();

results = [];
failure1 = new result_set_1.Failure("MadeUpCheckName", sut.filename, boll_line_number_1.asBollLineNumber(4), "Failed due to MadeUpCheckName rule");
failure1 = new result_set_1.Failure("MadeUpCheckName", sut.filename, (0, boll_line_number_1.asBollLineNumber)(4), "Failed due to MadeUpCheckName rule");
results.push(failure1);

@@ -103,10 +106,10 @@ return [4 /*yield*/, suite.filterIgnoredChecksByLine(results, sut)];

}); });
exports.test("should skip a multiple disabled next line rules in a FileContext", function () { return __awaiter(void 0, void 0, void 0, function () {
(0, exports.test)("should skip a multiple 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 () {
case 0: return [4 /*yield*/, (0, test_internal_1.inFixtureDir)("standalone-source-files", __dirname, function (cwd) { return __awaiter(void 0, void 0, void 0, function () {
var sut, suite, results, failure, failure1, failure2, filteredResult;
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 0: return [4 /*yield*/, (0, file_context_1.getSourceFile)(cwd, "multiple-disable-next-line.ts", {})];
case 1:

@@ -116,7 +119,7 @@ sut = _a.sent();

results = [];
failure = new result_set_1.Failure("MadeUpCheckName", sut.filename, boll_line_number_1.asBollLineNumber(2), "Failed due to MadeUpCheckName rule");
failure = new result_set_1.Failure("MadeUpCheckName", sut.filename, (0, boll_line_number_1.asBollLineNumber)(2), "Failed due to MadeUpCheckName rule");
results.push(failure);
failure1 = new result_set_1.Failure("AlsoMadeUpName", sut.filename, boll_line_number_1.asBollLineNumber(2), "Failed due to MadeUpCheckName rule");
failure1 = new result_set_1.Failure("AlsoMadeUpName", sut.filename, (0, boll_line_number_1.asBollLineNumber)(2), "Failed due to MadeUpCheckName rule");
results.push(failure1);
failure2 = new result_set_1.Failure("MadeUpCheckName", sut.filename, boll_line_number_1.asBollLineNumber(5), "Failed due to MadeUpCheckName rule");
failure2 = new result_set_1.Failure("MadeUpCheckName", sut.filename, (0, boll_line_number_1.asBollLineNumber)(5), "Failed due to MadeUpCheckName rule");
results.push(failure2);

@@ -123,0 +126,0 @@ return [4 /*yield*/, suite.filterIgnoredChecksByLine(results, sut)];

import { BollFile } from "./boll-file";
import { FileContext } from "./file-context";
import { Result } from "./result-set";
import { Logger } from "./logger";
export interface CheckConfiguration {

@@ -34,6 +35,12 @@ rule: string;

}
export interface CheckFunctionOptions {
logger: Logger;
[key: string]: string | Logger;
}
export interface PackageRule extends Rule {
check(file: FileContext, options?: CheckFunctionOptions): Promise<Result[]>;
check(file: FileContext): Promise<Result[]>;
}
export interface PackageMetaRule extends Rule {
check(files: FileContext[], options?: CheckFunctionOptions): Promise<Result[]>;
check(files: FileContext[]): Promise<Result[]>;

@@ -58,2 +65,2 @@ }

}
export declare type CheckSeverity = "warn" | "error";
export type CheckSeverity = "warn" | "error";

@@ -10,3 +10,4 @@ {

"parse-gitignore": "^1.0.1",
"typescript": "^3.9.7",
"typescript": "^4.9.4",
"workspace-tools": "^0.29.1",
"yaml": "^1.10.0"

@@ -22,3 +23,3 @@ },

"baretest": "^2.0.0",
"prettier": "^2.0.5",
"prettier": "^2.8.1",
"rimraf": "^3.0.2",

@@ -50,3 +51,3 @@ "ts-node-dev": "^1.0.0-pre.58",

},
"version": "2.0.0"
"version": "3.0.0"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc