From e2e65cfc1e674914277e3193a8d291c994942b1b Mon Sep 17 00:00:00 2001 From: Bogdan Chadkin Date: Fri, 11 Nov 2022 12:19:38 +0300 Subject: [PATCH] Move plugin types into d.ts --- plugins/addAttributesToSVGElement.js | 5 +- plugins/addClassesToSVGElement.js | 5 +- plugins/cleanupAttrs.js | 6 +- plugins/cleanupEnableBackground.js | 2 +- plugins/cleanupIds.js | 8 +- plugins/cleanupListOfValues.js | 7 +- plugins/cleanupNumericValues.js | 7 +- plugins/collapseGroups.js | 2 +- plugins/convertColors.js | 8 +- plugins/convertEllipseToCircle.js | 2 +- plugins/convertPathData.js | 21 +-- plugins/convertShapeToPath.js | 5 +- plugins/convertStyleToAttrs.js | 4 +- plugins/convertTransform.js | 15 +- plugins/inlineStyles.js | 7 +- plugins/mergePaths.js | 6 +- plugins/mergeStyles.js | 2 +- plugins/minifyStyles.js | 9 +- plugins/moveElemsAttrsToGroup.js | 2 +- plugins/moveGroupAttrsToElems.js | 2 +- plugins/plugins-types.ts | 213 ++++++++++++++++++++++ plugins/prefixIds.js | 12 +- plugins/removeAttributesBySelector.js | 2 +- plugins/removeAttrs.js | 6 +- plugins/removeComments.js | 2 +- plugins/removeDesc.js | 2 +- plugins/removeDimensions.js | 2 +- plugins/removeDoctype.js | 2 +- plugins/removeEditorsNSData.js | 4 +- plugins/removeElementsByAttr.js | 5 +- plugins/removeEmptyAttrs.js | 2 +- plugins/removeEmptyContainers.js | 2 +- plugins/removeEmptyText.js | 6 +- plugins/removeHiddenElems.js | 18 +- plugins/removeMetadata.js | 2 +- plugins/removeNonInheritableGroupAttrs.js | 2 +- plugins/removeOffCanvasPaths.js | 2 +- plugins/removeRasterImages.js | 2 +- plugins/removeScriptElement.js | 2 +- plugins/removeStyleElement.js | 2 +- plugins/removeTitle.js | 2 +- plugins/removeUnknownsAndDefaults.js | 10 +- plugins/removeUnusedNS.js | 2 +- plugins/removeUselessDefs.js | 2 +- plugins/removeUselessStrokeAndFill.js | 6 +- plugins/removeViewBox.js | 2 +- plugins/removeXMLNS.js | 2 +- plugins/removeXMLProcInst.js | 2 +- plugins/reusePaths.js | 2 +- plugins/sortAttrs.js | 5 +- plugins/sortDefsChildren.js | 2 +- 51 files changed, 263 insertions(+), 189 deletions(-) create mode 100644 plugins/plugins-types.ts diff --git a/plugins/addAttributesToSVGElement.js b/plugins/addAttributesToSVGElement.js index 0214a6c18..845cb056a 100644 --- a/plugins/addAttributesToSVGElement.js +++ b/plugins/addAttributesToSVGElement.js @@ -47,10 +47,7 @@ plugins: [ * * @author April Arcus * - * @type {import('../lib/types').Plugin<{ - * attribute?: string | Record, - * attributes?: Array> - * }>} + * @type {import('./plugins-types').Plugin<'addAttributesToSVGElement'>} */ exports.fn = (root, params) => { if (!Array.isArray(params.attributes) && !params.attribute) { diff --git a/plugins/addClassesToSVGElement.js b/plugins/addClassesToSVGElement.js index 1bde12a25..9a015c7bd 100644 --- a/plugins/addClassesToSVGElement.js +++ b/plugins/addClassesToSVGElement.js @@ -49,10 +49,7 @@ plugins: [ * * @author April Arcus * - * @type {import('../lib/types').Plugin<{ - * className?: string, - * classNames?: Array - * }>} + * @type {import('./plugins-types').Plugin<'addClassesToSVGElement'>} */ exports.fn = (root, params) => { if ( diff --git a/plugins/cleanupAttrs.js b/plugins/cleanupAttrs.js index 54b703fd6..399de1940 100644 --- a/plugins/cleanupAttrs.js +++ b/plugins/cleanupAttrs.js @@ -13,11 +13,7 @@ const regSpaces = /\s{2,}/g; * * @author Kir Belevich * - * @type {import('../lib/types').Plugin<{ - * newlines?: boolean, - * trim?: boolean, - * spaces?: boolean - * }>} + * @type {import('./plugins-types').Plugin<'cleanupAttrs'>} */ exports.fn = (root, params) => { const { newlines = true, trim = true, spaces = true } = params; diff --git a/plugins/cleanupEnableBackground.js b/plugins/cleanupEnableBackground.js index 3afb48ea5..80be32be1 100644 --- a/plugins/cleanupEnableBackground.js +++ b/plugins/cleanupEnableBackground.js @@ -18,7 +18,7 @@ exports.description = * * @author Kir Belevich * - * @type {import('../lib/types').Plugin} + * @type {import('./plugins-types').Plugin<'cleanupEnableBackground'>} */ exports.fn = (root) => { const regEnableBackground = diff --git a/plugins/cleanupIds.js b/plugins/cleanupIds.js index 33545bcbf..fa6292bed 100644 --- a/plugins/cleanupIds.js +++ b/plugins/cleanupIds.js @@ -123,13 +123,7 @@ const getIdString = (arr) => { * * @author Kir Belevich * - * @type {import('../lib/types').Plugin<{ - * remove?: boolean, - * minify?: boolean, - * preserve?: Array, - * preservePrefixes?: Array, - * force?: boolean, - * }>} + * @type {import('./plugins-types').Plugin<'cleanupIds'>} */ exports.fn = (_root, params) => { const { diff --git a/plugins/cleanupListOfValues.js b/plugins/cleanupListOfValues.js index ca2997b31..7150449eb 100644 --- a/plugins/cleanupListOfValues.js +++ b/plugins/cleanupListOfValues.js @@ -32,12 +32,7 @@ const absoluteLengths = { * * @author kiyopikko * - * @type {import('../lib/types').Plugin<{ - * floatPrecision?: number, - * leadingZero?: boolean, - * defaultPx?: boolean, - * convertToPx?: boolean - * }>} + * @type {import('./plugins-types').Plugin<'cleanupListOfValues'>} */ exports.fn = (_root, params) => { const { diff --git a/plugins/cleanupNumericValues.js b/plugins/cleanupNumericValues.js index f099b50b5..6a15dddd7 100644 --- a/plugins/cleanupNumericValues.js +++ b/plugins/cleanupNumericValues.js @@ -25,12 +25,7 @@ const absoluteLengths = { * * @author Kir Belevich * - * @type {import('../lib/types').Plugin<{ - * floatPrecision?: number, - * leadingZero?: boolean, - * defaultPx?: boolean, - * convertToPx?: boolean - * }>} + * @type {import('./plugins-types').Plugin<'cleanupNumericValues'>} */ exports.fn = (_root, params) => { const { diff --git a/plugins/collapseGroups.js b/plugins/collapseGroups.js index 469ca6949..ff38caff6 100644 --- a/plugins/collapseGroups.js +++ b/plugins/collapseGroups.js @@ -49,7 +49,7 @@ const hasAnimatedAttr = (node, name) => { * * @author Kir Belevich * - * @type {import('../lib/types').Plugin} + * @type {import('./plugins-types').Plugin<'collapseGroups'>} */ exports.fn = () => { return { diff --git a/plugins/convertColors.js b/plugins/convertColors.js index 1e14fca35..c9609d8b3 100644 --- a/plugins/convertColors.js +++ b/plugins/convertColors.js @@ -61,13 +61,7 @@ const convertRgbToHex = ([r, g, b]) => { * * @author Kir Belevich * - * @type {import('../lib/types').Plugin<{ - * currentColor?: boolean | string | RegExp, - * names2hex?: boolean, - * rgb2hex?: boolean, - * shorthex?: boolean, - * shortname?: boolean, - * }>} + * @type {import('./plugins-types').Plugin<'convertColors'>} */ exports.fn = (_root, params) => { const { diff --git a/plugins/convertEllipseToCircle.js b/plugins/convertEllipseToCircle.js index aa6821edc..50fa20db8 100644 --- a/plugins/convertEllipseToCircle.js +++ b/plugins/convertEllipseToCircle.js @@ -10,7 +10,7 @@ exports.description = 'converts non-eccentric s to s'; * * @author Taylor Hunt * - * @type {import('../lib/types').Plugin} + * @type {import('./plugins-types').Plugin<'convertEllipseToCircle'>} */ exports.fn = () => { return { diff --git a/plugins/convertPathData.js b/plugins/convertPathData.js index 88d0086b2..a5f375bad 100644 --- a/plugins/convertPathData.js +++ b/plugins/convertPathData.js @@ -82,26 +82,7 @@ let arcTolerance; * * @author Kir Belevich * - * @type {import('../lib/types').Plugin<{ - * applyTransforms?: boolean, - * applyTransformsStroked?: boolean, - * makeArcs?: { - * threshold: number, - * tolerance: number, - * }, - * straightCurves?: boolean, - * lineShorthands?: boolean, - * curveSmoothShorthands?: boolean, - * floatPrecision?: number | false, - * transformPrecision?: number, - * removeUseless?: boolean, - * collapseRepeated?: boolean, - * utilizeAbsolute?: boolean, - * leadingZero?: boolean, - * negativeExtraSpace?: boolean, - * noSpaceAfterFlags?: boolean, - * forceAbsolutePath?: boolean, - * }>} + * @type {import('./plugins-types').Plugin<'convertPathData'>} */ exports.fn = (root, params) => { const { diff --git a/plugins/convertShapeToPath.js b/plugins/convertShapeToPath.js index b33e6e71a..7705fa97d 100644 --- a/plugins/convertShapeToPath.js +++ b/plugins/convertShapeToPath.js @@ -21,10 +21,7 @@ const regNumber = /[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?/g; * * @author Lev Solntsev * - * @type {import('../lib/types').Plugin<{ - * convertArcs?: boolean, - * floatPrecision?: number - * }>} + * @type {import('./plugins-types').Plugin<'convertShapeToPath'>} */ exports.fn = (root, params) => { const { convertArcs = false, floatPrecision: precision } = params; diff --git a/plugins/convertStyleToAttrs.js b/plugins/convertStyleToAttrs.js index 5986615d5..5d5107d6f 100644 --- a/plugins/convertStyleToAttrs.js +++ b/plugins/convertStyleToAttrs.js @@ -65,9 +65,7 @@ const regStripComments = new RegExp( * * @author Kir Belevich * - * @type {import('../lib/types').Plugin<{ - * keepImportant?: boolean - * }>} + * @type {import('./plugins-types').Plugin<'convertStyleToAttrs'>} */ exports.fn = (_root, params) => { const { keepImportant = false } = params; diff --git a/plugins/convertTransform.js b/plugins/convertTransform.js index f07634e06..d90c3efdb 100644 --- a/plugins/convertTransform.js +++ b/plugins/convertTransform.js @@ -24,20 +24,7 @@ exports.description = 'collapses multiple transformations and optimizes it'; * * @author Kir Belevich * - * @type {import('../lib/types').Plugin<{ - * convertToShorts?: boolean, - * degPrecision?: number, - * floatPrecision?: number, - * transformPrecision?: number, - * matrixToTransform?: boolean, - * shortTranslate?: boolean, - * shortScale?: boolean, - * shortRotate?: boolean, - * removeUseless?: boolean, - * collapseIntoOne?: boolean, - * leadingZero?: boolean, - * negativeExtraSpace?: boolean, - * }>} + * @type {import('./plugins-types').Plugin<'convertTransform'>} */ exports.fn = (_root, params) => { const { diff --git a/plugins/inlineStyles.js b/plugins/inlineStyles.js index e446a6c18..e931b5f68 100644 --- a/plugins/inlineStyles.js +++ b/plugins/inlineStyles.js @@ -63,12 +63,7 @@ const toAny = (value) => value; * * @author strarsis * - * @type {import('../lib/types').Plugin<{ - * onlyMatchedOnce?: boolean, - * removeMatchedSelectors?: boolean, - * useMqs?: Array, - * usePseudos?: Array - * }>} + * @type {import('./plugins-types').Plugin<'inlineStyles'>} */ exports.fn = (root, params) => { const { diff --git a/plugins/mergePaths.js b/plugins/mergePaths.js index 011dad913..05c7ac705 100644 --- a/plugins/mergePaths.js +++ b/plugins/mergePaths.js @@ -12,11 +12,7 @@ exports.description = 'merges multiple paths in one if possible'; * * @author Kir Belevich, Lev Solntsev * - * @type {import('../lib/types').Plugin<{ - * force?: boolean, - * floatPrecision?: number, - * noSpaceAfterFlags?: boolean - * }>} + * @type {import('./plugins-types').Plugin<'mergePaths'>} */ exports.fn = (root, params) => { const { diff --git a/plugins/mergeStyles.js b/plugins/mergeStyles.js index 18a6e2b1f..1cc320158 100644 --- a/plugins/mergeStyles.js +++ b/plugins/mergeStyles.js @@ -15,7 +15,7 @@ exports.description = 'merge multiple style elements into one'; * * @author strarsis * - * @type {import('../lib/types').Plugin} + * @type {import('./plugins-types').Plugin<'mergeStyles'>} */ exports.fn = () => { /** diff --git a/plugins/minifyStyles.js b/plugins/minifyStyles.js index a53675eed..a10b8d207 100644 --- a/plugins/minifyStyles.js +++ b/plugins/minifyStyles.js @@ -15,14 +15,7 @@ exports.description = * * @author strarsis * - * @type {import('../lib/types').Plugin & { - * usage?: boolean | { - * force?: boolean, - * ids?: boolean, - * classes?: boolean, - * tags?: boolean - * } - * }>} + * @type {import('./plugins-types').Plugin<'minifyStyles'>} */ exports.fn = (_root, { usage, ...params }) => { let enableTagsUsage = true; diff --git a/plugins/moveElemsAttrsToGroup.js b/plugins/moveElemsAttrsToGroup.js index 7fe28d062..5f46e6329 100644 --- a/plugins/moveElemsAttrsToGroup.js +++ b/plugins/moveElemsAttrsToGroup.js @@ -26,7 +26,7 @@ exports.description = 'Move common attributes of group children to the group'; * * @author Kir Belevich * - * @type {import('../lib/types').Plugin} + * @type {import('./plugins-types').Plugin<'moveElemsAttrsToGroup'>} */ exports.fn = (root) => { // find if any style element is present diff --git a/plugins/moveGroupAttrsToElems.js b/plugins/moveGroupAttrsToElems.js index a25984eb1..60b55676b 100644 --- a/plugins/moveGroupAttrsToElems.js +++ b/plugins/moveGroupAttrsToElems.js @@ -23,7 +23,7 @@ const pathElemsWithGroupsAndText = [...pathElems, 'g', 'text']; * * @author Kir Belevich * - * @type {import('../lib/types').Plugin} + * @type {import('./plugins-types').Plugin<'moveGroupAttrsToElems'>} */ exports.fn = () => { return { diff --git a/plugins/plugins-types.ts b/plugins/plugins-types.ts new file mode 100644 index 000000000..0cd1c4b9e --- /dev/null +++ b/plugins/plugins-types.ts @@ -0,0 +1,213 @@ +import type * as csso from 'csso'; +import type { + Plugin as PluginDef, + PluginInfo, + XastElement, +} from '../lib/types'; + +type DefaultPlugins = { + cleanupAttrs: { + newlines?: boolean; + trim?: boolean; + spaces?: boolean; + }; + cleanupEnableBackground: void; + cleanupIds: { + remove?: boolean; + minify?: boolean; + preserve?: Array; + preservePrefixes?: Array; + force?: boolean; + }; + cleanupNumericValues: { + floatPrecision?: number; + leadingZero?: boolean; + defaultPx?: boolean; + convertToPx?: boolean; + }; + collapseGroups: void; + convertColors: { + currentColor?: boolean | string | RegExp; + names2hex?: boolean; + rgb2hex?: boolean; + shorthex?: boolean; + shortname?: boolean; + }; + convertEllipseToCircle: void; + convertPathData: { + applyTransforms?: boolean; + applyTransformsStroked?: boolean; + makeArcs?: { + threshold: number; + tolerance: number; + }; + straightCurves?: boolean; + lineShorthands?: boolean; + curveSmoothShorthands?: boolean; + floatPrecision?: number | false; + transformPrecision?: number; + removeUseless?: boolean; + collapseRepeated?: boolean; + utilizeAbsolute?: boolean; + leadingZero?: boolean; + negativeExtraSpace?: boolean; + noSpaceAfterFlags?: boolean; + forceAbsolutePath?: boolean; + }; + convertShapeToPath: { + convertArcs?: boolean; + floatPrecision?: number; + }; + convertTransform: { + convertToShorts?: boolean; + degPrecision?: number; + floatPrecision?: number; + transformPrecision?: number; + matrixToTransform?: boolean; + shortTranslate?: boolean; + shortScale?: boolean; + shortRotate?: boolean; + removeUseless?: boolean; + collapseIntoOne?: boolean; + leadingZero?: boolean; + negativeExtraSpace?: boolean; + }; + mergeStyles: void; + inlineStyles: { + onlyMatchedOnce?: boolean; + removeMatchedSelectors?: boolean; + useMqs?: Array; + usePseudos?: Array; + }; + mergePaths: { + force?: boolean; + floatPrecision?: number; + noSpaceAfterFlags?: boolean; + }; + minifyStyles: csso.MinifyOptions & + Omit & { + usage?: + | boolean + | { + force?: boolean; + ids?: boolean; + classes?: boolean; + tags?: boolean; + }; + }; + moveElemsAttrsToGroup: void; + moveGroupAttrsToElems: void; + removeComments: void; + removeDesc: { + removeAny?: boolean; + }; + removeDoctype: void; + removeEditorsNSData: { + additionalNamespaces?: Array; + }; + removeEmptyAttrs: void; + removeEmptyContainers: void; + removeEmptyText: { + text?: boolean; + tspan?: boolean; + tref?: boolean; + }; + removeHiddenElems: { + isHidden?: boolean; + displayNone?: boolean; + opacity0?: boolean; + circleR0?: boolean; + ellipseRX0?: boolean; + ellipseRY0?: boolean; + rectWidth0?: boolean; + rectHeight0?: boolean; + patternWidth0?: boolean; + patternHeight0?: boolean; + imageWidth0?: boolean; + imageHeight0?: boolean; + pathEmptyD?: boolean; + polylineEmptyPoints?: boolean; + polygonEmptyPoints?: boolean; + }; + removeMetadata: void; + removeNonInheritableGroupAttrs: void; + removeTitle: void; + removeUnknownsAndDefaults: { + unknownContent?: boolean; + unknownAttrs?: boolean; + defaultAttrs?: boolean; + uselessOverrides?: boolean; + keepDataAttrs?: boolean; + keepAriaAttrs?: boolean; + keepRoleAttr?: boolean; + }; + removeUnusedNS: void; + removeUselessDefs: void; + removeUselessStrokeAndFill: { + stroke?: boolean; + fill?: boolean; + removeNone?: boolean; + }; + removeViewBox: void; + removeXMLProcInst: void; + sortAttrs: { + order?: Array; + xmlnsOrder?: 'front' | 'alphabetical'; + }; + sortDefsChildren: void; +}; + +type BuiltinsWithOptionalParams = DefaultPlugins & { + cleanupListOfValues: { + floatPrecision?: number; + leadingZero?: boolean; + defaultPx?: boolean; + convertToPx?: boolean; + }; + convertStyleToAttrs: { + keepImportant?: boolean; + }; + prefixIds: { + prefix?: + | boolean + | string + | ((node: XastElement, info: PluginInfo) => string); + delim?: string; + prefixIds?: boolean; + prefixClassNames?: boolean; + }; + removeDimensions: void; + removeOffCanvasPaths: void; + removeRasterImages: void; + removeScriptElement: void; + removeStyleElement: void; + removeXMLNS: void; + reusePaths: void; +}; + +type BuiltinsWithRequiredParams = { + addAttributesToSVGElement: { + attribute?: string | Record; + attributes?: Array>; + }; + addClassesToSVGElement: { + className?: string; + classNames?: Array; + }; + removeAttributesBySelector: any; + removeAttrs: { + elemSeparator?: string; + preserveCurrentColor?: boolean; + attrs: string | Array; + }; + removeElementsByAttr: { + id?: string | Array; + class?: string | Array; + }; +}; + +type PluginsParams = BuiltinsWithOptionalParams & BuiltinsWithRequiredParams; + +export type Plugin = PluginDef< + PluginsParams[Name] +>; diff --git a/plugins/prefixIds.js b/plugins/prefixIds.js index 6ae23ce5a..667629366 100644 --- a/plugins/prefixIds.js +++ b/plugins/prefixIds.js @@ -3,11 +3,6 @@ const csstree = require('css-tree'); const { referencesProps } = require('./_collections.js'); -/** - * @typedef {import('../lib/types').XastElement} XastElement - * @typedef {import('../lib/types').PluginInfo} PluginInfo - */ - exports.name = 'prefixIds'; exports.description = 'prefix IDs'; @@ -75,12 +70,7 @@ const toAny = (value) => value; * * @author strarsis * - * @type {import('../lib/types').Plugin<{ - * prefix?: boolean | string | ((node: XastElement, info: PluginInfo) => string), - * delim?: string, - * prefixIds?: boolean, - * prefixClassNames?: boolean, - * }>} + * @type {import('./plugins-types').Plugin<'prefixIds'>} */ exports.fn = (_root, params, info) => { const { delim = '__', prefixIds = true, prefixClassNames = true } = params; diff --git a/plugins/removeAttributesBySelector.js b/plugins/removeAttributesBySelector.js index 92a331b9f..09db8a8d0 100644 --- a/plugins/removeAttributesBySelector.js +++ b/plugins/removeAttributesBySelector.js @@ -73,7 +73,7 @@ exports.description = * * @author Bradley Mease * - * @type {import('../lib/types').Plugin} + * @type {import('./plugins-types').Plugin<'removeAttributesBySelector'>} */ exports.fn = (root, params) => { const selectors = Array.isArray(params.selectors) diff --git a/plugins/removeAttrs.js b/plugins/removeAttrs.js index 7773e2ae8..c289d8cac 100644 --- a/plugins/removeAttrs.js +++ b/plugins/removeAttrs.js @@ -81,11 +81,7 @@ plugins: [ * * @author Benny Schudel * - * @type {import('../lib/types').Plugin<{ - * elemSeparator?: string, - * preserveCurrentColor?: boolean, - * attrs: string | Array - * }>} + * @type {import('./plugins-types').Plugin<'removeAttrs'>} */ exports.fn = (root, params) => { if (typeof params.attrs == 'undefined') { diff --git a/plugins/removeComments.js b/plugins/removeComments.js index 8da9d75a8..70e462714 100644 --- a/plugins/removeComments.js +++ b/plugins/removeComments.js @@ -14,7 +14,7 @@ exports.description = 'removes comments'; * * @author Kir Belevich * - * @type {import('../lib/types').Plugin} + * @type {import('./plugins-types').Plugin<'removeComments'>} */ exports.fn = () => { return { diff --git a/plugins/removeDesc.js b/plugins/removeDesc.js index eeafb7020..5d9e57aef 100644 --- a/plugins/removeDesc.js +++ b/plugins/removeDesc.js @@ -16,7 +16,7 @@ const standardDescs = /^(Created with|Created using)/; * * @author Daniel Wabyick * - * @type {import('../lib/types').Plugin<{ removeAny?: boolean }>} + * @type {import('./plugins-types').Plugin<'removeDesc'>} */ exports.fn = (root, params) => { const { removeAny = true } = params; diff --git a/plugins/removeDimensions.js b/plugins/removeDimensions.js index 4024b2390..4f4f39840 100644 --- a/plugins/removeDimensions.js +++ b/plugins/removeDimensions.js @@ -14,7 +14,7 @@ exports.description = * * @author Benny Schudel * - * @type {import('../lib/types').Plugin} + * @type {import('./plugins-types').Plugin<'removeDimensions'>} */ exports.fn = () => { return { diff --git a/plugins/removeDoctype.js b/plugins/removeDoctype.js index 416212827..cbdcd013a 100644 --- a/plugins/removeDoctype.js +++ b/plugins/removeDoctype.js @@ -27,7 +27,7 @@ exports.description = 'removes doctype declaration'; * * @author Kir Belevich * - * @type {import('../lib/types').Plugin} + * @type {import('./plugins-types').Plugin<'removeDoctype'>} */ exports.fn = () => { return { diff --git a/plugins/removeEditorsNSData.js b/plugins/removeEditorsNSData.js index 25d1ae6b9..cf8016cde 100644 --- a/plugins/removeEditorsNSData.js +++ b/plugins/removeEditorsNSData.js @@ -16,9 +16,7 @@ exports.description = 'removes editors namespaces, elements and attributes'; * * @author Kir Belevich * - * @type {import('../lib/types').Plugin<{ - * additionalNamespaces?: Array - * }>} + * @type {import('./plugins-types').Plugin<'removeEditorsNSData'>} */ exports.fn = (_root, params) => { let namespaces = editorNamespaces; diff --git a/plugins/removeElementsByAttr.js b/plugins/removeElementsByAttr.js index d38761e41..b5fd91bac 100644 --- a/plugins/removeElementsByAttr.js +++ b/plugins/removeElementsByAttr.js @@ -37,10 +37,7 @@ exports.description = * * @author Eli Dupuis (@elidupuis) * - * @type {import('../lib/types').Plugin<{ - * id?: string | Array, - * class?: string | Array - * }>} + * @type {import('./plugins-types').Plugin<'removeElementsByAttr'>} */ exports.fn = (root, params) => { const ids = diff --git a/plugins/removeEmptyAttrs.js b/plugins/removeEmptyAttrs.js index f9a7af3ec..83f567c3b 100644 --- a/plugins/removeEmptyAttrs.js +++ b/plugins/removeEmptyAttrs.js @@ -10,7 +10,7 @@ exports.description = 'removes empty attributes'; * * @author Kir Belevich * - * @type {import('../lib/types').Plugin} + * @type {import('./plugins-types').Plugin<'removeEmptyAttrs'>} */ exports.fn = () => { return { diff --git a/plugins/removeEmptyContainers.js b/plugins/removeEmptyContainers.js index cef0adec9..d803fc9c9 100644 --- a/plugins/removeEmptyContainers.js +++ b/plugins/removeEmptyContainers.js @@ -19,7 +19,7 @@ exports.description = 'removes empty container elements'; * * @author Kir Belevich * - * @type {import('../lib/types').Plugin} + * @type {import('./plugins-types').Plugin<'removeEmptyContainers'>} */ exports.fn = () => { return { diff --git a/plugins/removeEmptyText.js b/plugins/removeEmptyText.js index d39b9c9ae..5f6db3d37 100644 --- a/plugins/removeEmptyText.js +++ b/plugins/removeEmptyText.js @@ -22,11 +22,7 @@ exports.description = 'removes empty elements'; * * @author Kir Belevich * - * @type {import('../lib/types').Plugin<{ - * text?: boolean, - * tspan?: boolean, - * tref?: boolean - * }>} + * @type {import('./plugins-types').Plugin<'removeEmptyText'>} */ exports.fn = (root, params) => { const { text = true, tspan = true, tref = true } = params; diff --git a/plugins/removeHiddenElems.js b/plugins/removeHiddenElems.js index 95979f77f..5c1a01355 100644 --- a/plugins/removeHiddenElems.js +++ b/plugins/removeHiddenElems.js @@ -28,23 +28,7 @@ exports.description = * * @author Kir Belevich * - * @type {import('../lib/types').Plugin<{ - * isHidden: boolean, - * displayNone: boolean, - * opacity0: boolean, - * circleR0: boolean, - * ellipseRX0: boolean, - * ellipseRY0: boolean, - * rectWidth0: boolean, - * rectHeight0: boolean, - * patternWidth0: boolean, - * patternHeight0: boolean, - * imageWidth0: boolean, - * imageHeight0: boolean, - * pathEmptyD: boolean, - * polylineEmptyPoints: boolean, - * polygonEmptyPoints: boolean, - * }>} + * @type {import('./plugins-types').Plugin<'removeHiddenElems'>} */ exports.fn = (root, params) => { const { diff --git a/plugins/removeMetadata.js b/plugins/removeMetadata.js index 8353bd203..8c9de27e5 100644 --- a/plugins/removeMetadata.js +++ b/plugins/removeMetadata.js @@ -12,7 +12,7 @@ exports.description = 'removes '; * * @author Kir Belevich * - * @type {import('../lib/types').Plugin} + * @type {import('./plugins-types').Plugin<'removeMetadata'>} */ exports.fn = () => { return { diff --git a/plugins/removeNonInheritableGroupAttrs.js b/plugins/removeNonInheritableGroupAttrs.js index 10a3528d5..faa93dffe 100644 --- a/plugins/removeNonInheritableGroupAttrs.js +++ b/plugins/removeNonInheritableGroupAttrs.js @@ -15,7 +15,7 @@ exports.description = * * @author Kir Belevich * - * @type {import('../lib/types').Plugin} + * @type {import('./plugins-types').Plugin<'removeNonInheritableGroupAttrs'>} */ exports.fn = () => { return { diff --git a/plugins/removeOffCanvasPaths.js b/plugins/removeOffCanvasPaths.js index 7494d8017..7a3d131d3 100644 --- a/plugins/removeOffCanvasPaths.js +++ b/plugins/removeOffCanvasPaths.js @@ -17,7 +17,7 @@ exports.description = * * @author JoshyPHP * - * @type {import('../lib/types').Plugin} + * @type {import('./plugins-types').Plugin<'removeOffCanvasPaths'>} */ exports.fn = () => { /** diff --git a/plugins/removeRasterImages.js b/plugins/removeRasterImages.js index 4f43ba147..8a3635318 100644 --- a/plugins/removeRasterImages.js +++ b/plugins/removeRasterImages.js @@ -12,7 +12,7 @@ exports.description = 'removes raster images (disabled by default)'; * * @author Kir Belevich * - * @type {import('../lib/types').Plugin} + * @type {import('./plugins-types').Plugin<'removeRasterImages'>} */ exports.fn = () => { return { diff --git a/plugins/removeScriptElement.js b/plugins/removeScriptElement.js index dc41a5105..0e42de4c5 100644 --- a/plugins/removeScriptElement.js +++ b/plugins/removeScriptElement.js @@ -12,7 +12,7 @@ exports.description = 'removes