ESLint: allow `for..of`

This commit is contained in:
Evan Hahn 2021-08-26 13:18:00 -05:00 committed by GitHub
parent ff4aa228f6
commit 9e9a815a2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 6 additions and 57 deletions

View File

@ -95,11 +95,6 @@ const rules = {
message: message:
'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.', 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
}, },
{
selector: 'ForOfStatement',
message:
'iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.',
},
{ {
selector: 'LabeledStatement', selector: 'LabeledStatement',
message: message:

View File

@ -1,4 +1,4 @@
// Copyright 2018-2020 Signal Messenger, LLC // Copyright 2018-2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
const { isFunction, isObject, isString, omit } = require('lodash'); const { isFunction, isObject, isString, omit } = require('lodash');
@ -392,7 +392,6 @@ exports.upgradeSchema = async (
} }
let message = rawMessage; let message = rawMessage;
// eslint-disable-next-line no-restricted-syntax
for (let index = 0, max = VERSIONS.length; index < max; index += 1) { for (let index = 0, max = VERSIONS.length; index < max; index += 1) {
if (maxVersion < index) { if (maxVersion < index) {
break; break;

View File

@ -2,7 +2,6 @@
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable class-methods-use-this */ /* eslint-disable class-methods-use-this */
/* eslint-disable no-restricted-syntax */
import PQueue from 'p-queue'; import PQueue from 'p-queue';
import { isNumber } from 'lodash'; import { isNumber } from 'lodash';

View File

@ -1,6 +1,5 @@
// Copyright 2021 Signal Messenger, LLC // Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable no-restricted-syntax */
// `ChallengeHandler` is responsible for: // `ChallengeHandler` is responsible for:
// 1. tracking the messages that failed to send with 428 error and could be // 1. tracking the messages that failed to send with 428 error and could be

View File

@ -1,6 +1,5 @@
// Copyright 2021 Signal Messenger, LLC // Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable no-restricted-syntax */
import React, { useState } from 'react'; import React, { useState } from 'react';

View File

@ -125,9 +125,6 @@ export abstract class JobQueue<T> {
log.info(`${this.logPrefix} starting to stream jobs`); log.info(`${this.logPrefix} starting to stream jobs`);
const stream = this.store.stream(this.queueType); const stream = this.store.stream(this.queueType);
// We want to enqueue the jobs in sequence, not in parallel. `for await ... of` is a
// good way to do that.
// eslint-disable-next-line no-restricted-syntax
for await (const storedJob of stream) { for await (const storedJob of stream) {
this.enqueueStoredJob(storedJob); this.enqueueStoredJob(storedJob);
} }

View File

@ -293,8 +293,6 @@ const getHtmlDocument = async (
let bytesLoadedSoFar = 0; let bytesLoadedSoFar = 0;
try { try {
// `for ... of` is much cleaner here, so we allow it.
/* eslint-disable no-restricted-syntax */
for await (let chunk of body) { for await (let chunk of body) {
if (abortSignal.aborted) { if (abortSignal.aborted) {
break; break;
@ -322,7 +320,6 @@ const getHtmlDocument = async (
break; break;
} }
} }
/* eslint-enable no-restricted-syntax */
} catch (err) { } catch (err) {
window.log.warn( window.log.warn(
'getHtmlDocument: error when reading body; continuing with what we got' 'getHtmlDocument: error when reading body; continuing with what we got'

View File

@ -1,6 +1,5 @@
// Copyright 2021 Signal Messenger, LLC // Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable no-restricted-syntax */
import { ipcMain as ipc, nativeTheme, BrowserWindow } from 'electron'; import { ipcMain as ipc, nativeTheme, BrowserWindow } from 'electron';

View File

@ -1,6 +1,6 @@
// Copyright 2021 Signal Messenger, LLC // Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable no-restricted-syntax, no-console */ /* eslint-disable no-console */
import { ipcMain as ipc, IpcMainEvent } from 'electron'; import { ipcMain as ipc, IpcMainEvent } from 'electron';

View File

@ -45,7 +45,6 @@ export function migrateLegacySendAttributes(
return undefined; return undefined;
} }
/* eslint-disable no-restricted-syntax */
const pendingSendState: SendState = { const pendingSendState: SendState = {
status: SendStatus.Pending, status: SendStatus.Pending,
updatedAt: message.sent_at, updatedAt: message.sent_at,
@ -129,7 +128,6 @@ export function migrateLegacySendAttributes(
} }
return sendStateByConversationId; return sendStateByConversationId;
/* eslint-enable no-restricted-syntax */
} }
function getConversationIdsFromErrors( function getConversationIdsFromErrors(

View File

@ -1237,7 +1237,6 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
const recipients: Array<string> = []; const recipients: Array<string> = [];
const newSendStateByConversationId = { ...oldSendStateByConversationId }; const newSendStateByConversationId = { ...oldSendStateByConversationId };
// eslint-disable-next-line no-restricted-syntax
for (const [conversationId, sendState] of Object.entries( for (const [conversationId, sendState] of Object.entries(
oldSendStateByConversationId oldSendStateByConversationId
)) { )) {

View File

@ -1,9 +1,6 @@
// Copyright 2021 Signal Messenger, LLC // Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
// We use `for ... of` to deal with iterables in several places in this file.
/* eslint-disable no-restricted-syntax */
import { isNil, sortBy } from 'lodash'; import { isNil, sortBy } from 'lodash';
import PQueue from 'p-queue'; import PQueue from 'p-queue';

View File

@ -7,7 +7,6 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/ban-types */ /* eslint-disable @typescript-eslint/ban-types */
/* eslint-disable no-restricted-syntax */
import { ipcRenderer } from 'electron'; import { ipcRenderer } from 'electron';
import { import {

View File

@ -4,7 +4,6 @@
/* eslint-disable no-nested-ternary */ /* eslint-disable no-nested-ternary */
/* eslint-disable camelcase */ /* eslint-disable camelcase */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable no-restricted-syntax */
/* eslint-disable no-console */ /* eslint-disable no-console */
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */

View File

@ -129,9 +129,6 @@ function cleanDataInner(
const result: CleanedArray = []; const result: CleanedArray = [];
let index = 0; let index = 0;
pathsChanged.push(path); pathsChanged.push(path);
// `for ... of` is the cleanest way to go through "generic" iterables without
// a helper library.
// eslint-disable-next-line no-restricted-syntax
for (const value of dataAsRecord) { for (const value of dataAsRecord) {
result.push( result.push(
cleanDataInner( cleanDataInner(

View File

@ -1,8 +1,6 @@
// Copyright 2021 Signal Messenger, LLC // Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable no-restricted-syntax */
import { assert } from 'chai'; import { assert } from 'chai';
import { AsyncQueue } from '../util/AsyncQueue'; import { AsyncQueue } from '../util/AsyncQueue';

View File

@ -1,6 +1,6 @@
// Copyright 2021 Signal Messenger, LLC // Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable no-await-in-loop, no-restricted-syntax */ /* eslint-disable no-await-in-loop */
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
import { assert } from 'chai'; import { assert } from 'chai';

View File

@ -1,6 +1,5 @@
// Copyright 2021 Signal Messenger, LLC // Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable no-restricted-syntax */
import { assert } from 'chai'; import { assert } from 'chai';
import Long from 'long'; import Long from 'long';

View File

@ -2,7 +2,6 @@
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable no-await-in-loop */ /* eslint-disable no-await-in-loop */
/* eslint-disable no-restricted-syntax */
import { assert } from 'chai'; import { assert } from 'chai';

View File

@ -1,8 +1,6 @@
// Copyright 2021 Signal Messenger, LLC // Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable no-restricted-syntax */
import { assert } from 'chai'; import { assert } from 'chai';
import { explodePromise } from '../../util/explodePromise'; import { explodePromise } from '../../util/explodePromise';

View File

@ -1,8 +1,6 @@
// Copyright 2021 Signal Messenger, LLC // Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable no-restricted-syntax */
import { assert } from 'chai'; import { assert } from 'chai';
import * as sinon from 'sinon'; import * as sinon from 'sinon';
import { noop } from 'lodash'; import { noop } from 'lodash';

View File

@ -2,7 +2,6 @@
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable max-classes-per-file */ /* eslint-disable max-classes-per-file */
/* eslint-disable no-restricted-syntax */
/* eslint-disable no-await-in-loop */ /* eslint-disable no-await-in-loop */
import EventEmitter, { once } from 'events'; import EventEmitter, { once } from 'events';

View File

@ -95,9 +95,6 @@ describe('uploadDebugLogs', () => {
{ fields: { key: '123' }, url: 'not a valid URL' }, { fields: { key: '123' }, url: 'not a valid URL' },
]; ];
// We want to make sure these run serially, so we can't use `Promise.all`. They're
// async, so we can't use `forEach`. `for ... of` is a reasonable option here.
// eslint-disable-next-line no-restricted-syntax
for (const body of bodies) { for (const body of bodies) {
this.fakeGet.resolves({ body }); this.fakeGet.resolves({ body });

View File

@ -4,7 +4,6 @@
/* eslint-disable no-bitwise */ /* eslint-disable no-bitwise */
/* eslint-disable class-methods-use-this */ /* eslint-disable class-methods-use-this */
/* eslint-disable camelcase */ /* eslint-disable camelcase */
/* eslint-disable no-restricted-syntax */
import { isNumber, map } from 'lodash'; import { isNumber, map } from 'lodash';
import PQueue from 'p-queue'; import PQueue from 'p-queue';

View File

@ -2,7 +2,6 @@
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable guard-for-in */ /* eslint-disable guard-for-in */
/* eslint-disable no-restricted-syntax */
/* eslint-disable class-methods-use-this */ /* eslint-disable class-methods-use-this */
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable more/no-then */ /* eslint-disable more/no-then */

View File

@ -1,6 +1,5 @@
// Copyright 2021 Signal Messenger, LLC // Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable no-restricted-syntax */
import URL from 'url'; import URL from 'url';
import ProxyAgent from 'proxy-agent'; import ProxyAgent from 'proxy-agent';

View File

@ -1,6 +1,5 @@
// Copyright 2020-2021 Signal Messenger, LLC // Copyright 2020-2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable no-restricted-syntax */
import { import {
StorageAccessType as Access, StorageAccessType as Access,

View File

@ -1,7 +1,7 @@
// Copyright 2020 Signal Messenger, LLC // Copyright 2020-2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable max-classes-per-file, no-restricted-syntax */ /* eslint-disable max-classes-per-file */
/* /*
* WebSocket-Resources * WebSocket-Resources
* *

View File

@ -1,6 +1,5 @@
// Copyright 2019-2021 Signal Messenger, LLC // Copyright 2019-2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable no-restricted-syntax */
import { isNumber, pick, reject, groupBy, values } from 'lodash'; import { isNumber, pick, reject, groupBy, values } from 'lodash';
import pMap from 'p-map'; import pMap from 'p-map';

View File

@ -1,6 +1,5 @@
// Copyright 2021 Signal Messenger, LLC // Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable no-restricted-syntax */
import * as Errors from '../types/errors'; import * as Errors from '../types/errors';

View File

@ -3,7 +3,6 @@
/* eslint-disable max-classes-per-file */ /* eslint-disable max-classes-per-file */
/* eslint-disable no-await-in-loop */ /* eslint-disable no-await-in-loop */
/* eslint-disable no-restricted-syntax */
export type MaybeAsyncIterable<T> = Iterable<T> | AsyncIterable<T>; export type MaybeAsyncIterable<T> = Iterable<T> | AsyncIterable<T>;

View File

@ -1,6 +1,5 @@
// Copyright 2021 Signal Messenger, LLC // Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable no-restricted-syntax */
export async function awaitObject<Result extends { [key: string]: unknown }>( export async function awaitObject<Result extends { [key: string]: unknown }>(
settings: { settings: {

View File

@ -1,4 +1,4 @@
// Copyright 2020 Signal Messenger, LLC // Copyright 2020-2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable camelcase */ /* eslint-disable camelcase */
@ -56,7 +56,6 @@ export function combineNames(
} }
function isAllCKJV(name: string): boolean { function isAllCKJV(name: string): boolean {
// eslint-disable-next-line no-restricted-syntax
for (const codePoint of name) { for (const codePoint of name) {
if (!isCKJV(codePoint)) { if (!isCKJV(codePoint)) {
return false; return false;

View File

@ -1,6 +1,5 @@
// Copyright 2021 Signal Messenger, LLC // Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable no-restricted-syntax */
export type NullToUndefined<T> = Extract<T, null> extends never export type NullToUndefined<T> = Extract<T, null> extends never
? T ? T

View File

@ -1,6 +1,5 @@
// Copyright 2021 Signal Messenger, LLC // Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable no-restricted-syntax */
import emojiRegex from 'emoji-regex/es2015/RGI_Emoji'; import emojiRegex from 'emoji-regex/es2015/RGI_Emoji';

View File

@ -2,7 +2,6 @@
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable max-classes-per-file */ /* eslint-disable max-classes-per-file */
/* eslint-disable no-restricted-syntax */
import { getOwn } from './getOwn'; import { getOwn } from './getOwn';