From c2cacc7060a87ce1c2cd81bb7fa4245838189e78 Mon Sep 17 00:00:00 2001 From: Seth Falco Date: Wed, 27 Dec 2023 12:54:30 +0000 Subject: [PATCH] chore: move health files to .github (#1906) --- .github/FUNDING.yml | 3 -- SECURITY.md | 5 --- lib/parser.js | 2 +- lib/path.js | 6 +-- lib/path.test.js | 4 +- lib/style.js | 10 ++--- lib/svgo/coa.js | 10 ++--- lib/svgo/tools.js | 2 +- lib/types.d.ts | 10 ++--- lib/xast.js | 2 +- lib/xast.test.js | 12 ++--- plugins/_path.js | 44 +++++++++---------- plugins/_transforms.js | 20 ++++----- plugins/applyTransforms.js | 4 +- plugins/cleanupIds.js | 6 +-- plugins/convertColors.js | 2 +- plugins/convertShapeToPath.js | 10 ++--- plugins/convertTransform.js | 20 ++++----- plugins/inlineStyles.js | 14 +++--- plugins/minifyStyles.js | 2 +- plugins/removeEditorsNSData.js | 2 +- plugins/removeOffCanvasPaths.js | 2 +- plugins/removeUselessDefs.js | 4 +- plugins/reusePaths.js | 2 +- test/regression-extract.js | 2 +- test/svgo/_index.test.js | 2 +- ...le-specifity.svg => style-specificity.svg} | 0 27 files changed, 95 insertions(+), 107 deletions(-) delete mode 100644 .github/FUNDING.yml delete mode 100644 SECURITY.md rename test/svgo/{style-specifity.svg => style-specificity.svg} (100%) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index e09ac4c74..000000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,3 +0,0 @@ -# These are supported funding model platforms - -open_collective: svgo diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 7a6e08a62..000000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security Policy - -## Reporting a Vulnerability - -Please report security vulnerabilities to [trysound@yandex.ru](mailto:trysound@yandex.ru). diff --git a/lib/parser.js b/lib/parser.js index 4359373a9..4637acf15 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -100,7 +100,7 @@ const parseSvg = (data, from) => { */ let current = root; /** - * @type {Array} + * @type {XastParent[]} */ const stack = [root]; diff --git a/lib/path.js b/lib/path.js index a5f7d5bfc..8e6b47221 100644 --- a/lib/path.js +++ b/lib/path.js @@ -135,11 +135,11 @@ const readNumber = (string, cursor) => { }; /** - * @type {(string: string) => Array} + * @type {(string: string) => PathDataItem[]} */ const parsePathData = (string) => { /** - * @type {Array} + * @type {PathDataItem[]} */ const pathData = []; /** @@ -307,7 +307,7 @@ const stringifyArgs = (command, args, precision, disableSpaceAfterFlags) => { /** * @typedef {{ - * pathData: Array; + * pathData: PathDataItem[]; * precision?: number; * disableSpaceAfterFlags?: boolean; * }} StringifyPathDataOptions diff --git a/lib/path.test.js b/lib/path.test.js index 8282ea95c..91e6eaa91 100644 --- a/lib/path.test.js +++ b/lib/path.test.js @@ -146,7 +146,7 @@ describe('stringify path data', () => { }); it('should configure precision', () => { /** - * @type {Array} + * @type {PathDataItem[]} */ const pathData = [ { command: 'M', args: [0, -1.9876] }, @@ -169,7 +169,7 @@ describe('stringify path data', () => { }); it('allows to avoid spaces after arc flags', () => { /** - * @type {Array} + * @type {PathDataItem[]} */ const pathData = [ { command: 'M', args: [0, 0] }, diff --git a/lib/style.js b/lib/style.js index e54993a3c..fbfffc6b4 100644 --- a/lib/style.js +++ b/lib/style.js @@ -34,7 +34,7 @@ const csstreeWalkSkip = csstree.walk.skip; */ const parseRule = (ruleNode, dynamic) => { /** - * @type {Array} + * @type {StylesheetDeclaration[]} */ const declarations = []; // collect declarations @@ -74,10 +74,10 @@ const parseRule = (ruleNode, dynamic) => { }; /** - * @type {(css: string, dynamic: boolean) => Array} + * @type {(css: string, dynamic: boolean) => StylesheetRule[]} */ const parseStylesheet = (css, dynamic) => { - /** @type {Array} */ + /** @type {StylesheetRule[]} */ const rules = []; const ast = csstree.parse(css, { parseValue: false, @@ -108,10 +108,10 @@ const parseStylesheet = (css, dynamic) => { }; /** - * @type {(css: string) => Array} + * @type {(css: string) => StylesheetDeclaration[]} */ const parseStyleDeclarations = (css) => { - /** @type {Array} */ + /** @type {StylesheetDeclaration[]} */ const declarations = []; const ast = csstree.parse(css, { context: 'declarationList', diff --git a/lib/svgo/coa.js b/lib/svgo/coa.js index 331812f5e..8e638d068 100644 --- a/lib/svgo/coa.js +++ b/lib/svgo/coa.js @@ -254,10 +254,7 @@ async function action(args, opts, command) { process.stdin .on('data', (chunk) => (data += chunk)) .once('end', () => - processSVGData(config, { input: 'string' }, data, file).then( - resolve, - reject, - ), + processSVGData(config, null, data, file).then(resolve, reject), ); }); // file @@ -271,7 +268,7 @@ async function action(args, opts, command) { } else if (opts.string) { var data = decodeSVGDatauri(opts.string); - return processSVGData(config, { input: 'string' }, data, output[0]); + return processSVGData(config, null, data, output[0]); } } @@ -372,8 +369,7 @@ function getFilesDescriptions(config, dir, files, output) { */ function optimizeFile(config, file, output) { return fs.promises.readFile(file, 'utf8').then( - (data) => - processSVGData(config, { input: 'file', path: file }, data, output, file), + (data) => processSVGData(config, { path: file }, data, output, file), (error) => checkOptimizeFileError(config, file, output, error), ); } diff --git a/lib/svgo/tools.js b/lib/svgo/tools.js index afbda50c0..618ca70aa 100644 --- a/lib/svgo/tools.js +++ b/lib/svgo/tools.js @@ -74,7 +74,7 @@ exports.decodeSVGDatauri = (str) => { * @example * [0, -1, .5, .5] → "0-1 .5.5" * - * @type {(data: Array, params: CleanupOutDataParams, command?: PathDataCommand) => string} + * @type {(data: number[], params: CleanupOutDataParams, command?: PathDataCommand) => string} */ exports.cleanupOutData = (data, params, command) => { let str = ''; diff --git a/lib/types.d.ts b/lib/types.d.ts index 75818c4a6..68dc97478 100644 --- a/lib/types.d.ts +++ b/lib/types.d.ts @@ -31,7 +31,7 @@ export type XastElement = { type: 'element'; name: string; attributes: Record; - children: Array; + children: XastChild[]; }; export type XastChild = @@ -44,7 +44,7 @@ export type XastChild = export type XastRoot = { type: 'root'; - children: Array; + children: XastChild[]; }; export type XastParent = XastRoot | XastElement; @@ -123,11 +123,11 @@ export type StylesheetRule = { dynamic: boolean; selector: string; specificity: Specificity; - declarations: Array; + declarations: StylesheetDeclaration[]; }; export type Stylesheet = { - rules: Array; + rules: StylesheetRule[]; parents: Map; }; @@ -168,7 +168,7 @@ export type PathDataCommand = export type PathDataItem = { command: PathDataCommand; - args: Array; + args: number[]; }; export type DataUri = 'base64' | 'enc' | 'unenc'; diff --git a/lib/xast.js b/lib/xast.js index 7f14e2a87..9dca96460 100644 --- a/lib/xast.js +++ b/lib/xast.js @@ -16,7 +16,7 @@ const cssSelectOptions = { }; /** - * @type {(node: XastNode, selector: string) => Array} + * @type {(node: XastNode, selector: string) => XastChild[]} */ const querySelectorAll = (node, selector) => { return selectAll(selector, node, cssSelectOptions); diff --git a/lib/xast.test.js b/lib/xast.test.js index aefaaed5e..4371fc938 100644 --- a/lib/xast.test.js +++ b/lib/xast.test.js @@ -8,7 +8,7 @@ const { visit, visitSkip, detachNodeFromParent } = require('./xast.js'); /** - * @type {(children: Array) => XastRoot} + * @type {(children: XastElement[]) => XastRoot} */ const root = (children) => { return { type: 'root', children }; @@ -18,7 +18,7 @@ const root = (children) => { * @type {( * name: string, * attrs?: ?Record, - * children?: Array + * children?: XastElement[] * ) => XastElement} */ const x = (name, attrs = null, children = []) => { @@ -28,7 +28,7 @@ const x = (name, attrs = null, children = []) => { test('visit enters into nodes', () => { const ast = root([x('g', null, [x('rect'), x('circle')]), x('ellipse')]); /** - * @type {Array} + * @type {string[]} */ const entered = []; visit(ast, { @@ -55,7 +55,7 @@ test('visit enters into nodes', () => { test('visit exits from nodes', () => { const ast = root([x('g', null, [x('rect'), x('circle')]), x('ellipse')]); /** - * @type {Array} + * @type {string[]} */ const exited = []; visit(ast, { @@ -82,7 +82,7 @@ test('visit exits from nodes', () => { test('visit skips entering children if node is detached', () => { const ast = root([x('g', null, [x('rect'), x('circle')]), x('ellipse')]); /** - * @type {Array} + * @type {string[]} */ const entered = []; visit(ast, { @@ -102,7 +102,7 @@ test('visit skips entering children if node is detached', () => { test('visit skips entering children when symbol is passed', () => { const ast = root([x('g', null, [x('rect'), x('circle')]), x('ellipse')]); /** - * @type {Array} + * @type {string[]} */ const entered = []; visit(ast, { diff --git a/plugins/_path.js b/plugins/_path.js index 60b4a9d72..7c3a28b93 100644 --- a/plugins/_path.js +++ b/plugins/_path.js @@ -15,13 +15,13 @@ var prevCtrlPoint; /** * Convert path string to JS representation. * - * @type {(path: XastElement) => Array} + * @type {(path: XastElement) => PathDataItem[]} */ const path2js = (path) => { // @ts-ignore legacy if (path.pathJS) return path.pathJS; /** - * @type {Array} + * @type {PathDataItem[]} */ const pathData = []; // JS representation of the path data const newPathData = parsePathData(path.attributes.d); @@ -41,12 +41,12 @@ exports.path2js = path2js; /** * Convert relative Path data to absolute. * - * @type {(data: Array) => Array} + * @type {(data: PathDataItem[]) => PathDataItem[]} * */ const convertRelativeToAbsolute = (data) => { /** - * @type {Array} + * @type {PathDataItem[]} */ const newData = []; let start = [0, 0]; @@ -179,7 +179,7 @@ const convertRelativeToAbsolute = (data) => { /** * Convert path array to string. * - * @type {(path: XastElement, data: Array, params: Js2PathParams) => void} + * @type {(path: XastElement, data: PathDataItem[], params: Js2PathParams) => void} */ exports.js2path = function (path, data, params) { // @ts-ignore legacy @@ -211,7 +211,7 @@ exports.js2path = function (path, data, params) { }; /** - * @type {(dest: Array, source: Array) => Array} + * @type {(dest: number[], source: number[]) => number[]} */ function set(dest, source) { dest[0] = source[source.length - 2]; @@ -224,7 +224,7 @@ function set(dest, source) { * collision using Gilbert-Johnson-Keerthi distance algorithm * https://web.archive.org/web/20180822200027/http://entropyinteractive.com/2011/04/gjk-algorithm/ * - * @type {(path1: Array, path2: Array) => boolean} + * @type {(path1: PathDataItem[], path2: PathDataItem[]) => boolean} */ exports.intersects = function (path1, path2) { // Collect points of every subpath. @@ -284,7 +284,7 @@ exports.intersects = function (path1, path2) { }); /** - * @type {(a: Point, b: Point, direction: Array) => Array} + * @type {(a: Point, b: Point, direction: number[]) => number[]} */ function getSupport(a, b, direction) { return sub(supportPoint(a, direction), supportPoint(b, minus(direction))); @@ -294,7 +294,7 @@ exports.intersects = function (path1, path2) { // Thanks to knowledge of min/max x and y coordinates we can choose a quadrant to search in. // Since we're working on convex hull, the dot product is increasing until we find the farthest point. /** - * @type {(polygon: Point, direction: Array) => Array} + * @type {(polygon: Point, direction: number[]) => number[]} */ function supportPoint(polygon, direction) { var index = @@ -316,7 +316,7 @@ exports.intersects = function (path1, path2) { }; /** - * @type {(simplex: Array>, direction: Array) => boolean} + * @type {(simplex: number[][], direction: number[]) => boolean} */ function processSimplex(simplex, direction) { // we only need to handle to 1-simplex and 2-simplex @@ -373,28 +373,28 @@ function processSimplex(simplex, direction) { } /** - * @type {(v: Array) => Array} + * @type {(v: number[]) => number[]} */ function minus(v) { return [-v[0], -v[1]]; } /** - * @type {(v1: Array, v2: Array) => Array} + * @type {(v1: number[], v2: number[]) => number[]} */ function sub(v1, v2) { return [v1[0] - v2[0], v1[1] - v2[1]]; } /** - * @type {(v1: Array, v2: Array) => number} + * @type {(v1: number[], v2: number[]) => number} */ function dot(v1, v2) { return v1[0] * v2[0] + v1[1] * v2[1]; } /** - * @type {(v1: Array, v2: Array) => Array} + * @type {(v1: number[], v2: number[]) => number[]} */ function orth(v, from) { var o = [-v[1], v[0]]; @@ -403,7 +403,7 @@ function orth(v, from) { /** * @typedef {{ - * list: Array>, + * list: number[][], * minX: number, * minY: number, * maxX: number, @@ -413,7 +413,7 @@ function orth(v, from) { /** * @typedef {{ - * list: Array, + * list: Point[], * minX: number, * minY: number, * maxX: number, @@ -422,7 +422,7 @@ function orth(v, from) { */ /** - * @type {(pathData: Array) => Points} + * @type {(pathData: PathDataItem[]) => Points} */ function gatherPoints(pathData) { /** @@ -432,7 +432,7 @@ function gatherPoints(pathData) { // Writes data about the extreme points on each axle /** - * @type {(path: Point, point: Array) => void} + * @type {(path: Point, point: number[]) => void} */ const addPoint = (path, point) => { if (!path.list.length || point[1] > path.list[path.maxY][1]) { @@ -670,7 +670,7 @@ function convexHull(points) { } /** - * @type {(o: Array, a: Array, b: Array) => number} + * @type {(o: number[], a: number[], b: number[]) => number} */ function cross(o, a, b) { return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]); @@ -690,8 +690,8 @@ function cross(o, a, b) { * sweep_flag: number, * x2: number, * y2: number, - * recursive: Array - * ) => Array} + * recursive: number[] + * ) => number[]} */ const a2c = ( x1, @@ -710,7 +710,7 @@ const a2c = ( const _120 = (Math.PI * 120) / 180; const rad = (Math.PI / 180) * (+angle || 0); /** - * @type {Array} + * @type {number[]} */ let res = []; /** diff --git a/plugins/_transforms.js b/plugins/_transforms.js index df327bc65..5606b6e7d 100644 --- a/plugins/_transforms.js +++ b/plugins/_transforms.js @@ -6,18 +6,18 @@ const regTransformSplit = const regNumericValues = /[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?/g; /** - * @typedef {{ name: string, data: Array }} TransformItem + * @typedef {{ name: string, data: number[] }} TransformItem */ /** * Convert transform string to JS representation. * - * @type {(transformString: string) => Array} + * @type {(transformString: string) => TransformItem[]} */ exports.transform2js = (transformString) => { // JS representation of the transform data /** - * @type {Array} + * @type {TransformItem[]} */ const transforms = []; // current transform context @@ -53,7 +53,7 @@ exports.transform2js = (transformString) => { /** * Multiply transforms into one. * - * @type {(transforms: Array) => TransformItem} + * @type {(transforms: TransformItem[]) => TransformItem} */ exports.transformsMultiply = (transforms) => { // convert transforms objects to the matrices @@ -153,7 +153,7 @@ const mth = { * Decompose matrix into simple transforms. See * https://frederic-wang.fr/decomposition-of-2d-transform-matrices.html * - * @type {(transform: TransformItem, params: TransformParams) => Array} + * @type {(transform: TransformItem, params: TransformParams) => TransformItem[]} */ exports.matrixToTransform = (transform, params) => { let floatPrecision = params.floatPrecision; @@ -248,7 +248,7 @@ exports.matrixToTransform = (transform, params) => { /** * Convert transform to the matrix data. * - * @type {(transform: TransformItem) => Array } + * @type {(transform: TransformItem) => number[] } */ const transformToMatrix = (transform) => { if (transform.name === 'matrix') { @@ -301,9 +301,9 @@ const transformToMatrix = (transform) => { * * @type {( * cursor: [x: number, y: number], - * arc: Array, - * transform: Array - * ) => Array} + * arc: number[], + * transform: number[] + * ) => number[]} */ exports.transformArc = (cursor, arc, transform) => { const x = arc[5] - cursor[0]; @@ -364,7 +364,7 @@ exports.transformArc = (cursor, arc, transform) => { /** * Multiply transformation matrices. * - * @type {(a: Array, b: Array) => Array} + * @type {(a: number[], b: number[]) => number[]} */ const multiplyTransformMatrices = (a, b) => { return [ diff --git a/plugins/applyTransforms.js b/plugins/applyTransforms.js index 3817c3d64..ae492d54a 100644 --- a/plugins/applyTransforms.js +++ b/plugins/applyTransforms.js @@ -19,8 +19,8 @@ const { const { referencesProps, attrsGroupsDefaults } = require('./_collections.js'); /** - * @typedef {Array} PathData - * @typedef {Array} Matrix + * @typedef {PathDataItem[]} PathData + * @typedef {number[]} Matrix */ const regNumericValues = /[-+]?(\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?/g; diff --git a/plugins/cleanupIds.js b/plugins/cleanupIds.js index cdbc207a8..bfabcca55 100644 --- a/plugins/cleanupIds.js +++ b/plugins/cleanupIds.js @@ -69,7 +69,7 @@ const maxIdIndex = generateIdChars.length - 1; /** * Check if an ID starts with any one of a list of strings. * - * @type {(string: string, prefixes: Array) => boolean} + * @type {(string: string, prefixes: string[]) => boolean} */ const hasStringPrefix = (string, prefixes) => { for (const prefix of prefixes) { @@ -109,7 +109,7 @@ const generateId = (currentId) => { /** * Get string from generated ID array. * - * @type {(arr: Array) => string} + * @type {(arr: number[]) => string} */ const getIdString = (arr) => { return arr.map((i) => generateIdChars[i]).join(''); @@ -144,7 +144,7 @@ exports.fn = (_root, params) => { */ const nodeById = new Map(); /** - * @type {Map>} + * @type {Map} */ const referencesById = new Map(); let deoptimized = false; diff --git a/plugins/convertColors.js b/plugins/convertColors.js index 98517a08a..d894283f8 100644 --- a/plugins/convertColors.js +++ b/plugins/convertColors.js @@ -22,7 +22,7 @@ const regHEX = /^#(([a-fA-F0-9])\2){3}$/; * * @author Jed Schmidt * - * @type {(rgb: Array) => string} + * @type {(rgb: number[]) => string} */ const convertRgbToHex = ([r, g, b]) => { // combine the octets into a 32-bit integer as: [1][r][g][b] diff --git a/plugins/convertShapeToPath.js b/plugins/convertShapeToPath.js index 8aa41cb72..f0ba0fd84 100644 --- a/plugins/convertShapeToPath.js +++ b/plugins/convertShapeToPath.js @@ -46,7 +46,7 @@ exports.fn = (root, params) => { // TODO: Calculate sizes from % and non-px units if possible. if (Number.isNaN(x - y + width - height)) return; /** - * @type {Array} + * @type {PathDataItem[]} */ const pathData = [ { command: 'M', args: [x, y] }, @@ -71,7 +71,7 @@ exports.fn = (root, params) => { const y2 = Number(node.attributes.y2 || '0'); if (Number.isNaN(x1 - y1 + x2 - y2)) return; /** - * @type {Array} + * @type {PathDataItem[]} */ const pathData = [ { command: 'M', args: [x1, y1] }, @@ -98,7 +98,7 @@ exports.fn = (root, params) => { return; } /** - * @type {Array} + * @type {PathDataItem[]} */ const pathData = []; for (let i = 0; i < coords.length; i += 2) { @@ -124,7 +124,7 @@ exports.fn = (root, params) => { return; } /** - * @type {Array} + * @type {PathDataItem[]} */ const pathData = [ { command: 'M', args: [cx, cy - r] }, @@ -149,7 +149,7 @@ exports.fn = (root, params) => { return; } /** - * @type {Array} + * @type {PathDataItem[]} */ const pathData = [ { command: 'M', args: [ecx, ecy - ry] }, diff --git a/plugins/convertTransform.js b/plugins/convertTransform.js index b8f75602e..730227ea3 100644 --- a/plugins/convertTransform.js +++ b/plugins/convertTransform.js @@ -94,7 +94,7 @@ exports.fn = (_root, params) => { */ /** - * @typedef {{ name: string, data: Array }} TransformItem + * @typedef {{ name: string, data: number[] }} TransformItem */ /** @@ -134,7 +134,7 @@ const convertTransform = (item, attrName, params) => { * degPrecision - for rotate and skew. By default it's equal to (roughly) * transformPrecision - 2 or floatPrecision whichever is lower. Can be set in params. * - * @type {(data: Array, params: TransformParams) => TransformParams} + * @type {(data: TransformItem[], params: TransformParams) => TransformParams} * * clone params so it don't affect other elements transformations. */ @@ -171,7 +171,7 @@ const definePrecision = (data, { ...newParams }) => { }; /** - * @type {(data: Array, params: TransformParams) => Array} + * @type {(data: number[], params: TransformParams) => number[]} */ const degRound = (data, params) => { if ( @@ -185,7 +185,7 @@ const degRound = (data, params) => { } }; /** - * @type {(data: Array, params: TransformParams) => Array} + * @type {(data: number[], params: TransformParams) => number[]} */ const floatRound = (data, params) => { if (params.floatPrecision >= 1 && params.floatPrecision < 20) { @@ -196,7 +196,7 @@ const floatRound = (data, params) => { }; /** - * @type {(data: Array, params: TransformParams) => Array} + * @type {(data: number[], params: TransformParams) => number[]} */ const transformRound = (data, params) => { if (params.transformPrecision >= 1 && params.floatPrecision < 20) { @@ -219,7 +219,7 @@ const floatDigits = (n) => { /** * Convert transforms to the shorthand alternatives. * - * @type {(transforms: Array, params: TransformParams) => Array} + * @type {(transforms: TransformItem[], params: TransformParams) => TransformItem[]} */ const convertToShorts = (transforms, params) => { for (var i = 0; i < transforms.length; i++) { @@ -294,7 +294,7 @@ const convertToShorts = (transforms, params) => { /** * Remove useless transforms. * - * @type {(transforms: Array) => Array} + * @type {(transforms: TransformItem[]) => TransformItem[]} */ const removeUseless = (transforms) => { return transforms.filter((transform) => { @@ -332,7 +332,7 @@ const removeUseless = (transforms) => { /** * Convert transforms JS representation to string. * - * @type {(transformJS: Array, params: TransformParams) => string} + * @type {(transformJS: TransformItem[], params: TransformParams) => string} */ const js2transform = (transformJS, params) => { const transformString = transformJS @@ -379,7 +379,7 @@ const roundTransform = (transform, params) => { /** * Rounds numbers in array. * - * @type {(data: Array) => Array} + * @type {(data: number[]) => number[]} */ const round = (data) => { return data.map(Math.round); @@ -390,7 +390,7 @@ const round = (data) => { * in transforms keeping a specified number of decimals. * Smart rounds values like 2.349 to 2.35. * - * @type {(precision: number, data: Array) => Array} + * @type {(precision: number, data: number[]) => number[]} */ const smartRound = (precision, data) => { for ( diff --git a/plugins/inlineStyles.js b/plugins/inlineStyles.js index 84b264eac..42029d2bd 100644 --- a/plugins/inlineStyles.js +++ b/plugins/inlineStyles.js @@ -51,16 +51,16 @@ exports.fn = (root, params) => { } = params; /** - * @type {Array<{ node: XastElement, parentNode: XastParent, cssAst: csstree.StyleSheet }>} + * @type {{ node: XastElement, parentNode: XastParent, cssAst: csstree.StyleSheet }[]} */ const styles = []; /** - * @type {Array<{ + * @type {{ * node: csstree.Selector, * item: csstree.ListItem, * rule: csstree.Rule, - * matchedElements?: Array - * }>} + * matchedElements?: XastElement[] + * }[]} */ let selectors = []; @@ -123,10 +123,10 @@ exports.fn = (root, params) => { node.prelude.children.forEach((childNode, item) => { if (childNode.type === 'Selector') { /** - * @type {Array<{ + * @type {{ * item: csstree.ListItem, * list: csstree.List - * }>} + * }[]} */ const pseudos = []; @@ -187,7 +187,7 @@ exports.fn = (root, params) => { for (const selector of sortedSelectors) { // match selectors const selectorText = csstree.generate(selector.item.data); - /** @type {Array} */ + /** @type {XastElement[]} */ const matchedElements = []; try { for (const node of querySelectorAll(root, selectorText)) { diff --git a/plugins/minifyStyles.js b/plugins/minifyStyles.js index 598b6db33..ade441b3b 100644 --- a/plugins/minifyStyles.js +++ b/plugins/minifyStyles.js @@ -22,7 +22,7 @@ exports.fn = (_root, { usage, ...params }) => { /** @type {Map} */ const styleElements = new Map(); - /** @type {Array} */ + /** @type {XastElement[]} */ const elementsWithStyleAttributes = []; /** @type {Set} */ diff --git a/plugins/removeEditorsNSData.js b/plugins/removeEditorsNSData.js index 992241ea2..852681bf8 100644 --- a/plugins/removeEditorsNSData.js +++ b/plugins/removeEditorsNSData.js @@ -24,7 +24,7 @@ exports.fn = (_root, params) => { namespaces = [...editorNamespaces, ...params.additionalNamespaces]; } /** - * @type {Array} + * @type {string[]} */ const prefixes = []; return { diff --git a/plugins/removeOffCanvasPaths.js b/plugins/removeOffCanvasPaths.js index 5f625d370..60a69fb1a 100644 --- a/plugins/removeOffCanvasPaths.js +++ b/plugins/removeOffCanvasPaths.js @@ -116,7 +116,7 @@ exports.fn = () => { const { left, top, width, height } = viewBoxData; /** - * @type {Array} + * @type {PathDataItem[]} */ const viewBoxPathData = [ { command: 'M', args: [left, top] }, diff --git a/plugins/removeUselessDefs.js b/plugins/removeUselessDefs.js index d642b874e..5d19810e3 100644 --- a/plugins/removeUselessDefs.js +++ b/plugins/removeUselessDefs.js @@ -23,7 +23,7 @@ exports.fn = () => { enter: (node, parentNode) => { if (node.name === 'defs') { /** - * @type {Array} + * @type {XastElement[]} */ const usefulNodes = []; collectUsefulNodes(node, usefulNodes); @@ -50,7 +50,7 @@ exports.fn = () => { }; /** - * @type {(node: XastElement, usefulNodes: Array) => void} + * @type {(node: XastElement, usefulNodes: XastElement[]) => void} */ const collectUsefulNodes = (node, usefulNodes) => { for (const child of node.children) { diff --git a/plugins/reusePaths.js b/plugins/reusePaths.js index 6079aceb7..8c2ddf0d3 100644 --- a/plugins/reusePaths.js +++ b/plugins/reusePaths.js @@ -27,7 +27,7 @@ exports.fn = (root) => { const stylesheet = collectStylesheet(root); /** - * @type {Map>} + * @type {Map} */ const paths = new Map(); diff --git a/test/regression-extract.js b/test/regression-extract.js index 2c0e6232f..e5a594e65 100644 --- a/test/regression-extract.js +++ b/test/regression-extract.js @@ -73,7 +73,7 @@ const extractTarGz = async (url, baseDir, include) => { (async () => { try { - console.info('Download W3C SVG 1.1 Test Suite and extract SVG files'); + console.info('Downloading W3C SVG 1.1 Test Suite and extracting files'); await extractTarGz( 'https://www.w3.org/Graphics/SVG/Test/20110816/archives/W3C_SVG_11_TestSuite.tar.gz', path.join(__dirname, 'regression-fixtures', 'w3c-svg-11-test-suite'), diff --git a/test/svgo/_index.test.js b/test/svgo/_index.test.js index a9e5f06c7..e855dc6bf 100644 --- a/test/svgo/_index.test.js +++ b/test/svgo/_index.test.js @@ -36,7 +36,7 @@ describe('svgo', () => { expect(result.data).toEqual(''); }); it('should preserve style specificity over attributes', async () => { - const [original, expected] = await parseFixture('style-specifity.svg'); + const [original, expected] = await parseFixture('style-specificity.svg'); const result = optimize(original, { path: 'input.svg', js2svg: { pretty: true }, diff --git a/test/svgo/style-specifity.svg b/test/svgo/style-specificity.svg similarity index 100% rename from test/svgo/style-specifity.svg rename to test/svgo/style-specificity.svg