1
0
mirror of https://github.com/robonen/tools.git synced 2026-03-21 03:14:43 +00:00

feat(configs/oxlint): add linter

This commit is contained in:
2026-02-14 22:49:47 +07:00
parent 2a5412c3b8
commit 49b9f2aa79
98 changed files with 1236 additions and 201 deletions

View File

@@ -4,7 +4,7 @@ import { useCached } from '.';
const arrayEquals = (a: number[], b: number[]) => a.length === b.length && a.every((v, i) => v === b[i]);
describe('useCached', () => {
describe(useCached, () => {
it('default comparator', async () => {
const externalValue = ref(0);
const cachedValue = useCached(externalValue);

View File

@@ -1,4 +1,5 @@
import { ref, watch, toValue, type MaybeRefOrGetter, type Ref, type WatchOptions } from 'vue';
import { ref, watch, toValue } from 'vue';
import type { MaybeRefOrGetter, Ref, WatchOptions } from 'vue';
export type Comparator<Value> = (a: Value, b: Value) => boolean;

View File

@@ -3,7 +3,7 @@ import { describe, it, expect } from 'vitest';
import { useLastChanged } from '.';
import { timestamp } from '@robonen/stdlib';
describe('useLastChanged', () => {
describe(useLastChanged, () => {
it('initialize with null if no initialValue is provided', () => {
const source = ref(0);
const lastChanged = useLastChanged(source);

View File

@@ -1,5 +1,6 @@
import { timestamp } from '@robonen/stdlib';
import { ref, watch, type WatchSource, type WatchOptions, type Ref } from 'vue';
import { ref, watch } from 'vue';
import type { WatchSource, WatchOptions, Ref } from 'vue';
export interface UseLastChangedOptions<
Immediate extends boolean,
@@ -32,7 +33,7 @@ export function useLastChanged(source: WatchSource, options: UseLastChangedOptio
export function useLastChanged(source: WatchSource, options: UseLastChangedOptions<boolean, any> = {}): Ref<number | null> | Ref<number> {
const lastChanged = ref<number | null>(options.initialValue ?? null);
watch(source, () => lastChanged.value = timestamp(), options);
watch(source, () => { lastChanged.value = timestamp(); }, options);
return lastChanged;
}

View File

@@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest';
import { ref } from 'vue';
import { useSyncRefs } from '.';
describe('useSyncRefs', () => {
describe(useSyncRefs, () => {
it('sync the value of a source ref with multiple target refs', () => {
const source = ref(0);
const target1 = ref(0);

View File

@@ -1,4 +1,5 @@
import { watch, type Ref, type WatchOptions, type WatchSource } from 'vue';
import { watch } from 'vue';
import type { Ref, WatchOptions, WatchSource } from 'vue';
import { isArray } from '@robonen/stdlib';
/**
@@ -40,7 +41,7 @@ export function useSyncRefs<T = unknown>(
return watch(
source,
(value) => targets.forEach((target) => target.value = value),
(value) => targets.forEach((target) => { target.value = value; }),
{ flush, deep, immediate },
);
}