Skip to content

Commit 1a0a981

Browse files
authored
Update Eslint configuration to allow await inside of loops (#1177)
2 parents c5e2e15 + 026b73b commit 1a0a981

File tree

16 files changed

+23
-27
lines changed

16 files changed

+23
-27
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 # allows intentional sequential processing of async operations
116117

117118
overrides:
118119
- files:

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All changes that impact users of this module are documented in this file, in the [Common Changelog](https://common-changelog.org) format with some additional specifications defined in the CONTRIBUTING file. This codebase adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
44

5+
## Unreleased [no-release]
6+
7+
_Modifications made in this changeset do not add, remove or alter any behavior, dependency, API or functionality of the software. They only change non-functional parts of the repository, such as the README file or CI workflows._
8+
59
## 6.1.0 - 2025-07-21
610

711
_Full changeset and discussions: [#1176](https://github.com/OpenTermsArchive/engine/pull/1176)._

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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,12 @@ export async function extractFromHTML(sourceDocument) {
5959

6060
for (const filterFunction of serviceSpecificFilters) {
6161
try {
62-
/* eslint-disable no-await-in-loop */
63-
// We want this to be made in series
6462
await filterFunction(webPageDOM, {
6563
fetch: location,
6664
select: contentSelectors,
6765
remove: insignificantContentSelectors,
6866
filter: serviceSpecificFilters.map(filter => filter.name),
6967
});
70-
/* eslint-enable no-await-in-loop */
7168
} catch (error) {
7269
throw new Error(`The filter function "${filterFunction.name}" failed: ${error}`);
7370
}

src/archivist/fetcher/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const FETCHER_TYPES = {
2727
* @throws {FetchDocumentError} When the fetch operation fails
2828
* @async
2929
*/
30-
export default async function fetch({
30+
export default function fetch({
3131
url,
3232
executeClientScripts,
3333
cssSelectors,

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;

0 commit comments

Comments
 (0)