Skip to content

Commit 8451c9e

Browse files
committed
fix lint
1 parent 936005e commit 8451c9e

File tree

4 files changed

+28
-27
lines changed

4 files changed

+28
-27
lines changed

src/__tests__/router.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@ describe('router', () => {
1010
});
1111

1212
it('provides analytics templates for every route', () => {
13-
router.getRoutes().forEach((route) => {
13+
for (const route of router.getRoutes()) {
1414
const template = route.meta?.analytics?.pageviewTemplate;
1515
expect(template).toBeTypeOf('function');
1616
const payload = template({ path: route.path });
1717
expect(payload).toMatchObject({ page: route.path });
1818
expect(payload.title.length).toBeGreaterThan(0);
19-
});
19+
}
2020
});
2121

2222
it('resolves each lazy component definition', async () => {
2323
const configs = router.options.routes;
2424
const components = await Promise.all(configs.map((route) => route.component()));
25-
components.forEach((module) => {
25+
for (const module of components) {
2626
expect(module).toBeTruthy();
27-
});
27+
}
2828
});
2929
});

src/__tests__/store.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ describe('store internals', () => {
270270
internals.restoreSelectionSnapshot(snapshot);
271271

272272
expect(selection.rangeCount).toBe(1);
273-
delete editable.textContent;
273+
Reflect.deleteProperty(editable, 'textContent');
274274
});
275275

276276
it('skips selection restoration when overrides return null positions', () => {
@@ -295,9 +295,9 @@ describe('store without DOM APIs', () => {
295295
const realDocument = globalThis.document;
296296
const realNodeFilter = globalThis.NodeFilter;
297297

298-
delete globalThis.window;
299-
delete globalThis.document;
300-
delete globalThis.NodeFilter;
298+
globalThis.window = undefined;
299+
globalThis.document = undefined;
300+
globalThis.NodeFilter = undefined;
301301

302302
vi.resetModules();
303303

src/components/ExportBtn.vue

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,27 @@ const store = useStore();
2727
const showMenu = ref(false);
2828
const btnRef = ref(null);
2929
30-
onClickOutside(btnRef, () => (showMenu.value = false));
30+
onClickOutside(btnRef, () => {
31+
showMenu.value = false;
32+
});
3133
3234
const downloadImage = (imgsrc, name) => {
3335
//下载图片地址和图片名
34-
let image = new Image();
36+
const image = new Image();
3537
// 解决跨域 Canvas 污染问题
3638
image.setAttribute('crossOrigin', 'anonymous');
37-
image.onload = function () {
38-
let canvas = document.createElement('canvas');
39+
image.onload = () => {
40+
const canvas = document.createElement('canvas');
3941
canvas.width = image.width;
4042
canvas.height = image.height;
41-
let context = canvas.getContext('2d');
43+
const context = canvas.getContext('2d');
4244
context.drawImage(image, 0, 0, image.width, image.height);
43-
let url = canvas.toDataURL('image/png');
44-
let a = document.createElement('a');
45-
let event = new MouseEvent('click');
46-
a.download = name || 'photo';
47-
a.href = url;
48-
a.dispatchEvent(event);
45+
const url = canvas.toDataURL('image/png');
46+
const link = document.createElement('a');
47+
const clickEvent = new MouseEvent('click');
48+
link.download = name || 'photo';
49+
link.href = url;
50+
link.dispatchEvent(clickEvent);
4951
};
5052
image.src = imgsrc;
5153
};
@@ -58,14 +60,14 @@ const download = (type) => {
5860
if (!node) return;
5961
6062
if (type === 'png') {
61-
domtoimage.toPng(node).then(function (res) {
62-
downloadImage(res, store.prefix + '-' + store.suffix + '.png');
63+
domtoimage.toPng(node).then((res) => {
64+
downloadImage(res, `${store.prefix}-${store.suffix}.png`);
6365
store.editable = true;
6466
});
6567
} else if (type === 'svg') {
66-
domtoimage.toSvg(node).then(function (res) {
67-
var link = document.createElement('a');
68-
link.download = store.prefix + '-' + store.suffix + '.svg';
68+
domtoimage.toSvg(node).then((res) => {
69+
const link = document.createElement('a');
70+
link.download = `${store.prefix}-${store.suffix}.svg`;
6971
link.href = res;
7072
link.click();
7173
store.editable = true;

vitest.setup.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ config.global.stubs = {
3131
...(config.global.stubs ?? {}),
3232
...Object.fromEntries(vuetifyTags.map((tag) => [tag, slotStub])),
3333
'router-link': {
34-
template: `<a><slot /></a>`
34+
template: '<a><slot /></a>'
3535
},
3636
'router-view': {
37-
template: `<div><slot /></div>`
37+
template: '<div><slot /></div>'
3838
}
3939
};
4040

@@ -69,7 +69,6 @@ class ResizeObserver {
6969
}
7070

7171
class IntersectionObserver {
72-
constructor() {}
7372
observe() {}
7473
unobserve() {}
7574
disconnect() {}

0 commit comments

Comments
 (0)