From 7e0f50d6e0c7dc583d40e196c283eb20dc386ae6 Mon Sep 17 00:00:00 2001 From: Florent Date: Sat, 6 Aug 2022 15:20:43 +0200 Subject: [PATCH] Use single quotes in server/ and update eslint rules --- .eslintrc.json | 10 +++++++++- server/lib/activitypub/activity.ts | 2 +- server/middlewares/validators/config.ts | 4 ++-- server/tests/api/moderation/abuses.ts | 20 ++++++++++---------- server/tests/feeds/feeds.ts | 2 +- server/tools/peertube-import-videos.ts | 4 ++-- 6 files changed, 25 insertions(+), 17 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index c2dd2fc44..770913bf1 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -38,6 +38,7 @@ } } ], + "quotes": "off", "@typescript-eslint/indent": [ "error", 2, @@ -78,7 +79,14 @@ "@typescript-eslint/dot-notation": "off", "@typescript-eslint/method-signature-style": "off", "@typescript-eslint/no-base-to-string": "off", - "@typescript-eslint/quotes": "off", + "@typescript-eslint/quotes": [ + "error", + "single", + { + "avoidEscape": true, + "allowTemplateLiterals": true + } + ], "@typescript-eslint/no-var-requires": "off", "@typescript-eslint/explicit-function-return-type": "off", "@typescript-eslint/promise-function-async": "off", diff --git a/server/lib/activitypub/activity.ts b/server/lib/activitypub/activity.ts index ba2967ce9..1f6ec221e 100644 --- a/server/lib/activitypub/activity.ts +++ b/server/lib/activitypub/activity.ts @@ -1,4 +1,4 @@ -import { ActivityType } from "@shared/models" +import { ActivityType } from '@shared/models' function getAPId (object: string | { id: string }) { if (typeof object === 'string') return object diff --git a/server/middlewares/validators/config.ts b/server/middlewares/validators/config.ts index 1e839d577..a44fcb854 100644 --- a/server/middlewares/validators/config.ts +++ b/server/middlewares/validators/config.ts @@ -30,7 +30,7 @@ const customConfigUpdateValidator = [ body('signup.enabled').isBoolean().withMessage('Should have a valid signup enabled boolean'), body('signup.limit').isInt().withMessage('Should have a valid signup limit'), body('signup.requiresEmailVerification').isBoolean().withMessage('Should have a valid requiresEmailVerification boolean'), - body('signup.minimumAge').isInt().withMessage("Should have a valid minimum age required"), + body('signup.minimumAge').isInt().withMessage('Should have a valid minimum age required'), body('admin.email').isEmail().withMessage('Should have a valid administrator email'), body('contactForm.enabled').isBoolean().withMessage('Should have a valid contact form enabled boolean'), @@ -38,7 +38,7 @@ const customConfigUpdateValidator = [ body('user.videoQuota').custom(isUserVideoQuotaValid).withMessage('Should have a valid video quota'), body('user.videoQuotaDaily').custom(isUserVideoQuotaDailyValid).withMessage('Should have a valid daily video quota'), - body('videoChannels.maxPerUser').isInt().withMessage("Should have a valid maximum amount of video channels per user"), + body('videoChannels.maxPerUser').isInt().withMessage('Should have a valid maximum amount of video channels per user'), body('transcoding.enabled').isBoolean().withMessage('Should have a valid transcoding enabled boolean'), body('transcoding.allowAdditionalExtensions').isBoolean().withMessage('Should have a valid additional extensions boolean'), diff --git a/server/tests/api/moderation/abuses.ts b/server/tests/api/moderation/abuses.ts index 568fbefcf..0a656b41f 100644 --- a/server/tests/api/moderation/abuses.ts +++ b/server/tests/api/moderation/abuses.ts @@ -260,12 +260,12 @@ describe('Test abuses', function () { await waitJobs(servers) const body = await commands[1].getAdminList() - expect(body.total).to.equal(2, "wrong number of videos returned") - expect(body.data).to.have.lengthOf(2, "wrong number of videos returned") + expect(body.total).to.equal(2, 'wrong number of videos returned') + expect(body.data).to.have.lengthOf(2, 'wrong number of videos returned') const abuse = body.data[0] - expect(abuse.id).to.equal(abuseServer2.id, "wrong origin server id for first video") - expect(abuse.video.id).to.equal(abuseServer2.video.id, "wrong video id") + expect(abuse.id).to.equal(abuseServer2.id, 'wrong origin server id for first video') + expect(abuse.video.id).to.equal(abuseServer2.video.id, 'wrong video id') expect(abuse.video.channel).to.exist expect(abuse.video.deleted).to.be.true }) @@ -299,13 +299,13 @@ describe('Test abuses', function () { const abuseVideo3 = body.data.find(a => a.video.id === video3Id) expect(abuseVideo3).to.not.be.undefined - expect(abuseVideo3.video.countReports).to.equal(1, "wrong reports count for video 3") - expect(abuseVideo3.video.nthReport).to.equal(1, "wrong report position in report list for video 3") - expect(abuseVideo3.countReportsForReportee).to.equal(1, "wrong reports count for reporter on video 3 abuse") - expect(abuseVideo3.countReportsForReporter).to.equal(3, "wrong reports count for reportee on video 3 abuse") + expect(abuseVideo3.video.countReports).to.equal(1, 'wrong reports count for video 3') + expect(abuseVideo3.video.nthReport).to.equal(1, 'wrong report position in report list for video 3') + expect(abuseVideo3.countReportsForReportee).to.equal(1, 'wrong reports count for reporter on video 3 abuse') + expect(abuseVideo3.countReportsForReporter).to.equal(3, 'wrong reports count for reportee on video 3 abuse') const abuseServer1 = abuses.find(a => a.video.id === servers[0].store.videoCreated.id) - expect(abuseServer1.countReportsForReportee).to.equal(3, "wrong reports count for reporter on video 1 abuse") + expect(abuseServer1.countReportsForReportee).to.equal(3, 'wrong reports count for reporter on video 1 abuse') } }) @@ -327,7 +327,7 @@ describe('Test abuses', function () { { const abuse = body.data.find(a => a.id === createRes.abuse.id) expect(abuse.reason).to.equals(reason5) - expect(abuse.predefinedReasons).to.deep.equals(predefinedReasons5, "predefined reasons do not match the one reported") + expect(abuse.predefinedReasons).to.deep.equals(predefinedReasons5, 'predefined reasons do not match the one reported') expect(abuse.video.startAt).to.equal(1, "starting timestamp doesn't match the one reported") expect(abuse.video.endAt).to.equal(5, "ending timestamp doesn't match the one reported") } diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts index c7331d544..67a9ed8e0 100644 --- a/server/tests/feeds/feeds.ts +++ b/server/tests/feeds/feeds.ts @@ -433,7 +433,7 @@ describe('Test syndication feeds', () => { { const body = await servers[0].subscriptions.listVideos({ token: userAccessToken }) - expect(body.total).to.equal(2, "there should be 2 videos part of the subscription") + expect(body.total).to.equal(2, 'there should be 2 videos part of the subscription') const query = { accountId: userAccountId, token: userFeedToken } const json = await servers[0].feed.getJSON({ feed: 'subscriptions', query, ignoreCache: true }) diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts index 661a4cf35..e2f80c703 100644 --- a/server/tools/peertube-import-videos.ts +++ b/server/tools/peertube-import-videos.ts @@ -37,7 +37,7 @@ command .option('--last ', 'Process last n elements of returned playlist') .option('--wait-interval ', 'Duration between two video imports (in seconds)', convertIntoMs) .option('-T, --tmpdir ', 'Working directory', __dirname) - .usage("[global options] [ -- youtube-dl options]") + .usage('[global options] [ -- youtube-dl options]') .parse(process.argv) const options = command.opts() @@ -97,7 +97,7 @@ async function run (url: string, username: string, password: string) { for (const [ index, info ] of infoArray.entries()) { try { if (index > 0 && options.waitInterval && !skipInterval) { - log.info("Wait for %d seconds before continuing.", options.waitInterval / 1000) + log.info('Wait for %d seconds before continuing.', options.waitInterval / 1000) await wait(options.waitInterval) }