New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

svglint

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svglint - npm Package Compare versions

Comparing version 2.2.0 to 2.3.0

23

bin/cli.js

@@ -20,2 +20,10 @@ #!/usr/bin/env node

const EXIT_CODES = Object.freeze({
success: 0,
violations: 1,
unexpected: 2,
interrupted: 3,
configuration: 4,
});
// used by meow's loud reject

@@ -28,5 +36,10 @@ // eslint-disable-next-line no-console

logger.error(err);
process.exit(1);
process.exit(EXIT_CODES.unexpected);
});
// Handle SIGINT
process.on("SIGINT", () => {
process.exit(EXIT_CODES.interrupted);
});
// Generates the CLI binding using meow

@@ -74,3 +87,3 @@ const cli = meow(`

logger.error("Configuration file not found");
process.exit(1);
process.exit(EXIT_CODES.configuration);
}

@@ -80,3 +93,3 @@ }

logger.error(`Failed to parse config: ${e.stack}`);
process.exit(1);
process.exit(EXIT_CODES.configuration);
}

@@ -92,3 +105,5 @@

if (activeLintings <= 0) {
process.exit(hasErrors ? 1 : 0);
process.exit(
hasErrors ? EXIT_CODES.violations : EXIT_CODES.success
);
}

@@ -95,0 +110,0 @@ };

{
"name": "svglint",
"version": "2.2.0",
"version": "2.3.0",
"description": "Linter for SVGs",

@@ -26,2 +26,9 @@ "type": "module",

"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/birjj/svglint"
},
"bugs": {
"url": "https://github.com/birjj/svglint/issues"
},
"scripts": {

@@ -28,0 +35,0 @@ "lint": "eslint .",

4

src/lib/reporter.js

@@ -67,6 +67,6 @@ /**

/**
* Reports that an exception occured during rule processing.
* Reports that an exception occurred during rule processing.
* This doesn't change the current linting result, but is important to show
* to users as it indicates that the linting result cannot be trusted.
* @param {Error} e The exception that occured.
* @param {Error} e The exception that occurred.
*/

@@ -73,0 +73,0 @@ exception(e) {

@@ -10,2 +10,3 @@ import Logger from "../lib/logger.js";

* @typedef {Object<string,string|string[]|boolean|RegExp>} AttrConfig
*
* The key represents the attribute name. The value has the following meanings:

@@ -21,2 +22,3 @@ * - `{Boolean}` If true, the attr must exist. If false, it must not exist.

* - `{ "rule::order": {Array<String> | Boolean} }` Default `null`. As array, attributes must be defined in the provided order. As `true`, attributes must be defined in alphabetical order.
* - `{ "<attribute>?": {Boolean|String|RegExp|Array<String>} }` Appending a `?` to an attribute name will make that attribute optional, and it will not error if it is missing when `rule::whitelist` is set.
*/

@@ -34,3 +36,3 @@

* - If disallowed, error and remove it from the attr list
* - If whitelist is true, error if there are attributes left
* - If whitelist is true, error if there are non-optional attributes left
*/

@@ -40,2 +42,6 @@

const OPTIONAL_SUFFIX = "?";
const isAttrOptional = (attr) => attr.endsWith(OPTIONAL_SUFFIX);
/**

@@ -56,15 +62,11 @@ * Executes on a single element.

if (SPECIAL_ATTRIBS.includes(attrib)) { return; }
// if it must exist
const conf = config[attrib];
if (conf === true
|| conf instanceof Array
|| typeof conf === "string"
|| conf instanceof RegExp) {
if (attrs[attrib] === undefined) {
reporter.error(
`Expected attribute '${attrib}', didn't find it`,
$elm,
ast
);
}
// do nothing with optional attributes
if (isAttrOptional(attrib)) { return; }
// if defined and not false it must exist
if (config[attrib] && !(attrib in attrs)) {
reporter.error(
`Expected attribute '${attrib}', didn't find it`,
$elm,
ast
);
}

@@ -112,3 +114,3 @@ }

const value = attrs[attrib];
const expected = config[attrib];
const expected = typeof config[attrib] !== "undefined" ? config[attrib] : config[`${attrib}${OPTIONAL_SUFFIX}`];
let handled = false;

@@ -179,3 +181,4 @@ // check each type

if (config["rule::whitelist"]) {
const remaining = Object.keys(attrs);
const remaining = Object.keys(attrs).filter((attr) => !isAttrOptional(attr));
if (remaining.length) {

@@ -182,0 +185,0 @@ reporter.error(

Sorry, the diff of this file is not supported yet

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