Skip to content

Commit 2582940

Browse files
committed
Lint
1 parent a6a4723 commit 2582940

10 files changed

Lines changed: 79 additions & 78 deletions

File tree

scripts/reporter/duplicate/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async function removeDuplicateIssues() {
3939
}
4040

4141
for (const [ title, duplicateIssues ] of issuesByTitle) {
42-
if (duplicateIssues.length === 1) continue;
42+
if (duplicateIssues.length === 1) { continue; }
4343

4444
const originalIssue = duplicateIssues.reduce((oldest, current) => (new Date(current.created_at) < new Date(oldest.created_at) ? current : oldest));
4545

src/archivist/collection/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('Collection', () => {
1818
try {
1919
metadataBackup = await fs.readFile(metadataPath, 'utf8');
2020
} catch (error) {
21-
if (error.code !== 'ENOENT') throw error;
21+
if (error.code !== 'ENOENT') { throw error; }
2222
}
2323
});
2424

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ export default class GitRepository extends RepositoryInterface {
9797
const records = [];
9898

9999
for (const commit of commits) {
100-
if (records.length >= limit) break;
100+
if (records.length >= limit) { break; }
101101

102102
const record = await this.#toDomain(commit, { deferContentLoading: true });
103103

104-
if (!record) continue;
104+
if (!record) { continue; }
105105

106-
if (serviceId !== undefined && record.serviceId !== serviceId) continue;
107-
if (termsType !== undefined && record.termsType !== termsType) continue;
106+
if (serviceId !== undefined && record.serviceId !== serviceId) { continue; }
107+
if (termsType !== undefined && record.termsType !== termsType) { continue; }
108108

109109
records.push(record);
110110
}

src/archivist/recorder/repositories/interface.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ class RepositoryInterface {
8383
* Find the most recent records in the repository, optionally filtered by service ID and terms type
8484
* For performance reasons, the content of the records will not be loaded. Use #loadRecordContent to load the content of individual records
8585
* @see RepositoryInterface#loadRecordContent
86-
* @param {number} limit - Maximum number of records to return
87-
* @param {object} [filters] - Optional filters
88-
* @param {string} [filters.serviceId] - Restrict results to this service ID
89-
* @param {string} [filters.termsType] - Restrict results to this terms type
90-
* @returns {Promise<Array<Record>>} Promise that will be resolved with an array of records in descending chronological order
86+
* @param {number} limit - Maximum number of records to return
87+
* @param {object} [filters] - Optional filters
88+
* @param {string} [filters.serviceId] - Restrict results to this service ID
89+
* @param {string} [filters.termsType] - Restrict results to this terms type
90+
* @returns {Promise<Array<Record>>} Promise that will be resolved with an array of records in descending chronological order
9191
*/
9292
async findRecent(limit, filters) {
9393
throw new Error(`#findRecent method is not implemented in ${this.constructor.name}`);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ export default class MongoRepository extends RepositoryInterface {
9696
async findRecent(limit, { serviceId, termsType } = {}) {
9797
const query = {};
9898

99-
if (serviceId !== undefined) query.serviceId = serviceId;
100-
if (termsType !== undefined) query.termsType = termsType;
99+
if (serviceId !== undefined) { query.serviceId = serviceId; }
100+
if (termsType !== undefined) { query.termsType = termsType; }
101101

102102
const mongoDocuments = await this.collection
103103
.find(query)

src/archivist/services/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ function getHistoryFilePaths(serviceId) {
281281
}
282282

283283
async function loadServiceHistory(historyFilePath) {
284-
if (!(await fileExists(historyFilePath))) return {};
284+
if (!(await fileExists(historyFilePath))) { return {}; }
285285

286286
try {
287287
return JSON.parse(await fs.readFile(historyFilePath));

src/collection-api/routes/feed.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { getCollection } from '../../archivist/collection/index.js';
66
import { COMMIT_MESSAGE_PREFIXES } from '../../archivist/recorder/repositories/git/dataMapper.js';
77
import { toISODateWithoutMilliseconds } from '../../archivist/utils/date.js';
88

9-
import versionsRepository, { storageConfig } from './versionsRepository.js';
109
import { findServiceCaseInsensitive } from './utils.js';
10+
import versionsRepository, { storageConfig } from './versionsRepository.js';
1111

1212
const TAG_AUTHORITY = 'opentermsarchive.org,2026';
1313
const FEED_AUTHOR_NAME = 'OTA-Bot';
@@ -38,17 +38,16 @@ function buildAbsoluteBaseUrl(req) {
3838
}
3939

4040
function classifyRecordType(version) {
41-
if (version.isFirstRecord) return RECORD_TYPES.firstRecord;
42-
if (version.isTechnicalUpgrade) return RECORD_TYPES.technicalUpgrade;
41+
if (version.isFirstRecord) { return RECORD_TYPES.firstRecord; }
42+
if (version.isTechnicalUpgrade) { return RECORD_TYPES.technicalUpgrade; }
4343

4444
return RECORD_TYPES.change;
4545
}
4646

4747
function buildEntryTitle(version) {
4848
let prefix = COMMIT_MESSAGE_PREFIXES.update;
4949

50-
if (version.isFirstRecord) prefix = COMMIT_MESSAGE_PREFIXES.startTracking;
51-
else if (version.isTechnicalUpgrade) prefix = COMMIT_MESSAGE_PREFIXES.technicalUpgrade;
50+
if (version.isFirstRecord) { prefix = COMMIT_MESSAGE_PREFIXES.startTracking; } else if (version.isTechnicalUpgrade) { prefix = COMMIT_MESSAGE_PREFIXES.technicalUpgrade; }
5251

5352
return `${prefix} ${version.serviceId} ${version.termsType}`;
5453
}

src/collection-api/routes/feed.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ describe('Feed API', () => {
149149
let firstEntry;
150150

151151
before(() => {
152-
firstEntry = response.text.match(/<entry>[\s\S]*?<\/entry>/)[0];
152+
[firstEntry] = response.text.match(/<entry>[\s\S]*?<\/entry>/);
153153
});
154154

155155
it('has an id tag URI including storage type and record id', () => {

src/collection-api/routes/versions.js

Lines changed: 59 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import express from 'express';
22

33
import { toISODateWithoutMilliseconds } from '../../archivist/utils/date.js';
44

5-
import versionsRepository from './versionsRepository.js';
65
import { findServiceCaseInsensitive } from './utils.js';
6+
import versionsRepository from './versionsRepository.js';
77

88
/**
9+
* @param {object} services The services to be exposed by the API
10+
* @returns {express.Router} The router instance
911
* @private
1012
* @swagger
1113
* tags:
@@ -32,62 +34,62 @@ export default function versionsRouter(services) {
3234
const router = express.Router();
3335

3436
/**
35-
* @private
36-
* @swagger
37-
* /version/{serviceId}/{termsType}/{date}:
38-
* get:
39-
* summary: Get a specific version of some terms at a given date.
40-
* tags: [Versions]
41-
* produces:
42-
* - application/json
43-
* parameters:
44-
* - in: path
45-
* name: serviceId
46-
* description: The ID of the service whose version will be returned.
47-
* schema:
48-
* type: string
49-
* required: true
50-
* - in: path
51-
* name: termsType
52-
* description: The type of terms whose version will be returned.
53-
* schema:
54-
* type: string
55-
* required: true
56-
* - in: path
57-
* name: date
58-
* description: The date and time for which the version is requested, in ISO 8601 format.
59-
* schema:
60-
* type: string
61-
* format: date-time
62-
* required: true
63-
* responses:
64-
* 200:
65-
* description: A JSON object containing the version content and metadata.
66-
* content:
67-
* application/json:
68-
* schema:
69-
* $ref: '#/components/schemas/Version'
70-
* 404:
71-
* description: No version found for the specified combination of service ID, terms type and date.
72-
* content:
73-
* application/json:
74-
* schema:
75-
* type: object
76-
* properties:
77-
* error:
78-
* type: string
79-
* description: Error message indicating that no version is found.
80-
* 416:
81-
* description: The requested date is in the future.
82-
* content:
83-
* application/json:
84-
* schema:
85-
* type: object
86-
* properties:
87-
* error:
88-
* type: string
89-
* description: Error message indicating that the requested date is in the future.
90-
*/
37+
* @private
38+
* @swagger
39+
* /version/{serviceId}/{termsType}/{date}:
40+
* get:
41+
* summary: Get a specific version of some terms at a given date.
42+
* tags: [Versions]
43+
* produces:
44+
* - application/json
45+
* parameters:
46+
* - in: path
47+
* name: serviceId
48+
* description: The ID of the service whose version will be returned.
49+
* schema:
50+
* type: string
51+
* required: true
52+
* - in: path
53+
* name: termsType
54+
* description: The type of terms whose version will be returned.
55+
* schema:
56+
* type: string
57+
* required: true
58+
* - in: path
59+
* name: date
60+
* description: The date and time for which the version is requested, in ISO 8601 format.
61+
* schema:
62+
* type: string
63+
* format: date-time
64+
* required: true
65+
* responses:
66+
* 200:
67+
* description: A JSON object containing the version content and metadata.
68+
* content:
69+
* application/json:
70+
* schema:
71+
* $ref: '#/components/schemas/Version'
72+
* 404:
73+
* description: No version found for the specified combination of service ID, terms type and date.
74+
* content:
75+
* application/json:
76+
* schema:
77+
* type: object
78+
* properties:
79+
* error:
80+
* type: string
81+
* description: Error message indicating that no version is found.
82+
* 416:
83+
* description: The requested date is in the future.
84+
* content:
85+
* application/json:
86+
* schema:
87+
* type: object
88+
* properties:
89+
* error:
90+
* type: string
91+
* description: Error message indicating that the requested date is in the future.
92+
*/
9193
router.get('/version/:serviceId/:termsType/:date', async (req, res) => {
9294
const { termsType, date } = req.params;
9395
const requestedDate = new Date(date);

src/reporter/gitlab/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ export default class GitLab {
358358
try {
359359
let apiUrl = `${this.apiBaseURL}/projects/${this.projectId}/issues?search=${encodeURIComponent(title)}&state=${searchParams.state}&per_page=100`;
360360

361-
if (searchParams.state == 'all') apiUrl = `${this.apiBaseURL}/projects/${this.projectId}/issues?search=${encodeURIComponent(title)}&per_page=100`;
361+
if (searchParams.state == 'all') { apiUrl = `${this.apiBaseURL}/projects/${this.projectId}/issues?search=${encodeURIComponent(title)}&per_page=100`; }
362362

363363
const options = GitLab.baseOptionsHttpReq();
364364

0 commit comments

Comments
 (0)