From 4b7397c187a7693a0db41b80ecc65e5801a43475 Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 23 Dec 2023 21:56:05 +0800 Subject: [PATCH] chore: lint fix --- README.md | 5 ++++- packages/core/src/utils.ts | 2 +- test/utils.test.ts | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e0b9512..783740f 100644 --- a/README.md +++ b/README.md @@ -209,7 +209,10 @@ export function postprocessWithUnColor(unColor: string): Postprocessor { export function importantProcess(): Postprocessor { return (util) => { - util.entries.forEach(i => i[1] += ' !important') + util.entries.forEach((i) => { + if (i[1] != null && !String(i[1]).includes('!important')) + i[1] += ' !important' + }) } } ``` diff --git a/packages/core/src/utils.ts b/packages/core/src/utils.ts index b1be0c0..9944dac 100644 --- a/packages/core/src/utils.ts +++ b/packages/core/src/utils.ts @@ -143,5 +143,5 @@ export function toArray(val: T | T[]): T[] { } export function camelToHyphen(str: string): string { - return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase(); + return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase() } diff --git a/test/utils.test.ts b/test/utils.test.ts index 9443d84..cca863c 100644 --- a/test/utils.test.ts +++ b/test/utils.test.ts @@ -1,6 +1,6 @@ import type { CSSObject } from 'unocss' import { describe, expect, it } from 'vitest' -import { cssObj2StrSync, resolveAnimation, stringifyObj, camelToHyphen } from 'unocss-preset-useful' +import { cssObj2StrSync, resolveAnimation, stringifyObj } from 'unocss-preset-useful' describe('utils', () => { const _animation = { @@ -54,7 +54,7 @@ describe('utils', () => { const obj = { foo: 'bb', bar: 'dd', - fooBar: 'fooBar' + fooBar: 'fooBar', } expect(stringifyObj(obj)).toMatchInlineSnapshot(`"{foo:bb;bar:dd;foo-bar:fooBar;}"`)