diff --git a/lib/svgo/coa.js b/lib/svgo/coa.js index 8950ffc..97c8ffa 100644 --- a/lib/svgo/coa.js +++ b/lib/svgo/coa.js @@ -58,18 +58,23 @@ export default function makeProgram() { '--exclude ', "Use with '--folder'. Exclude files matching regular expression pattern.", ) - .option( - '--preset ', - 'Specify which set of predefined plugins to use', - 'default', + .addOption( + new Option( + '--preset ', + 'Specify which set of predefined plugins to use', + ) + .default('default') + .choices(['default', 'none', 'next']), ) .option( '--enable ', 'Specify one or more builtin plugins to run in addition to those in the preset or config', ) - .option( - '--options ', - 'Path to a JSON file containing configuration parameters for enabled plugins', + .addOption( + new Option( + '--options ', + 'Path to a JSON file containing configuration parameters for enabled plugins', + ).conflicts('config'), ) .option( '--disable ', diff --git a/package.json b/package.json index 6ba19dd..7afec8b 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ }, "devDependencies": { "@eslint/js": "^9.12.0", - "@rollup/plugin-commonjs": "^28.0.0", + "@rollup/plugin-commonjs": "^28.0.1", "@rollup/plugin-node-resolve": "^15.3.0", "@rollup/plugin-terser": "^0.4.4", "@types/csso": "^5.0.4", diff --git a/plugins/round.js b/plugins/round.js index a2cc74d..2312aca 100644 --- a/plugins/round.js +++ b/plugins/round.js @@ -194,7 +194,7 @@ function getCoordContext(element, digits) { } const viewBox = element.attributes.viewBox; - if (viewBox) { + if (typeof viewBox === 'string' && viewBox) { const vbParsed = viewBox.trim().split(/\s+/); if (vbParsed.length === 4) { const width = parseFloat(vbParsed[2]); @@ -275,13 +275,13 @@ function roundOpacity(attValue, digits) { } /** - * @param {string} attValue + * @param {import('../lib/types.js').SVGAttValue} attValue * @param {number|null} xDigits * @param {number|null} yDigits * @returns {string|null} */ function roundPath(attValue, xDigits, yDigits) { - if (xDigits === null || yDigits === null) { + if (typeof attValue !== 'string' || xDigits === null || yDigits === null) { return null; } const commands = parsePathCommands(attValue); diff --git a/yarn.lock b/yarn.lock index a456dbf..83b83d2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -858,23 +858,23 @@ __metadata: languageName: node linkType: hard -"@rollup/plugin-commonjs@npm:^28.0.0": - version: 28.0.0 - resolution: "@rollup/plugin-commonjs@npm:28.0.0" +"@rollup/plugin-commonjs@npm:^28.0.1": + version: 28.0.1 + resolution: "@rollup/plugin-commonjs@npm:28.0.1" dependencies: "@rollup/pluginutils": ^5.0.1 commondir: ^1.0.1 estree-walker: ^2.0.2 - fdir: ^6.1.1 + fdir: ^6.2.0 is-reference: 1.2.1 magic-string: ^0.30.3 - picomatch: ^2.3.1 + picomatch: ^4.0.2 peerDependencies: rollup: ^2.68.0||^3.0.0||^4.0.0 peerDependenciesMeta: rollup: optional: true - checksum: cd2dbb85375a077dae326da482b8590552e18267f17b6213bfa638824c50384e01376579535a9ab7d42a8fc2c674cc0ef8d850a8c36878cc182f8e32b634d0ad + checksum: b230b2733b7198fca1b585f6b237ab05f3305ef7a50083caff28baef0fd611c0e90399ea7548181f97a4d0b0372487ca27f81327e355db495396a0fb8934244d languageName: node linkType: hard @@ -2249,7 +2249,7 @@ __metadata: languageName: node linkType: hard -"fdir@npm:^6.1.1": +"fdir@npm:^6.2.0": version: 6.4.0 resolution: "fdir@npm:6.4.0" peerDependencies: @@ -3914,6 +3914,13 @@ __metadata: languageName: node linkType: hard +"picomatch@npm:^4.0.2": + version: 4.0.2 + resolution: "picomatch@npm:4.0.2" + checksum: a7a5188c954f82c6585720e9143297ccd0e35ad8072231608086ca950bee672d51b0ef676254af0788205e59bd4e4deb4e7708769226bed725bf13370a7d1464 + languageName: node + linkType: hard + "pirates@npm:^4.0.4": version: 4.0.6 resolution: "pirates@npm:4.0.6" @@ -4533,7 +4540,7 @@ __metadata: resolution: "svgo-ll@workspace:." dependencies: "@eslint/js": ^9.12.0 - "@rollup/plugin-commonjs": ^28.0.0 + "@rollup/plugin-commonjs": ^28.0.1 "@rollup/plugin-node-resolve": ^15.3.0 "@rollup/plugin-terser": ^0.4.4 "@types/csso": ^5.0.4