From 520e64b53acbb060f9c3a3bc5126b40bff038ce6 Mon Sep 17 00:00:00 2001 From: Seth Falco Date: Thu, 25 Jan 2024 19:11:51 +0000 Subject: [PATCH] chore: add optional schema prop to plugins --- .../add-attributes-to-svg-elements.mdx | 5 - .../03-plugins/add-classes-to-svg-element.mdx | 6 - docs/03-plugins/cleanup-attrs.mdx | 13 - docs/03-plugins/cleanup-ids.mdx | 16 - docs/03-plugins/cleanup-list-of-values.mdx | 13 - docs/03-plugins/cleanup-numeric-values.mdx | 13 - docs/03-plugins/convert-colors.mdx | 19 - docs/03-plugins/convert-path-data.mdx | 47 - docs/03-plugins/convert-shape-to-path.mdx | 7 - docs/03-plugins/convert-style-to-attrs.mdx | 5 - docs/03-plugins/convert-transform.mdx | 30 - docs/03-plugins/inline-styles.mdx | 11 - docs/03-plugins/merge-paths.mdx | 9 - docs/03-plugins/minify-styles.mdx | 4 - docs/03-plugins/prefix-ids.mdx | 12 - .../remove-attributes-by-selector.mdx | 4 - docs/03-plugins/remove-attrs.mdx | 10 - docs/03-plugins/remove-comments.mdx | 5 - docs/03-plugins/remove-deprecated-attrs.mdx | 5 - docs/03-plugins/remove-desc.mdx | 5 - docs/03-plugins/remove-editors-ns-data.mdx | 4 - docs/03-plugins/remove-elements-by-attr.mdx | 7 - docs/03-plugins/remove-empty-text.mdx | 10 - docs/03-plugins/remove-hidden-elems.mdx | 46 - .../remove-unknowns-and-defaults.mdx | 25 - .../remove-useless-stroke-and-fill.mdx | 10 - docs/03-plugins/remove-xlink.mdx | 4 - docs/03-plugins/sort-attrs.mdx | 24 - lib/svgo.d.ts | 9 + package.json | 1 + plugins/addAttributesToSVGElement.js | 23 + plugins/addClassesToSVGElement.js | 23 + plugins/cleanupAttrs.js | 31 + plugins/cleanupEnableBackground.js | 1 + plugins/cleanupIds.js | 46 + plugins/cleanupListOfValues.js | 37 + plugins/cleanupNumericValues.js | 37 + plugins/collapseGroups.js | 1 + plugins/convertColors.js | 52 + plugins/convertEllipseToCircle.js | 1 + plugins/convertOneStopGradients.js | 2 + plugins/convertPathData.js | 111 ++ plugins/convertShapeToPath.js | 21 + plugins/convertStyleToAttrs.js | 18 + plugins/convertTransform.js | 74 + plugins/inlineStyles.js | 32 + plugins/mergePaths.js | 32 +- plugins/mergeStyles.js | 1 + plugins/minifyStyles.js | 22 +- plugins/moveElemsAttrsToGroup.js | 1 + plugins/moveGroupAttrsToElems.js | 1 + plugins/prefixIds.js | 31 + plugins/removeAttributesBySelector.js | 29 + plugins/removeAttrs.js | 31 + plugins/removeComments.js | 34 + plugins/removeDeprecatedAttrs.js | 21 +- plugins/removeDesc.js | 18 + plugins/removeDimensions.js | 1 + plugins/removeDoctype.js | 1 + plugins/removeEditorsNSData.js | 21 + plugins/removeElementsByAttr.js | 31 + plugins/removeEmptyAttrs.js | 1 + plugins/removeEmptyContainers.js | 1 + plugins/removeEmptyText.js | 32 + plugins/removeHiddenElems.js | 125 +- plugins/removeMetadata.js | 1 + plugins/removeNonInheritableGroupAttrs.js | 1 + plugins/removeOffCanvasPaths.js | 9 +- plugins/removeRasterImages.js | 1 + plugins/removeScriptElement.js | 1 + plugins/removeStyleElement.js | 1 + plugins/removeTitle.js | 1 + plugins/removeUnknownsAndDefaults.js | 67 + plugins/removeUnusedNS.js | 1 + plugins/removeUselessDefs.js | 1 + plugins/removeUselessStrokeAndFill.js | 30 + plugins/removeViewBox.js | 1 + plugins/removeXMLNS.js | 1 + plugins/removeXMLProcInst.js | 1 + plugins/removeXlink.js | 15 + plugins/reusePaths.js | 1 + plugins/sortAttrs.js | 46 + plugins/sortDefsChildren.js | 1 + yarn.lock | 1481 ++++++++--------- 84 files changed, 1834 insertions(+), 1150 deletions(-) diff --git a/docs/03-plugins/add-attributes-to-svg-elements.mdx b/docs/03-plugins/add-attributes-to-svg-elements.mdx index f313895c6..22e8d5496 100644 --- a/docs/03-plugins/add-attributes-to-svg-elements.mdx +++ b/docs/03-plugins/add-attributes-to-svg-elements.mdx @@ -2,11 +2,6 @@ title: Add Attributes to Elements svgo: pluginId: addAttributesToSVGElement - parameters: - attributes: - description: Attributes to add to the <svg> element. If key/value pairs are passed, the attributes and added with the paired value. If an array is passed, attributes are added with no key associated with them. - default: null - attribute: --- Adds attributes to the outer most [``](https://developer.mozilla.org/docs/Web/SVG/Element/svg) element in the document. This is not an optimization and will increase the size of SVG documents. diff --git a/docs/03-plugins/add-classes-to-svg-element.mdx b/docs/03-plugins/add-classes-to-svg-element.mdx index 29b05eed4..bd73a22a8 100644 --- a/docs/03-plugins/add-classes-to-svg-element.mdx +++ b/docs/03-plugins/add-classes-to-svg-element.mdx @@ -2,12 +2,6 @@ title: Add Classes to SVG svgo: pluginId: addClassesToSVGElement - parameters: - classNames: - description: Adds the specified class names to the outer most <svg> element. - default: null - className: - description: Adds the specified class name to the outer most <svg> element. If classNames is specified, this is ignored. --- Overrides the `class` attribute in the outer most `` element, omitting duplicates or null classes if found in your configuration. diff --git a/docs/03-plugins/cleanup-attrs.mdx b/docs/03-plugins/cleanup-attrs.mdx index 14cb71e50..5ed946cde 100644 --- a/docs/03-plugins/cleanup-attrs.mdx +++ b/docs/03-plugins/cleanup-attrs.mdx @@ -3,19 +3,6 @@ title: Cleanup Attributes svgo: pluginId: cleanupAttrs defaultPlugin: true - parameters: - newlines: - description: Replace instances of a newline with a single whitespace. - type: boolean - default: true - trim: - description: Trim whitespace characters from the start and end of attribute values. - type: boolean - default: true - spaces: - description: Replace all instances of 2 or more whitespace characters with a single whitespace. - type: boolean - default: true --- Removes redundant whitespaces from attribute values. diff --git a/docs/03-plugins/cleanup-ids.mdx b/docs/03-plugins/cleanup-ids.mdx index d1c862e82..16ea3832f 100644 --- a/docs/03-plugins/cleanup-ids.mdx +++ b/docs/03-plugins/cleanup-ids.mdx @@ -2,22 +2,6 @@ title: Cleanup IDs svgo: pluginId: cleanupIds - parameters: - remove: - description: If to remove all unreferenced IDs. - default: true - minify: - description: If to minify referenced IDs. - default: true - preserve: - description: Elements with one of these IDs will be ignored. - default: [] - preservePrefixes: - description: Elements with an ID that starts with one of these prefixes will be ignored. - default: [] - force: - description: This plugin normally does nothing if a <script> or <style> element is found. Setting this to true will bypass that behaviour, which may result in destructive changes. - default: false defaultPlugin: true --- diff --git a/docs/03-plugins/cleanup-list-of-values.mdx b/docs/03-plugins/cleanup-list-of-values.mdx index 1f6923e72..7491c2635 100644 --- a/docs/03-plugins/cleanup-list-of-values.mdx +++ b/docs/03-plugins/cleanup-list-of-values.mdx @@ -2,19 +2,6 @@ title: Cleanup List of Values svgo: pluginId: cleanupListOfValues - parameters: - floatPrecision: - description: Number of decimal places to round to, using conventional rounding rules. - default: 3 - leadingZero: - description: If to trim leading zeros. - default: true - defaultPx: - description: If to remove the units when it's px, as this is the default if not specified. - default: true - convertToPx: - description: If to convert absolute units like cm and in to px. - default: true --- # Cleanup List of Values diff --git a/docs/03-plugins/cleanup-numeric-values.mdx b/docs/03-plugins/cleanup-numeric-values.mdx index f38c96212..cb2a03af6 100644 --- a/docs/03-plugins/cleanup-numeric-values.mdx +++ b/docs/03-plugins/cleanup-numeric-values.mdx @@ -3,19 +3,6 @@ title: Cleanup Numeric Values svgo: pluginId: cleanupNumericValues defaultPlugin: true - parameters: - floatPrecision: - description: Number of decimal places to round to, using conventional rounding rules. - default: 3 - leadingZero: - description: If to trim leading zeros. - default: true - defaultPx: - description: If to remove the units when it's px, as this is the default if not specified. - default: true - convertToPx: - description: If to convert absolute units like cm and in to px. - default: true --- Rounds numeric values, and removes the unit when it's `px` as this is the default. diff --git a/docs/03-plugins/convert-colors.mdx b/docs/03-plugins/convert-colors.mdx index 944a545e2..fb7904c3e 100644 --- a/docs/03-plugins/convert-colors.mdx +++ b/docs/03-plugins/convert-colors.mdx @@ -3,25 +3,6 @@ title: Convert Colors svgo: pluginId: convertColors defaultPlugin: true - parameters: - currentColor: - description: If to convert all instances of a color to currentcolor. This means to inherit the active foreground color, for example in HTML5 this would be the color property in CSS. - default: false - names2hex: - description: If to convert color names to the hex equivalent. - default: true - rgb2hex: - description: If to convert RGB colors to the hex equivalent, ignores RGBA. - default: true - convertCase: - description: Convert all color values to either upper or lower case by setting this to 'upper' or 'lower' respectively to improve compression. Set to false to disable this behavior. - default: 'lower' - shorthex: - description: If to convert 6 character hex colors to the 3 character equivalent where possible. - default: true - shortname: - description: If to convert hex colors to the color name, if the color name is shorter then the hex equivalent. - default: true --- Converts color references to the shortest equivalent. diff --git a/docs/03-plugins/convert-path-data.mdx b/docs/03-plugins/convert-path-data.mdx index 1f1dc3cdd..3d406ca90 100644 --- a/docs/03-plugins/convert-path-data.mdx +++ b/docs/03-plugins/convert-path-data.mdx @@ -3,53 +3,6 @@ title: Convert Path Commands svgo: pluginId: convertPathData defaultPlugin: true - parameters: - applyTransforms: - description: If to apply transforms. - default: true - applyTransformsStroked: - description: If to apply transforms to paths with a stroke. - default: true - makeArcs: - description: If to convert from curves to arcs when possible. This is an object with two properties, threshold and tolerance. - straightCurves: - description: If to convert curve commands that are effectively straight lines to line commands. - default: true - convertToQ: - description: If to convert cubic beziers to quadratic beziers when they effectively are. - default: true - lineShorthands: - description: If to convert regular lines to an explicit horizontal or vertical line where possible. - default: true - convertToZ: - description: If to convert lines that go to the start to a z command. - default: true - curveSmoothShorthands: - description: If to convert curves to smooth curves where possible. - default: true - floatPrecision: - description: Number of decimal places to round to, using conventional rounding rules. - default: 3 - transformPrecision: - description: Number of decimal places to round to, using conventional rounding rules. - default: 5 - smartArcRounding: - description: Round the radius of circular arcs when the effective change is under the error. The effective change is determined using the sagitta of the arc. - default: true - removeUseless: - description: Remove redundant path commands that don't draw anything. - default: true - collapseRepeated: - description: Collapse repeated commands when they can be merged into one. - default: true - utilizeAbsolute: - description: If to convert between absolute or relative coordinates, whichever is shortest. - default: true - negativeExtraSpace: - default: true - forceAbsolutePath: - description: If to always convert to absolute coordinates, even if it adds more bytes. - default: false --- Optimize path commands found in ``, ``, and `` elements. Path commands are the syntax used in the `d` attribute, each character represents an instruction to draw paths. diff --git a/docs/03-plugins/convert-shape-to-path.mdx b/docs/03-plugins/convert-shape-to-path.mdx index bc5139c89..1f5f227f5 100644 --- a/docs/03-plugins/convert-shape-to-path.mdx +++ b/docs/03-plugins/convert-shape-to-path.mdx @@ -3,13 +3,6 @@ title: Convert Shape to Path svgo: pluginId: convertShapeToPath defaultPlugin: true - parameters: - convertArcs: - description: If to convert <circle> and <ellipse> elements to paths. - default: false - floatPrecision: - description: Number of decimal places to round to, using conventional rounding rules. - default: null --- Convert basic shapes to [``](https://developer.mozilla.org/docs/Web/SVG/Element/path) elements. diff --git a/docs/03-plugins/convert-style-to-attrs.mdx b/docs/03-plugins/convert-style-to-attrs.mdx index a6dfce926..8e27168f5 100644 --- a/docs/03-plugins/convert-style-to-attrs.mdx +++ b/docs/03-plugins/convert-style-to-attrs.mdx @@ -2,11 +2,6 @@ title: Convert Style to Attributes svgo: pluginId: convertStyleToAttrs - parameters: - keepImportant: - description: If to always keep !important styles. - type: boolean - default: false --- Converts [presentation attributes](https://developer.mozilla.org/docs/Web/SVG/Attribute/Presentation) in element styles to the equvilent XML attribute. diff --git a/docs/03-plugins/convert-transform.mdx b/docs/03-plugins/convert-transform.mdx index d11864baf..61aae0221 100644 --- a/docs/03-plugins/convert-transform.mdx +++ b/docs/03-plugins/convert-transform.mdx @@ -3,36 +3,6 @@ title: Convert Transform svgo: pluginId: convertTransform defaultPlugin: true - parameters: - convertToShorts: - description: Convert transforms to their shorthand alternatives. - default: true - degPrecision: - description: Number of decimal places to round degrees values to, using conventional rounding rules. Used for rotate and skew. - floatPrecision: - description: Number of decimal places to round to, using conventional rounding rules. - default: 3 - transformPrecision: - description: Number of decimal places to round to, using conventional rounding rules. - default: 5 - matrixToTransform: - description: If decompose matrices into simple transforms. See Decomposition of 2D-transform matrices for more context. - default: true - shortTranslate: - description: If to shorten references to translate with redundant parameters to omit them. i.e. translate(10 0)translate(10) - default: true - shortScale: - description: If to shorten references to scale with redundant parameters to omit them. i.e. scale(2 2)scale(2) - default: true - shortRotate: - description: If to shorten references to rotate with redundant parameters to omit them. i.e. translate(cx cy) rotate(a) translate(-cx -cy)rotate(a cx cy) - default: true - removeUseless: - description: If to remove redundant transforms like translate(0), skewX(0), or skewY(0). - default: true - collapseIntoOne: - description: If to multiply transforms into one. - default: true --- Collapse multiple transforms into one, convert matrices to the short aliases, and much more. diff --git a/docs/03-plugins/inline-styles.mdx b/docs/03-plugins/inline-styles.mdx index c690790ef..c2d8439af 100644 --- a/docs/03-plugins/inline-styles.mdx +++ b/docs/03-plugins/inline-styles.mdx @@ -3,17 +3,6 @@ title: Inline Styles svgo: pluginId: inlineStyles defaultPlugin: true - parameters: - onlyMatchedOnce: - description: If to only inline styles if the selector matches one element. - default: true - removeMatchedSelectors: - description: If to remove the selector and styles from the stylesheet while inlining the styles. This does not remove selectors that did not match any elements. - default: true - useMqs: - description: An array of media query conditions to use, such as screen. An empty string signifies all selectors outside of a media query. - usePseudos: - description: What pseudo-classes and pseudo-elements to use. An empty string signifies all non-pseudo-classes and non-pseudo-elements. --- Merges styles from `