Skip to content

Commit

Permalink
chore: fix cheerio types
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberalien committed Aug 11, 2024
1 parent 89052a0 commit 3d8d54b
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 606 deletions.
5 changes: 3 additions & 2 deletions @iconify/tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "module",
"description": "Collection of functions for cleaning up and parsing SVG for Iconify project",
"author": "Vjacheslav Trushkin",
"version": "4.0.4",
"version": "4.0.5",
"license": "MIT",
"bugs": "https://github.com/iconify/tools/issues",
"homepage": "https://github.com/iconify/tools",
Expand All @@ -29,7 +29,8 @@
"@iconify/utils": "^2.1.29",
"@types/tar": "^6.1.13",
"axios": "^1.7.3",
"cheerio": "1.0.0-rc.12",
"cheerio": "1.0.0",
"domhandler": "^5.0.3",
"extract-zip": "^2.0.1",
"local-pkg": "^0.5.0",
"pathe": "^1.1.2",
Expand Down
7 changes: 4 additions & 3 deletions @iconify/tools/src/misc/cheerio.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as cheerio from 'cheerio';
import type { Element } from 'domhandler';
import type { Cheerio } from 'cheerio';

/**
* Shortcuts for Cheerio elements
*/
export type CheerioElement = cheerio.Element;
export type WrappedCheerioElement = cheerio.Cheerio<cheerio.Element>;
export type CheerioElement = Element;
export type WrappedCheerioElement = Cheerio<CheerioElement>;
2 changes: 1 addition & 1 deletion @iconify/tools/src/optimise/figma.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { colorToString, stringToColor } from '@iconify/utils';
import { CheerioElement } from '../misc/cheerio';
import type { CheerioElement } from '../misc/cheerio';
import { SVG } from '../svg';
import { cleanupInlineStyle } from '../svg/cleanup/inline-style';
import { defsTag, maskTags, symbolTag } from '../svg/data/tags';
Expand Down
2 changes: 1 addition & 1 deletion @iconify/tools/src/svg/analyse/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CheerioElement } from '../../misc/cheerio';
import type { CheerioElement } from '../../misc/cheerio';

/**
* Options
Expand Down
3 changes: 2 additions & 1 deletion @iconify/tools/src/svg/cleanup/root-svg.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CheerioElement } from '../../misc/cheerio';
import type { CheerioElement } from '../../misc/cheerio';
import type { SVG } from '../../svg';
import {
badAttributes,
Expand Down Expand Up @@ -112,6 +112,7 @@ export function cleanupSVGRoot(svg: SVG) {

$root.children().each((_index, child) => {
const $child = cheerio(child);
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
if (child.type !== 'tag') {
$child.appendTo($wrapper);
return;
Expand Down
1 change: 1 addition & 0 deletions @iconify/tools/src/svg/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export class SVG {

// Load content
this.$svg = cheerio.load(content.trim(), {
// @ts-expect-error Legacy attribute, kept because Cheerio types are a unstable
lowerCaseAttributeNames: false,
xmlMode: true,
});
Expand Down
Loading

0 comments on commit 3d8d54b

Please sign in to comment.