Skip to content

Commit

Permalink
Move plugin types into d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
TrySound committed Nov 11, 2022
1 parent a40fa21 commit e2e65cf
Show file tree
Hide file tree
Showing 51 changed files with 263 additions and 189 deletions.
5 changes: 1 addition & 4 deletions plugins/addAttributesToSVGElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ plugins: [
*
* @author April Arcus
*
* @type {import('../lib/types').Plugin<{
* attribute?: string | Record<string, null | string>,
* attributes?: Array<string | Record<string, null | string>>
* }>}
* @type {import('./plugins-types').Plugin<'addAttributesToSVGElement'>}
*/
exports.fn = (root, params) => {
if (!Array.isArray(params.attributes) && !params.attribute) {
Expand Down
5 changes: 1 addition & 4 deletions plugins/addClassesToSVGElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ plugins: [
*
* @author April Arcus
*
* @type {import('../lib/types').Plugin<{
* className?: string,
* classNames?: Array<string>
* }>}
* @type {import('./plugins-types').Plugin<'addClassesToSVGElement'>}
*/
exports.fn = (root, params) => {
if (
Expand Down
6 changes: 1 addition & 5 deletions plugins/cleanupAttrs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion plugins/cleanupEnableBackground.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exports.description =
*
* @author Kir Belevich
*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'cleanupEnableBackground'>}
*/
exports.fn = (root) => {
const regEnableBackground =
Expand Down
8 changes: 1 addition & 7 deletions plugins/cleanupIds.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,7 @@ const getIdString = (arr) => {
*
* @author Kir Belevich
*
* @type {import('../lib/types').Plugin<{
* remove?: boolean,
* minify?: boolean,
* preserve?: Array<string>,
* preservePrefixes?: Array<string>,
* force?: boolean,
* }>}
* @type {import('./plugins-types').Plugin<'cleanupIds'>}
*/
exports.fn = (_root, params) => {
const {
Expand Down
7 changes: 1 addition & 6 deletions plugins/cleanupListOfValues.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 1 addition & 6 deletions plugins/cleanupNumericValues.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion plugins/collapseGroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const hasAnimatedAttr = (node, name) => {
*
* @author Kir Belevich
*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'collapseGroups'>}
*/
exports.fn = () => {
return {
Expand Down
8 changes: 1 addition & 7 deletions plugins/convertColors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion plugins/convertEllipseToCircle.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exports.description = 'converts non-eccentric <ellipse>s to <circle>s';
*
* @author Taylor Hunt
*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'convertEllipseToCircle'>}
*/
exports.fn = () => {
return {
Expand Down
21 changes: 1 addition & 20 deletions plugins/convertPathData.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 1 addition & 4 deletions plugins/convertShapeToPath.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions plugins/convertStyleToAttrs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 1 addition & 14 deletions plugins/convertTransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 1 addition & 6 deletions plugins/inlineStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,7 @@ const toAny = (value) => value;
*
* @author strarsis <strarsis@gmail.com>
*
* @type {import('../lib/types').Plugin<{
* onlyMatchedOnce?: boolean,
* removeMatchedSelectors?: boolean,
* useMqs?: Array<string>,
* usePseudos?: Array<string>
* }>}
* @type {import('./plugins-types').Plugin<'inlineStyles'>}
*/
exports.fn = (root, params) => {
const {
Expand Down
6 changes: 1 addition & 5 deletions plugins/mergePaths.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion plugins/mergeStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exports.description = 'merge multiple style elements into one';
*
* @author strarsis <strarsis@gmail.com>
*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'mergeStyles'>}
*/
exports.fn = () => {
/**
Expand Down
9 changes: 1 addition & 8 deletions plugins/minifyStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,7 @@ exports.description =
*
* @author strarsis <strarsis@gmail.com>
*
* @type {import('../lib/types').Plugin<csso.MinifyOptions & Omit<csso.CompressOptions, 'usage'> & {
* usage?: boolean | {
* force?: boolean,
* ids?: boolean,
* classes?: boolean,
* tags?: boolean
* }
* }>}
* @type {import('./plugins-types').Plugin<'minifyStyles'>}
*/
exports.fn = (_root, { usage, ...params }) => {
let enableTagsUsage = true;
Expand Down
2 changes: 1 addition & 1 deletion plugins/moveElemsAttrsToGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ exports.description = 'Move common attributes of group children to the group';
*
* @author Kir Belevich
*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'moveElemsAttrsToGroup'>}
*/
exports.fn = (root) => {
// find if any style element is present
Expand Down
2 changes: 1 addition & 1 deletion plugins/moveGroupAttrsToElems.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const pathElemsWithGroupsAndText = [...pathElems, 'g', 'text'];
*
* @author Kir Belevich
*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'moveGroupAttrsToElems'>}
*/
exports.fn = () => {
return {
Expand Down
Loading

0 comments on commit e2e65cf

Please sign in to comment.