Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberalien committed Dec 30, 2023
1 parent 29c70a6 commit 7b65c8b
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 14 deletions.
4 changes: 3 additions & 1 deletion @iconify/tools/src/colors/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -494,7 +496,7 @@ export function parseColors(
element,
item,
iconData
)
)
: defaultColor;

// Add color to results and change attribute
Expand Down
12 changes: 6 additions & 6 deletions @iconify/tools/src/download/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ interface DownloadNPMPackage {
export type DownloadParamsMixin<T extends DownloadSourceType> = 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
Expand Down
4 changes: 2 additions & 2 deletions @iconify/tools/src/export/directory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion @iconify/tools/src/export/json-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export async function exportJSONPackage(
? {
prefix: iconSet.prefix,
...exportedJSON.info,
}
}
: undefined;
const contents: ExportContents = {
icons,
Expand Down
4 changes: 2 additions & 2 deletions @iconify/tools/src/misc/scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ type Callback<T> = (
type AsyncCallback<T> = Callback<T | Promise<T>>;

export type ScanDirectoryCallback = AsyncCallback<
ScanDirectoryCallbackStringResult | unknown
ScanDirectoryCallbackStringResult | undefined
>;

export type ScanDirectorySyncCallback = Callback<
ScanDirectoryCallbackStringResult | unknown
ScanDirectoryCallbackStringResult | undefined
>;

/**
Expand Down
6 changes: 6 additions & 0 deletions @iconify/tools/src/optimise/figma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ function checkClipPathNode(
}

// Check child nodes: should have only <rect />
// 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;
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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)) {
Expand All @@ -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'
) {
Expand All @@ -214,6 +219,7 @@ export function removeFigmaClipPathFromSVG(svg: SVG): boolean {
// Check if <defs> is empty
const validChildren = node.children.filter(
(test) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
if (test.type === 'text') {
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions @iconify/tools/src/optimise/svgo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down Expand Up @@ -162,7 +162,7 @@ export function runSVGO(svg: SVG, options: SVGOOptions = {}) {
? () => {
// Return prefix with number
return prefix + (counter++).toString(36);
}
}
: prefix
);
}
Expand Down

0 comments on commit 7b65c8b

Please sign in to comment.