1
0
mirror of https://github.com/robonen/tools.git synced 2026-03-20 19:04:46 +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

@@ -3,7 +3,7 @@ import { computed, defineComponent, nextTick, ref, shallowRef } from 'vue';
import { mount } from '@vue/test-utils'
import { unrefElement } from '.';
describe('unrefElement', () => {
describe(unrefElement, () => {
it('returns a plain element when passed a raw element', () => {
const htmlEl = document.createElement('div');
const svgEl = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
@@ -47,14 +47,14 @@ describe('unrefElement', () => {
const result = unrefElement(childInstance);
expect(result).toBe(childInstance.$el);
expect((result as HTMLElement).classList.contains('child-el')).toBe(true);
expect((result as HTMLElement).classList.contains('child-el')).toBeTruthy();
});
it('handles null and undefined values', () => {
expect(unrefElement(undefined)).toBe(undefined);
expect(unrefElement(null)).toBe(null);
expect(unrefElement(ref(null))).toBe(null);
expect(unrefElement(ref(undefined))).toBe(undefined);
expect(unrefElement(ref<null>(null))).toBe(null);
expect(unrefElement(ref<undefined>(undefined))).toBe(undefined);
expect(unrefElement(() => null)).toBe(null);
expect(unrefElement(() => undefined)).toBe(undefined);
});

View File

@@ -14,7 +14,7 @@ const ComponentStub = defineComponent({
template: `<div>{{ visibleCount }}</div>`,
});
describe('useRenderCount', () => {
describe(useRenderCount, () => {
it('return the number of times the component has been rendered', async () => {
const component = mount(ComponentStub);

View File

@@ -1,4 +1,5 @@
import { onMounted, onUpdated, readonly, type ComponentInternalInstance } from 'vue';
import { onMounted, onUpdated, readonly } from 'vue';
import type { ComponentInternalInstance } from 'vue';
import { useCounter } from '@/composables/state/useCounter';
import { getLifeCycleTarger } from '@/utils';

View File

@@ -26,7 +26,7 @@ const UnnamedComponentStub = defineComponent({
template: `<div>{{ visibleCount }}</div>`,
});
describe('useRenderInfo', () => {
describe(useRenderInfo, () => {
it('return uid if component name is not available', async () => {
const wrapper = mount(UnnamedComponentStub);
@@ -42,8 +42,8 @@ describe('useRenderInfo', () => {
expect(wrapper.vm.info.duration.value).toBeGreaterThan(0);
expect(wrapper.vm.info.lastRendered).toBeGreaterThan(0);
let lastRendered = wrapper.vm.info.lastRendered;
let duration = wrapper.vm.info.duration.value;
const lastRendered = wrapper.vm.info.lastRendered;
const duration = wrapper.vm.info.duration.value;
// Will not trigger a render
wrapper.vm.hiddenCount++;
@@ -76,8 +76,8 @@ describe('useRenderInfo', () => {
expect(info.duration.value).toBe(0);
expect(info.lastRendered).toBeGreaterThan(0);
let lastRendered = info.lastRendered;
let duration = info.duration.value;
const lastRendered = info.lastRendered;
const duration = info.duration.value;
// Will not trigger a render
wrapper.vm.hiddenCount++;

View File

@@ -1,5 +1,6 @@
import { timestamp } from '@robonen/stdlib';
import { onBeforeMount, onBeforeUpdate, onMounted, onUpdated, readonly, ref, type ComponentInternalInstance } from 'vue';
import { onBeforeMount, onBeforeUpdate, onMounted, onUpdated, readonly, ref } from 'vue';
import type { ComponentInternalInstance } from 'vue';
import { useRenderCount } from '../useRenderCount';
import { getLifeCycleTarger } from '@/utils';
@@ -24,7 +25,7 @@ export function useRenderInfo(instance?: ComponentInternalInstance) {
const duration = ref(0);
let renderStartTime = 0;
const startMark = () => renderStartTime = performance.now();
const startMark = () => { renderStartTime = performance.now(); };
const endMark = () => {
duration.value = Math.max(performance.now() - renderStartTime, 0);
renderStartTime = 0;