mirror of
https://github.com/iconify/iconify.git
synced 2024-09-20 09:19:02 +00:00
lint
This commit is contained in:
parent
c119726e1a
commit
052c86c07b
@ -8,7 +8,7 @@ export function FileSystemIconLoader(dir: string, transform?: (svg: string) => A
|
|||||||
const paths = [
|
const paths = [
|
||||||
`${dir}/${name}.svg`,
|
`${dir}/${name}.svg`,
|
||||||
`${dir}/${camelize(name)}.svg`,
|
`${dir}/${camelize(name)}.svg`,
|
||||||
`${dir}/${pascalize(name)}.svg`,
|
`${dir}/${pascalize(name)}.svg`
|
||||||
];
|
];
|
||||||
for (const path of paths) {
|
for (const path of paths) {
|
||||||
if (existsSync(path)) {
|
if (existsSync(path)) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import type { Awaitable } from '@antfu/utils';
|
import type { Awaitable } from '@antfu/utils';
|
||||||
|
|
||||||
export type CustomIconLoader = (name: string) => Awaitable<string | undefined>
|
export type CustomIconLoader = (name: string) => Awaitable<string | undefined>;
|
||||||
export type InlineCollection = Record<string, string | (() => Awaitable<string | undefined>)>
|
export type InlineCollection = Record<string, string | (() => Awaitable<string | undefined>)>;
|
||||||
export type CustomCollections = Record<string, CustomIconLoader | InlineCollection>
|
export type CustomCollections = Record<string, CustomIconLoader | InlineCollection>;
|
||||||
|
@ -8,7 +8,7 @@ export function camelize(str: string): string {
|
|||||||
|
|
||||||
export function pascalize(str: string): string {
|
export function pascalize(str: string): string {
|
||||||
const camel = camelize(str);
|
const camel = camelize(str);
|
||||||
return camel[0].toUpperCase() + camel.slice(1);
|
return `${camel[0].toUpperCase()}${camel.slice(1)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function camelToKebab(key: string): string {
|
export function camelToKebab(key: string): string {
|
||||||
@ -19,12 +19,12 @@ export function camelToKebab(key: string): string {
|
|||||||
return result.split(/\s+/g).join('-').toLowerCase();
|
return result.split(/\s+/g).join('-').toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
const warnned = new Set<string>();
|
const warned = new Set<string>();
|
||||||
|
|
||||||
export function warnOnce(msg: string): void {
|
export function warnOnce(msg: string): void {
|
||||||
if (!warnned.has(msg)) {
|
if (!warned.has(msg)) {
|
||||||
warnned.add(msg);
|
warned.add(msg);
|
||||||
console.warn(yellow(`[@iconify-loader] ${msg}`))
|
console.warn(yellow(`[@iconify-loader] ${msg}`));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,11 +44,11 @@ export async function tryInstallPkg(name: string): Promise<void | undefined> {
|
|||||||
.then(() => sleep(300))
|
.then(() => sleep(300))
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
.catch((e: any) => {
|
.catch((e: any) => {
|
||||||
warnOnce(`Failed to install ${name}`)
|
warnOnce(`Failed to install ${name}`);
|
||||||
console.error(e)
|
console.error(e);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
pending = undefined
|
pending = undefined;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user