fix: add prefer-for-of rule (#5121)

This commit is contained in:
LongYinan 2023-11-29 04:44:21 +00:00
parent acf2de813a
commit e9ea67bd38
No known key found for this signature in database
GPG Key ID: C3666B7FC82ADAD7
3 changed files with 6 additions and 5 deletions

View File

@ -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',
{

View File

@ -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;
}

View File

@ -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;
}
}