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-for-of rule (#5121)

LongYinane9ea67bd38a5
diff --git a/.eslintrc.js b/.eslintrc.js
index 16302e62b9..2bac52fb92 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -137,6 +137,7 @@ const config = {
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/require-array-sort-compare': 'error',
'@typescript-eslint/unified-signatures': 'error',
+ '@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
diff --git a/packages/frontend/component/src/components/page-list/utils.tsx b/packages/frontend/component/src/components/page-list/utils.tsx
index 1c33f2fd1f..c0f29a9e10 100644
--- a/packages/frontend/component/src/components/page-list/utils.tsx
+++ b/packages/frontend/component/src/components/page-list/utils.tsx
@@ -162,10 +162,10 @@ export function shallowEqual(objA: any, objB: any) {
}
// Test for A's keys different from B.
- for (let i = 0; i < keysA.length; i++) {
+ for (const key of keysA) {
if (
- !Object.prototype.hasOwnProperty.call(objB, keysA[i]) ||
- !Object.is(objA[keysA[i]], objB[keysA[i]])
+ !Object.prototype.hasOwnProperty.call(objB, key) ||
+ !Object.is(objA[key], objB[key])
) {
return false;
}
diff --git a/tools/workers/src/index.ts b/tools/workers/src/index.ts
index 364d631abb..d49e2c433e 100644
--- a/tools/workers/src/index.ts
+++ b/tools/workers/src/index.ts
@@ -14,8 +14,8 @@ function isOriginAllowed(
allowedOrigin: string | RegExp | Array<string | RegExp>
): boolean {
if (Array.isArray(allowedOrigin)) {
- for (let i = 0; i < allowedOrigin.length; ++i) {
- if (isOriginAllowed(origin, allowedOrigin[i])) {
+ for (const allowed of allowedOrigin) {
+ if (isOriginAllowed(origin, allowed)) {
return true;
}
}