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 1.0.1 to 1.0.2

dist/eslint-rules.d.ts

17

CHANGELOG.json

@@ -5,3 +5,18 @@ {

{
"date": "Thu, 17 Sep 2020 22:06:33 GMT",
"date": "Fri, 18 Sep 2020 17:09:55 GMT",
"tag": "@boll/core_v1.0.2",
"version": "1.0.2",
"comments": {
"patch": [
{
"comment": "Add ESLint rule",
"author": "email not defined",
"commit": "a0e085a50c4e57a28850195287716ed5eb68cb2e",
"package": "@boll/core"
}
]
}
},
{
"date": "Thu, 17 Sep 2020 22:06:55 GMT",
"tag": "@boll/core_v1.0.1",

@@ -8,0 +23,0 @@ "version": "1.0.1",

# Change Log - @boll/core
This log was last generated on Thu, 17 Sep 2020 22:06:33 GMT and should not be manually modified.
This log was last generated on Fri, 18 Sep 2020 17:09:55 GMT and should not be manually modified.
<!-- Start content -->
## 1.0.2
Fri, 18 Sep 2020 17:09:55 GMT
### Patches
- Add ESLint rule (email not defined)
## 1.0.1
Thu, 17 Sep 2020 22:06:33 GMT
Thu, 17 Sep 2020 22:06:55 GMT

@@ -11,0 +19,0 @@ ### Patches

4

dist/config.d.ts

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

import { ConfigDefinition, Rule, FileGlob } from "./types";
import { ConfigDefinition, PackageRule, FileGlob } from "./types";
import { RuleRegistry } from "./rule-registry";

@@ -11,3 +11,3 @@ import { Suite } from "./suite";

buildSuite(): Suite;
loadChecks(): Rule[];
loadChecks(): PackageRule[];
buildFileGlob(): FileGlob;

@@ -14,0 +14,0 @@ load(def: ConfigDefinition): void;

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

Config.prototype.buildSuite = function () {
var suite = new suite_1.Suite();
var suite = new suite_1.Suite(this.resolvedConfiguration());
suite.checks = this.loadChecks();

@@ -27,0 +27,0 @@ suite.fileGlob = this.buildFileGlob();

import ts from "typescript";
import { BollDirectory } from "./boll-directory";
import { BollFile } from "./boll-file";
import { ESLintRules } from "./eslint-rules";
import { DependencyMap, Package } from "./package";
import { Rule } from "./types";
import { PackageRule } from "./types";
export declare class FileContext {

@@ -11,2 +12,3 @@ packageRoot: BollDirectory;

content: string;
private eslintRules;
private _parsedIgnoreChecks;

@@ -16,8 +18,11 @@ private _ignoredChecks;

private _sourceFile?;
constructor(packageRoot: BollDirectory, packageContext: Package, filename: BollFile, content: string);
private _eslintConfigLoaded;
private _eslintConfig?;
constructor(packageRoot: BollDirectory, packageContext: Package, filename: BollFile, content: string, eslintRules: ESLintRules);
get source(): ts.SourceFile;
get eslintConfig(): Promise<any>;
get packageDependencies(): DependencyMap;
get ignoredChecks(): string[];
shouldSkip(r: Rule): boolean;
shouldSkip(r: PackageRule): boolean;
}
export declare function getSourceFile(projectRoot: BollDirectory, filename: string, packageContext: Package): Promise<FileContext>;
export declare function getSourceFile(projectRoot: BollDirectory, filename: string, packageContext: Package, eslintRules: ESLintRules): Promise<FileContext>;

@@ -43,9 +43,9 @@ "use strict";

exports.getSourceFile = exports.FileContext = void 0;
var fs_1 = __importDefault(require("fs"));
var graceful_fs_1 = __importDefault(require("graceful-fs"));
var typescript_1 = __importDefault(require("typescript"));
var util_1 = require("util");
var boll_file_1 = require("./boll-file");
var readFileAsync = util_1.promisify(fs_1.default.readFile);
var readFileAsync = util_1.promisify(graceful_fs_1.default.readFile);
var FileContext = /** @class */ (function () {
function FileContext(packageRoot, packageContext, filename, content) {
function FileContext(packageRoot, packageContext, filename, content, eslintRules) {
this.packageRoot = packageRoot;

@@ -55,2 +55,3 @@ this.packageContext = packageContext;

this.content = content;
this.eslintRules = eslintRules;
this._parsedIgnoreChecks = false;

@@ -60,2 +61,4 @@ this._ignoredChecks = [];

this._sourceFile = undefined;
this._eslintConfigLoaded = false;
this._eslintConfig = undefined;
}

@@ -73,2 +76,13 @@ Object.defineProperty(FileContext.prototype, "source", {

});
Object.defineProperty(FileContext.prototype, "eslintConfig", {
get: function () {
if (this._eslintConfigLoaded)
return this._eslintConfig;
this._eslintConfig = this.eslintRules.getSourceFileConfig(boll_file_1.asBollFile(this.source.fileName));
this._eslintConfigLoaded = true;
return this._eslintConfig;
},
enumerable: false,
configurable: true
});
Object.defineProperty(FileContext.prototype, "packageDependencies", {

@@ -108,3 +122,3 @@ get: function () {

exports.FileContext = FileContext;
function getSourceFile(projectRoot, filename, packageContext) {
function getSourceFile(projectRoot, filename, packageContext, eslintRules) {
return __awaiter(this, void 0, void 0, function () {

@@ -119,3 +133,3 @@ var bollFile, content;

content = _a.sent();
return [2 /*return*/, new FileContext(projectRoot, packageContext, bollFile, content.toString("utf8"))];
return [2 /*return*/, new FileContext(projectRoot, packageContext, bollFile, content.toString("utf8"), eslintRules)];
}

@@ -122,0 +136,0 @@ });

@@ -60,2 +60,3 @@ "use strict";

paths = _d.sent();
paths = paths.filter(function (path) { return !path.includes("node_modules"); });
if (!this.options.exclude) return [3 /*break*/, 5];

@@ -62,0 +63,0 @@ _loop_1 = function (excludeGlob) {

export * from "./boll-directory";
export * from "./boll-file";
export * from "./boll-line-number";
export * from "./config-context";
export * from "./config-registry";
export * from "./config-rule-base";
export * from "./config";
export * from "./constants";
export * from "./eslint-rules";
export * from "./file-context";

@@ -10,0 +9,0 @@ export * from "./glob";

@@ -16,7 +16,6 @@ "use strict";

__exportStar(require("./boll-line-number"), exports);
__exportStar(require("./config-context"), exports);
__exportStar(require("./config-registry"), exports);
__exportStar(require("./config-rule-base"), exports);
__exportStar(require("./config"), exports);
__exportStar(require("./constants"), exports);
__exportStar(require("./eslint-rules"), exports);
__exportStar(require("./file-context"), exports);

@@ -23,0 +22,0 @@ __exportStar(require("./glob"), exports);

@@ -8,2 +8,3 @@ declare type MessagePrinter = (msg: string) => void;

log(msg: string): void;
warn(msg: string): void;
error(msg: string): void;

@@ -10,0 +11,0 @@ }

@@ -13,2 +13,5 @@ "use strict";

};
Logger.prototype.warn = function (msg) {
this.warnPrinter(msg);
};
Logger.prototype.error = function (msg) {

@@ -15,0 +18,0 @@ this.errorPrinter(msg);

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

import { Rule } from "./types";
export declare type RuleDefinition = () => Rule;
import { PackageRule } from "./types";
export declare type RuleDefinition = () => PackageRule;
export declare class RuleRegistry {

@@ -4,0 +4,0 @@ registrations: {

@@ -1,11 +0,14 @@

import { FileGlob, Rule } from "./types";
import { FileGlob, ConfigDefinition, PackageRule } from "./types";
import { Logger } from "./logger";
import { ResultSet } from "./result-set";
export declare class Suite {
private config;
private _hasRun;
fileGlob: FileGlob;
checks: Rule[];
checks: PackageRule[];
constructor(config: ConfigDefinition);
get hasRun(): boolean;
run(logger: Logger): Promise<ResultSet>;
private loadPackage;
private getESLintRules;
}

@@ -51,5 +51,7 @@ "use strict";

var util_1 = require("util");
var eslint_rules_1 = require("./eslint-rules");
var readFileAsync = util_1.promisify(fs_1.default.readFile);
var Suite = /** @class */ (function () {
function Suite() {
function Suite(config) {
this.config = config;
this._hasRun = false;

@@ -68,3 +70,4 @@ this.fileGlob = new glob_1.TypescriptSourceGlob();

return __awaiter(this, void 0, void 0, function () {
var resultSet, packageContext, sourceFilePaths, projectRoot, sourceFiles;
var resultSet, packageContext, sourceFilePaths, eslintRules, projectRoot, sourceFiles;
var _this = this;
return __generator(this, function (_a) {

@@ -81,13 +84,23 @@ switch (_a.label) {

sourceFilePaths = _a.sent();
eslintRules = this.getESLintRules(logger);
projectRoot = boll_directory_1.asBollDirectory(process.cwd());
return [4 /*yield*/, Promise.all(sourceFilePaths.map(function (filename) { return file_context_1.getSourceFile(projectRoot, filename, packageContext); }))];
return [4 /*yield*/, Promise.all(sourceFilePaths.map(function (filename) { return file_context_1.getSourceFile(projectRoot, filename, packageContext, eslintRules); }))];
case 3:
sourceFiles = _a.sent();
this.checks.forEach(function (r) {
sourceFiles.forEach(function (s) {
if (s.shouldSkip(r))
return;
var results = r.check(s);
resultSet.add(results);
});
sourceFiles.forEach(function (s) { return __awaiter(_this, void 0, void 0, function () {
var results;
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();
resultSet.add(results);
return [2 /*return*/];
}
});
}); });
});

@@ -124,4 +137,11 @@ return [2 /*return*/, resultSet];

};
Suite.prototype.getESLintRules = function (logger) {
var resolvePluginsRelativeTo = this.config.eslintOptions && this.config.eslintOptions.resolvePluginsRelativeTo;
var fullPath = resolvePluginsRelativeTo && path_1.default.resolve(process.cwd(), resolvePluginsRelativeTo);
return fullPath
? new eslint_rules_1.ESLintRules({ resolvePluginsRelativeTo: boll_directory_1.asBollDirectory(fullPath), logger: logger })
: new eslint_rules_1.ESLintRules({ logger: logger });
};
return Suite;
}());
exports.Suite = Suite;

@@ -40,2 +40,3 @@ "use strict";

var config_test_1 = require("./config.test");
var eslint_rules_test_1 = require("./eslint-rules.test");
var format_test_1 = require("./format.test");

@@ -51,11 +52,14 @@ var glob_test_1 = require("./glob.test");

_a.sent();
return [4 /*yield*/, format_test_1.test.run()];
return [4 /*yield*/, eslint_rules_test_1.test.run()];
case 2:
_a.sent();
return [4 /*yield*/, glob_test_1.test.run()];
return [4 /*yield*/, format_test_1.test.run()];
case 3:
_a.sent();
return [4 /*yield*/, pragma_test_1.test.run()];
return [4 /*yield*/, glob_test_1.test.run()];
case 4:
_a.sent();
return [4 /*yield*/, pragma_test_1.test.run()];
case 5:
_a.sent();
return [2 /*return*/];

@@ -62,0 +66,0 @@ }

@@ -21,2 +21,38 @@ "use strict";

};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) 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;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -38,3 +74,7 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

FakeRule.prototype.check = function (file) {
throw new Error("Method not implemented.");
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
throw new Error("Method not implemented.");
});
});
};

@@ -66,3 +106,3 @@ return FakeRule;

var suite = config.buildSuite();
assert.deepEqual(suite.fileGlob.exclude, ["testme"]);
assert.deepStrictEqual(suite.fileGlob.exclude, ["testme"]);
});

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

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

@@ -150,3 +150,3 @@ }

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

@@ -153,0 +153,0 @@ }

@@ -67,2 +67,3 @@ "use strict";

var package_1 = require("../package");
var eslint_rules_1 = require("../eslint-rules");
exports.test = baretest_1.default("Source detector");

@@ -76,6 +77,6 @@ exports.test("should keep track of a disabled rule in a FileContext", function () { return __awaiter(void 0, void 0, void 0, function () {

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*/, file_context_1.getSourceFile(cwd, "simple-disable.ts", new package_1.Package({}), new eslint_rules_1.ESLintRules())];
case 1:
sut = _a.sent();
assert.deepEqual(sut.ignoredChecks, ["MadeUpCheckName"]);
assert.deepStrictEqual(sut.ignoredChecks, ["MadeUpCheckName"]);
return [2 /*return*/];

@@ -98,6 +99,6 @@ }

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*/, file_context_1.getSourceFile(cwd, "multiple-disable.ts", new package_1.Package({}), new eslint_rules_1.ESLintRules())];
case 1:
sut = _a.sent();
assert.deepEqual(sut.ignoredChecks, ["MadeUpCheckName", "AlsoMadeUpName"]);
assert.deepStrictEqual(sut.ignoredChecks, ["MadeUpCheckName", "AlsoMadeUpName"]);
return [2 /*return*/];

@@ -104,0 +105,0 @@ }

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

@@ -15,13 +14,11 @@ rule: string;

include?: string[];
eslintOptions?: ESLintOptions;
}
export interface Rule {
export interface ESLintOptions {
resolvePluginsRelativeTo?: string;
}
export interface PackageRule {
name: string;
check(file: any): Result[];
check(file: FileContext): Promise<Result[]>;
}
export interface PackageRule extends Rule {
check(file: FileContext): Result[];
}
export interface ConfigRule extends Rule {
check(file: ConfigContext): Result[];
}
export declare enum ResultStatus {

@@ -28,0 +25,0 @@ success = 0,

@@ -7,3 +7,5 @@ {

"dependencies": {
"eslint": "^7.8.1",
"glob": "^7.1.6",
"graceful-fs": "4.2.4",
"typescript": "^3.9.7",

@@ -15,5 +17,8 @@ "yaml": "^1.10.0"

"@types/baretest": "^2.0.0",
"@types/eslint": "^7.2.2",
"@types/glob": "^7.1.3",
"@types/graceful-fs": "4.1.3",
"baretest": "^2.0.0",
"prettier": "^2.0.5",
"rimraf": "^3.0.2",
"ts-node-dev": "^1.0.0-pre.58",

@@ -40,6 +45,7 @@ "typedoc": "^0.19.1",

"build": "tsc",
"clean": "rimraf ./dist",
"docs": "typedoc --mode file --out ./docs --theme markdown ./src",
"test": "node dist/tests/all.test.js"
},
"version": "1.0.1"
"version": "1.0.2"
}
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