Comparing version 0.9.0-RC to 0.9.1-RC
{ | ||
"name": "svglint", | ||
"version": "0.9.0-RC", | ||
"version": "0.9.1-RC", | ||
"description": "Linter for SVGs", | ||
"main": "src/svglint.js", | ||
"bin": { "svglint": "./bin/cli.js" }, | ||
"bin": { | ||
"svglint": "./bin/cli.js" | ||
}, | ||
"keywords": [ | ||
@@ -8,0 +10,0 @@ "svg", |
@@ -11,4 +11,4 @@ const path = require("path"); | ||
*/ | ||
function getConfigurationFile(filename=".svglintrc.js", folder=__dirname) { | ||
let resolved = path.isAbsolute(filename) | ||
function getConfigurationFile(filename=".svglintrc.js", folder=process.cwd()) { | ||
const resolved = path.isAbsolute(filename) | ||
? filename | ||
@@ -24,3 +24,3 @@ : path.resolve(folder, filename); | ||
if (parent === folder) { | ||
return rej(new Error("Config file not found")); | ||
return rej(new Error(`Config file not found at '${resolved}'`)); | ||
} | ||
@@ -27,0 +27,0 @@ // if not, get next folder |
@@ -45,3 +45,3 @@ /** | ||
} else { | ||
this.update(); | ||
this.update(true); | ||
} | ||
@@ -53,5 +53,23 @@ } | ||
* Should be called any time anything has changed. | ||
* @param {Boolean} force If true, don't debounce | ||
*/ | ||
update() { | ||
update(force = false) { | ||
if (this.ci) { return; } | ||
clearTimeout(this._updateDebounce); | ||
this._lastUpdate = this._lastUpdate || 0; | ||
const cur = Date.now(); | ||
const exceededTimeout = (cur - this._lastUpdate) > 50; | ||
if (exceededTimeout || force) { | ||
this._update(); | ||
} else { | ||
this._updateDebounce = setTimeout(() => this._update(), 50); | ||
} | ||
} | ||
/** | ||
* Actually re-renders the GUI, without debouncing. | ||
* Shouldn't be called by an external user, unless they know what they're doing. | ||
*/ | ||
_update() { | ||
this._lastUpdate = Date.now(); | ||
logUpdate(this.render()); | ||
@@ -80,6 +98,9 @@ | ||
if (this.$lintings.length) { | ||
let $lintings = this.$lintings.filter( | ||
$linting => $linting.linting.state !== $linting.linting.STATES.success | ||
); | ||
outp.push( | ||
"", | ||
this.$titles.lints, | ||
this.$lintings | ||
$lintings | ||
.join("\n"), | ||
@@ -86,0 +107,0 @@ ); |
@@ -51,3 +51,3 @@ /** | ||
this.state = STATES.linting; | ||
/** If false, the linting has at least one rule that errored when executing */ | ||
/** If false, the linting has at least one rule that threw when executing */ | ||
this.valid = true; | ||
@@ -54,0 +54,0 @@ /** The name used for logging/human consumption */ |
@@ -8,6 +8,7 @@ const logger = require("../lib/logger")("rule:attr"); | ||
/** | ||
* @typedef {Object<string,string|string[]|boolean>} AttrConfig | ||
* @typedef {Object<string,string|string[]|boolean|RegExp>} AttrConfig | ||
* The key represents the attribute name. The value has the following meanings: | ||
* - `{Boolean}` If true, the attr must exist. If false, it must not exist. | ||
* - `{String}` The attr value must match this exactly. It must also exist. | ||
* - `{RegExp}` The attr value must match the regex. | ||
* - `{Array<String>}` The attr value must be one of these. It must also exist. | ||
@@ -67,9 +68,9 @@ * | ||
const value = attrs[attrib]; | ||
const conf = config[attrib]; | ||
const expected = config[attrib]; | ||
let handled = false; | ||
// check each type | ||
switch (typeof conf) { | ||
switch (typeof expected) { | ||
case "boolean": | ||
handled = true; | ||
if (conf === false) { | ||
if (expected === false) { | ||
reporter.error( | ||
@@ -84,5 +85,5 @@ `Attribute '${attrib}' is disallowed`, | ||
handled = true; | ||
if (value !== config) { | ||
if (value !== expected) { | ||
reporter.error( | ||
`Expected attribute '${attrib}' to be "${conf}", was "${value}"`, | ||
`Expected attribute '${attrib}' to be "${expected}", was "${value}"`, | ||
$elm, | ||
@@ -94,8 +95,8 @@ ast | ||
case "object": | ||
if (conf instanceof Array) { | ||
if (expected instanceof Array) { | ||
handled = true; | ||
if (!conf.includes(value)) { | ||
if (!expected.includes(value)) { | ||
reporter.error( | ||
`Expected attribute '${attrib}' to be one of ${ | ||
JSON.stringify(conf) | ||
JSON.stringify(expected) | ||
}, was "${value}"`, | ||
@@ -106,6 +107,15 @@ $elm, | ||
} | ||
} else if (expected instanceof RegExp) { | ||
handled = true; | ||
if (!expected.test(value)) { | ||
reporter.error( | ||
`Expected attribute '${attrib}' to match ${expected}, was "${value}"`, | ||
$elm, | ||
ast | ||
); | ||
} | ||
} else { | ||
reporter.warn( | ||
`Unknown config for attribute '${attrib}' (${ | ||
JSON.stringify(conf) | ||
JSON.stringify(expected) | ||
}), ignoring`, | ||
@@ -112,0 +122,0 @@ $elm, |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
109239
2211
0