From 7b65c8b11432ca7f0f71fea10240ca0348e26996 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 30 Dec 2023 19:54:15 +0200 Subject: [PATCH] chore: lint --- @iconify/tools/src/colors/parse.ts | 4 +++- @iconify/tools/src/download/index.ts | 12 ++++++------ @iconify/tools/src/export/directory.ts | 4 ++-- @iconify/tools/src/export/json-package.ts | 2 +- @iconify/tools/src/misc/scan.ts | 4 ++-- @iconify/tools/src/optimise/figma.ts | 6 ++++++ @iconify/tools/src/optimise/svgo.ts | 4 ++-- 7 files changed, 22 insertions(+), 14 deletions(-) diff --git a/@iconify/tools/src/colors/parse.ts b/@iconify/tools/src/colors/parse.ts index 873ea67..1d5f782 100644 --- a/@iconify/tools/src/colors/parse.ts +++ b/@iconify/tools/src/colors/parse.ts @@ -48,6 +48,7 @@ export interface FindColorsResult { * - 'unset' to delete old value * - 'remove' to remove shape or rule */ +// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents type ParseColorsCallbackResult = Color | string | 'remove' | 'unset'; type ParseColorsCallback = ( attr: ColorAttributes, @@ -339,6 +340,7 @@ export function parseColors( // Mark all children as removed (direct children as in DOM) function removeChildren(element: ExtendedTagElementWithColors) { element.children.forEach((item) => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison if (item.type !== 'tag') { return; } @@ -494,7 +496,7 @@ export function parseColors( element, item, iconData - ) + ) : defaultColor; // Add color to results and change attribute diff --git a/@iconify/tools/src/download/index.ts b/@iconify/tools/src/download/index.ts index 8ea77f3..8482bf7 100644 --- a/@iconify/tools/src/download/index.ts +++ b/@iconify/tools/src/download/index.ts @@ -52,12 +52,12 @@ interface DownloadNPMPackage { export type DownloadParamsMixin = T extends 'git' ? DownloadGitRepo : T extends 'github' - ? DownloadGitHubRepo - : T extends 'gitlab' - ? DownloadGitLabRepo - : T extends 'npm' - ? DownloadNPMPackage - : never; + ? DownloadGitHubRepo + : T extends 'gitlab' + ? DownloadGitLabRepo + : T extends 'npm' + ? DownloadNPMPackage + : never; /** * Combinations diff --git a/@iconify/tools/src/export/directory.ts b/@iconify/tools/src/export/directory.ts index 3abcbd3..4bfe4a1 100644 --- a/@iconify/tools/src/export/directory.ts +++ b/@iconify/tools/src/export/directory.ts @@ -40,11 +40,11 @@ export async function exportToDirectory( options.autoHeight === false ? { height: '1em', - } + } : { width: 'auto', height: 'auto', - }; + }; // Function to save icon to file const store = async (name: string, target: string) => { diff --git a/@iconify/tools/src/export/json-package.ts b/@iconify/tools/src/export/json-package.ts index cef7593..2587554 100644 --- a/@iconify/tools/src/export/json-package.ts +++ b/@iconify/tools/src/export/json-package.ts @@ -96,7 +96,7 @@ export async function exportJSONPackage( ? { prefix: iconSet.prefix, ...exportedJSON.info, - } + } : undefined; const contents: ExportContents = { icons, diff --git a/@iconify/tools/src/misc/scan.ts b/@iconify/tools/src/misc/scan.ts index 443261d..5afa1e5 100644 --- a/@iconify/tools/src/misc/scan.ts +++ b/@iconify/tools/src/misc/scan.ts @@ -30,11 +30,11 @@ type Callback = ( type AsyncCallback = Callback>; export type ScanDirectoryCallback = AsyncCallback< - ScanDirectoryCallbackStringResult | unknown + ScanDirectoryCallbackStringResult | undefined >; export type ScanDirectorySyncCallback = Callback< - ScanDirectoryCallbackStringResult | unknown + ScanDirectoryCallbackStringResult | undefined >; /** diff --git a/@iconify/tools/src/optimise/figma.ts b/@iconify/tools/src/optimise/figma.ts index 5523fd0..941bac2 100644 --- a/@iconify/tools/src/optimise/figma.ts +++ b/@iconify/tools/src/optimise/figma.ts @@ -34,12 +34,14 @@ function checkClipPathNode( } // Check child nodes: should have only + // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison const children = clipNode.children.filter((node) => node.type !== 'text'); if (children.length !== 1) { return false; } const childNode = children[0]; + // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison if (childNode.type !== 'tag' || childNode.children.length) { // Not tag or has children return false; @@ -141,6 +143,7 @@ export function removeFigmaClipPathFromSVG(svg: SVG): boolean { let clipID: string | undefined; for (let i = 0; i < children.length; i++) { const node = children[i]; + // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison if (node.type === 'tag') { const tagName = node.tagName; if ( @@ -198,6 +201,7 @@ export function removeFigmaClipPathFromSVG(svg: SVG): boolean { const findClipPath = () => { for (let i = 0; i < children.length; i++) { const node = children[i]; + // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison if (node.type === 'tag') { const tagName = node.tagName; if (defsTag.has(tagName)) { @@ -206,6 +210,7 @@ export function removeFigmaClipPathFromSVG(svg: SVG): boolean { for (let j = 0; j < defsChildren.length; j++) { const childNode = defsChildren[j]; if ( + // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison childNode.type === 'tag' && childNode.tagName === 'clipPath' ) { @@ -214,6 +219,7 @@ export function removeFigmaClipPathFromSVG(svg: SVG): boolean { // Check if is empty const validChildren = node.children.filter( (test) => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison if (test.type === 'text') { return false; } diff --git a/@iconify/tools/src/optimise/svgo.ts b/@iconify/tools/src/optimise/svgo.ts index fcdc794..c7c7669 100644 --- a/@iconify/tools/src/optimise/svgo.ts +++ b/@iconify/tools/src/optimise/svgo.ts @@ -67,7 +67,7 @@ export function getSVGOPlugins(options: GetSVGOPluginOptions): PluginConfig[] { }, // 'removeOffCanvasPaths', // bugged for some icons 'reusePaths', - ]) as PluginConfig[]), + ]) as PluginConfig[]), // Clean up IDs, first run // Sometimes bugs out on animated icons. Do not use with animations! @@ -162,7 +162,7 @@ export function runSVGO(svg: SVG, options: SVGOOptions = {}) { ? () => { // Return prefix with number return prefix + (counter++).toString(36); - } + } : prefix ); }