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.3.0 to 1.4.0

17

CHANGELOG.json

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

{
"date": "Thu, 22 Oct 2020 18:26:06 GMT",
"date": "Tue, 27 Oct 2020 20:20:29 GMT",
"tag": "@boll/core_v1.4.0",
"version": "1.4.0",
"comments": {
"minor": [
{
"comment": "Allow downstream configuration more control over globs and options.",
"author": "jdh@microsoft.com",
"commit": "520017ec2b79b581f322ab88207f1c058bef7758",
"package": "@boll/core"
}
]
}
},
{
"date": "Thu, 22 Oct 2020 18:26:52 GMT",
"tag": "@boll/core_v1.3.0",

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

# Change Log - @boll/core
This log was last generated on Thu, 22 Oct 2020 18:26:06 GMT and should not be manually modified.
This log was last generated on Tue, 27 Oct 2020 20:20:29 GMT and should not be manually modified.
<!-- Start content -->
## 1.4.0
Tue, 27 Oct 2020 20:20:29 GMT
### Minor changes
- Allow downstream configuration more control over globs and options. (jdh@microsoft.com)
## 1.3.0
Thu, 22 Oct 2020 18:26:06 GMT
Thu, 22 Oct 2020 18:26:52 GMT

@@ -11,0 +19,0 @@ ### Minor changes

@@ -18,2 +18,3 @@ import { ConfigDefinition } from "./types";

resolveParentConfiguration(baseConfigName: string | null | undefined): ConfigDefinition;
private mergeConfigurations;
}

@@ -41,2 +41,8 @@ "use strict";

var exclude = __spreadArrays((ruleSetConfig.exclude || []), (config.exclude || []));
if (ruleSetConfig.name &&
config.configuration &&
config.configuration.ruleSets &&
config.configuration.ruleSets[ruleSetConfig.name]) {
exclude = __spreadArrays(exclude, (config.configuration.ruleSets[ruleSetConfig.name].exclude || []));
}
var glob = ruleSetConfig.fileLocator;

@@ -46,3 +52,5 @@ glob.exclude = exclude;

var checks = (ruleSetConfig.checks || []).map(function (check) {
return _this.ruleRegistry.get(check.rule)(_this.logger, check.options);
var optionsFromConfig = (config.configuration && config.configuration.rules && config.configuration.rules[check.rule]) || {};
var options = __assign(__assign({}, check.options), optionsFromConfig);
return _this.ruleRegistry.get(check.rule)(_this.logger, options);
});

@@ -55,5 +63,6 @@ return new rule_set_1.RuleSet(glob, checks);

};
// TODO this will need a hand-crafted "deep merge" at some point
Config.prototype.resolvedConfiguration = function () {
return __assign(__assign({}, this.resolveParentConfiguration(this.configuration.extends)), this.configuration);
var parentConfiguration = this.resolveParentConfiguration(this.configuration.extends);
var finalResult = this.mergeConfigurations(this.configuration, parentConfiguration);
return finalResult;
};

@@ -65,6 +74,41 @@ Config.prototype.resolveParentConfiguration = function (baseConfigName) {

var baseConfig = this.configRegistry.get(baseConfigName);
return __assign(__assign({}, this.resolveParentConfiguration(baseConfig.extends)), baseConfig);
var parentConfig = this.resolveParentConfiguration(baseConfig.extends);
return this.mergeConfigurations(parentConfig, baseConfig);
};
Config.prototype.mergeConfigurations = function (parentConfiguration, childConfiguration) {
var obj = {
configuration: {
rules: {},
ruleSets: {}
}
};
if (childConfiguration.name) {
obj.name = childConfiguration.name;
}
obj.ruleSets = __spreadArrays((parentConfiguration.ruleSets || []), (childConfiguration.ruleSets || []));
obj.exclude = __spreadArrays((parentConfiguration.exclude || []), (childConfiguration.exclude || []));
if (parentConfiguration.configuration && parentConfiguration.configuration.ruleSets) {
Object.keys(parentConfiguration.configuration.ruleSets).forEach(function (k) {
obj.configuration.ruleSets[k] = parentConfiguration.configuration.ruleSets[k];
});
}
if (parentConfiguration.configuration && parentConfiguration.configuration.rules) {
Object.keys(parentConfiguration.configuration.rules).forEach(function (k) {
obj.configuration.rules[k] = parentConfiguration.configuration.rules[k];
});
}
if (childConfiguration.configuration && childConfiguration.configuration.ruleSets) {
Object.keys(childConfiguration.configuration.ruleSets).forEach(function (k) {
obj.configuration.ruleSets[k] = childConfiguration.configuration.ruleSets[k];
});
}
if (childConfiguration.configuration && childConfiguration.configuration.rules) {
Object.keys(childConfiguration.configuration.rules).forEach(function (k) {
obj.configuration.rules[k] = childConfiguration.configuration.rules[k];
});
}
return obj;
};
return Config;
}());
exports.Config = Config;

@@ -70,3 +70,5 @@ "use strict";

var FakeRule = /** @class */ (function () {
function FakeRule() {
function FakeRule(options) {
if (options === void 0) { options = {}; }
this.options = options;
this.name = "fakerule";

@@ -134,1 +136,65 @@ }

});
exports.test("downstream rules configuration applies to rules", function () {
var configRegistry = new config_registry_1.ConfigRegistry();
configRegistry.register({
name: "base",
ruleSets: [{ fileLocator: new FakeGlob(), checks: [{ rule: "foo", options: { bar: "baz" } }] }]
});
var ruleRegistry = new rule_registry_1.RuleRegistry();
ruleRegistry.register("foo", function (l, options) {
return new FakeRule(options);
});
var config = new config_1.Config(configRegistry, ruleRegistry, logger_1.NullLogger);
var myConfig = {
extends: "base",
configuration: {
rules: {
foo: { some: "rule" }
}
}
};
config.load(myConfig);
var suite = config.buildSuite();
var fakeRuleInstance = suite.ruleSets[0].checks[0];
assert.deepStrictEqual(fakeRuleInstance.options, { bar: "baz", some: "rule" });
});
exports.test("downstream ruleSet configuration applies to ruleSets", function () {
var configRegistry = new config_registry_1.ConfigRegistry();
configRegistry.register({
name: "base",
ruleSets: [{ fileLocator: new FakeGlob(), name: "fake", exclude: ["bar"] }],
exclude: ["baz"]
});
var config = new config_1.Config(configRegistry, new rule_registry_1.RuleRegistry(), logger_1.NullLogger);
var myConfig = {
extends: "base",
exclude: ["foo2"],
configuration: {
ruleSets: {
fake: {
exclude: ["foo"]
}
}
}
};
config.load(myConfig);
var suite = config.buildSuite();
var ruleSet = suite.ruleSets[0];
assert.deepStrictEqual(ruleSet.fileGlob.exclude, ["bar", "foo2", "baz", "foo"]);
});
exports.test("resolveConfiguration merges exclude", function () {
var configRegistry = new config_registry_1.ConfigRegistry();
configRegistry.register({
name: "base",
exclude: ["baz"]
});
configRegistry.register({
name: "child",
exclude: ["foo"],
extends: "base"
});
var config = new config_1.Config(configRegistry, new rule_registry_1.RuleRegistry(), logger_1.NullLogger);
config.load({ extends: "child" });
var result = config.resolvedConfiguration();
assert.deepStrictEqual(result.exclude, ["baz", "foo"]);
});

@@ -13,2 +13,3 @@ import { BollFile } from "./boll-file";

include?: string[];
name?: string;
}

@@ -20,2 +21,6 @@ export interface ConfigDefinition {

ruleSets?: RuleSetConfiguration[];
configuration?: {
rules?: {};
ruleSets?: {};
};
}

@@ -22,0 +27,0 @@ export interface PackageRule {

2

package.json

@@ -46,3 +46,3 @@ {

},
"version": "1.3.0"
"version": "1.4.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