Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix: add prefer-blob-reading-methods rule (#5118)

LongYinaneadf8a085bd7
diff --git a/.eslintrc.js b/.eslintrc.js
index 9f1fd2bba0..d0ac35f591 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -212,6 +212,7 @@ const config = {
'unicorn/prefer-dom-node-remove': 'error',
'unicorn/prefer-array-some': 'error',
'unicorn/prefer-date-now': 'error',
+ 'unicorn/prefer-blob-reading-methods': 'error',
'unicorn/no-typeof-undefined': 'error',
'unicorn/no-useless-promise-resolve-reject': 'error',
'unicorn/no-new-array': 'error',
diff --git a/tests/affine-cloud/e2e/collaboration.spec.ts b/tests/affine-cloud/e2e/collaboration.spec.ts
index 2af8c02d54..a592bc494c 100644
--- a/tests/affine-cloud/e2e/collaboration.spec.ts
+++ b/tests/affine-cloud/e2e/collaboration.spec.ts
@@ -368,18 +368,10 @@ test('can sync svg between different browsers', async ({ page, browser }) => {
expect(src).not.toBeNull();
// fetch the src resource in the browser
- const svg2 = await page2.evaluate(async src => {
- async function blobToString(blob: Blob) {
- return new Promise((resolve, reject) => {
- const reader = new FileReader();
- reader.onloadend = () => resolve(reader.result);
- reader.onerror = reject;
- reader.readAsText(blob);
- });
- }
-
- const blob = fetch(src!).then(res => res.blob());
- return blobToString(await blob);
+ const svg2 = await page2.evaluate(src => {
+ return fetch(src!)
+ .then(res => res.blob())
+ .then(blob => blob.text());
}, src);
// turn the blob into string and check if it contains the svg