Skip to content

Commit b85db1f

Browse files
committed
Allow await inside of loops
1 parent c5e2e15 commit b85db1f

File tree

14 files changed

+18
-25
lines changed

14 files changed

+18
-25
lines changed

.eslintrc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ rules:
113113
- properties: false
114114
require-await: 1
115115
no-only-tests/no-only-tests: error
116+
no-await-in-loop: 0
116117

117118
overrides:
118119
- files:

scripts/history/migrate-services.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ async function rewriteSnapshots(repository, records, idsMapping, logger) {
140140
let i = 1;
141141

142142
for (const record of records) {
143-
const { id: recordId } = await repository.save(record); // eslint-disable-line no-await-in-loop
143+
const { id: recordId } = await repository.save(record);
144144

145145
idsMapping[record.id] = recordId; // Saves the mapping between the old ID and the new one.
146146

@@ -166,7 +166,7 @@ async function rewriteVersions(repository, records, idsMapping, logger) {
166166

167167
record.snapshotId = newSnapshotId;
168168

169-
const { id: recordId } = await repository.save(record); // eslint-disable-line no-await-in-loop
169+
const { id: recordId } = await repository.save(record);
170170

171171
if (recordId) {
172172
logger.info({ message: `Migrated version with new ID: ${recordId}`, serviceId: record.serviceId, type: record.termsType, id: record.id, current: i++, total: records.length });

scripts/import/loadCommits.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ let client;
4242
let counter = 1;
4343

4444
for (const commit of filteredCommits.reverse()) { // reverse array to insert most recent commits first
45-
await collection.updateOne({ hash: commit.hash }, { $set: { ...commit } }, { upsert: true }); // eslint-disable-line no-await-in-loop
45+
await collection.updateOne({ hash: commit.hash }, { $set: { ...commit } }, { upsert: true });
4646

4747
if (counter % 1000 == 0) {
4848
logger.info({ message: ' ', current: counter, total: totalCommitToLoad });

scripts/reporter/duplicate/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ async function removeDuplicateIssues() {
4848
continue;
4949
}
5050

51-
await octokit.request('PATCH /repos/{owner}/{repo}/issues/{issue_number}', { /* eslint-disable-line no-await-in-loop */
51+
await octokit.request('PATCH /repos/{owner}/{repo}/issues/{issue_number}', {
5252
owner,
5353
repo,
5454
issue_number: issue.number,
5555
state: 'closed',
5656
});
5757

58-
await octokit.request('POST /repos/{owner}/{repo}/issues/{issue_number}/comments', { /* eslint-disable-line no-await-in-loop */
58+
await octokit.request('POST /repos/{owner}/{repo}/issues/{issue_number}/comments', {
5959
owner,
6060
repo,
6161
issue_number: issue.number,

scripts/rewrite/rewrite-snapshots.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ let recorder;
6464
const filteredCommits = commits.filter(({ message }) =>
6565
message.match(/^(Start tracking|Update)/));
6666

67-
/* eslint-disable no-await-in-loop */
6867
/* eslint-disable no-continue */
6968
for (const commit of filteredCommits) {
7069
console.log(Date.now(), commit.hash, commit.date, commit.message);

scripts/rewrite/rewrite-versions.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ let recorder;
7474
const filteredCommits = commits.filter(({ message }) =>
7575
message.match(/^(Start tracking|Update)/));
7676

77-
/* eslint-disable no-await-in-loop */
7877
/* eslint-disable no-continue */
7978
for (const commit of filteredCommits) {
8079
console.log(Date.now(), commit.hash, commit.date, commit.message);

src/archivist/extract/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,13 @@ export async function extractFromHTML(sourceDocument) {
5959

6060
for (const filterFunction of serviceSpecificFilters) {
6161
try {
62-
/* eslint-disable no-await-in-loop */
6362
// We want this to be made in series
6463
await filterFunction(webPageDOM, {
6564
fetch: location,
6665
select: contentSelectors,
6766
remove: insignificantContentSelectors,
6867
filter: serviceSpecificFilters.map(filter => filter.name),
6968
});
70-
/* eslint-enable no-await-in-loop */
7169
} catch (error) {
7270
throw new Error(`The filter function "${filterFunction.name}" failed: ${error}`);
7371
}

src/archivist/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export default class Archivist extends events.EventEmitter {
187187
const { location: url, executeClientScripts, cssSelectors } = sourceDocument;
188188

189189
try {
190-
const { mimeType, content, fetcher } = await this.fetch({ url, executeClientScripts, cssSelectors }); // eslint-disable-line no-await-in-loop
190+
const { mimeType, content, fetcher } = await this.fetch({ url, executeClientScripts, cssSelectors });
191191

192192
sourceDocument.content = content;
193193
sourceDocument.mimeType = mimeType;

src/archivist/recorder/repositories/git/index.test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,6 @@ describe('GitRepository', () => {
13821382

13831383
await subject.initialize();
13841384

1385-
/* eslint-disable no-await-in-loop */
13861385
for (const commit of Object.values(commits)) {
13871386
const { path: relativeFilePath, date, content, message } = commit;
13881387
const filePath = path.join(RECORDER_PATH, relativeFilePath);
@@ -1396,7 +1395,6 @@ describe('GitRepository', () => {
13961395
expectedIds.push(sha);
13971396
expectedDates.push(date);
13981397
}
1399-
/* eslint-enable no-await-in-loop */
14001398
});
14011399

14021400
after(() => subject.removeAll());

src/archivist/recorder/repositories/mongo/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,11 @@ export default class MongoRepository extends RepositoryInterface {
9696
async* iterate() {
9797
const cursor = this.collection.find().sort({ fetchDate: 1 });
9898

99-
/* eslint-disable no-await-in-loop */
10099
while (await cursor.hasNext()) {
101100
const mongoDocument = await cursor.next();
102101

103102
yield this.#toDomain(mongoDocument);
104103
}
105-
/* eslint-enable no-await-in-loop */
106104
}
107105

108106
removeAll() {

0 commit comments

Comments
 (0)