diff --git a/.prettierrc.yml b/.prettierrc.yml index d894f63007abed9176ec5bea38bfc879c6b0e16e..32e72f4c5dda37f9e34a74cad0e2aa7cb02bc700 100644 --- a/.prettierrc.yml +++ b/.prettierrc.yml @@ -1,5 +1,5 @@ semi: false singleQuote: true -trailingComma: es5 bracketSpacing: true endOfLine: lf +arrowParens: avoid diff --git a/badge-maker/lib/badge-cli.spec.js b/badge-maker/lib/badge-cli.spec.js index b7c7eac69bc69d16c53f1e2ecc9f216cbd7f4ca0..4b6fbb3dc9f90a617e75b59104dd5cb6279f8d47 100644 --- a/badge-maker/lib/badge-cli.spec.js +++ b/badge-maker/lib/badge-cli.spec.js @@ -13,13 +13,13 @@ function runCli(args) { }) } -describe('The CLI', function() { - it('should provide a help message', async function() { +describe('The CLI', function () { + it('should provide a help message', async function () { const { stdout } = await runCli([]) expect(stdout).to.startWith('Usage') }) - it('should produce default badges', async function() { + it('should produce default badges', async function () { const { stdout } = await runCli(['cactus', 'grown']) expect(stdout) .to.satisfy(isSvg) @@ -27,15 +27,13 @@ describe('The CLI', function() { .and.to.include('grown') }) - it('should produce colorschemed badges', async function() { + it('should produce colorschemed badges', async function () { const { stdout } = await runCli(['cactus', 'grown', ':green']) expect(stdout).to.satisfy(isSvg) }) - it('should produce right-color badges', async function() { + it('should produce right-color badges', async function () { const { stdout } = await runCli(['cactus', 'grown', '#abcdef']) - expect(stdout) - .to.satisfy(isSvg) - .and.to.include('#abcdef') + expect(stdout).to.satisfy(isSvg).and.to.include('#abcdef') }) }) diff --git a/badge-maker/lib/badge-renderers.js b/badge-maker/lib/badge-renderers.js index 7df3ae02ab8eb636e1d6175995a29a6079d44767..e49713910260a1c9557d4c0d2a636dd196e3f09b 100644 --- a/badge-maker/lib/badge-renderers.js +++ b/badge-maker/lib/badge-renderers.js @@ -131,10 +131,7 @@ function renderBadge({ links, leftWidth, rightWidth, height }, main) { } function stripXmlWhitespace(xml) { - return xml - .replace(/>\s+/g, '>') - .replace(/<\s+/g, '<') - .trim() + return xml.replace(/>\s+/g, '>').replace(/<\s+/g, '<').trim() } class Badge { @@ -595,10 +592,11 @@ function forTheBadge({ <g fill="#fff" text-anchor="middle" ${fontFamily} text-rendering="geometricPrecision" font-size="100"> ${renderedLogo} ${hasLabel ? renderLabelText() : ''} - <text x="${(labelWidth + messageWidth / 2) * - 10}" y="175" font-weight="bold" transform="scale(.1)" textLength="${(messageWidth - - 24) * - 10}"> + <text x="${ + (labelWidth + messageWidth / 2) * 10 + }" y="175" font-weight="bold" transform="scale(.1)" textLength="${ + (messageWidth - 24) * 10 + }"> ${escapeXml(message)}</text> </g>` ) diff --git a/badge-maker/lib/index.js b/badge-maker/lib/index.js index 49bef6c58aee8cf0acd52518d2c894fcbee79861..b957ee0cdc7271f82447e8513211f73925184971 100644 --- a/badge-maker/lib/index.js +++ b/badge-maker/lib/index.js @@ -17,7 +17,7 @@ function _validate(format) { } const stringFields = ['labelColor', 'color', 'message', 'label'] - stringFields.forEach(function(field) { + stringFields.forEach(function (field) { if (field in format && typeof format[field] !== 'string') { throw new ValidationError(`Field \`${field}\` must be of type string`) } diff --git a/badge-maker/lib/index.spec.js b/badge-maker/lib/index.spec.js index 27ed81591d7b0f86c40f7183d34d54ff46791622..68da62655b1825ebc5358f8cafd28a8d3a8a5762 100644 --- a/badge-maker/lib/index.spec.js +++ b/badge-maker/lib/index.spec.js @@ -4,8 +4,8 @@ const { expect } = require('chai') const isSvg = require('is-svg') const { makeBadge, ValidationError } = require('.') -describe('makeBadge function', function() { - it('should produce badge with valid input', function() { +describe('makeBadge function', function () { + it('should produce badge with valid input', function () { expect( makeBadge({ label: 'build', @@ -27,7 +27,7 @@ describe('makeBadge function', function() { ).to.satisfy(isSvg) }) - it('should throw a ValidationError with invalid inputs', function() { + it('should throw a ValidationError with invalid inputs', function () { ;[null, undefined, 7, 'foo', 4.25].forEach(x => { console.log(x) expect(() => makeBadge(x)).to.throw( diff --git a/badge-maker/lib/make-badge.spec.js b/badge-maker/lib/make-badge.spec.js index 152f07b006cff01598fbdb7ca40071e73817d8fd..f3eed32900ff2c68b96932fed801d21c22214531 100644 --- a/badge-maker/lib/make-badge.spec.js +++ b/badge-maker/lib/make-badge.spec.js @@ -16,8 +16,8 @@ function testColor(color = '', colorAttr = 'color') { ).color } -describe('The badge generator', function() { - describe('color test', function() { +describe('The badge generator', function () { + describe('color test', function () { test(testColor, () => { // valid hex forCases([ @@ -69,14 +69,14 @@ describe('The badge generator', function() { }) }) - describe('color aliases', function() { + describe('color aliases', function () { test(testColor, () => { forCases([given('#4c1', 'color')]).expect('#4c1') }) }) - describe('SVG', function() { - it('should produce SVG', function() { + describe('SVG', function () { + it('should produce SVG', function () { const svg = makeBadge({ text: ['cactus', 'grown'], format: 'svg' }) expect(svg) .to.satisfy(isSvg) @@ -84,14 +84,14 @@ describe('The badge generator', function() { .and.to.include('grown') }) - it('should match snapshot', function() { + it('should match snapshot', function () { const svg = makeBadge({ text: ['cactus', 'grown'], format: 'svg' }) snapshot(svg) }) }) - describe('JSON', function() { - it('should produce the expected JSON', function() { + describe('JSON', function () { + it('should produce the expected JSON', function () { const json = makeBadge({ text: ['cactus', 'grown'], format: 'json', @@ -106,7 +106,7 @@ describe('The badge generator', function() { }) }) - it('should replace undefined svg template with "flat"', function() { + it('should replace undefined svg template with "flat"', function () { const jsonBadgeWithUnknownStyle = makeBadge({ text: ['name', 'Bob'], format: 'svg', @@ -121,7 +121,7 @@ describe('The badge generator', function() { .and.to.satisfy(isSvg) }) - it('should fail with unknown svg template', function() { + it('should fail with unknown svg template', function () { expect(() => makeBadge({ text: ['name', 'Bob'], @@ -132,8 +132,8 @@ describe('The badge generator', function() { }) }) - describe('"flat" template badge generation', function() { - it('should match snapshots: message/label, no logo', function() { + describe('"flat" template badge generation', function () { + it('should match snapshots: message/label, no logo', function () { snapshot( makeBadge({ text: ['cactus', 'grown'], @@ -145,7 +145,7 @@ describe('The badge generator', function() { ) }) - it('should match snapshots: message/label, with logo', function() { + it('should match snapshots: message/label, with logo', function () { snapshot( makeBadge({ text: ['cactus', 'grown'], @@ -158,7 +158,7 @@ describe('The badge generator', function() { ) }) - it('should match snapshots: message only, no logo', function() { + it('should match snapshots: message only, no logo', function () { snapshot( makeBadge({ text: ['', 'grown'], @@ -169,7 +169,7 @@ describe('The badge generator', function() { ) }) - it('should match snapshots: message only, with logo', function() { + it('should match snapshots: message only, with logo', function () { snapshot( makeBadge({ text: ['', 'grown'], @@ -181,7 +181,7 @@ describe('The badge generator', function() { ) }) - it('should match snapshots: message only, with logo and labelColor', function() { + it('should match snapshots: message only, with logo and labelColor', function () { snapshot( makeBadge({ text: ['', 'grown'], @@ -194,7 +194,7 @@ describe('The badge generator', function() { ) }) - it('should match snapshots: message/label, with links', function() { + it('should match snapshots: message/label, with links', function () { snapshot( makeBadge({ text: ['cactus', 'grown'], @@ -208,8 +208,8 @@ describe('The badge generator', function() { }) }) - describe('"flat-square" template badge generation', function() { - it('should match snapshots: message/label, no logo', function() { + describe('"flat-square" template badge generation', function () { + it('should match snapshots: message/label, no logo', function () { snapshot( makeBadge({ text: ['cactus', 'grown'], @@ -221,7 +221,7 @@ describe('The badge generator', function() { ) }) - it('should match snapshots: message/label, with logo', function() { + it('should match snapshots: message/label, with logo', function () { snapshot( makeBadge({ text: ['cactus', 'grown'], @@ -234,7 +234,7 @@ describe('The badge generator', function() { ) }) - it('should match snapshots: message only, no logo', function() { + it('should match snapshots: message only, no logo', function () { snapshot( makeBadge({ text: ['', 'grown'], @@ -245,7 +245,7 @@ describe('The badge generator', function() { ) }) - it('should match snapshots: message only, with logo', function() { + it('should match snapshots: message only, with logo', function () { snapshot( makeBadge({ text: ['', 'grown'], @@ -257,7 +257,7 @@ describe('The badge generator', function() { ) }) - it('should match snapshots: message only, with logo and labelColor', function() { + it('should match snapshots: message only, with logo and labelColor', function () { snapshot( makeBadge({ text: ['', 'grown'], @@ -270,7 +270,7 @@ describe('The badge generator', function() { ) }) - it('should match snapshots: message/label, with links', function() { + it('should match snapshots: message/label, with links', function () { snapshot( makeBadge({ text: ['cactus', 'grown'], @@ -284,8 +284,8 @@ describe('The badge generator', function() { }) }) - describe('"plastic" template badge generation', function() { - it('should match snapshots: message/label, no logo', function() { + describe('"plastic" template badge generation', function () { + it('should match snapshots: message/label, no logo', function () { snapshot( makeBadge({ text: ['cactus', 'grown'], @@ -297,7 +297,7 @@ describe('The badge generator', function() { ) }) - it('should match snapshots: message/label, with logo', function() { + it('should match snapshots: message/label, with logo', function () { snapshot( makeBadge({ text: ['cactus', 'grown'], @@ -310,7 +310,7 @@ describe('The badge generator', function() { ) }) - it('should match snapshots: message only, no logo', function() { + it('should match snapshots: message only, no logo', function () { snapshot( makeBadge({ text: ['', 'grown'], @@ -321,7 +321,7 @@ describe('The badge generator', function() { ) }) - it('should match snapshots: message only, with logo', function() { + it('should match snapshots: message only, with logo', function () { snapshot( makeBadge({ text: ['', 'grown'], @@ -333,7 +333,7 @@ describe('The badge generator', function() { ) }) - it('should match snapshots: message only, with logo and labelColor', function() { + it('should match snapshots: message only, with logo and labelColor', function () { snapshot( makeBadge({ text: ['', 'grown'], @@ -346,7 +346,7 @@ describe('The badge generator', function() { ) }) - it('should match snapshots: message/label, with links', function() { + it('should match snapshots: message/label, with links', function () { snapshot( makeBadge({ text: ['cactus', 'grown'], @@ -360,31 +360,27 @@ describe('The badge generator', function() { }) }) - describe('"for-the-badge" template badge generation', function() { + describe('"for-the-badge" template badge generation', function () { // https://github.com/badges/shields/issues/1280 - it('numbers should produce a string', function() { + it('numbers should produce a string', function () { const svg = makeBadge({ text: [1998, 1999], format: 'svg', template: 'for-the-badge', }) - expect(svg) - .to.include('1998') - .and.to.include('1999') + expect(svg).to.include('1998').and.to.include('1999') }) - it('lowercase/mixedcase string should produce uppercase string', function() { + it('lowercase/mixedcase string should produce uppercase string', function () { const svg = makeBadge({ text: ['Label', '1 string'], format: 'svg', template: 'for-the-badge', }) - expect(svg) - .to.include('LABEL') - .and.to.include('1 STRING') + expect(svg).to.include('LABEL').and.to.include('1 STRING') }) - it('should match snapshots: message/label, no logo', function() { + it('should match snapshots: message/label, no logo', function () { snapshot( makeBadge({ text: ['cactus', 'grown'], @@ -396,7 +392,7 @@ describe('The badge generator', function() { ) }) - it('should match snapshots: message/label, with logo', function() { + it('should match snapshots: message/label, with logo', function () { snapshot( makeBadge({ text: ['cactus', 'grown'], @@ -409,7 +405,7 @@ describe('The badge generator', function() { ) }) - it('should match snapshots: message only, no logo', function() { + it('should match snapshots: message only, no logo', function () { snapshot( makeBadge({ text: ['', 'grown'], @@ -420,7 +416,7 @@ describe('The badge generator', function() { ) }) - it('should match snapshots: message only, with logo', function() { + it('should match snapshots: message only, with logo', function () { snapshot( makeBadge({ text: ['', 'grown'], @@ -432,7 +428,7 @@ describe('The badge generator', function() { ) }) - it('should match snapshots: message only, with logo and labelColor', function() { + it('should match snapshots: message only, with logo and labelColor', function () { snapshot( makeBadge({ text: ['', 'grown'], @@ -445,7 +441,7 @@ describe('The badge generator', function() { ) }) - it('should match snapshots: message/label, with links', function() { + it('should match snapshots: message/label, with links', function () { snapshot( makeBadge({ text: ['cactus', 'grown'], @@ -459,31 +455,27 @@ describe('The badge generator', function() { }) }) - describe('"social" template badge generation', function() { - it('should produce capitalized string for badge key', function() { + describe('"social" template badge generation', function () { + it('should produce capitalized string for badge key', function () { const svg = makeBadge({ text: ['some-key', 'some-value'], format: 'svg', template: 'social', }) - expect(svg) - .to.include('Some-key') - .and.to.include('some-value') + expect(svg).to.include('Some-key').and.to.include('some-value') }) // https://github.com/badges/shields/issues/1606 - it('should handle empty strings used as badge keys', function() { + it('should handle empty strings used as badge keys', function () { const svg = makeBadge({ text: ['', 'some-value'], format: 'json', template: 'social', }) - expect(svg) - .to.include('""') - .and.to.include('some-value') + expect(svg).to.include('""').and.to.include('some-value') }) - it('should match snapshots: message/label, no logo', function() { + it('should match snapshots: message/label, no logo', function () { snapshot( makeBadge({ text: ['cactus', 'grown'], @@ -495,7 +487,7 @@ describe('The badge generator', function() { ) }) - it('should match snapshots: message/label, with logo', function() { + it('should match snapshots: message/label, with logo', function () { snapshot( makeBadge({ text: ['cactus', 'grown'], @@ -508,7 +500,7 @@ describe('The badge generator', function() { ) }) - it('should match snapshots: message only, no logo', function() { + it('should match snapshots: message only, no logo', function () { snapshot( makeBadge({ text: ['', 'grown'], @@ -519,7 +511,7 @@ describe('The badge generator', function() { ) }) - it('should match snapshots: message only, with logo', function() { + it('should match snapshots: message only, with logo', function () { snapshot( makeBadge({ text: ['', 'grown'], @@ -531,7 +523,7 @@ describe('The badge generator', function() { ) }) - it('should match snapshots: message only, with logo and labelColor', function() { + it('should match snapshots: message only, with logo and labelColor', function () { snapshot( makeBadge({ text: ['', 'grown'], @@ -544,7 +536,7 @@ describe('The badge generator', function() { ) }) - it('should match snapshots: message/label, with links', function() { + it('should match snapshots: message/label, with links', function () { snapshot( makeBadge({ text: ['cactus', 'grown'], @@ -558,8 +550,8 @@ describe('The badge generator', function() { }) }) - describe('badges with logos should always produce the same badge', function() { - it('badge with logo', function() { + describe('badges with logos should always produce the same badge', function () { + it('badge with logo', function () { const svg = makeBadge({ text: ['label', 'message'], format: 'svg', diff --git a/core/badge-urls/make-badge-url.spec.js b/core/badge-urls/make-badge-url.spec.js index 450b15d673136eff2f7861797402b0f6b3472fb9..94642db1f85c5a48adb48d39772dab61a505e23e 100644 --- a/core/badge-urls/make-badge-url.spec.js +++ b/core/badge-urls/make-badge-url.spec.js @@ -10,7 +10,7 @@ const { dynamicBadgeUrl, } = require('./make-badge-url') -describe('Badge URL generation functions', function() { +describe('Badge URL generation functions', function () { test(badgeUrlFromPath, () => { given({ baseUrl: 'http://example.com', diff --git a/core/base-service/auth-helper.spec.js b/core/base-service/auth-helper.spec.js index bec321dde1cf0c52445e02f0c19d3955bba1cf34..2666c818aa909658e1f4593ff582c9be3d4e1bb7 100644 --- a/core/base-service/auth-helper.spec.js +++ b/core/base-service/auth-helper.spec.js @@ -5,20 +5,20 @@ const { test, given, forCases } = require('sazerac') const { AuthHelper } = require('./auth-helper') const { InvalidParameter } = require('./errors') -describe('AuthHelper', function() { - describe('constructor checks', function() { - it('throws without userKey or passKey', function() { +describe('AuthHelper', function () { + describe('constructor checks', function () { + it('throws without userKey or passKey', function () { expect(() => new AuthHelper({}, {})).to.throw( Error, 'Expected userKey or passKey to be set' ) }) - it('throws without serviceKey or authorizedOrigins', function() { + it('throws without serviceKey or authorizedOrigins', function () { expect( () => new AuthHelper({ userKey: 'myci_user', passKey: 'myci_pass' }, {}) ).to.throw(Error, 'Expected authorizedOrigins or serviceKey to be set') }) - it('throws when authorizedOrigins is not an array', function() { + it('throws when authorizedOrigins is not an array', function () { expect( () => new AuthHelper( @@ -33,7 +33,7 @@ describe('AuthHelper', function() { }) }) - describe('isValid', function() { + describe('isValid', function () { function validate(config, privateConfig) { return new AuthHelper( { authorizedOrigins: ['https://example.test'], ...config }, @@ -89,7 +89,7 @@ describe('AuthHelper', function() { }) }) - describe('_basicAuth', function() { + describe('_basicAuth', function () { function validate(config, privateConfig) { return new AuthHelper( { authorizedOrigins: ['https://example.test'], ...config }, @@ -128,7 +128,7 @@ describe('AuthHelper', function() { }) }) - describe('_isInsecureSslRequest', function() { + describe('_isInsecureSslRequest', function () { test(AuthHelper._isInsecureSslRequest, () => { forCases([ given({ url: 'http://example.test' }), @@ -146,31 +146,31 @@ describe('AuthHelper', function() { }) }) - describe('enforceStrictSsl', function() { + describe('enforceStrictSsl', function () { const authConfig = { userKey: 'myci_user', passKey: 'myci_pass', serviceKey: 'myci', } - context('by default', function() { + context('by default', function () { const authHelper = new AuthHelper(authConfig, { public: { services: { myci: { authorizedOrigins: ['http://myci.test'] } }, }, private: { myci_user: 'admin', myci_pass: 'abc123' }, }) - it('does not throw for secure requests', function() { + it('does not throw for secure requests', function () { expect(() => authHelper.enforceStrictSsl({})).not.to.throw() }) - it('throws for insecure requests', function() { + it('throws for insecure requests', function () { expect(() => authHelper.enforceStrictSsl({ options: { strictSSL: false } }) ).to.throw(InvalidParameter) }) }) - context("when strict SSL isn't required", function() { + context("when strict SSL isn't required", function () { const authHelper = new AuthHelper(authConfig, { public: { services: { @@ -182,10 +182,10 @@ describe('AuthHelper', function() { }, private: { myci_user: 'admin', myci_pass: 'abc123' }, }) - it('does not throw for secure requests', function() { + it('does not throw for secure requests', function () { expect(() => authHelper.enforceStrictSsl({})).not.to.throw() }) - it('does not throw for insecure requests', function() { + it('does not throw for insecure requests', function () { expect(() => authHelper.enforceStrictSsl({ options: { strictSSL: false } }) ).not.to.throw() @@ -193,14 +193,14 @@ describe('AuthHelper', function() { }) }) - describe('shouldAuthenticateRequest', function() { + describe('shouldAuthenticateRequest', function () { const authConfig = { userKey: 'myci_user', passKey: 'myci_pass', serviceKey: 'myci', } - context('by default', function() { + context('by default', function () { const authHelper = new AuthHelper(authConfig, { public: { services: { @@ -213,12 +213,12 @@ describe('AuthHelper', function() { }) const shouldAuthenticateRequest = requestOptions => authHelper.shouldAuthenticateRequest(requestOptions) - describe('a secure request to an authorized origin', function() { + describe('a secure request to an authorized origin', function () { test(shouldAuthenticateRequest, () => { given({ url: 'https://myci.test/api' }).expect(true) }) }) - describe('an insecure request', function() { + describe('an insecure request', function () { test(shouldAuthenticateRequest, () => { given({ url: 'https://myci.test/api', @@ -226,7 +226,7 @@ describe('AuthHelper', function() { }).expect(false) }) }) - describe('a request to an unauthorized origin', function() { + describe('a request to an unauthorized origin', function () { test(shouldAuthenticateRequest, () => { forCases([ given({ url: 'http://myci.test/api' }), @@ -237,7 +237,7 @@ describe('AuthHelper', function() { }) }) - context('when auth over insecure SSL is allowed', function() { + context('when auth over insecure SSL is allowed', function () { const authHelper = new AuthHelper(authConfig, { public: { services: { @@ -251,12 +251,12 @@ describe('AuthHelper', function() { }) const shouldAuthenticateRequest = requestOptions => authHelper.shouldAuthenticateRequest(requestOptions) - describe('a secure request to an authorized origin', function() { + describe('a secure request to an authorized origin', function () { test(shouldAuthenticateRequest, () => { given({ url: 'https://myci.test' }).expect(true) }) }) - describe('an insecure request', function() { + describe('an insecure request', function () { test(shouldAuthenticateRequest, () => { given({ url: 'https://myci.test', @@ -264,7 +264,7 @@ describe('AuthHelper', function() { }).expect(true) }) }) - describe('a request to an unauthorized origin', function() { + describe('a request to an unauthorized origin', function () { test(shouldAuthenticateRequest, () => { forCases([ given({ url: 'http://myci.test' }), @@ -275,7 +275,7 @@ describe('AuthHelper', function() { }) }) - context('when the service is partly configured', function() { + context('when the service is partly configured', function () { const authHelper = new AuthHelper(authConfig, { public: { services: { @@ -289,7 +289,7 @@ describe('AuthHelper', function() { }) const shouldAuthenticateRequest = requestOptions => authHelper.shouldAuthenticateRequest(requestOptions) - describe('a secure request to an authorized origin', function() { + describe('a secure request to an authorized origin', function () { test(shouldAuthenticateRequest, () => { given({ url: 'https://myci.test' }).expect(false) }) @@ -297,7 +297,7 @@ describe('AuthHelper', function() { }) }) - describe('withBasicAuth', function() { + describe('withBasicAuth', function () { const authHelper = new AuthHelper( { userKey: 'myci_user', @@ -318,7 +318,7 @@ describe('AuthHelper', function() { const withBasicAuth = requestOptions => authHelper.withBasicAuth(requestOptions) - describe('authenticates a secure request to an authorized origin', function() { + describe('authenticates a secure request to an authorized origin', function () { test(withBasicAuth, () => { given({ url: 'https://myci.test/api', @@ -343,7 +343,7 @@ describe('AuthHelper', function() { }) }) - describe('does not authenticate a request to an unauthorized origin', function() { + describe('does not authenticate a request to an unauthorized origin', function () { test(withBasicAuth, () => { given({ url: 'https://other.test/api', @@ -364,7 +364,7 @@ describe('AuthHelper', function() { }) }) - describe('throws on an insecure SSL request', function() { + describe('throws on an insecure SSL request', function () { expect(() => withBasicAuth({ url: 'https://myci.test/api', diff --git a/core/base-service/base-graphql.spec.js b/core/base-service/base-graphql.spec.js index 4f72887d2d68c53e8c5a0273fd3afa5f49547b10..5b0a1eb1a3b0407dff99353b94191a5fed62013b 100644 --- a/core/base-service/base-graphql.spec.js +++ b/core/base-service/base-graphql.spec.js @@ -36,10 +36,10 @@ class DummyGraphqlService extends BaseGraphqlService { } } -describe('BaseGraphqlService', function() { - describe('Making requests', function() { +describe('BaseGraphqlService', function () { + describe('Making requests', function () { let sendAndCacheRequest - beforeEach(function() { + beforeEach(function () { sendAndCacheRequest = sinon.stub().returns( Promise.resolve({ buffer: '{"some": "json"}', @@ -48,7 +48,7 @@ describe('BaseGraphqlService', function() { ) }) - it('invokes _sendAndCacheRequest', async function() { + it('invokes _sendAndCacheRequest', async function () { await DummyGraphqlService.invoke( { sendAndCacheRequest }, { handleInternalErrors: false } @@ -64,7 +64,7 @@ describe('BaseGraphqlService', function() { ) }) - it('forwards options to _sendAndCacheRequest', async function() { + it('forwards options to _sendAndCacheRequest', async function () { class WithOptions extends DummyGraphqlService { async handle() { const { value } = await this._requestGraphql({ @@ -98,8 +98,8 @@ describe('BaseGraphqlService', function() { }) }) - describe('Making badges', function() { - it('handles valid json responses', async function() { + describe('Making badges', function () { + it('handles valid json responses', async function () { const sendAndCacheRequest = async () => ({ buffer: '{"requiredString": "some-string"}', res: { statusCode: 200 }, @@ -114,7 +114,7 @@ describe('BaseGraphqlService', function() { }) }) - it('handles json responses which do not match the schema', async function() { + it('handles json responses which do not match the schema', async function () { const sendAndCacheRequest = async () => ({ buffer: '{"unexpectedKey": "some-string"}', res: { statusCode: 200 }, @@ -131,7 +131,7 @@ describe('BaseGraphqlService', function() { }) }) - it('handles unparseable json responses', async function() { + it('handles unparseable json responses', async function () { const sendAndCacheRequest = async () => ({ buffer: 'not json', res: { statusCode: 200 }, @@ -149,8 +149,8 @@ describe('BaseGraphqlService', function() { }) }) - describe('Error handling', function() { - it('handles generic error', async function() { + describe('Error handling', function () { + it('handles generic error', async function () { const sendAndCacheRequest = async () => ({ buffer: '{ "errors": [ { "message": "oh noes!!" } ] }', res: { statusCode: 200 }, @@ -167,7 +167,7 @@ describe('BaseGraphqlService', function() { }) }) - it('handles custom error', async function() { + it('handles custom error', async function () { class WithErrorHandler extends DummyGraphqlService { async handle() { const { requiredString } = await this._requestGraphql({ @@ -178,7 +178,7 @@ describe('BaseGraphqlService', function() { requiredString } `, - transformErrors: function(errors) { + transformErrors: function (errors) { if (errors[0].message === 'oh noes!!') { return new InvalidResponse({ prettyMessage: 'a terrible thing has happened', diff --git a/core/base-service/base-json.spec.js b/core/base-service/base-json.spec.js index a6596fb4e028b43d844e6ece44adb2521ab6892d..44e7b2b95a5b59f7af8f2da9799254c175a4cd0f 100644 --- a/core/base-service/base-json.spec.js +++ b/core/base-service/base-json.spec.js @@ -29,10 +29,10 @@ class DummyJsonService extends BaseJsonService { } } -describe('BaseJsonService', function() { - describe('Making requests', function() { +describe('BaseJsonService', function () { + describe('Making requests', function () { let sendAndCacheRequest - beforeEach(function() { + beforeEach(function () { sendAndCacheRequest = sinon.stub().returns( Promise.resolve({ buffer: '{"some": "json"}', @@ -41,7 +41,7 @@ describe('BaseJsonService', function() { ) }) - it('invokes _sendAndCacheRequest', async function() { + it('invokes _sendAndCacheRequest', async function () { await DummyJsonService.invoke( { sendAndCacheRequest }, { handleInternalErrors: false } @@ -55,7 +55,7 @@ describe('BaseJsonService', function() { ) }) - it('forwards options to _sendAndCacheRequest', async function() { + it('forwards options to _sendAndCacheRequest', async function () { class WithOptions extends DummyJsonService { async handle() { const { value } = await this._requestJson({ @@ -83,8 +83,8 @@ describe('BaseJsonService', function() { }) }) - describe('Making badges', function() { - it('handles valid json responses', async function() { + describe('Making badges', function () { + it('handles valid json responses', async function () { const sendAndCacheRequest = async () => ({ buffer: '{"requiredString": "some-string"}', res: { statusCode: 200 }, @@ -99,7 +99,7 @@ describe('BaseJsonService', function() { }) }) - it('handles json responses which do not match the schema', async function() { + it('handles json responses which do not match the schema', async function () { const sendAndCacheRequest = async () => ({ buffer: '{"unexpectedKey": "some-string"}', res: { statusCode: 200 }, @@ -116,7 +116,7 @@ describe('BaseJsonService', function() { }) }) - it('handles unparseable json responses', async function() { + it('handles unparseable json responses', async function () { const sendAndCacheRequest = async () => ({ buffer: 'not json', res: { statusCode: 200 }, diff --git a/core/base-service/base-svg-scraping.spec.js b/core/base-service/base-svg-scraping.spec.js index 520b7b9a2ff93c5f45f7c575f1452bb4054641a5..40e3257585498f48e7a4004060665c1514ce492b 100644 --- a/core/base-service/base-svg-scraping.spec.js +++ b/core/base-service/base-svg-scraping.spec.js @@ -33,7 +33,7 @@ class DummySvgScrapingService extends BaseSvgScrapingService { } } -describe('BaseSvgScrapingService', function() { +describe('BaseSvgScrapingService', function () { const exampleLabel = 'this is the label' const exampleMessage = 'this is the result!' const exampleSvg = makeExampleSvg({ @@ -41,17 +41,17 @@ describe('BaseSvgScrapingService', function() { message: exampleMessage, }) - describe('valueFromSvgBadge', function() { - it('should find the correct value', function() { + describe('valueFromSvgBadge', function () { + it('should find the correct value', function () { expect(BaseSvgScrapingService.valueFromSvgBadge(exampleSvg)).to.equal( exampleMessage ) }) }) - describe('Making requests', function() { + describe('Making requests', function () { let sendAndCacheRequest - beforeEach(function() { + beforeEach(function () { sendAndCacheRequest = sinon.stub().returns( Promise.resolve({ buffer: exampleSvg, @@ -60,7 +60,7 @@ describe('BaseSvgScrapingService', function() { ) }) - it('invokes _sendAndCacheRequest with the expected header', async function() { + it('invokes _sendAndCacheRequest with the expected header', async function () { await DummySvgScrapingService.invoke( { sendAndCacheRequest }, { handleInternalErrors: false } @@ -74,7 +74,7 @@ describe('BaseSvgScrapingService', function() { ) }) - it('forwards options to _sendAndCacheRequest', async function() { + it('forwards options to _sendAndCacheRequest', async function () { class WithCustomOptions extends DummySvgScrapingService { async handle() { const { message } = await this._requestSvg({ @@ -105,8 +105,8 @@ describe('BaseSvgScrapingService', function() { }) }) - describe('Making badges', function() { - it('handles valid svg responses', async function() { + describe('Making badges', function () { + it('handles valid svg responses', async function () { const sendAndCacheRequest = async () => ({ buffer: exampleSvg, res: { statusCode: 200 }, @@ -121,7 +121,7 @@ describe('BaseSvgScrapingService', function() { }) }) - it('allows overriding the valueMatcher', async function() { + it('allows overriding the valueMatcher', async function () { class WithValueMatcher extends BaseSvgScrapingService { static get route() { return {} @@ -149,7 +149,7 @@ describe('BaseSvgScrapingService', function() { }) }) - it('handles unparseable svg responses', async function() { + it('handles unparseable svg responses', async function () { const sendAndCacheRequest = async () => ({ buffer: 'not svg yo', res: { statusCode: 200 }, diff --git a/core/base-service/base-xml.spec.js b/core/base-service/base-xml.spec.js index 7f36b209dd28ef4e95995b4a11bcd44c2df27deb..9d9a595472b79db199701e4334a6a1d393e85ba7 100644 --- a/core/base-service/base-xml.spec.js +++ b/core/base-service/base-xml.spec.js @@ -29,10 +29,10 @@ class DummyXmlService extends BaseXmlService { } } -describe('BaseXmlService', function() { - describe('Making requests', function() { +describe('BaseXmlService', function () { + describe('Making requests', function () { let sendAndCacheRequest - beforeEach(function() { + beforeEach(function () { sendAndCacheRequest = sinon.stub().returns( Promise.resolve({ buffer: '<requiredString>some-string</requiredString>', @@ -41,7 +41,7 @@ describe('BaseXmlService', function() { ) }) - it('invokes _sendAndCacheRequest', async function() { + it('invokes _sendAndCacheRequest', async function () { await DummyXmlService.invoke( { sendAndCacheRequest }, { handleInternalErrors: false } @@ -55,7 +55,7 @@ describe('BaseXmlService', function() { ) }) - it('forwards options to _sendAndCacheRequest', async function() { + it('forwards options to _sendAndCacheRequest', async function () { class WithCustomOptions extends BaseXmlService { static get route() { return {} @@ -87,8 +87,8 @@ describe('BaseXmlService', function() { }) }) - describe('Making badges', function() { - it('handles valid xml responses', async function() { + describe('Making badges', function () { + it('handles valid xml responses', async function () { const sendAndCacheRequest = async () => ({ buffer: '<requiredString>some-string</requiredString>', res: { statusCode: 200 }, @@ -103,7 +103,7 @@ describe('BaseXmlService', function() { }) }) - it('parses XML response with custom parser options', async function() { + it('parses XML response with custom parser options', async function () { const customParserOption = { trimValues: false } class DummyXmlServiceWithParserOption extends DummyXmlService { async handle() { @@ -130,7 +130,7 @@ describe('BaseXmlService', function() { }) }) - it('handles xml responses which do not match the schema', async function() { + it('handles xml responses which do not match the schema', async function () { const sendAndCacheRequest = async () => ({ buffer: '<unexpectedAttribute>some-string</unexpectedAttribute>', res: { statusCode: 200 }, @@ -147,7 +147,7 @@ describe('BaseXmlService', function() { }) }) - it('handles unparseable xml responses', async function() { + it('handles unparseable xml responses', async function () { const sendAndCacheRequest = async () => ({ buffer: 'not xml', res: { statusCode: 200 }, diff --git a/core/base-service/base-yaml.spec.js b/core/base-service/base-yaml.spec.js index 8098501a0efbdf8b6acc73ad99ae5df4df98b9a9..b2747e5ad3566b1a93d83d818bdc5914af35909f 100644 --- a/core/base-service/base-yaml.spec.js +++ b/core/base-service/base-yaml.spec.js @@ -45,10 +45,10 @@ foo: bar foo: baz ` -describe('BaseYamlService', function() { - describe('Making requests', function() { +describe('BaseYamlService', function () { + describe('Making requests', function () { let sendAndCacheRequest - beforeEach(function() { + beforeEach(function () { sendAndCacheRequest = sinon.stub().returns( Promise.resolve({ buffer: expectedYaml, @@ -57,7 +57,7 @@ describe('BaseYamlService', function() { ) }) - it('invokes _sendAndCacheRequest', async function() { + it('invokes _sendAndCacheRequest', async function () { await DummyYamlService.invoke( { sendAndCacheRequest }, { handleInternalErrors: false } @@ -74,7 +74,7 @@ describe('BaseYamlService', function() { ) }) - it('forwards options to _sendAndCacheRequest', async function() { + it('forwards options to _sendAndCacheRequest', async function () { class WithOptions extends DummyYamlService { async handle() { const { requiredString } = await this._requestYaml({ @@ -105,8 +105,8 @@ describe('BaseYamlService', function() { }) }) - describe('Making badges', function() { - it('handles valid yaml responses', async function() { + describe('Making badges', function () { + it('handles valid yaml responses', async function () { const sendAndCacheRequest = async () => ({ buffer: expectedYaml, res: { statusCode: 200 }, @@ -121,7 +121,7 @@ describe('BaseYamlService', function() { }) }) - it('handles yaml responses which do not match the schema', async function() { + it('handles yaml responses which do not match the schema', async function () { const sendAndCacheRequest = async () => ({ buffer: unexpectedYaml, res: { statusCode: 200 }, @@ -138,7 +138,7 @@ describe('BaseYamlService', function() { }) }) - it('handles unparseable yaml responses', async function() { + it('handles unparseable yaml responses', async function () { const sendAndCacheRequest = async () => ({ buffer: invalidYaml, res: { statusCode: 200 }, diff --git a/core/base-service/base.js b/core/base-service/base.js index db671e1c1dd6405e407a0991e5440d576a7d2494..89520b123d546cbcbce4693a2f7b521f9f989854 100644 --- a/core/base-service/base.js +++ b/core/base-service/base.js @@ -58,10 +58,7 @@ const serviceDataSchema = Joi.object({ // `render()` to always return a string. message: Joi.alternatives(Joi.string().allow(''), Joi.number()).required(), color: Joi.string(), - link: Joi.array() - .items(Joi.string().uri()) - .single() - .max(2), + link: Joi.array().items(Joi.string().uri()).single().max(2), // Generally services should not use these options, which are provided to // support the Endpoint badge. labelColor: Joi.string(), @@ -70,9 +67,7 @@ const serviceDataSchema = Joi.object({ logoColor: optionalStringWhenNamedLogoPresent, logoWidth: optionalNumberWhenAnyLogoPresent, logoPosition: optionalNumberWhenAnyLogoPresent, - cacheSeconds: Joi.number() - .integer() - .min(0), + cacheSeconds: Joi.number().integer().min(0), style: Joi.string(), }) .oxor('namedLogo', 'logoSvg') diff --git a/core/base-service/base.spec.js b/core/base-service/base.spec.js index 01f28d0f5fbc7cb864cd43dbe95fcba625766bdf..0c6886a203a05fd28af44f4f0025ecb6c3802b62 100644 --- a/core/base-service/base.spec.js +++ b/core/base-service/base.spec.js @@ -73,7 +73,7 @@ class DummyServiceWithServiceResponseSizeMetricEnabled extends DummyService { } } -describe('BaseService', function() { +describe('BaseService', function () { const defaultConfig = { public: { handleInternalErrors: false, @@ -82,7 +82,7 @@ describe('BaseService', function() { private: {}, } - it('Invokes the handler as expected', async function() { + it('Invokes the handler as expected', async function () { expect( await DummyService.invoke( {}, @@ -95,7 +95,7 @@ describe('BaseService', function() { }) }) - it('Validates query params', async function() { + it('Validates query params', async function () { expect( await DummyService.invoke( {}, @@ -110,14 +110,14 @@ describe('BaseService', function() { }) }) - describe('Required overrides', function() { - it('Should throw if render() is not overridden', function() { + describe('Required overrides', function () { + it('Should throw if render() is not overridden', function () { expect(() => BaseService.render()).to.throw( /^render\(\) function not implemented for BaseService$/ ) }) - it('Should throw if route is not overridden', function() { + it('Should throw if route is not overridden', function () { return expect(BaseService.invoke({}, {}, {})).to.be.rejectedWith( /^Route not defined for BaseService$/ ) @@ -128,31 +128,31 @@ describe('BaseService', function() { return {} } } - it('Should throw if handle() is not overridden', function() { + it('Should throw if handle() is not overridden', function () { return expect(WithRoute.invoke({}, {}, {})).to.be.rejectedWith( /^Handler not implemented for WithRoute$/ ) }) - it('Should throw if category is not overridden', function() { + it('Should throw if category is not overridden', function () { expect(() => BaseService.category).to.throw( /^Category not set for BaseService$/ ) }) }) - describe('Logging', function() { + describe('Logging', function () { let sandbox - beforeEach(function() { + beforeEach(function () { sandbox = sinon.createSandbox() }) - afterEach(function() { + afterEach(function () { sandbox.restore() }) - beforeEach(function() { + beforeEach(function () { sandbox.stub(trace, 'logTrace') }) - it('Invokes the logger as expected', async function() { + it('Invokes the logger as expected', async function () { await DummyService.invoke( {}, defaultConfig, @@ -180,8 +180,8 @@ describe('BaseService', function() { }) }) - describe('Service data validation', function() { - it('Allows a link array', async function() { + describe('Service data validation', function () { + it('Allows a link array', async function () { const message = 'hello' const link = ['https://example.com/', 'https://other.example.com/'] class LinkService extends DummyService { @@ -202,7 +202,7 @@ describe('BaseService', function() { }) }) - context('On invalid data', function() { + context('On invalid data', function () { class ThrowingService extends DummyService { async handle() { return { @@ -211,7 +211,7 @@ describe('BaseService', function() { } } - it('Throws a validation error on invalid data', async function() { + it('Throws a validation error on invalid data', async function () { try { await ThrowingService.invoke( {}, @@ -229,7 +229,7 @@ describe('BaseService', function() { // Ensure debuggabillity. // https://github.com/badges/shields/issues/3784 - it('Includes the service class in the stack trace', async function() { + it('Includes the service class in the stack trace', async function () { try { await ThrowingService.invoke( {}, @@ -244,8 +244,8 @@ describe('BaseService', function() { }) }) - describe('Error handling', function() { - it('Handles internal errors', async function() { + describe('Error handling', function () { + it('Handles internal errors', async function () { class ThrowingService extends DummyService { async handle() { throw Error("I've made a huge mistake") @@ -265,8 +265,8 @@ describe('BaseService', function() { }) }) - describe('Handles known subtypes of ShieldsInternalError', function() { - it('handles NotFound errors', async function() { + describe('Handles known subtypes of ShieldsInternalError', function () { + it('handles NotFound errors', async function () { class ThrowingService extends DummyService { async handle() { throw new NotFound() @@ -281,7 +281,7 @@ describe('BaseService', function() { }) }) - it('handles Inaccessible errors', async function() { + it('handles Inaccessible errors', async function () { class ThrowingService extends DummyService { async handle() { throw new Inaccessible() @@ -296,7 +296,7 @@ describe('BaseService', function() { }) }) - it('handles InvalidResponse errors', async function() { + it('handles InvalidResponse errors', async function () { class ThrowingService extends DummyService { async handle() { throw new InvalidResponse() @@ -311,7 +311,7 @@ describe('BaseService', function() { }) }) - it('handles Deprecated', async function() { + it('handles Deprecated', async function () { class ThrowingService extends DummyService { async handle() { throw new Deprecated() @@ -326,7 +326,7 @@ describe('BaseService', function() { }) }) - it('handles InvalidParameter errors', async function() { + it('handles InvalidParameter errors', async function () { class ThrowingService extends DummyService { async handle() { throw new InvalidParameter() @@ -343,7 +343,7 @@ describe('BaseService', function() { }) }) - describe('ScoutCamp integration', function() { + describe('ScoutCamp integration', function () { // TODO Strangly, without the useless escape the regexes do not match in Node 12. // eslint-disable-next-line no-useless-escape const expectedRouteRegex = /^\/foo\/([^\/]+?)(|\.svg|\.json)$/ @@ -351,7 +351,7 @@ describe('BaseService', function() { let mockCamp let mockHandleRequest - beforeEach(function() { + beforeEach(function () { mockCamp = { route: sinon.spy(), } @@ -362,12 +362,12 @@ describe('BaseService', function() { ) }) - it('registers the service', function() { + it('registers the service', function () { expect(mockCamp.route).to.have.been.calledOnce expect(mockCamp.route).to.have.been.calledWith(expectedRouteRegex) }) - it('handles the request', async function() { + it('handles the request', async function () { expect(mockHandleRequest).to.have.been.calledOnce const { @@ -404,8 +404,8 @@ describe('BaseService', function() { }) }) - describe('getDefinition', function() { - it('returns the expected result', function() { + describe('getDefinition', function () { + it('returns the expected result', function () { const { category, name, @@ -432,12 +432,12 @@ describe('BaseService', function() { }) }) - describe('validate', function() { + describe('validate', function () { const dummySchema = Joi.object({ requiredString: Joi.string().required(), }).required() - it('throws error for invalid responses', function() { + it('throws error for invalid responses', function () { expect(() => DummyService._validate( { requiredString: ['this', "shouldn't", 'work'] }, @@ -449,19 +449,19 @@ describe('BaseService', function() { }) }) - describe('request', function() { + describe('request', function () { let sandbox - beforeEach(function() { + beforeEach(function () { sandbox = sinon.createSandbox() }) - afterEach(function() { + afterEach(function () { sandbox.restore() }) - beforeEach(function() { + beforeEach(function () { sandbox.stub(trace, 'logTrace') }) - it('logs appropriate information', async function() { + it('logs appropriate information', async function () { const sendAndCacheRequest = async () => ({ buffer: '', res: { statusCode: 200 }, @@ -491,7 +491,7 @@ describe('BaseService', function() { ) }) - it('handles errors', async function() { + it('handles errors', async function () { const sendAndCacheRequest = async () => ({ buffer: '', res: { statusCode: 404 }, @@ -512,14 +512,14 @@ describe('BaseService', function() { }) }) - describe('Metrics', function() { + describe('Metrics', function () { let register - beforeEach(function() { + beforeEach(function () { register = new prometheus.Registry() }) const url = 'some-url' - it('service response size metric is optional', async function() { + it('service response size metric is optional', async function () { const metricHelper = MetricHelper.create({ metricInstance: new PrometheusMetrics({ register }), ServiceClass: DummyServiceWithServiceResponseSizeMetricEnabled, @@ -544,7 +544,7 @@ describe('BaseService', function() { ) }) - it('service response size metric is disabled by default', async function() { + it('service response size metric is disabled by default', async function () { const metricHelper = MetricHelper.create({ metricInstance: new PrometheusMetrics({ register }), ServiceClass: DummyService, @@ -565,7 +565,7 @@ describe('BaseService', function() { ).to.not.contain('service_response_bytes_bucket') }) }) - describe('auth', function() { + describe('auth', function () { class AuthService extends DummyService { static get auth() { return { @@ -582,7 +582,7 @@ describe('BaseService', function() { } } - it('when auth is configured properly, invoke() sets authHelper', async function() { + it('when auth is configured properly, invoke() sets authHelper', async function () { expect( await AuthService.invoke( {}, @@ -598,7 +598,7 @@ describe('BaseService', function() { ).to.deep.equal({ message: 'The CI password is abc123' }) }) - it('when auth is not configured properly, invoke() returns inacessible', async function() { + it('when auth is not configured properly, invoke() returns inacessible', async function () { expect( await AuthService.invoke( {}, diff --git a/core/base-service/cache-headers.js b/core/base-service/cache-headers.js index 7ab14187c947b8adc074680153a295f94dfa8cf3..e8ce9f712fcc7e734c59e85f31df15614b807d6e 100644 --- a/core/base-service/cache-headers.js +++ b/core/base-service/cache-headers.js @@ -7,9 +7,7 @@ const coalesce = require('./coalesce') const serverStartTimeGMTString = new Date().toGMTString() const serverStartTimestamp = Date.now() -const isOptionalNonNegativeInteger = Joi.number() - .integer() - .min(0) +const isOptionalNonNegativeInteger = Joi.number().integer().min(0) const queryParamSchema = Joi.object({ cacheSeconds: isOptionalNonNegativeInteger, diff --git a/core/base-service/cache-headers.spec.js b/core/base-service/cache-headers.spec.js index 404c820b175ccbe53a99eabc20882401fc52e19a..65832f50de3e390c74838f4dd1c7e8df072a271c 100644 --- a/core/base-service/cache-headers.spec.js +++ b/core/base-service/cache-headers.spec.js @@ -15,13 +15,13 @@ const { chai.use(require('chai-datetime')) -describe('Cache header functions', function() { +describe('Cache header functions', function () { let res - beforeEach(function() { + beforeEach(function () { res = httpMocks.createResponse() }) - describe('coalesceCacheLength', function() { + describe('coalesceCacheLength', function () { const cacheHeaderConfig = { defaultCacheLengthSeconds: 777 } test(coalesceCacheLength, () => { given({ cacheHeaderConfig, queryParams: {} }).expect(777) @@ -101,18 +101,18 @@ describe('Cache header functions', function() { }) }) - describe('setHeadersForCacheLength', function() { + describe('setHeadersForCacheLength', function () { let sandbox - beforeEach(function() { + beforeEach(function () { sandbox = sinon.createSandbox() sandbox.useFakeTimers() }) - afterEach(function() { + afterEach(function () { sandbox.restore() sandbox = undefined }) - it('should set the correct Date header', function() { + it('should set the correct Date header', function () { // Confidence check. expect(res._headers.date).to.equal(undefined) @@ -124,42 +124,42 @@ describe('Cache header functions', function() { expect(res._headers.date).to.equal(now) }) - context('cacheLengthSeconds is zero', function() { - beforeEach(function() { + context('cacheLengthSeconds is zero', function () { + beforeEach(function () { setHeadersForCacheLength(res, 0) }) - it('should set the expected Cache-Control header', function() { + it('should set the expected Cache-Control header', function () { expect(res._headers['cache-control']).to.equal( 'no-cache, no-store, must-revalidate' ) }) - it('should set the expected Expires header', function() { + it('should set the expected Expires header', function () { expect(res._headers.expires).to.equal(new Date().toGMTString()) }) }) - context('cacheLengthSeconds is nonzero', function() { - beforeEach(function() { + context('cacheLengthSeconds is nonzero', function () { + beforeEach(function () { setHeadersForCacheLength(res, 123) }) - it('should set the expected Cache-Control header', function() { + it('should set the expected Cache-Control header', function () { expect(res._headers['cache-control']).to.equal( 'max-age=123 s-maxage=123' ) }) - it('should set the expected Expires header', function() { + it('should set the expected Expires header', function () { const expires = new Date(Date.now() + 123 * 1000).toGMTString() expect(res._headers.expires).to.equal(expires) }) }) }) - describe('setCacheHeaders', function() { - it('sets the expected fields', function() { + describe('setCacheHeaders', function () { + it('sets the expected fields', function () { const expectedFields = ['date', 'cache-control', 'expires'] expectedFields.forEach(field => expect(res._headers[field]).to.equal(undefined) @@ -180,18 +180,18 @@ describe('Cache header functions', function() { }) }) - describe('setCacheHeadersForStaticResource', function() { - beforeEach(function() { + describe('setCacheHeadersForStaticResource', function () { + beforeEach(function () { setCacheHeadersForStaticResource(res) }) - it('should set the expected Cache-Control header', function() { + it('should set the expected Cache-Control header', function () { expect(res._headers['cache-control']).to.equal( `max-age=${24 * 3600} s-maxage=${24 * 3600}` ) }) - it('should set the expected Last-Modified header', function() { + it('should set the expected Last-Modified header', function () { const lastModified = res._headers['last-modified'] expect(new Date(lastModified)).to.be.withinTime( // Within the last 60 seconds. @@ -201,17 +201,17 @@ describe('Cache header functions', function() { }) }) - describe('serverHasBeenUpSinceResourceCached', function() { + describe('serverHasBeenUpSinceResourceCached', function () { // The stringified req's are hard to understand. I thought Sazerac // provided a way to override the describe message, though I can't find it. - context('when there is no If-Modified-Since header', function() { - it('returns false', function() { + context('when there is no If-Modified-Since header', function () { + it('returns false', function () { const req = httpMocks.createRequest() expect(serverHasBeenUpSinceResourceCached(req)).to.equal(false) }) }) - context('when the If-Modified-Since header is invalid', function() { - it('returns false', function() { + context('when the If-Modified-Since header is invalid', function () { + it('returns false', function () { const req = httpMocks.createRequest({ headers: { 'If-Modified-Since': 'this-is-not-a-date' }, }) @@ -220,8 +220,8 @@ describe('Cache header functions', function() { }) context( 'when the If-Modified-Since header is before the process started', - function() { - it('returns false', function() { + function () { + it('returns false', function () { const req = httpMocks.createRequest({ headers: { 'If-Modified-Since': '2018-02-01T05:00:00.000Z' }, }) @@ -231,8 +231,8 @@ describe('Cache header functions', function() { ) context( 'when the If-Modified-Since header is after the process started', - function() { - it('returns true', function() { + function () { + it('returns true', function () { const modifiedTimeStamp = new Date(Date.now() + 1800000) const req = httpMocks.createRequest({ headers: { 'If-Modified-Since': modifiedTimeStamp.toISOString() }, diff --git a/core/base-service/check-error-response.js b/core/base-service/check-error-response.js index 1968e6eb056efc56ea33a99598f8f4323f3975f8..1c4816b1117b79c9c5e6e75605e7ae71f0fca999 100644 --- a/core/base-service/check-error-response.js +++ b/core/base-service/check-error-response.js @@ -7,7 +7,7 @@ const defaultErrorMessages = { } module.exports = function checkErrorResponse(errorMessages = {}) { - return async function({ buffer, res }) { + return async function ({ buffer, res }) { let error errorMessages = { ...defaultErrorMessages, ...errorMessages } if (res.statusCode === 404) { diff --git a/core/base-service/check-error-response.spec.js b/core/base-service/check-error-response.spec.js index 9e55d8ed097c8b4e87a3ff37f9cf7375dd2157cd..34404aa658d726d300c7275006cb8033fa557043 100644 --- a/core/base-service/check-error-response.spec.js +++ b/core/base-service/check-error-response.spec.js @@ -4,11 +4,11 @@ const { expect } = require('chai') const { NotFound, InvalidResponse, Inaccessible } = require('./errors') const checkErrorResponse = require('./check-error-response') -describe('async error handler', function() { +describe('async error handler', function () { const buffer = Buffer.from('some stuff') - context('when status is 200', function() { - it('passes through the inputs', async function() { + context('when status is 200', function () { + it('passes through the inputs', async function () { const res = { statusCode: 200 } expect(await checkErrorResponse()({ res, buffer })).to.deep.equal({ res, @@ -17,11 +17,11 @@ describe('async error handler', function() { }) }) - context('when status is 404', function() { + context('when status is 404', function () { const buffer = Buffer.from('some stuff') const res = { statusCode: 404 } - it('throws NotFound', async function() { + it('throws NotFound', async function () { try { await checkErrorResponse()({ res, buffer }) expect.fail('Expected to throw') @@ -34,7 +34,7 @@ describe('async error handler', function() { } }) - it('displays the custom not found message', async function() { + it('displays the custom not found message', async function () { const notFoundMessage = 'no goblins found' try { await checkErrorResponse({ 404: notFoundMessage })({ res, buffer }) @@ -47,8 +47,8 @@ describe('async error handler', function() { }) }) - context('when status is 4xx', function() { - it('throws InvalidResponse', async function() { + context('when status is 4xx', function () { + it('throws InvalidResponse', async function () { const res = { statusCode: 499 } try { await checkErrorResponse()({ res, buffer }) @@ -64,7 +64,7 @@ describe('async error handler', function() { } }) - it('displays the custom error message', async function() { + it('displays the custom error message', async function () { const res = { statusCode: 403 } try { await checkErrorResponse({ 403: 'access denied' })({ res }) @@ -79,8 +79,8 @@ describe('async error handler', function() { }) }) - context('when status is 5xx', function() { - it('throws Inaccessible', async function() { + context('when status is 5xx', function () { + it('throws Inaccessible', async function () { const res = { statusCode: 503 } try { await checkErrorResponse()({ res, buffer }) @@ -96,7 +96,7 @@ describe('async error handler', function() { } }) - it('displays the custom error message', async function() { + it('displays the custom error message', async function () { const res = { statusCode: 500 } try { await checkErrorResponse({ 500: 'server overloaded' })({ res, buffer }) diff --git a/core/base-service/coalesce-badge.spec.js b/core/base-service/coalesce-badge.spec.js index 443fec3db28a195dc1e6b063b7944ad642fea5ea..7efe9e990cca526041fdfd3e20ad40d6a521ba1c 100644 --- a/core/base-service/coalesce-badge.spec.js +++ b/core/base-service/coalesce-badge.spec.js @@ -4,9 +4,9 @@ const { expect } = require('chai') const { getShieldsIcon, getSimpleIcon } = require('../../lib/logos') const coalesceBadge = require('./coalesce-badge') -describe('coalesceBadge', function() { - describe('Label', function() { - it('uses the default label', function() { +describe('coalesceBadge', function () { + describe('Label', function () { + it('uses the default label', function () { expect(coalesceBadge({}, {}, { label: 'heyo' }).text).to.deep.equal([ 'heyo', 'n/a', @@ -14,34 +14,34 @@ describe('coalesceBadge', function() { }) // This behavior isn't great and we might want to remove it. - it('uses the category as a default label', function() { + it('uses the category as a default label', function () { expect( coalesceBadge({}, {}, {}, { category: 'cat' }).text ).to.deep.equal(['cat', 'n/a']) }) - it('preserves an empty label', function() { + it('preserves an empty label', function () { expect( coalesceBadge({}, { label: '', message: '10k' }, {}).text ).to.deep.equal(['', '10k']) }) - it('overrides the label', function() { + it('overrides the label', function () { expect( coalesceBadge({ label: 'purr count' }, { label: 'purrs' }, {}).text ).to.deep.equal(['purr count', 'n/a']) }) }) - describe('Message', function() { - it('applies the service message', function() { + describe('Message', function () { + it('applies the service message', function () { expect(coalesceBadge({}, { message: '10k' }, {}).text).to.deep.equal([ undefined, '10k', ]) }) - it('applies a numeric service message', function() { + it('applies a numeric service message', function () { // While a number of badges use this, in the long run we may want // `render()` to always return a string. expect(coalesceBadge({}, { message: 10 }, {}).text).to.deep.equal([ @@ -51,12 +51,12 @@ describe('coalesceBadge', function() { }) }) - describe('Right color', function() { - it('uses the default color', function() { + describe('Right color', function () { + it('uses the default color', function () { expect(coalesceBadge({}, {}, {}).color).to.equal('lightgrey') }) - it('overrides the color', function() { + it('overrides the color', function () { expect( coalesceBadge({ color: '10ADED' }, { color: 'red' }, {}).color ).to.equal('10ADED') @@ -66,8 +66,8 @@ describe('coalesceBadge', function() { ).to.equal('B0ADED') }) - context('In case of an error', function() { - it('does not override the color', function() { + context('In case of an error', function () { + it('does not override the color', function () { expect( coalesceBadge( { color: '10ADED' }, @@ -86,23 +86,23 @@ describe('coalesceBadge', function() { }) }) - it('applies the service color', function() { + it('applies the service color', function () { expect(coalesceBadge({}, { color: 'red' }, {}).color).to.equal('red') }) }) - describe('Left color', function() { - it('provides no default label color', function() { + describe('Left color', function () { + it('provides no default label color', function () { expect(coalesceBadge({}, {}, {}).labelColor).to.be.undefined }) - it('applies the service label color', function() { + it('applies the service label color', function () { expect(coalesceBadge({}, { labelColor: 'red' }, {}).labelColor).to.equal( 'red' ) }) - it('overrides the label color', function() { + it('overrides the label color', function () { expect( coalesceBadge({ labelColor: '42f483' }, { color: 'green' }, {}) .labelColor @@ -113,7 +113,7 @@ describe('coalesceBadge', function() { ).to.equal('B2f483') }) - it('converts a query-string numeric color to a string', function() { + it('converts a query-string numeric color to a string', function () { expect( coalesceBadge( // Scoutcamp converts numeric query params to numbers. @@ -134,20 +134,20 @@ describe('coalesceBadge', function() { }) }) - describe('Named logos', function() { - it('when not a social badge, ignores the default named logo', function() { + describe('Named logos', function () { + it('when not a social badge, ignores the default named logo', function () { expect(coalesceBadge({}, {}, { namedLogo: 'appveyor' }).logo).to.be .undefined }) - it('when a social badge, uses the default named logo', function() { + it('when a social badge, uses the default named logo', function () { // .not.be.empty for confidence that nothing has changed with `getShieldsIcon()`. expect( coalesceBadge({ style: 'social' }, {}, { namedLogo: 'appveyor' }).logo ).to.equal(getSimpleIcon({ name: 'appveyor' })).and.not.be.empty }) - it('applies the named logo', function() { + it('applies the named logo', function () { expect(coalesceBadge({}, { namedLogo: 'npm' }, {}).namedLogo).to.equal( 'npm' ) @@ -156,20 +156,20 @@ describe('coalesceBadge', function() { ).and.not.to.be.empty }) - it('applies the named logo with color', function() { + it('applies the named logo with color', function () { expect( coalesceBadge({}, { namedLogo: 'npm', logoColor: 'blue' }, {}).logo ).to.equal(getShieldsIcon({ name: 'npm', color: 'blue' })).and.not.to.be .empty }) - it('overrides the logo', function() { + it('overrides the logo', function () { expect( coalesceBadge({ logo: 'npm' }, { namedLogo: 'appveyor' }, {}).logo ).to.equal(getShieldsIcon({ name: 'npm' })).and.not.be.empty }) - it('overrides the logo with a color', function() { + it('overrides the logo with a color', function () { expect( coalesceBadge( { logo: 'npm', logoColor: 'blue' }, @@ -180,7 +180,7 @@ describe('coalesceBadge', function() { .empty }) - it("when the logo is overridden, it ignores the service's logo color, position, and width", function() { + it("when the logo is overridden, it ignores the service's logo color, position, and width", function () { expect( coalesceBadge( { logo: 'npm' }, @@ -195,7 +195,7 @@ describe('coalesceBadge', function() { ).to.equal(getShieldsIcon({ name: 'npm' })).and.not.be.empty }) - it("overrides the service logo's color", function() { + it("overrides the service logo's color", function () { expect( coalesceBadge( { logoColor: 'blue' }, @@ -207,7 +207,7 @@ describe('coalesceBadge', function() { }) // https://github.com/badges/shields/issues/2998 - it('overrides logoSvg', function() { + it('overrides logoSvg', function () { const logoSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxu' expect(coalesceBadge({ logo: 'npm' }, { logoSvg }, {}).logo).to.equal( getShieldsIcon({ name: 'npm' }) @@ -215,15 +215,15 @@ describe('coalesceBadge', function() { }) }) - describe('Custom logos', function() { - it('overrides the logo with custom svg', function() { + describe('Custom logos', function () { + it('overrides the logo with custom svg', function () { const logoSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxu' expect( coalesceBadge({ logo: logoSvg }, { namedLogo: 'appveyor' }, {}).logo ).to.equal(logoSvg) }) - it('ignores the color when custom svg is provided', function() { + it('ignores the color when custom svg is provided', function () { const logoSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxu' expect( coalesceBadge( @@ -235,26 +235,26 @@ describe('coalesceBadge', function() { }) }) - describe('Logo width', function() { - it('overrides the logoWidth', function() { + describe('Logo width', function () { + it('overrides the logoWidth', function () { expect(coalesceBadge({ logoWidth: 20 }, {}, {}).logoWidth).to.equal(20) }) - it('applies the logo width', function() { + it('applies the logo width', function () { expect( coalesceBadge({}, { namedLogo: 'npm', logoWidth: 275 }, {}).logoWidth ).to.equal(275) }) }) - describe('Logo position', function() { - it('overrides the logoPosition', function() { + describe('Logo position', function () { + it('overrides the logoPosition', function () { expect( coalesceBadge({ logoPosition: -10 }, {}, {}).logoPosition ).to.equal(-10) }) - it('applies the logo position', function() { + it('applies the logo position', function () { expect( coalesceBadge({}, { namedLogo: 'npm', logoPosition: -10 }, {}) .logoPosition @@ -262,8 +262,8 @@ describe('coalesceBadge', function() { }) }) - describe('Links', function() { - it('overrides the links', function() { + describe('Links', function () { + it('overrides the links', function () { expect( coalesceBadge( { link: 'https://circleci.com/gh/badges/daily-tests' }, @@ -277,8 +277,8 @@ describe('coalesceBadge', function() { }) }) - describe('Style', function() { - it('falls back to flat with invalid style', function() { + describe('Style', function () { + it('falls back to flat with invalid style', function () { expect(coalesceBadge({ style: 'pill' }, {}, {}).template).to.equal('flat') expect(coalesceBadge({ style: 7 }, {}, {}).template).to.equal('flat') expect(coalesceBadge({ style: undefined }, {}, {}).template).to.equal( @@ -286,7 +286,7 @@ describe('coalesceBadge', function() { ) }) - it('replaces legacy popout styles', function() { + it('replaces legacy popout styles', function () { expect(coalesceBadge({ style: 'popout' }, {}, {}).template).to.equal( 'flat' ) @@ -296,8 +296,8 @@ describe('coalesceBadge', function() { }) }) - describe('Cache length', function() { - it('overrides the cache length', function() { + describe('Cache length', function () { + it('overrides the cache length', function () { expect( coalesceBadge({ style: 'pill' }, { cacheSeconds: 123 }, {}) .cacheLengthSeconds diff --git a/core/base-service/coalesce.spec.js b/core/base-service/coalesce.spec.js index 180f9e1e6aa1dc9749a75d135a9ae9249ff0a9b9..b83b458caf3e3fd1a99379f4891787af61b2dca5 100644 --- a/core/base-service/coalesce.spec.js +++ b/core/base-service/coalesce.spec.js @@ -7,8 +7,8 @@ const coalesce = require('./coalesce') // `undefined` instead of `null`, though h/t to // https://github.com/royriojas/coalescy for these tests! -describe('coalesce', function() { - test(coalesce, function() { +describe('coalesce', function () { + test(coalesce, function () { given().expect(undefined) given(null, []).expect([]) given(null, [], {}).expect([]) diff --git a/core/base-service/deprecated-service.spec.js b/core/base-service/deprecated-service.spec.js index d448bfde452f4f4074caaa1c3f4f4982bda9237c..3cc321efe32a4356f40dbb4c8a8dd58d0459d7a5 100644 --- a/core/base-service/deprecated-service.spec.js +++ b/core/base-service/deprecated-service.spec.js @@ -3,7 +3,7 @@ const { expect } = require('chai') const deprecatedService = require('./deprecated-service') -describe('DeprecatedService', function() { +describe('DeprecatedService', function () { const route = { base: 'service/that/no/longer/exists', format: '(?:.+)', @@ -12,33 +12,33 @@ describe('DeprecatedService', function() { const dateAdded = new Date() const commonAttrs = { route, category, dateAdded } - it('returns true on isDeprecated', function() { + it('returns true on isDeprecated', function () { const service = deprecatedService({ ...commonAttrs }) expect(service.isDeprecated).to.be.true }) - it('has the expected name', function() { + it('has the expected name', function () { const service = deprecatedService({ ...commonAttrs }) expect(service.name).to.equal('DeprecatedServiceThatNoLongerExists') }) - it('sets specified route', function() { + it('sets specified route', function () { const service = deprecatedService({ ...commonAttrs }) expect(service.route).to.deep.equal(route) }) - it('sets specified label', function() { + it('sets specified label', function () { const label = 'coverity' const service = deprecatedService({ ...commonAttrs, label }) expect(service.defaultBadgeData.label).to.equal(label) }) - it('sets specified category', function() { + it('sets specified category', function () { const service = deprecatedService({ ...commonAttrs }) expect(service.category).to.equal(category) }) - it('sets specified examples', function() { + it('sets specified examples', function () { const examples = [ { title: 'Not sure we would have examples', @@ -48,7 +48,7 @@ describe('DeprecatedService', function() { expect(service.examples).to.deep.equal(examples) }) - it('uses default deprecation message when no message specified', async function() { + it('uses default deprecation message when no message specified', async function () { const service = deprecatedService({ ...commonAttrs }) expect(await service.invoke()).to.deep.equal({ isError: true, @@ -57,7 +57,7 @@ describe('DeprecatedService', function() { }) }) - it('uses custom deprecation message when specified', async function() { + it('uses custom deprecation message when specified', async function () { const message = 'extended outage' const service = deprecatedService({ ...commonAttrs, message }) expect(await service.invoke()).to.deep.equal({ diff --git a/core/base-service/examples.js b/core/base-service/examples.js index 61f121bfbe4e85e9bfc0384e51b2adf5e49b2178..b62fc96760401d9e7361f034f8cf79272dd0e87a 100644 --- a/core/base-service/examples.js +++ b/core/base-service/examples.js @@ -21,19 +21,12 @@ const schema = Joi.object({ staticPreview: Joi.object({ label: Joi.string(), message: Joi.alternatives() - .try( - Joi.string() - .allow('') - .required(), - Joi.number() - ) + .try(Joi.string().allow('').required(), Joi.number()) .required(), color: Joi.string(), style: Joi.string(), }).required(), - keywords: Joi.array() - .items(Joi.string()) - .default([]), + keywords: Joi.array().items(Joi.string()).default([]), documentation: Joi.string(), // Valid HTML. }).required() diff --git a/core/base-service/examples.spec.js b/core/base-service/examples.spec.js index 387fec0456d160005da9d63db3e2d3a69e524a28..3428771bfbc9c54db3068b9f3e4561136f3e570c 100644 --- a/core/base-service/examples.spec.js +++ b/core/base-service/examples.spec.js @@ -4,8 +4,8 @@ const { expect } = require('chai') const { test, given } = require('sazerac') const { validateExample, transformExample } = require('./examples') -describe('validateExample function', function() { - it('passes valid examples', function() { +describe('validateExample function', function () { + it('passes valid examples', function () { const validExamples = [ { title: 'Package manager versioning badge', @@ -23,7 +23,7 @@ describe('validateExample function', function() { }) }) - it('rejects invalid examples', function() { + it('rejects invalid examples', function () { const invalidExamples = [ {}, { staticPreview: { message: '123' } }, @@ -74,7 +74,7 @@ describe('validateExample function', function() { }) }) -test(transformExample, function() { +test(transformExample, function () { const ExampleService = { name: 'ExampleService', route: { diff --git a/core/base-service/graphql.spec.js b/core/base-service/graphql.spec.js index a77e40f85d88efc9250b71755015f083642a289d..52c811d7bcfff1cdb8a143e9eac308f2899a4fe7 100644 --- a/core/base-service/graphql.spec.js +++ b/core/base-service/graphql.spec.js @@ -7,8 +7,8 @@ const { mergeQueries } = require('./graphql') require('../register-chai-plugins.spec') -describe('mergeQueries function', function() { - it('merges valid gql queries', function() { +describe('mergeQueries function', function () { + it('merges valid gql queries', function () { expect( print( mergeQueries( @@ -86,7 +86,7 @@ describe('mergeQueries function', function() { ).to.equalIgnoreSpaces('{ foo bar }') }) - it('throws an error when passed invalid params', function() { + it('throws an error when passed invalid params', function () { expect(() => mergeQueries('', '')).to.throw(Error) expect(() => mergeQueries(undefined, 17, true)).to.throw(Error) expect(() => mergeQueries(gql``, gql`foo`)).to.throw(Error) diff --git a/core/base-service/legacy-request-handler.spec.js b/core/base-service/legacy-request-handler.spec.js index d13614a44b70da666f01c837cf82b064c3135b86..580e7ab93d4ca230e55ceff1cc421507b11530f1 100644 --- a/core/base-service/legacy-request-handler.spec.js +++ b/core/base-service/legacy-request-handler.spec.js @@ -70,19 +70,19 @@ function fakeHandlerWithNetworkIo(queryParams, match, sendBadge, request) { }) } -describe('The request handler', function() { +describe('The request handler', function () { let port, baseUrl - beforeEach(async function() { + beforeEach(async function () { port = await portfinder.getPortPromise() baseUrl = `http://127.0.0.1:${port}` }) let camp - beforeEach(function(done) { + beforeEach(function (done) { camp = Camp.start({ port, hostname: '::' }) camp.on('listening', () => done()) }) - afterEach(function(done) { + afterEach(function (done) { clearRequestCache() if (camp) { camp.close(() => done()) @@ -92,15 +92,15 @@ describe('The request handler', function() { const standardCacheHeaders = { defaultCacheLengthSeconds: 120 } - describe('the options object calling style', function() { - beforeEach(function() { + describe('the options object calling style', function () { + beforeEach(function () { camp.route( /^\/testing\/([^/]+)\.(svg|png|gif|jpg|json)$/, handleRequest(standardCacheHeaders, { handler: fakeHandler }) ) }) - it('should return the expected response', async function() { + it('should return the expected response', async function () { const { statusCode, body } = await got(`${baseUrl}/testing/123.json`, { responseType: 'json', }) @@ -116,15 +116,15 @@ describe('The request handler', function() { }) }) - describe('the function shorthand calling style', function() { - beforeEach(function() { + describe('the function shorthand calling style', function () { + beforeEach(function () { camp.route( /^\/testing\/([^/]+)\.(svg|png|gif|jpg|json)$/, handleRequest(standardCacheHeaders, fakeHandler) ) }) - it('should return the expected response', async function() { + it('should return the expected response', async function () { const { statusCode, body } = await got(`${baseUrl}/testing/123.json`, { responseType: 'json', }) @@ -140,8 +140,8 @@ describe('The request handler', function() { }) }) - describe('the response size limit', function() { - beforeEach(function() { + describe('the response size limit', function () { + beforeEach(function () { camp.route( /^\/testing\/([^/]+)\.(svg|png|gif|jpg|json)$/, handleRequest(standardCacheHeaders, { @@ -151,7 +151,7 @@ describe('The request handler', function() { ) }) - it('should not throw an error if the response <= fetchLimitBytes', async function() { + it('should not throw an error if the response <= fetchLimitBytes', async function () { nock('https://www.google.com') .get('/foo/bar') .once() @@ -170,7 +170,7 @@ describe('The request handler', function() { }) }) - it('should throw an error if the response is > fetchLimitBytes', async function() { + it('should throw an error if the response is > fetchLimitBytes', async function () { nock('https://www.google.com') .get('/foo/bar') .once() @@ -189,15 +189,15 @@ describe('The request handler', function() { }) }) - afterEach(function() { + afterEach(function () { nock.cleanAll() }) }) - describe('caching', function() { - describe('standard query parameters', function() { + describe('caching', function () { + describe('standard query parameters', function () { let handlerCallCount - beforeEach(function() { + beforeEach(function () { handlerCallCount = 0 }) @@ -214,12 +214,12 @@ describe('The request handler', function() { ) } - context('With standard cache settings', function() { - beforeEach(function() { + context('With standard cache settings', function () { + beforeEach(function () { register({ cacheHeaderConfig: standardCacheHeaders }) }) - it('should cache identical requests', async function() { + it('should cache identical requests', async function () { await performTwoRequests( baseUrl, '/testing/123.svg', @@ -228,7 +228,7 @@ describe('The request handler', function() { expect(handlerCallCount).to.equal(1) }) - it('should differentiate known query parameters', async function() { + it('should differentiate known query parameters', async function () { await performTwoRequests( baseUrl, '/testing/123.svg?label=foo', @@ -237,7 +237,7 @@ describe('The request handler', function() { expect(handlerCallCount).to.equal(2) }) - it('should ignore unknown query parameters', async function() { + it('should ignore unknown query parameters', async function () { await performTwoRequests( baseUrl, '/testing/123.svg?foo=1', @@ -247,7 +247,7 @@ describe('The request handler', function() { }) }) - it('should set the expires header to current time + defaultCacheLengthSeconds', async function() { + it('should set the expires header to current time + defaultCacheLengthSeconds', async function () { register({ cacheHeaderConfig: { defaultCacheLengthSeconds: 900 } }) const { headers } = await got(`${baseUrl}/testing/123.json`) const expectedExpiry = new Date( @@ -257,7 +257,7 @@ describe('The request handler', function() { expect(headers['cache-control']).to.equal('max-age=900 s-maxage=900') }) - it('should set the expected cache headers on cached responses', async function() { + it('should set the expected cache headers on cached responses', async function () { register({ cacheHeaderConfig: { defaultCacheLengthSeconds: 900 } }) // Make first request. @@ -271,7 +271,7 @@ describe('The request handler', function() { expect(headers['cache-control']).to.equal('max-age=900 s-maxage=900') }) - it('should let live service data override the default cache headers with longer value', async function() { + it('should let live service data override the default cache headers with longer value', async function () { camp.route( /^\/testing\/([^/]+)\.(svg|png|gif|jpg|json)$/, handleRequest( @@ -292,7 +292,7 @@ describe('The request handler', function() { expect(headers['cache-control']).to.equal('max-age=400 s-maxage=400') }) - it('should not let live service data override the default cache headers with shorter value', async function() { + it('should not let live service data override the default cache headers with shorter value', async function () { camp.route( /^\/testing\/([^/]+)\.(svg|png|gif|jpg|json)$/, handleRequest( @@ -313,7 +313,7 @@ describe('The request handler', function() { expect(headers['cache-control']).to.equal('max-age=300 s-maxage=300') }) - it('should set the expires header to current time + cacheSeconds', async function() { + it('should set the expires header to current time + cacheSeconds', async function () { register({ cacheHeaderConfig: { defaultCacheLengthSeconds: 0 } }) const { headers } = await got( `${baseUrl}/testing/123.json?cacheSeconds=3600` @@ -325,7 +325,7 @@ describe('The request handler', function() { expect(headers['cache-control']).to.equal('max-age=3600 s-maxage=3600') }) - it('should ignore cacheSeconds when shorter than defaultCacheLengthSeconds', async function() { + it('should ignore cacheSeconds when shorter than defaultCacheLengthSeconds', async function () { register({ cacheHeaderConfig: { defaultCacheLengthSeconds: 600 } }) const { headers } = await got( `${baseUrl}/testing/123.json?cacheSeconds=300` @@ -337,7 +337,7 @@ describe('The request handler', function() { expect(headers['cache-control']).to.equal('max-age=600 s-maxage=600') }) - it('should set Cache-Control: no-cache, no-store, must-revalidate if cache seconds is 0', async function() { + it('should set Cache-Control: no-cache, no-store, must-revalidate if cache seconds is 0', async function () { register({ cacheHeaderConfig: { defaultCacheLengthSeconds: 0 } }) const { headers } = await got(`${baseUrl}/testing/123.json`) expect(headers.expires).to.equal(headers.date) @@ -346,25 +346,25 @@ describe('The request handler', function() { ) }) - describe('the cache key', function() { - beforeEach(function() { + describe('the cache key', function () { + beforeEach(function () { register({ cacheHeaderConfig: standardCacheHeaders }) }) const expectedCacheKey = '/testing/123.json?color=123&label=foo' - it('should match expected and use canonical order - 1', async function() { + it('should match expected and use canonical order - 1', async function () { await got(`${baseUrl}/testing/123.json?color=123&label=foo`) expect(_requestCache.cache).to.have.keys(expectedCacheKey) }) - it('should match expected and use canonical order - 2', async function() { + it('should match expected and use canonical order - 2', async function () { await got(`${baseUrl}/testing/123.json?label=foo&color=123`) expect(_requestCache.cache).to.have.keys(expectedCacheKey) }) }) }) - describe('custom query parameters', function() { + describe('custom query parameters', function () { let handlerCallCount - beforeEach(function() { + beforeEach(function () { handlerCallCount = 0 camp.route( /^\/testing\/([^/]+)\.(svg|png|gif|jpg|json)$/, @@ -378,7 +378,7 @@ describe('The request handler', function() { ) }) - it('should differentiate them', async function() { + it('should differentiate them', async function () { await performTwoRequests( baseUrl, '/testing/123.svg?foo=1', diff --git a/core/base-service/loader.spec.js b/core/base-service/loader.spec.js index a8a0443ad164f3059564c65af202141634f60fea..374c17cb004e051a257f885ac2a59a754fbdff3e 100644 --- a/core/base-service/loader.spec.js +++ b/core/base-service/loader.spec.js @@ -3,8 +3,8 @@ const { expect } = require('chai') const { loadServiceClasses, InvalidService } = require('./loader') -describe('loadServiceClasses function', function() { - it('throws if module exports empty', function() { +describe('loadServiceClasses function', function () { + it('throws if module exports empty', function () { expect(() => loadServiceClasses(['./loader-test-fixtures/empty-undefined.fixture.js']) ).to.throw(InvalidService) @@ -26,7 +26,7 @@ describe('loadServiceClasses function', function() { ).to.throw(InvalidService) }) - it('throws if module exports invalid', function() { + it('throws if module exports invalid', function () { expect(() => loadServiceClasses(['./loader-test-fixtures/invalid-no-base.fixture.js']) ).to.throw(InvalidService) @@ -47,7 +47,7 @@ describe('loadServiceClasses function', function() { ).to.throw(InvalidService) }) - it('registers services if module exports valid service classes', function() { + it('registers services if module exports valid service classes', function () { expect( loadServiceClasses([ './loader-test-fixtures/valid-array.fixture.js', diff --git a/core/base-service/lru-cache.js b/core/base-service/lru-cache.js index 3aacf7277dc8d6359c6390f5cb2fd33358a46665..ec15f84c995b991b35c91550605895b495c27697 100644 --- a/core/base-service/lru-cache.js +++ b/core/base-service/lru-cache.js @@ -126,7 +126,7 @@ Cache.prototype = { } }, - clear: function() { + clear: function () { this.cache.clear() this.newest = null this.oldest = null diff --git a/core/base-service/lru-cache.spec.js b/core/base-service/lru-cache.spec.js index 203eb8e156c918af1a1829b653bf49b0131c71fd..c6362bfb0015b9a096fcf75808a3c1b429c49fae 100644 --- a/core/base-service/lru-cache.spec.js +++ b/core/base-service/lru-cache.spec.js @@ -25,14 +25,14 @@ function expectCacheSlots(cache, keys) { } } -describe('The LRU cache', function() { - it('should support a zero capacity', function() { +describe('The LRU cache', function () { + it('should support a zero capacity', function () { const cache = new LRU(0) cache.set('key', 'value') expect(cache.cache.size).to.equal(0) }) - it('should support a one capacity', function() { + it('should support a one capacity', function () { const cache = new LRU(1) cache.set('key1', 'value1') expectCacheSlots(cache, ['key1']) @@ -42,7 +42,7 @@ describe('The LRU cache', function() { expect(cache.get('key2')).to.equal('value2') }) - it('should remove the oldest element when reaching capacity', function() { + it('should remove the oldest element when reaching capacity', function () { const cache = new LRU(2) cache.set('key1', 'value1') @@ -57,7 +57,7 @@ describe('The LRU cache', function() { expect(cache.get('key3')).to.equal('value3') }) - it('should make sure that resetting a key in cache makes it newest', function() { + it('should make sure that resetting a key in cache makes it newest', function () { const cache = new LRU(2) cache.set('key', 'value') @@ -70,9 +70,9 @@ describe('The LRU cache', function() { expectCacheSlots(cache, ['key2', 'key']) }) - describe('getting a key in the cache', function() { - context('when the requested key is oldest', function() { - it('should leave the keys in the expected order', function() { + describe('getting a key in the cache', function () { + context('when the requested key is oldest', function () { + it('should leave the keys in the expected order', function () { const cache = new LRU(2) cache.set('key1', 'value1') cache.set('key2', 'value2') @@ -85,8 +85,8 @@ describe('The LRU cache', function() { }) }) - context('when the requested key is newest', function() { - it('should leave the keys in the expected order', function() { + context('when the requested key is newest', function () { + it('should leave the keys in the expected order', function () { const cache = new LRU(2) cache.set('key1', 'value1') cache.set('key2', 'value2') @@ -97,8 +97,8 @@ describe('The LRU cache', function() { }) }) - context('when the requested key is in the middle', function() { - it('should leave the keys in the expected order', function() { + context('when the requested key is in the middle', function () { + it('should leave the keys in the expected order', function () { const cache = new LRU(3) cache.set('key1', 'value1') cache.set('key2', 'value2') @@ -113,7 +113,7 @@ describe('The LRU cache', function() { }) }) - it('should clear', function() { + it('should clear', function () { // Set up. const cache = new LRU(2) cache.set('key1', 'value1') diff --git a/core/base-service/redirector.spec.js b/core/base-service/redirector.spec.js index 40eeab816af1ab9fd64706964616afc67f655bf9..57402e623251e946accf483fd5a026291d07da4e 100644 --- a/core/base-service/redirector.spec.js +++ b/core/base-service/redirector.spec.js @@ -6,7 +6,7 @@ const { expect } = require('chai') const got = require('../got-test-client') const redirector = require('./redirector') -describe('Redirector', function() { +describe('Redirector', function () { const route = { base: 'very/old/service', pattern: ':namedParamA', @@ -16,15 +16,15 @@ describe('Redirector', function() { const dateAdded = new Date() const attrs = { category, route, transformPath, dateAdded } - it('returns true on isDeprecated', function() { + it('returns true on isDeprecated', function () { expect(redirector(attrs).isDeprecated).to.be.true }) - it('has the expected name', function() { + it('has the expected name', function () { expect(redirector(attrs).name).to.equal('VeryOldServiceRedirect') }) - it('overrides the name', function() { + it('overrides the name', function () { expect( redirector({ ...attrs, @@ -33,33 +33,33 @@ describe('Redirector', function() { ).to.equal('ShinyRedirect') }) - it('sets specified route', function() { + it('sets specified route', function () { expect(redirector(attrs).route).to.deep.equal(route) }) - it('sets specified category', function() { + it('sets specified category', function () { expect(redirector(attrs).category).to.equal(category) }) - it('throws the expected error when dateAdded is missing', function() { + it('throws the expected error when dateAdded is missing', function () { expect(() => redirector({ route, category, transformPath }).validateDefinition() ).to.throw('"dateAdded" is required') }) - describe('ScoutCamp integration', function() { + describe('ScoutCamp integration', function () { let port, baseUrl - beforeEach(async function() { + beforeEach(async function () { port = await portfinder.getPortPromise() baseUrl = `http://127.0.0.1:${port}` }) let camp - beforeEach(async function() { + beforeEach(async function () { camp = Camp.start({ port, hostname: '::' }) await new Promise(resolve => camp.on('listening', () => resolve())) }) - afterEach(async function() { + afterEach(async function () { if (camp) { await new Promise(resolve => camp.close(resolve)) camp = undefined @@ -68,7 +68,7 @@ describe('Redirector', function() { const transformPath = ({ namedParamA }) => `/new/service/${namedParamA}` - beforeEach(function() { + beforeEach(function () { const ServiceClass = redirector({ category, route, @@ -81,7 +81,7 @@ describe('Redirector', function() { ) }) - it('should redirect as configured', async function() { + it('should redirect as configured', async function () { const { statusCode, headers } = await got( `${baseUrl}/very/old/service/hello-world.svg`, { @@ -93,7 +93,7 @@ describe('Redirector', function() { expect(headers.location).to.equal('/new/service/hello-world.svg') }) - it('should redirect raster extensions to the canonical path as configured', async function() { + it('should redirect raster extensions to the canonical path as configured', async function () { const { statusCode, headers } = await got( `${baseUrl}/very/old/service/hello-world.png`, { @@ -107,7 +107,7 @@ describe('Redirector', function() { ) }) - it('should forward the query params', async function() { + it('should forward the query params', async function () { const { statusCode, headers } = await got( `${baseUrl}/very/old/service/hello-world.svg?color=123&style=flat-square`, { @@ -121,14 +121,14 @@ describe('Redirector', function() { ) }) - describe('transformQueryParams', function() { + describe('transformQueryParams', function () { const route = { base: 'another/old/service', pattern: 'token/:token/:namedParamA', } const transformQueryParams = ({ token }) => ({ token }) - beforeEach(function() { + beforeEach(function () { const ServiceClass = redirector({ category, route, @@ -139,7 +139,7 @@ describe('Redirector', function() { ServiceClass.register({ camp }, {}) }) - it('should forward the transformed query params', async function() { + it('should forward the transformed query params', async function () { const { statusCode, headers } = await got( `${baseUrl}/another/old/service/token/abc123/hello-world.svg`, { @@ -153,7 +153,7 @@ describe('Redirector', function() { ) }) - it('should forward the specified and transformed query params', async function() { + it('should forward the specified and transformed query params', async function () { const { statusCode, headers } = await got( `${baseUrl}/another/old/service/token/abc123/hello-world.svg?color=123&style=flat-square`, { @@ -167,7 +167,7 @@ describe('Redirector', function() { ) }) - it('should use transformed query params on param conflicts by default', async function() { + it('should use transformed query params on param conflicts by default', async function () { const { statusCode, headers } = await got( `${baseUrl}/another/old/service/token/abc123/hello-world.svg?color=123&style=flat-square&token=def456`, { @@ -181,7 +181,7 @@ describe('Redirector', function() { ) }) - it('should use specified query params on param conflicts when configured', async function() { + it('should use specified query params on param conflicts when configured', async function () { const route = { base: 'override/service', pattern: 'token/:token/:namedParamA', diff --git a/core/base-service/route.js b/core/base-service/route.js index a785f80dadd544006f9928932e9341a9e285615a..73c45e266febdb4dd552b297b47db70263510117 100644 --- a/core/base-service/route.js +++ b/core/base-service/route.js @@ -9,9 +9,7 @@ function makeFullUrl(base, partialUrl) { } const isValidRoute = Joi.object({ - base: Joi.string() - .allow('') - .required(), + base: Joi.string().allow('').required(), pattern: Joi.string().allow(''), format: Joi.string(), capture: Joi.alternatives().conditional('format', { diff --git a/core/base-service/route.spec.js b/core/base-service/route.spec.js index 113162d9c93fd8241b61f5e5281fee89742e5968..2c199939f7162c2c7ce99e03e0711a1b7b6ead5d 100644 --- a/core/base-service/route.spec.js +++ b/core/base-service/route.spec.js @@ -9,8 +9,8 @@ const { getQueryParamNames, } = require('./route') -describe('Route helpers', function() { - context('A `pattern` with a named param is declared', function() { +describe('Route helpers', function () { + context('A `pattern` with a named param is declared', function () { const { regex, captureNames } = prepareRoute({ base: 'foo', pattern: ':namedParamA', @@ -36,7 +36,7 @@ describe('Route helpers', function() { }) }) - context('A `format` with a named param is declared', function() { + context('A `format` with a named param is declared', function () { const { regex, captureNames } = prepareRoute({ base: 'foo', format: '([^/]+?)', @@ -62,7 +62,7 @@ describe('Route helpers', function() { }) }) - context('No named params are declared', function() { + context('No named params are declared', function () { const { regex, captureNames } = prepareRoute({ base: 'foo', format: '(?:[^/]+)', @@ -78,7 +78,7 @@ describe('Route helpers', function() { }) }) - context('The wrong number of params are declared', function() { + context('The wrong number of params are declared', function () { const { regex, captureNames } = prepareRoute({ base: 'foo', format: '([^/]+)/([^/]+)', @@ -94,7 +94,7 @@ describe('Route helpers', function() { ) }) - it('getQueryParamNames', function() { + it('getQueryParamNames', function () { expect( getQueryParamNames({ queryParamSchema: Joi.object({ foo: Joi.string() }).required(), diff --git a/core/base-service/service-definitions.js b/core/base-service/service-definitions.js index c89f151bc28e24eb89a162123a2fa99ce2ffe1a6..1ad387cc766da3d0d742bc1d1857d042afc5ac59 100644 --- a/core/base-service/service-definitions.js +++ b/core/base-service/service-definitions.js @@ -5,10 +5,7 @@ const Joi = require('@hapi/joi') // This should be kept in sync with the schema in // `frontend/lib/service-definitions/index.ts`. -const arrayOfStrings = Joi.array() - .items(Joi.string()) - .min(0) - .required() +const arrayOfStrings = Joi.array().items(Joi.string()).min(0).required() const objectOfKeyValues = Joi.object() .pattern(/./, Joi.string().allow(null)) @@ -39,9 +36,7 @@ const serviceDefinition = Joi.object({ }).required(), preview: Joi.object({ label: Joi.string(), - message: Joi.string() - .allow('') - .required(), + message: Joi.string().allow('').required(), color: Joi.string().required(), style: Joi.string(), namedLogo: Joi.string(), @@ -70,9 +65,7 @@ const serviceDefinitionExport = Joi.object({ }) ) .required(), - services: Joi.array() - .items(serviceDefinition) - .required(), + services: Joi.array().items(serviceDefinition).required(), }).required() function assertValidServiceDefinitionExport(examples, message = undefined) { diff --git a/core/base-service/validate.spec.js b/core/base-service/validate.spec.js index a7c2280ed586b2849d3407c98cea48ee89fb503c..1cdde0cec76e532982a3e6f10c72023e458830ac 100644 --- a/core/base-service/validate.spec.js +++ b/core/base-service/validate.spec.js @@ -7,19 +7,19 @@ const trace = require('./trace') const { InvalidParameter } = require('./errors') const validate = require('./validate') -describe('validate', function() { +describe('validate', function () { const schema = Joi.object({ requiredString: Joi.string().required(), }).required() let sandbox - beforeEach(function() { + beforeEach(function () { sandbox = sinon.createSandbox() }) - afterEach(function() { + afterEach(function () { sandbox.restore() }) - beforeEach(function() { + beforeEach(function () { sandbox.stub(trace, 'logTrace') }) @@ -35,8 +35,8 @@ describe('validate', function() { traceSuccessMessage, } - context('schema is not provided', function() { - it('throws the expected programmer error', function() { + context('schema is not provided', function () { + it('throws the expected programmer error', function () { try { validate(options, { requiredString: 'bar' }, undefined) expect.fail('Expected to throw') @@ -47,8 +47,8 @@ describe('validate', function() { }) }) - context('data matches schema', function() { - it('logs the data', function() { + context('data matches schema', function () { + it('logs the data', function () { validate(options, { requiredString: 'bar' }, schema) expect(trace.logTrace).to.be.calledWithMatch( 'validate', @@ -60,8 +60,8 @@ describe('validate', function() { }) }) - context('data does not match schema', function() { - it('logs the data and throws the expected error', function() { + context('data does not match schema', function () { + it('logs the data and throws the expected error', function () { try { validate( options, @@ -84,8 +84,8 @@ describe('validate', function() { ) }) - context('with includeKeys: true', function() { - it('includes keys in the error text', function() { + context('with includeKeys: true', function () { + it('includes keys in the error text', function () { try { validate( { ...options, includeKeys: true }, @@ -108,7 +108,7 @@ describe('validate', function() { }) }) - it('allowAndStripUnknownKeys', function() { + it('allowAndStripUnknownKeys', function () { try { validate( { ...options, allowAndStripUnknownKeys: false, includeKeys: true }, diff --git a/core/server/influx-metrics.spec.js b/core/server/influx-metrics.spec.js index fc472b6bc28864c5c76f9287bc06fd20187c1a19..f03f96f2140266bb62fb62fe75aeb3f43ca19372 100644 --- a/core/server/influx-metrics.spec.js +++ b/core/server/influx-metrics.spec.js @@ -6,7 +6,7 @@ const { expect } = require('chai') const log = require('./log') const InfluxMetrics = require('./influx-metrics') require('../register-chai-plugins.spec') -describe('Influx metrics', function() { +describe('Influx metrics', function () { const metricInstance = { metrics() { return [ @@ -20,16 +20,16 @@ describe('Influx metrics', function() { ] }, } - describe('"metrics" function', function() { + describe('"metrics" function', function () { let osHostnameStub - afterEach(function() { + afterEach(function () { nock.enableNetConnect() delete process.env.INSTANCE_ID if (osHostnameStub) { osHostnameStub.restore() } }) - it('should use an environment variable value as an instance label', async function() { + it('should use an environment variable value as an instance label', async function () { process.env.INSTANCE_ID = 'instance3' const influxMetrics = new InfluxMetrics(metricInstance, { instanceIdFrom: 'env-var', @@ -39,7 +39,7 @@ describe('Influx metrics', function() { expect(influxMetrics.metrics()).to.contain('instance=instance3') }) - it('should use a hostname as an instance label', async function() { + it('should use a hostname as an instance label', async function () { osHostnameStub = sinon.stub(os, 'hostname').returns('test-hostname') const customConfig = { instanceIdFrom: 'hostname', @@ -49,7 +49,7 @@ describe('Influx metrics', function() { expect(influxMetrics.metrics()).to.be.contain('instance=test-hostname') }) - it('should use a random string as an instance label', async function() { + it('should use a random string as an instance label', async function () { const customConfig = { instanceIdFrom: 'random', } @@ -58,7 +58,7 @@ describe('Influx metrics', function() { expect(influxMetrics.metrics()).to.be.match(/instance=\w+ /) }) - it('should use a hostname alias as an instance label', async function() { + it('should use a hostname alias as an instance label', async function () { osHostnameStub = sinon.stub(os, 'hostname').returns('test-hostname') const customConfig = { instanceIdFrom: 'hostname', @@ -72,12 +72,12 @@ describe('Influx metrics', function() { }) }) - describe('startPushingMetrics', function() { + describe('startPushingMetrics', function () { let influxMetrics, clock - beforeEach(function() { + beforeEach(function () { clock = sinon.useFakeTimers() }) - afterEach(function() { + afterEach(function () { influxMetrics.stopPushingMetrics() nock.cleanAll() nock.enableNetConnect() @@ -85,7 +85,7 @@ describe('Influx metrics', function() { clock.restore() }) - it('should send metrics', async function() { + it('should send metrics', async function () { const scope = nock('http://shields-metrics.io/', { reqheaders: { 'Content-Type': 'application/x-www-form-urlencoded', @@ -120,11 +120,11 @@ describe('Influx metrics', function() { }) }) - describe('sendMetrics', function() { - beforeEach(function() { + describe('sendMetrics', function () { + beforeEach(function () { sinon.stub(log, 'error') }) - afterEach(function() { + afterEach(function () { log.error.restore() nock.cleanAll() nock.enableNetConnect() @@ -137,7 +137,7 @@ describe('Influx metrics', function() { username: 'metrics-username', password: 'metrics-password', }) - it('should log errors', async function() { + it('should log errors', async function () { nock.disableNetConnect() await influxMetrics.sendMetrics() @@ -154,11 +154,8 @@ describe('Influx metrics', function() { ) }) - it('should log error responses', async function() { - nock('http://shields-metrics.io/') - .persist() - .post('/metrics') - .reply(400) + it('should log error responses', async function () { + nock('http://shields-metrics.io/').persist().post('/metrics').reply(400) await influxMetrics.sendMetrics() diff --git a/core/server/instance-id-generator.js b/core/server/instance-id-generator.js index 0036df2648842f0ab739a91a60687377746bcb11..e156070161ec559e8dd54b8d8e62c52822bdb324 100644 --- a/core/server/instance-id-generator.js +++ b/core/server/instance-id-generator.js @@ -2,9 +2,7 @@ function generateInstanceId() { // from https://gist.github.com/gordonbrander/2230317 - return Math.random() - .toString(36) - .substr(2, 9) + return Math.random().toString(36).substr(2, 9) } module.exports = generateInstanceId diff --git a/core/server/metrics/format-converters.spec.js b/core/server/metrics/format-converters.spec.js index 373c3d9cdab2ba7f99382a4896efb22a9efc9384..eb944f27957a9360cb7b7a44c59aad04a08c4df1 100644 --- a/core/server/metrics/format-converters.spec.js +++ b/core/server/metrics/format-converters.spec.js @@ -4,9 +4,9 @@ const { expect } = require('chai') const prometheus = require('prom-client') const { promClientJsonToInfluxV2 } = require('./format-converters') -describe('Metric format converters', function() { - describe('prom-client JSON to InfluxDB line protocol (version 2)', function() { - it('converts a counter', function() { +describe('Metric format converters', function () { + describe('prom-client JSON to InfluxDB line protocol (version 2)', function () { + it('converts a counter', function () { const json = [ { help: 'counter 1 help', @@ -22,7 +22,7 @@ describe('Metric format converters', function() { expect(influx).to.be.equal('prometheus counter1=11') }) - it('converts a counter (from prometheus registry)', function() { + it('converts a counter (from prometheus registry)', function () { const register = new prometheus.Registry() const counter = new prometheus.Counter({ name: 'counter1', @@ -36,7 +36,7 @@ describe('Metric format converters', function() { expect(influx).to.be.equal('prometheus counter1=11') }) - it('converts a gauge', function() { + it('converts a gauge', function () { const json = [ { help: 'gause 1 help', @@ -52,7 +52,7 @@ describe('Metric format converters', function() { expect(influx).to.be.equal('prometheus gauge1=20') }) - it('converts a gauge (from prometheus registry)', function() { + it('converts a gauge (from prometheus registry)', function () { const register = new prometheus.Registry() const gauge = new prometheus.Gauge({ name: 'gauge1', @@ -66,13 +66,9 @@ describe('Metric format converters', function() { expect(influx).to.be.equal('prometheus gauge1=20') }) - const sortLines = text => - text - .split('\n') - .sort() - .join('\n') + const sortLines = text => text.split('\n').sort().join('\n') - it('converts a histogram', function() { + it('converts a histogram', function () { const json = [ { name: 'histogram1', @@ -105,7 +101,7 @@ prometheus histogram1_count=3,histogram1_sum=111`) ) }) - it('converts a histogram (from prometheus registry)', function() { + it('converts a histogram (from prometheus registry)', function () { const register = new prometheus.Registry() const histogram = new prometheus.Histogram({ name: 'histogram1', @@ -128,7 +124,7 @@ prometheus histogram1_count=3,histogram1_sum=111`) ) }) - it('converts a summary', function() { + it('converts a summary', function () { const json = [ { name: 'summary1', @@ -155,7 +151,7 @@ prometheus summary1_count=3,summary1_sum=111`) ) }) - it('converts a summary (from prometheus registry)', function() { + it('converts a summary (from prometheus registry)', function () { const register = new prometheus.Registry() const summary = new prometheus.Summary({ name: 'summary1', @@ -177,7 +173,7 @@ prometheus summary1_count=3,summary1_sum=111`) ) }) - it('converts a counter and skip a timestamp', function() { + it('converts a counter and skip a timestamp', function () { const json = [ { help: 'counter 4 help', @@ -193,7 +189,7 @@ prometheus summary1_count=3,summary1_sum=111`) expect(influx).to.be.equal('prometheus counter4=11') }) - it('converts a counter and adds extra labels', function() { + it('converts a counter and adds extra labels', function () { const json = [ { help: 'counter 1 help', diff --git a/core/server/monitor.js b/core/server/monitor.js index 96ef183af760d3533d7ad76ef9b9aca2354bc795..209dc6d42a35a9155d86549ac6adac0dd788ed7d 100644 --- a/core/server/monitor.js +++ b/core/server/monitor.js @@ -39,10 +39,7 @@ function setRoutes({ rateLimit }, { server, metricInstance }) { const ip = (req.headers['x-forwarded-for'] || '').split(', ')[0] || req.socket.remoteAddress - const badgeType = req.url - .split(/[/-]/) - .slice(0, 3) - .join('') + const badgeType = req.url.split(/[/-]/).slice(0, 3).join('') const referer = req.headers.referer if (ipRateLimit.isBanned(ip, req, res)) { @@ -91,7 +88,7 @@ function setRoutes({ rateLimit }, { server, metricInstance }) { }) }) - return function() { + return function () { ipRateLimit.stop() badgeTypeRateLimit.stop() refererRateLimit.stop() diff --git a/core/server/prometheus-metrics.spec.js b/core/server/prometheus-metrics.spec.js index 49660334df167c458258ab6e66875a88ee04acf5..22cffbaef78f8bb91b72ada694d1379fd6bfc6b6 100644 --- a/core/server/prometheus-metrics.spec.js +++ b/core/server/prometheus-metrics.spec.js @@ -6,15 +6,15 @@ const portfinder = require('portfinder') const got = require('../got-test-client') const Metrics = require('./prometheus-metrics') -describe('Prometheus metrics route', function() { +describe('Prometheus metrics route', function () { let port, baseUrl, camp, metrics - beforeEach(async function() { + beforeEach(async function () { port = await portfinder.getPortPromise() baseUrl = `http://127.0.0.1:${port}` camp = Camp.start({ port, hostname: '::' }) await new Promise(resolve => camp.on('listening', () => resolve())) }) - afterEach(async function() { + afterEach(async function () { if (metrics) { metrics.stop() } @@ -24,7 +24,7 @@ describe('Prometheus metrics route', function() { } }) - it('returns default metrics', async function() { + it('returns default metrics', async function () { metrics = new Metrics() metrics.registerMetricsEndpoint(camp) diff --git a/core/server/server.js b/core/server/server.js index 6d51f10e7921b88a8b4800b076f3fc64dd22e02f..adc9c7546578d5d6cc63c43b7d9e9a9bc6f25982 100644 --- a/core/server/server.js +++ b/core/server/server.js @@ -71,12 +71,8 @@ const publicConfigSchema = Joi.object({ Joi.string().pattern(/^\\\\\.\\pipe\\.+$/) ), address: Joi.alternatives().try( - Joi.string() - .ip() - .required(), - Joi.string() - .hostname() - .required() + Joi.string().ip().required(), + Joi.string().hostname().required() ), }, metrics: { @@ -119,9 +115,7 @@ const publicConfigSchema = Joi.object({ redirectUrl: optionalUrl, rasterUrl: optionalUrl, cors: { - allowedOrigin: Joi.array() - .items(optionalUrl) - .required(), + allowedOrigin: Joi.array().items(optionalUrl).required(), }, persistence: { dir: Joi.string().required(), @@ -133,10 +127,7 @@ const publicConfigSchema = Joi.object({ baseUri: requiredUrl, debug: { enabled: Joi.boolean().required(), - intervalSeconds: Joi.number() - .integer() - .min(1) - .required(), + intervalSeconds: Joi.number().integer().min(1).required(), }, }, jira: defaultService, @@ -152,9 +143,7 @@ const publicConfigSchema = Joi.object({ trace: Joi.boolean().required(), }).required(), cacheHeaders: { - defaultCacheLengthSeconds: Joi.number() - .integer() - .required(), + defaultCacheLengthSeconds: Joi.number().integer().required(), }, rateLimit: Joi.boolean().required(), handleInternalErrors: Joi.boolean().required(), diff --git a/core/server/server.spec.js b/core/server/server.spec.js index c2482b5d4177964c70c0c4ace705932f2c1f9aa1..faa4a4e09790488aaa0a72ef7f735439eb471ee4 100644 --- a/core/server/server.spec.js +++ b/core/server/server.spec.js @@ -7,24 +7,24 @@ const got = require('../got-test-client') const Server = require('./server') const { createTestServer } = require('./in-process-server-test-helpers') -describe('The server', function() { - describe('running', function() { +describe('The server', function () { + describe('running', function () { let server, baseUrl - before('Start the server', async function() { + before('Start the server', async function () { // Fixes https://github.com/badges/shields/issues/2611 this.timeout(10000) server = await createTestServer() baseUrl = server.baseUrl await server.start() }) - after('Shut down the server', async function() { + after('Shut down the server', async function () { if (server) { await server.stop() } server = undefined }) - it('should allow strings for port', async function() { + it('should allow strings for port', async function () { // fixes #4391 - This allows the app to be run using iisnode, which uses a named pipe for the port. const pipeServer = await createTestServer({ public: { @@ -36,7 +36,7 @@ describe('The server', function() { expect(pipeServer).to.not.be.undefined }) - it('should produce colorscheme badges', async function() { + it('should produce colorscheme badges', async function () { const { statusCode, body } = await got(`${baseUrl}:fruit-apple-green.svg`) expect(statusCode).to.equal(200) expect(body) @@ -45,7 +45,7 @@ describe('The server', function() { .and.to.include('apple') }) - it('should redirect colorscheme PNG badges as configured', async function() { + it('should redirect colorscheme PNG badges as configured', async function () { const { statusCode, headers } = await got( `${baseUrl}:fruit-apple-green.png`, { @@ -58,7 +58,7 @@ describe('The server', function() { ) }) - it('should redirect modern PNG badges as configured', async function() { + it('should redirect modern PNG badges as configured', async function () { const { statusCode, headers } = await got(`${baseUrl}npm/v/express.png`, { followRedirect: false, }) @@ -68,7 +68,7 @@ describe('The server', function() { ) }) - it('should produce json badges', async function() { + it('should produce json badges', async function () { const { statusCode, body, headers } = await got( `${baseUrl}twitter/follow/_Pyves.json` ) @@ -77,16 +77,14 @@ describe('The server', function() { expect(() => JSON.parse(body)).not.to.throw() }) - it('should preserve label case', async function() { + it('should preserve label case', async function () { const { statusCode, body } = await got(`${baseUrl}:fRuiT-apple-green.svg`) expect(statusCode).to.equal(200) - expect(body) - .to.satisfy(isSvg) - .and.to.include('fRuiT') + expect(body).to.satisfy(isSvg).and.to.include('fRuiT') }) // https://github.com/badges/shields/pull/1319 - it('should not crash with a numeric logo', async function() { + it('should not crash with a numeric logo', async function () { const { statusCode, body } = await got( `${baseUrl}:fruit-apple-green.svg?logo=1` ) @@ -97,7 +95,7 @@ describe('The server', function() { .and.to.include('apple') }) - it('should not crash with a numeric link', async function() { + it('should not crash with a numeric link', async function () { const { statusCode, body } = await got( `${baseUrl}:fruit-apple-green.svg?link=1` ) @@ -108,7 +106,7 @@ describe('The server', function() { .and.to.include('apple') }) - it('should not crash with a boolean link', async function() { + it('should not crash with a boolean link', async function () { const { statusCode, body } = await got( `${baseUrl}:fruit-apple-green.svg?link=true` ) @@ -119,7 +117,7 @@ describe('The server', function() { .and.to.include('apple') }) - it('should return the 404 badge for unknown badges', async function() { + it('should return the 404 badge for unknown badges', async function () { const { statusCode, body } = await got( `${baseUrl}this/is/not/a/badge.svg`, { @@ -133,7 +131,7 @@ describe('The server', function() { .and.to.include('badge not found') }) - it('should return the 404 badge page for rando links', async function() { + it('should return the 404 badge page for rando links', async function () { const { statusCode, body } = await got( `${baseUrl}this/is/most/definitely/not/a/badge.js`, { @@ -147,7 +145,7 @@ describe('The server', function() { .and.to.include('badge not found') }) - it('should redirect the root as configured', async function() { + it('should redirect the root as configured', async function () { const { statusCode, headers } = await got(baseUrl, { followRedirect: false, }) @@ -157,7 +155,7 @@ describe('The server', function() { expect(headers.location).to.equal('http://frontend.example.test') }) - it('should return the 410 badge for obsolete formats', async function() { + it('should return the 410 badge for obsolete formats', async function () { const { statusCode, body } = await got(`${baseUrl}npm/v/express.jpg`, { throwHttpErrors: false, }) @@ -170,15 +168,15 @@ describe('The server', function() { }) }) - describe('configuration', function() { + describe('configuration', function () { let server - afterEach(async function() { + afterEach(async function () { if (server) { server.stop() } }) - it('should allow to enable prometheus metrics', async function() { + it('should allow to enable prometheus metrics', async function () { // Fixes https://github.com/badges/shields/issues/2611 this.timeout(10000) server = await createTestServer({ @@ -193,7 +191,7 @@ describe('The server', function() { expect(statusCode).to.be.equal(200) }) - it('should allow to disable prometheus metrics', async function() { + it('should allow to disable prometheus metrics', async function () { // Fixes https://github.com/badges/shields/issues/2611 this.timeout(10000) server = await createTestServer({ @@ -211,10 +209,10 @@ describe('The server', function() { }) }) - describe('configuration validation', function() { - describe('influx', function() { + describe('configuration validation', function () { + describe('influx', function () { let customConfig - beforeEach(function() { + beforeEach(function () { customConfig = config.util.toObject() customConfig.public.metrics.influx = { enabled: true, @@ -232,46 +230,46 @@ describe('The server', function() { } }) - it('should not require influx configuration', function() { + it('should not require influx configuration', function () { delete customConfig.public.metrics.influx expect(() => new Server(config.util.toObject())).to.not.throw() }) - it('should require url when influx configuration is enabled', function() { + it('should require url when influx configuration is enabled', function () { delete customConfig.public.metrics.influx.url expect(() => new Server(customConfig)).to.throw( '"metrics.influx.url" is required' ) }) - it('should not require url when influx configuration is disabled', function() { + it('should not require url when influx configuration is disabled', function () { customConfig.public.metrics.influx.enabled = false delete customConfig.public.metrics.influx.url expect(() => new Server(customConfig)).to.not.throw() }) - it('should require timeoutMilliseconds when influx configuration is enabled', function() { + it('should require timeoutMilliseconds when influx configuration is enabled', function () { delete customConfig.public.metrics.influx.timeoutMilliseconds expect(() => new Server(customConfig)).to.throw( '"metrics.influx.timeoutMilliseconds" is required' ) }) - it('should require intervalSeconds when influx configuration is enabled', function() { + it('should require intervalSeconds when influx configuration is enabled', function () { delete customConfig.public.metrics.influx.intervalSeconds expect(() => new Server(customConfig)).to.throw( '"metrics.influx.intervalSeconds" is required' ) }) - it('should require instanceIdFrom when influx configuration is enabled', function() { + it('should require instanceIdFrom when influx configuration is enabled', function () { delete customConfig.public.metrics.influx.instanceIdFrom expect(() => new Server(customConfig)).to.throw( '"metrics.influx.instanceIdFrom" is required' ) }) - it('should require instanceIdEnvVarName when instanceIdFrom is env-var', function() { + it('should require instanceIdEnvVarName when instanceIdFrom is env-var', function () { customConfig.public.metrics.influx.instanceIdFrom = 'env-var' delete customConfig.public.metrics.influx.instanceIdEnvVarName expect(() => new Server(customConfig)).to.throw( @@ -279,53 +277,53 @@ describe('The server', function() { ) }) - it('should allow instanceIdFrom = hostname', function() { + it('should allow instanceIdFrom = hostname', function () { customConfig.public.metrics.influx.instanceIdFrom = 'hostname' expect(() => new Server(customConfig)).to.not.throw() }) - it('should allow instanceIdFrom = env-var', function() { + it('should allow instanceIdFrom = env-var', function () { customConfig.public.metrics.influx.instanceIdFrom = 'env-var' expect(() => new Server(customConfig)).to.not.throw() }) - it('should allow instanceIdFrom = random', function() { + it('should allow instanceIdFrom = random', function () { customConfig.public.metrics.influx.instanceIdFrom = 'random' expect(() => new Server(customConfig)).to.not.throw() }) - it('should require envLabel when influx configuration is enabled', function() { + it('should require envLabel when influx configuration is enabled', function () { delete customConfig.public.metrics.influx.envLabel expect(() => new Server(customConfig)).to.throw( '"metrics.influx.envLabel" is required' ) }) - it('should not require hostnameAliases', function() { + it('should not require hostnameAliases', function () { delete customConfig.public.metrics.influx.hostnameAliases expect(() => new Server(customConfig)).to.not.throw() }) - it('should allow empty hostnameAliases', function() { + it('should allow empty hostnameAliases', function () { customConfig.public.metrics.influx.hostnameAliases = {} expect(() => new Server(customConfig)).to.not.throw() }) - it('should require username when influx configuration is enabled', function() { + it('should require username when influx configuration is enabled', function () { delete customConfig.private.influx_username expect(() => new Server(customConfig)).to.throw( 'Private configuration is invalid. Check these paths: influx_username' ) }) - it('should require password when influx configuration is enabled', function() { + it('should require password when influx configuration is enabled', function () { delete customConfig.private.influx_password expect(() => new Server(customConfig)).to.throw( 'Private configuration is invalid. Check these paths: influx_password' ) }) - it('should allow other private keys', function() { + it('should allow other private keys', function () { customConfig.private.gh_token = 'my-token' expect(() => new Server(customConfig)).to.not.throw() }) diff --git a/core/service-test-runner/cli.js b/core/service-test-runner/cli.js index 822dff9f88b7145420d8b222dd4bb7d0b660494c..d63be95a0d3559e1e2439f13c156dea537037b51 100644 --- a/core/service-test-runner/cli.js +++ b/core/service-test-runner/cli.js @@ -73,7 +73,7 @@ if (process.env.TESTED_SERVER_URL) { } else { const port = 1111 baseUrl = 'http://localhost:1111' - before('Start running the server', async function() { + before('Start running the server', async function () { server = await createTestServer({ public: { bind: { @@ -83,7 +83,7 @@ if (process.env.TESTED_SERVER_URL) { }) server.start() }) - after('Shut down the server', async function() { + after('Shut down the server', async function () { if (server) { await server.stop() } diff --git a/core/service-test-runner/infer-pull-request.spec.js b/core/service-test-runner/infer-pull-request.spec.js index e3f46d3255593fb0568c562fddff6254cb85ae91..610c258eebb6e8a56754c128682a5b805352e9a8 100644 --- a/core/service-test-runner/infer-pull-request.spec.js +++ b/core/service-test-runner/infer-pull-request.spec.js @@ -6,7 +6,7 @@ const { inferPullRequest, } = require('./infer-pull-request') -describe('Pull request inference', function() { +describe('Pull request inference', function () { test(parseGithubPullRequestUrl, () => { forCases([ given('https://github.com/badges/shields/pull/1234'), diff --git a/core/service-test-runner/service-tester.js b/core/service-test-runner/service-tester.js index 8bc23ba517e9ad736870b29b97d8e61ec62c76aa..a6ab4ec0bc06e48fa1e8a3d87dc1e5b4746d3622 100644 --- a/core/service-test-runner/service-tester.js +++ b/core/service-test-runner/service-tester.js @@ -85,7 +85,7 @@ class ServiceTester { this.beforeEach() }) // eslint-disable-next-line mocha/prefer-arrow-callback - .finally(function() { + .finally(function () { // `this` is the IcedFrisby instance. let responseBody try { @@ -125,7 +125,7 @@ class ServiceTester { const fn = this._only ? describe.only : describe // eslint-disable-next-line mocha/prefer-arrow-callback - fn(this.title, function() { + fn(this.title, function () { specs.forEach(spec => { spec._message = `[${spec.hasIntercept ? 'mocked' : 'live'}] ${ spec._message diff --git a/core/service-test-runner/services-for-title.spec.js b/core/service-test-runner/services-for-title.spec.js index ca2960235ee58fdd2e00118942a2eb9e083cb1a7..40d216d8968a4f67b3ae669afa6b7a9a11b9653d 100644 --- a/core/service-test-runner/services-for-title.spec.js +++ b/core/service-test-runner/services-for-title.spec.js @@ -3,7 +3,7 @@ const { test, given } = require('sazerac') const servicesForTitle = require('./services-for-title') -describe('Services from PR title', function() { +describe('Services from PR title', function () { test(servicesForTitle, () => { given('[Travis] Fix timeout issues').expect(['travis']) given('[Travis Sonar] Support user token authentication').expect([ diff --git a/core/token-pooling/fs-token-persistence.spec.js b/core/token-pooling/fs-token-persistence.spec.js index fbed1cb31525d3a5f9e091ea1fd861278b6610b3..4624538c9ed2346111517351a6fb7153ec4e6a06 100644 --- a/core/token-pooling/fs-token-persistence.spec.js +++ b/core/token-pooling/fs-token-persistence.spec.js @@ -6,20 +6,20 @@ const readFile = require('fs-readfile-promise') const { expect } = require('chai') const FsTokenPersistence = require('./fs-token-persistence') -describe('File system token persistence', function() { +describe('File system token persistence', function () { let path, persistence - beforeEach(function() { + beforeEach(function () { path = tmp.tmpNameSync() persistence = new FsTokenPersistence({ path }) }) - context('when the file does not exist', function() { - it('does nothing', async function() { + context('when the file does not exist', function () { + it('does nothing', async function () { const tokens = await persistence.initialize() expect(tokens).to.deep.equal([]) }) - it('saving creates an empty file', async function() { + it('saving creates an empty file', async function () { await persistence.initialize() await persistence.save() @@ -29,20 +29,20 @@ describe('File system token persistence', function() { }) }) - context('when the file exists', function() { + context('when the file exists', function () { const initialTokens = ['a', 'b', 'c'].map(char => char.repeat(40)) - beforeEach(async function() { + beforeEach(async function () { fs.writeFileSync(path, JSON.stringify(initialTokens)) }) - it('loads the contents', async function() { + it('loads the contents', async function () { const tokens = await persistence.initialize() expect(tokens).to.deep.equal(initialTokens) }) - context('when tokens are added', function() { - it('saves the change', async function() { + context('when tokens are added', function () { + it('saves the change', async function () { const newToken = 'e'.repeat(40) const expected = Array.from(initialTokens) expected.push(newToken) @@ -55,8 +55,8 @@ describe('File system token persistence', function() { }) }) - context('when tokens are removed', function() { - it('saves the change', async function() { + context('when tokens are removed', function () { + it('saves the change', async function () { const expected = Array.from(initialTokens) const toRemove = expected.pop() diff --git a/core/token-pooling/redis-token-persistence.integration.js b/core/token-pooling/redis-token-persistence.integration.js index 363ef27086998a61dfc3068d1b2c714b2704396b..a852e28515a14ebab63de7ccdcac8d4c7f553dc5 100644 --- a/core/token-pooling/redis-token-persistence.integration.js +++ b/core/token-pooling/redis-token-persistence.integration.js @@ -5,11 +5,11 @@ const Redis = require('ioredis') const { expect } = require('chai') const RedisTokenPersistence = require('./redis-token-persistence') -describe('Redis token persistence', function() { +describe('Redis token persistence', function () { let server // In CI, expect redis already to be running. if (!process.env.CI) { - beforeEach(async function() { + beforeEach(async function () { server = new RedisServer({ config: { host: 'localhost' } }) await server.open() }) @@ -18,11 +18,11 @@ describe('Redis token persistence', function() { const key = 'tokenPersistenceIntegrationTest' let redis - beforeEach(async function() { + beforeEach(async function () { redis = new Redis() await redis.del(key) }) - afterEach(async function() { + afterEach(async function () { if (redis) { await redis.quit() redis = undefined @@ -30,44 +30,44 @@ describe('Redis token persistence', function() { }) if (!process.env.CI) { - afterEach(async function() { + afterEach(async function () { await server.close() server = undefined }) } let persistence - beforeEach(function() { + beforeEach(function () { persistence = new RedisTokenPersistence({ key }) }) - afterEach(async function() { + afterEach(async function () { if (persistence) { await persistence.stop() persistence = undefined } }) - context('when the key does not exist', function() { - it('does nothing', async function() { + context('when the key does not exist', function () { + it('does nothing', async function () { const tokens = await persistence.initialize() expect(tokens).to.deep.equal([]) }) }) - context('when the key exists', function() { + context('when the key exists', function () { const initialTokens = ['a', 'b', 'c'].map(char => char.repeat(40)) - beforeEach(async function() { + beforeEach(async function () { await redis.sadd(key, initialTokens) }) - it('loads the contents', async function() { + it('loads the contents', async function () { const tokens = await persistence.initialize() expect(tokens.sort()).to.deep.equal(initialTokens) }) - context('when tokens are added', function() { - it('saves the change', async function() { + context('when tokens are added', function () { + it('saves the change', async function () { const newToken = 'e'.repeat(40) const expected = initialTokens.slice() expected.push(newToken) @@ -80,8 +80,8 @@ describe('Redis token persistence', function() { }) }) - context('when tokens are removed', function() { - it('saves the change', async function() { + context('when tokens are removed', function () { + it('saves the change', async function () { const expected = Array.from(initialTokens) const toRemove = expected.pop() diff --git a/core/token-pooling/token-pool.js b/core/token-pooling/token-pool.js index 5061c8dbf6c168ebcb009870cfdcbec5cff619f3..54e4cfb8a951bf1870adb33c438056cc11ed850e 100644 --- a/core/token-pooling/token-pool.js +++ b/core/token-pooling/token-pool.js @@ -13,10 +13,7 @@ const PriorityQueue = require('priorityqueuejs') * @returns {string} hash */ function sanitizeToken(id) { - return crypto - .createHash('sha256') - .update(id, 'utf-8') - .digest('hex') + return crypto.createHash('sha256').update(id, 'utf-8').digest('hex') } function getUtcEpochSeconds() { diff --git a/core/token-pooling/token-pool.spec.js b/core/token-pooling/token-pool.spec.js index 1c62f2707f321c9d287777a10c457e8eb2eeb878..8780b17e6f74e039a1b1119aaaa56bbdb9d98489 100644 --- a/core/token-pooling/token-pool.spec.js +++ b/core/token-pooling/token-pool.spec.js @@ -11,27 +11,27 @@ function expectPoolToBeExhausted(pool) { }).to.throw(Error, /^Token pool is exhausted$/) } -describe('The token pool', function() { +describe('The token pool', function () { const ids = ['1', '2', '3', '4', '5'] const batchSize = 3 let tokenPool - beforeEach(function() { + beforeEach(function () { tokenPool = new TokenPool({ batchSize }) ids.forEach(id => tokenPool.add(id)) }) - it('allValidTokenIds() should return the full list', function() { + it('allValidTokenIds() should return the full list', function () { expect(tokenPool.allValidTokenIds()).to.deep.equal(ids) }) - it('should yield the expected tokens', function() { + it('should yield the expected tokens', function () { ids.forEach(id => times(batchSize, () => expect(tokenPool.next().id).to.equal(id)) ) }) - it('should repeat when reaching the end', function() { + it('should repeat when reaching the end', function () { ids.forEach(id => times(batchSize, () => expect(tokenPool.next().id).to.equal(id)) ) @@ -40,17 +40,17 @@ describe('The token pool', function() { ) }) - describe('serializeDebugInfo should initially return the expected', function() { - beforeEach(function() { + describe('serializeDebugInfo should initially return the expected', function () { + beforeEach(function () { sinon.useFakeTimers({ now: 1544307744484 }) }) - afterEach(function() { + afterEach(function () { sinon.restore() }) - context('sanitize is not specified', function() { - it('returns fully sanitized results', function() { + context('sanitize is not specified', function () { + it('returns fully sanitized results', function () { // This is `sha()` of '1', '2', '3', '4', '5'. These are written // literally for avoidance of doubt as to whether sanitization is // happening. @@ -79,8 +79,8 @@ describe('The token pool', function() { }) }) - context('with sanitize: false', function() { - it('returns unsanitized results', function() { + context('with sanitize: false', function () { + it('returns unsanitized results', function () { expect(tokenPool.serializeDebugInfo({ sanitize: false })).to.deep.equal( { allValidTokenIds: ids, @@ -101,8 +101,8 @@ describe('The token pool', function() { }) }) - context('tokens are marked exhausted immediately', function() { - it('should be exhausted', function() { + context('tokens are marked exhausted immediately', function () { + it('should be exhausted', function () { ids.forEach(() => { const token = tokenPool.next() token.update(0, Token.nextResetNever) @@ -112,8 +112,8 @@ describe('The token pool', function() { }) }) - context('tokens are marked after the last request', function() { - it('should be exhausted', function() { + context('tokens are marked after the last request', function () { + it('should be exhausted', function () { ids.forEach(() => { const token = times(batchSize, () => tokenPool.next()).pop() token.update(0, Token.nextResetNever) @@ -123,8 +123,8 @@ describe('The token pool', function() { }) }) - context('tokens are renewed', function() { - it('should keep using them', function() { + context('tokens are renewed', function () { + it('should keep using them', function () { const tokensToRenew = ['2', '4'] const renewalCount = 3 @@ -149,16 +149,16 @@ describe('The token pool', function() { }) }) - context('tokens reset', function() { + context('tokens reset', function () { let clock - beforeEach(function() { + beforeEach(function () { clock = sinon.useFakeTimers() }) - afterEach(function() { + afterEach(function () { clock.restore() }) - it('should start using them', function() { + it('should start using them', function () { const tokensToReset = ['2', '4'] const futureTime = 1440 @@ -183,8 +183,8 @@ describe('The token pool', function() { }) }) - context('when empty', function() { - it('next() should return the expected error', function() { + context('when empty', function () { + it('next() should return the expected error', function () { const tokenPool = new TokenPool() expect(() => tokenPool.next()).to.throw('Token pool is exhausted') }) diff --git a/cypress/integration/main-page.spec.js b/cypress/integration/main-page.spec.js index c75c0763a0a695f8d28e40999c9897bc5dd04327..874d056adba42af7368c6660091307d00fa76872 100644 --- a/cypress/integration/main-page.spec.js +++ b/cypress/integration/main-page.spec.js @@ -1,19 +1,17 @@ 'use strict' -describe('Main page', function() { +describe('Main page', function () { const backendUrl = Cypress.env('backend_url') const SEARCH_INPUT = 'input[placeholder="search / project URL"]' function expectBadgeExample(title, previewUrl, pattern) { - cy.contains('tr', `${title}:`) - .find('code') - .should('have.text', pattern) + cy.contains('tr', `${title}:`).find('code').should('have.text', pattern) cy.contains('tr', `${title}:`) .find('img') .should('have.attr', 'src', previewUrl) } - it('Search for badges', function() { + it('Search for badges', function () { cy.visit('/') cy.get(SEARCH_INPUT).type('pypi') @@ -21,7 +19,7 @@ describe('Main page', function() { cy.contains('PyPI - License') }) - it('Shows badge from category', function() { + it('Shows badge from category', function () { cy.visit('/category/chat') expectBadgeExample( @@ -31,7 +29,7 @@ describe('Main page', function() { ) }) - it('Suggest badges', function() { + it('Suggest badges', function () { const badgeUrl = `${backendUrl}/github/issues/badges/shields` cy.visit('/') @@ -41,7 +39,7 @@ describe('Main page', function() { expectBadgeExample('GitHub issues', badgeUrl, badgeUrl) }) - it('Customization form is filled with suggested badge details', function() { + it('Customization form is filled with suggested badge details', function () { const badgeUrl = `${backendUrl}/github/issues/badges/shields` cy.visit('/') cy.get(SEARCH_INPUT).type('https://github.com/badges/shields') @@ -53,7 +51,7 @@ describe('Main page', function() { cy.get('input[name="repo"]').should('have.value', 'shields') }) - it('Customizate suggested badge', function() { + it('Customizate suggested badge', function () { const badgeUrl = `${backendUrl}/github/issues/badges/shields` cy.visit('/') cy.get(SEARCH_INPUT).type('https://github.com/badges/shields') diff --git a/doc/rewriting-services.md b/doc/rewriting-services.md index 217af55515ff7bc9b61a70bb5f2aff6cf08c33f0..174e02bb6ec31daa106a8ee8a93388018c2a07d2 100644 --- a/doc/rewriting-services.md +++ b/doc/rewriting-services.md @@ -24,7 +24,7 @@ module.exports = class ExampleService extends LegacyService { static registerLegacyRouteHandler({ camp, cache }) { camp.route( /^\/example\/([^\/]+)\/([^\/]+)\.(svg|png|gif|jpg|json)$/, - cache(function(data, match, sendBadge, request) { + cache(function (data, match, sendBadge, request) { var first = match[1] var second = match[2] var format = match[3] diff --git a/entrypoint.spec.js b/entrypoint.spec.js index 73b7362b73fb5e68bdb6bef5543dba17b893f112..8395df6231420beb4f85bb539aa779d0f18ecf92 100644 --- a/entrypoint.spec.js +++ b/entrypoint.spec.js @@ -5,7 +5,7 @@ const isSvg = require('is-svg') const got = require('./core/got-test-client') let server -before(function() { +before(function () { this.timeout('5s') // remove args comming from mocha // https://github.com/badges/shields/issues/3365 @@ -13,17 +13,14 @@ before(function() { server = require('./server') }) -after('shut down the server', async function() { +after('shut down the server', async function () { await server.stop() }) -it('should render a badge', async function() { +it('should render a badge', async function () { const { statusCode, body } = await got( 'http://localhost:1111/badge/fruit-apple-green.svg' ) expect(statusCode).to.equal(200) - expect(body) - .to.satisfy(isSvg) - .and.to.include('fruit') - .and.to.include('apple') + expect(body).to.satisfy(isSvg).and.to.include('fruit').and.to.include('apple') }) diff --git a/frontend/lib/pattern-helpers.spec.ts b/frontend/lib/pattern-helpers.spec.ts index f5a376f2768f21204392defdd430b1cc2846a8af..8ca20d022f4a61a8bb6be2bc8c5ea402f4ee92fd 100644 --- a/frontend/lib/pattern-helpers.spec.ts +++ b/frontend/lib/pattern-helpers.spec.ts @@ -1,7 +1,7 @@ import { test, given } from 'sazerac' import { patternToOptions, removeRegexpFromPattern } from './pattern-helpers' -describe('Badge URL functions', function() { +describe('Badge URL functions', function () { test(patternToOptions, () => { given('[^\\/]+?').expect(undefined) given('abc|[^\\/]+').expect(undefined) diff --git a/frontend/lib/service-definitions/index.spec.ts b/frontend/lib/service-definitions/index.spec.ts index 5581caef40dfb686ece555d9da2dc1d83a8f1af4..83bb682b11c6fa6f874ffffd0e743cbdaf064004 100644 --- a/frontend/lib/service-definitions/index.spec.ts +++ b/frontend/lib/service-definitions/index.spec.ts @@ -2,13 +2,13 @@ import { expect } from 'chai' import { test, given } from 'sazerac' import { findCategory, getDefinitionsForCategory } from '.' -describe('Service definition helpers', function() { +describe('Service definition helpers', function () { test(findCategory, () => { given('build').expect({ id: 'build', name: 'Build', keywords: ['build'] }) given('foo').expect(undefined) }) - it('getDefinitionsForCategory', function() { + it('getDefinitionsForCategory', function () { expect(getDefinitionsForCategory('build')) .to.have.length.greaterThan(10) .and.lessThan(75) diff --git a/frontend/lib/service-definitions/service-definition-set-helper.spec.ts b/frontend/lib/service-definitions/service-definition-set-helper.spec.ts index d6ade05506feec4bedd06c5f95147b656930f513..7f2d85d7adbc0bc49f04af53f32b5a2881273604 100644 --- a/frontend/lib/service-definitions/service-definition-set-helper.spec.ts +++ b/frontend/lib/service-definitions/service-definition-set-helper.spec.ts @@ -2,7 +2,7 @@ import { test, given, forCases } from 'sazerac' import { predicateFromQuery } from './service-definition-set-helper' import { Example } from '.' -describe('Badge example functions', function() { +describe('Badge example functions', function () { function exampleMatchesQuery( { examples }: { examples: Example[] }, query: string diff --git a/lib/load-simple-icons.spec.js b/lib/load-simple-icons.spec.js index 985d198eb5a321a1abd10a3d6cc8fa653e26c66c..8529a5add2e5c438a327a2c7eb300b60532c11f3 100644 --- a/lib/load-simple-icons.spec.js +++ b/lib/load-simple-icons.spec.js @@ -3,13 +3,13 @@ const { expect } = require('chai') const loadSimpleIcons = require('./load-simple-icons') -describe('loadSimpleIcons', function() { +describe('loadSimpleIcons', function () { let simpleIcons - before(function() { + before(function () { simpleIcons = loadSimpleIcons() }) - it('prepares three color themes', function() { + it('prepares three color themes', function () { expect(simpleIcons.sentry.base64).to.have.all.keys( 'default', 'light', @@ -17,13 +17,13 @@ describe('loadSimpleIcons', function() { ) }) - it('normalizes icon keys', function() { + it('normalizes icon keys', function () { // original key in the simple-icons is 'Linux Foundation' expect(simpleIcons).to.include.key('linux-foundation') }) // https://github.com/badges/shields/issues/4016 - it('excludes "get" function provided by the simple-icons', function() { + it('excludes "get" function provided by the simple-icons', function () { expect(simpleIcons).to.not.have.property('get') }) }) diff --git a/lib/logos.spec.js b/lib/logos.spec.js index f0c7bac535859094d77b2e0d2a01e64744380c98..847f8ff13286d9b5a7be2b61afbfdf92028ea33d 100644 --- a/lib/logos.spec.js +++ b/lib/logos.spec.js @@ -9,7 +9,7 @@ const { makeLogo, } = require('./logos') -describe('Logo helpers', function() { +describe('Logo helpers', function () { test(prependPrefix, () => { given('data:image/svg+xml;base64,PHN2ZyB4bWxu', 'data:').expect( 'data:image/svg+xml;base64,PHN2ZyB4bWxu' @@ -46,7 +46,7 @@ describe('Logo helpers', function() { 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1NCA1NCIgZmlsbD0iIzAwN2VjNiI+PHBhdGggZD0iTTI1IDNhMSAxIDAgMCAwLTEgMXY3YTEgMSAwIDAgMCAxIDFoNXYzSDZhMyAzIDAgMCAwLTMgM3YxMkgxYTEgMSAwIDAgMC0xIDF2MTBhMSAxIDAgMCAwIDEgMWgydjZhMyAzIDAgMCAwIDMgM2g0MmEzIDMgMCAwIDAgMy0zdi02aDJhMSAxIDAgMCAwIDEtMVYzMWExIDEgMCAwIDAtMS0xaC0yVjE4YTMgMyAwIDAgMC0zLTNIMzNWNGExIDEgMCAwIDAtMS0xaC03em0tMy45ODIgMjZhMS4yMSAxLjIxIDAgMCAxIC44MzcuMzU1bDEuMjkgMS4yOWExLjIxIDEuMjEgMCAwIDEgMCAxLjcwOSAxLjIxIDEuMjEgMCAwIDEgMCAuMDAxbC02LjI5MSA2LjI5YTEuMjEgMS4yMSAwIDAgMS0xLjcxIDBsLTMuNzktMy43OTFhMS4yMSAxLjIxIDAgMCAxIDAtMS43MWwxLjI5LTEuMjlhMS4yMSAxLjIxIDAgMCAxIDEuNzEgMEwxNiAzMy41bDQuMTQ1LTQuMTQ1YTEuMjEgMS4yMSAwIDAgMSAuODczLS4zNTV6bTE5Ljk2MiAwYTEuMjEgMS4yMSAwIDAgMSAuODc0LjM1NGwxLjI5IDEuMjlhMS4yMSAxLjIxIDAgMCAxIDAgMS43MWwtNi4yOSA2LjI4OXYuMDAyYTEuMjEgMS4yMSAwIDAgMS0xLjcxMSAwbC0zLjc5LTMuNzlhMS4yMSAxLjIxIDAgMCAxIDAtMS43MWwxLjI5LTEuMjlhMS4yMSAxLjIxIDAgMCAxIDEuNzEgMGwxLjY0NSAxLjY0NSA0LjE0Ny00LjE0NkExLjIxIDEuMjEgMCAwIDEgNDAuOTggMjl6Ii8+PC9zdmc+' ) - it('preserves color if light logo on dark background', function() { + it('preserves color if light logo on dark background', function () { const logo = prepareNamedLogo({ name: 'javascript' }) const decodedLogo = Buffer.from( logo.replace('data:image/svg+xml;base64,', ''), @@ -54,7 +54,7 @@ describe('Logo helpers', function() { ).toString('ascii') expect(decodedLogo).to.contain('fill="#F7DF1E"') }) - it('recolors logo if light logo on light background', function() { + it('recolors logo if light logo on light background', function () { const logo = prepareNamedLogo({ name: 'javascript', style: 'social' }) const decodedLogo = Buffer.from( logo.replace('data:image/svg+xml;base64,', ''), @@ -63,7 +63,7 @@ describe('Logo helpers', function() { expect(decodedLogo).to.contain('fill="#333"') }) - it('preserves color if dark logo on light background', function() { + it('preserves color if dark logo on light background', function () { const logo = prepareNamedLogo({ name: 'nuget', style: 'social' }) const decodedLogo = Buffer.from( logo.replace('data:image/svg+xml;base64,', ''), @@ -71,7 +71,7 @@ describe('Logo helpers', function() { ).toString('ascii') expect(decodedLogo).to.contain('fill="#004880"') }) - it('recolors logo if dark logo on dark background', function() { + it('recolors logo if dark logo on dark background', function () { const logo = prepareNamedLogo({ name: 'nuget' }) const decodedLogo = Buffer.from( logo.replace('data:image/svg+xml;base64,', ''), @@ -80,7 +80,7 @@ describe('Logo helpers', function() { expect(decodedLogo).to.contain('fill="whitesmoke"') }) - it('preserves color if medium logo on dark background', function() { + it('preserves color if medium logo on dark background', function () { const logo = prepareNamedLogo({ name: 'skype' }) const decodedLogo = Buffer.from( logo.replace('data:image/svg+xml;base64,', ''), @@ -88,7 +88,7 @@ describe('Logo helpers', function() { ).toString('ascii') expect(decodedLogo).to.contain('fill="#00AFF0"') }) - it('preserves color if medium logo on light background', function() { + it('preserves color if medium logo on light background', function () { const logo = prepareNamedLogo({ name: 'skype', style: 'social' }) const decodedLogo = Buffer.from( logo.replace('data:image/svg+xml;base64,', ''), diff --git a/lib/svg-helpers.spec.js b/lib/svg-helpers.spec.js index 517794bc474f6485538f54fbba449fdd824a5381..c36fe39ffe7b47326dc0b2b646190f5c3f5c519f 100644 --- a/lib/svg-helpers.spec.js +++ b/lib/svg-helpers.spec.js @@ -3,7 +3,7 @@ const { test, given } = require('sazerac') const { svg2base64 } = require('./svg-helpers') -describe('SVG helpers', function() { +describe('SVG helpers', function () { test(svg2base64, () => { given('<svg xmlns="http://www.w3.org/2000/svg"/>').expect( 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciLz4=' diff --git a/package-lock.json b/package-lock.json index b0791a3aa287b8a210b114e7a4fa69eca2bafb60..d784c6617781270bbc35378b0f3f6106a9dae469 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25218,9 +25218,9 @@ "dev": true }, "prettier": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", - "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.5.tgz", + "integrity": "sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==", "dev": true }, "pretty-bytes": { diff --git a/package.json b/package.json index 4ec516ebafba6ca1af930167b61aea7d5931c3b0..ee67101010d35a82c0e01ca753d65e1ece125e3f 100644 --- a/package.json +++ b/package.json @@ -226,7 +226,7 @@ "nyc": "^15.0.1", "opn-cli": "^5.0.0", "portfinder": "^1.0.26", - "prettier": "1.19.1", + "prettier": "2.0.5", "react": "^16.13.1", "react-dom": "^16.13.1", "react-error-overlay": "^3.0.0", diff --git a/services/amo/amo-version.tester.js b/services/amo/amo-version.tester.js index 23dac4cb9aee8120ef010873e3f6d0d9cdd56ab3..9f63c1b0b0e6496b84061651b0e06fbe4292f153 100644 --- a/services/amo/amo-version.tester.js +++ b/services/amo/amo-version.tester.js @@ -3,12 +3,10 @@ const { isVPlusDottedVersionAtLeastOne } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('Version') - .get('/IndieGala-Helper.json') - .expectBadge({ - label: 'mozilla add-on', - message: isVPlusDottedVersionAtLeastOne, - }) +t.create('Version').get('/IndieGala-Helper.json').expectBadge({ + label: 'mozilla add-on', + message: isVPlusDottedVersionAtLeastOne, +}) t.create('Version (not found)') .get('/not-a-real-plugin.json') diff --git a/services/ansible/ansible-quality.service.js b/services/ansible/ansible-quality.service.js index 3590e03f6a2c521bc6de7dd00a9430c4b814d4ea..46b4130d7937fcfdce53e1eb04e15b9919f14383 100644 --- a/services/ansible/ansible-quality.service.js +++ b/services/ansible/ansible-quality.service.js @@ -5,9 +5,7 @@ const { floorCount } = require('../color-formatters') const { BaseJsonService, InvalidResponse } = require('..') const ansibleContentSchema = Joi.object({ - quality_score: Joi.number() - .allow(null) - .required(), + quality_score: Joi.number().allow(null).required(), }).required() class AnsibleGalaxyContent extends BaseJsonService { diff --git a/services/apm/apm.tester.js b/services/apm/apm.tester.js index de046039a906be494cecc8501da18d0d09f80164..c7553a491e750a145dc24d6ef44f466c7d516283 100644 --- a/services/apm/apm.tester.js +++ b/services/apm/apm.tester.js @@ -54,8 +54,6 @@ t.create('Invalid License') t.create('Unexpected response') .get('/dm/vim-mode.json') .intercept(nock => - nock('https://atom.io') - .get('/api/packages/vim-mode') - .reply(invalidJSON) + nock('https://atom.io').get('/api/packages/vim-mode').reply(invalidJSON) ) .expectBadge({ label: 'downloads', message: 'unparseable json response' }) diff --git a/services/appveyor/appveyor-base.js b/services/appveyor/appveyor-base.js index e97d3a38a5be4fb5ea3aede2066d360cfcb28e20..8d4b794d8c189d29e8ea46dd506da81b2912eb72 100644 --- a/services/appveyor/appveyor-base.js +++ b/services/appveyor/appveyor-base.js @@ -10,9 +10,7 @@ const schema = Joi.object({ status: isBuildStatus, jobs: Joi.array() .items({ - name: Joi.string() - .allow('') - .required(), + name: Joi.string().allow('').required(), status: isBuildStatus, testsCount: nonNegativeInteger, passedTestsCount: nonNegativeInteger, diff --git a/services/appveyor/appveyor-job-build.spec.js b/services/appveyor/appveyor-job-build.spec.js index 6422549aec48a235265d5f738858edf55ebaca52..5d539a72cd3403c053d3a486d6c77ff32a0a34e5 100644 --- a/services/appveyor/appveyor-job-build.spec.js +++ b/services/appveyor/appveyor-job-build.spec.js @@ -5,7 +5,7 @@ const { test, given } = require('sazerac') const { NotFound } = require('..') const AppveyorJobBuild = require('./appveyor-job-build.service') -describe('AppveyorJobBuild', function() { +describe('AppveyorJobBuild', function () { test(AppveyorJobBuild.prototype.transform, () => { given({ data: {} }).expect({ status: 'no builds found', @@ -31,13 +31,13 @@ describe('AppveyorJobBuild', function() { }) }) - it('throws NotFound when response is missing jobs', function() { + it('throws NotFound when response is missing jobs', function () { expect(() => AppveyorJobBuild.prototype.transform({ data: { build: {} } })) .to.throw(NotFound) .with.property('prettyMessage', 'no jobs found') }) - it('throws NotFound when specified job missing jobs', function() { + it('throws NotFound when specified job missing jobs', function () { expect(() => AppveyorJobBuild.prototype.transform({ jobName: 'mac', diff --git a/services/aur/aur.service.js b/services/aur/aur.service.js index e9bb63cab4579fc5251d02f445b388b7d1ea7a20..d5976149bdd4d753b87a80c82bc3fd6eb295f538 100644 --- a/services/aur/aur.service.js +++ b/services/aur/aur.service.js @@ -12,19 +12,13 @@ const { InvalidResponse } = require('..') const aurSchema = Joi.object({ resultcount: nonNegativeInteger, results: Joi.alternatives( - Joi.array() - .length(0) - .required(), + Joi.array().length(0).required(), Joi.object({ - License: Joi.string() - .required() - .allow(null), + License: Joi.string().required().allow(null), NumVotes: nonNegativeInteger, Version: Joi.string().required(), OutOfDate: nonNegativeInteger.allow(null), - Maintainer: Joi.string() - .required() - .allow(null), + Maintainer: Joi.string().required().allow(null), LastModified: nonNegativeInteger, }).required() ), diff --git a/services/aur/aur.tester.js b/services/aur/aur.tester.js index f725d64b133f97cffbb0879d9f17d5c9cd2d9524..d3c9ca0f766624936bbb96c11978c3478cd3c0d9 100644 --- a/services/aur/aur.tester.js +++ b/services/aur/aur.tester.js @@ -36,12 +36,10 @@ t.create('version (not found)') // votes tests -t.create('votes (valid)') - .get('/votes/google-chrome.json') - .expectBadge({ - label: 'votes', - message: isMetric, - }) +t.create('votes (valid)').get('/votes/google-chrome.json').expectBadge({ + label: 'votes', + message: isMetric, +}) t.create('votes (not found)') .get('/votes/not-a-package.json') diff --git a/services/azure-devops/azure-devops-build.tester.js b/services/azure-devops/azure-devops-build.tester.js index 6df777c07395ba5ab849bda96887209b732cff09..871d2a89b4d5d011248a5e73a6aa05c3d3c0b66a 100644 --- a/services/azure-devops/azure-devops-build.tester.js +++ b/services/azure-devops/azure-devops-build.tester.js @@ -6,19 +6,15 @@ const t = (module.exports = require('../tester').createServiceTester()) // https://dev.azure.com/totodem/Shields.io is a public Azure DevOps project // solely created for Shields.io testing. -t.create('default branch') - .get('/totodem/shields.io/2.json') - .expectBadge({ - label: 'build', - message: isBuildStatus, - }) - -t.create('named branch') - .get('/totodem/shields.io/2/master.json') - .expectBadge({ - label: 'build', - message: isBuildStatus, - }) +t.create('default branch').get('/totodem/shields.io/2.json').expectBadge({ + label: 'build', + message: isBuildStatus, +}) + +t.create('named branch').get('/totodem/shields.io/2/master.json').expectBadge({ + label: 'build', + message: isBuildStatus, +}) t.create('stage badge') .get('/totodem/Shields.io/5.json?stage=Successful%20Stage') diff --git a/services/azure-devops/azure-devops-coverage.tester.js b/services/azure-devops/azure-devops-coverage.tester.js index 859ac35c4d7a998fbfa8ca6712c42c2d9fb978c7..0644e1e39f1e8366897dec28bcffbff772d487f2 100644 --- a/services/azure-devops/azure-devops-coverage.tester.js +++ b/services/azure-devops/azure-devops-coverage.tester.js @@ -74,9 +74,7 @@ t.create('unknown build definition') t.create('404 latest build error response') .get(mockBadgeUriPath) .intercept(nock => - nock(azureDevOpsApiBaseUri) - .get(mockLatestBuildApiUriPath) - .reply(404) + nock(azureDevOpsApiBaseUri).get(mockLatestBuildApiUriPath).reply(404) ) .expectBadge({ label: 'coverage', diff --git a/services/azure-devops/azure-devops-release.tester.js b/services/azure-devops/azure-devops-release.tester.js index 4a6cb5cda623946f32619f954d3aa87ab4d2954a..c161bd618b83431fbd187f032f85286e59c66432 100644 --- a/services/azure-devops/azure-devops-release.tester.js +++ b/services/azure-devops/azure-devops-release.tester.js @@ -38,9 +38,7 @@ t.create('unknown project') .get('/totodem/515/515/515.json') .expectBadge({ label: 'deployment', message: 'project not found' }) -t.create('unknown user') - .get('/this-repo/does-not-exist/1/2.json') - .expectBadge({ - label: 'deployment', - message: 'user or environment not found', - }) +t.create('unknown user').get('/this-repo/does-not-exist/1/2.json').expectBadge({ + label: 'deployment', + message: 'user or environment not found', +}) diff --git a/services/azure-devops/azure-devops-tests.tester.js b/services/azure-devops/azure-devops-tests.tester.js index 5db7e4f236777901c210dde666066afb96ac0ac9..495e681a1d8b70f42c053cafd3d83aeb3b097d6e 100644 --- a/services/azure-devops/azure-devops-tests.tester.js +++ b/services/azure-devops/azure-devops-tests.tester.js @@ -121,9 +121,7 @@ t.create('unknown build definition') t.create('404 latest build error response') .get(mockBadgeUri) .intercept(nock => - nock(azureDevOpsApiBaseUri) - .get(mockLatestBuildApiUriPath) - .reply(404) + nock(azureDevOpsApiBaseUri).get(mockLatestBuildApiUriPath).reply(404) ) .expectBadge({ label: 'tests', @@ -133,12 +131,10 @@ t.create('404 latest build error response') t.create('no build response') .get(`${uriPrefix}/${nonExistentDefinitionId}.json`) .intercept(nock => - nock(azureDevOpsApiBaseUri) - .get(mockNonExistentBuildApiUriPath) - .reply(200, { - count: 0, - value: [], - }) + nock(azureDevOpsApiBaseUri).get(mockNonExistentBuildApiUriPath).reply(200, { + count: 0, + value: [], + }) ) .expectBadge({ label: 'tests', message: 'build pipeline not found' }) diff --git a/services/beerpay/beerpay.service.js b/services/beerpay/beerpay.service.js index 9e9619a09f4e374f705094b8f8eda0a0654e8049..bc0d70f27282d00ed2bc525cb206c21e797e39b0 100644 --- a/services/beerpay/beerpay.service.js +++ b/services/beerpay/beerpay.service.js @@ -4,9 +4,7 @@ const Joi = require('@hapi/joi') const { BaseJsonService } = require('..') const schema = Joi.object({ - total_amount: Joi.number() - .min(0) - .required(), + total_amount: Joi.number().min(0).required(), }).required() module.exports = class Beerpay extends BaseJsonService { diff --git a/services/beerpay/beerpay.tester.js b/services/beerpay/beerpay.tester.js index c9cf089de3d5cbcc81de105262119dcfebe806d6..e52ec83c5a7bcbc3dc53b97db3ddcf5cfdb3e365 100644 --- a/services/beerpay/beerpay.tester.js +++ b/services/beerpay/beerpay.tester.js @@ -5,12 +5,10 @@ const t = (module.exports = require('../tester').createServiceTester()) const amountOfMoney = withRegex(/^\$[0-9]+(\.[0-9]+)?/) -t.create('funding') - .get('/hashdog/scrapfy-chrome-extension.json') - .expectBadge({ - label: 'beerpay', - message: amountOfMoney, - }) +t.create('funding').get('/hashdog/scrapfy-chrome-extension.json').expectBadge({ + label: 'beerpay', + message: amountOfMoney, +}) t.create('funding (unknown project)') .get('/hashdog/not-a-real-project.json') diff --git a/services/bintray/bintray.spec.js b/services/bintray/bintray.spec.js index 2bb79cd71a84fea8b503d6fcf5d59492fefcff9d..5109f39d431ebc6e103bbadbb89b69413a8b7b0e 100644 --- a/services/bintray/bintray.spec.js +++ b/services/bintray/bintray.spec.js @@ -5,8 +5,8 @@ const nock = require('nock') const { cleanUpNockAfterEach, defaultContext } = require('../test-helpers') const Bintray = require('./bintray.service') -describe('Bintray', function() { - describe('auth', function() { +describe('Bintray', function () { + describe('auth', function () { cleanUpNockAfterEach() const user = 'admin' @@ -18,7 +18,7 @@ describe('Bintray', function() { }, } - it('sends the auth information as configured', async function() { + it('sends the auth information as configured', async function () { const scope = nock('https://bintray.com') .get('/api/v1/packages/asciidoctor/maven/asciidoctorj/versions/_latest') // This ensures that the expected credentials are actually being sent with the HTTP request. diff --git a/services/bintray/bintray.tester.js b/services/bintray/bintray.tester.js index e019a5f29d76b36717a04a8bdade9f12a09280be..a8efe740cc7c941e6aa27b8374bde6c629763792 100644 --- a/services/bintray/bintray.tester.js +++ b/services/bintray/bintray.tester.js @@ -5,12 +5,10 @@ const { } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('version') - .get('/asciidoctor/maven/asciidoctorj.json') - .expectBadge({ - label: 'bintray', - message: isVPlusDottedVersionNClausesWithOptionalSuffix, - }) +t.create('version').get('/asciidoctor/maven/asciidoctorj.json').expectBadge({ + label: 'bintray', + message: isVPlusDottedVersionNClausesWithOptionalSuffix, +}) t.create('version (not found)') .get('/asciidoctor/maven/not-a-real-package.json') diff --git a/services/bit/bit-components.tester.js b/services/bit/bit-components.tester.js index 7fc943384038c4dd2ad995ed3e940402767aff47..9a51426dd12cbdc3218c91b12c084eae5064cc22 100644 --- a/services/bit/bit-components.tester.js +++ b/services/bit/bit-components.tester.js @@ -3,12 +3,10 @@ const t = (module.exports = require('../tester').createServiceTester()) const { isMetric } = require('../test-validators') -t.create('collection (valid)') - .get('/ramda/ramda.json') - .expectBadge({ - label: 'components', - message: isMetric, - }) +t.create('collection (valid)').get('/ramda/ramda.json').expectBadge({ + label: 'components', + message: isMetric, +}) t.create('collection (valid)') .get('/bit/no-collection-test.json') diff --git a/services/bitbucket/bitbucket-pull-request.spec.js b/services/bitbucket/bitbucket-pull-request.spec.js index fce1ed1546b0ff38473a47e01d50a74428678c23..39aefaea118af0f11cc70679bb00712904e15f44 100644 --- a/services/bitbucket/bitbucket-pull-request.spec.js +++ b/services/bitbucket/bitbucket-pull-request.spec.js @@ -5,13 +5,13 @@ const nock = require('nock') const { cleanUpNockAfterEach, defaultContext } = require('../test-helpers') const [BitbucketPullRequest] = require('./bitbucket-pull-request.service') -describe('BitbucketPullRequest', function() { +describe('BitbucketPullRequest', function () { cleanUpNockAfterEach() const user = 'admin' const pass = 'password' - it('Sends auth headers to Bitbucket as configured', async function() { + it('Sends auth headers to Bitbucket as configured', async function () { const scope = nock('https://bitbucket.org/api/2.0/repositories/') .get(/.*/) .basicAuth({ user, pass }) @@ -40,7 +40,7 @@ describe('BitbucketPullRequest', function() { scope.done() }) - it('Sends auth headers to Bitbucket Server as configured', async function() { + it('Sends auth headers to Bitbucket Server as configured', async function () { const scope = nock('https://bitbucket.example.test/rest/api/1.0/projects') .get(/.*/) .basicAuth({ user, pass }) diff --git a/services/bitbucket/bitbucket-pull-request.tester.js b/services/bitbucket/bitbucket-pull-request.tester.js index fe00a95dab5f6fdd14062966b560c74dd32e881e..9e9f48ba85f3c295cde67f77af529ee8e49a99b4 100644 --- a/services/bitbucket/bitbucket-pull-request.tester.js +++ b/services/bitbucket/bitbucket-pull-request.tester.js @@ -24,12 +24,10 @@ t.create('pr-raw (private repo)') .get('/pr-raw/chris48s/example-private-repo.json') .expectBadge({ label: 'pull requests', message: 'private repo' }) -t.create('pr (valid)') - .get('/pr/atlassian/python-bitbucket.json') - .expectBadge({ - label: 'pull requests', - message: isMetricOpenIssues, - }) +t.create('pr (valid)').get('/pr/atlassian/python-bitbucket.json').expectBadge({ + label: 'pull requests', + message: isMetricOpenIssues, +}) t.create('pr (not found)') .get('/pr/atlassian/not-a-repo.json') diff --git a/services/bower/bower-version.tester.js b/services/bower/bower-version.tester.js index 258c61d0fb356240d24e16068fa912994dd25815..2e5ff2736d086267b83ada63f39b49e1c1ca8954 100644 --- a/services/bower/bower-version.tester.js +++ b/services/bower/bower-version.tester.js @@ -13,13 +13,10 @@ const isBowerPrereleaseVersion = Joi.string().regex( /^v\d+(\.\d+)?(\.\d+)?(-?[.\w\d])+?$/ ) -t.create('version') - .timeout(10000) - .get('/v/bootstrap.json') - .expectBadge({ - label: 'bower', - message: isVPlusDottedVersionAtLeastOne, - }) +t.create('version').timeout(10000).get('/v/bootstrap.json').expectBadge({ + label: 'bower', + message: isVPlusDottedVersionAtLeastOne, +}) t.create('pre version') // e.g. bower|v0.2.5-alpha-rc-pre .timeout(10000) diff --git a/services/bstats/bstats-players.tester.js b/services/bstats/bstats-players.tester.js index e7d6d1995b782886cb5fb9227f8fdae946b827a9..c4d7a7064e028b3ea6d75c71502d18db631d85d1 100644 --- a/services/bstats/bstats-players.tester.js +++ b/services/bstats/bstats-players.tester.js @@ -3,9 +3,7 @@ const { isMetric } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('Players') - .get('/1.json') - .expectBadge({ - label: 'players', - message: isMetric, - }) +t.create('Players').get('/1.json').expectBadge({ + label: 'players', + message: isMetric, +}) diff --git a/services/bstats/bstats-servers.tester.js b/services/bstats/bstats-servers.tester.js index b4be985b68502acfb238d8e4e24dbd21cd3a0a59..8fee06bcc6af294619532cd3740c41a235586417 100644 --- a/services/bstats/bstats-servers.tester.js +++ b/services/bstats/bstats-servers.tester.js @@ -3,9 +3,7 @@ const { isMetric } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('Servers') - .get('/1.json') - .expectBadge({ - label: 'servers', - message: isMetric, - }) +t.create('Servers').get('/1.json').expectBadge({ + label: 'servers', + message: isMetric, +}) diff --git a/services/bugzilla/bugzilla.service.js b/services/bugzilla/bugzilla.service.js index b7473c213832033815fe958d5fced28d6ab440e0..0b373c13695103384e8ddec3e2585e5da8eb4ead 100644 --- a/services/bugzilla/bugzilla.service.js +++ b/services/bugzilla/bugzilla.service.js @@ -13,9 +13,7 @@ const schema = Joi.object({ .items( Joi.object({ status: Joi.string().required(), - resolution: Joi.string() - .allow('') - .required(), + resolution: Joi.string().allow('').required(), }).required() ) .min(1) diff --git a/services/bugzilla/bugzilla.spec.js b/services/bugzilla/bugzilla.spec.js index 89453c32ae5f0a5fcadc78338b8748552b0c5c0b..64b50f94316bedbaa58daab9b7d58ebf1edc970c 100644 --- a/services/bugzilla/bugzilla.spec.js +++ b/services/bugzilla/bugzilla.spec.js @@ -3,8 +3,8 @@ const { test, given } = require('sazerac') const Bugzilla = require('./bugzilla.service') -describe('getDisplayStatus function', function() { - it('formats status correctly', async function() { +describe('getDisplayStatus function', function () { + it('formats status correctly', async function () { test(Bugzilla.getDisplayStatus, () => { given({ status: 'RESOLVED', resolution: 'WORKSFORME' }).expect( 'works for me' diff --git a/services/bugzilla/bugzilla.tester.js b/services/bugzilla/bugzilla.tester.js index de79edcd6821b7fa9ba17ff502dc4bc1dcc0143a..bcd666028e22c5fdcf3f86834256799347534fcc 100644 --- a/services/bugzilla/bugzilla.tester.js +++ b/services/bugzilla/bugzilla.tester.js @@ -15,12 +15,10 @@ const bzBugStatus = Joi.equal( 'incomplete' ) -t.create('Bugzilla valid bug status') - .get('/996038.json') - .expectBadge({ - label: 'bug 996038', - message: bzBugStatus, - }) +t.create('Bugzilla valid bug status').get('/996038.json').expectBadge({ + label: 'bug 996038', + message: bzBugStatus, +}) t.create('Bugzilla valid bug status with custom baseUrl') .get('/545424.json?baseUrl=https://bugs.eclipse.org/bugs') diff --git a/services/cdnjs/cdnjs.tester.js b/services/cdnjs/cdnjs.tester.js index 394384d065e8d939ac488bbf1161102ef5f820ce..6f7a3139d24ce7a08569378b44e46d539f329247 100644 --- a/services/cdnjs/cdnjs.tester.js +++ b/services/cdnjs/cdnjs.tester.js @@ -3,12 +3,10 @@ const { isVPlusTripleDottedVersion } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('cdnjs (valid)') - .get('/jquery.json') - .expectBadge({ - label: 'cdnjs', - message: isVPlusTripleDottedVersion, - }) +t.create('cdnjs (valid)').get('/jquery.json').expectBadge({ + label: 'cdnjs', + message: isVPlusTripleDottedVersion, +}) t.create('cdnjs (not found)') .get('/not-a-library.json') diff --git a/services/check-services.spec.js b/services/check-services.spec.js index 233b35a5daec749e909339adf0406596687d232f..a564c340a3e50838ffdf10650c4fce5e59fbaecc 100644 --- a/services/check-services.spec.js +++ b/services/check-services.spec.js @@ -8,11 +8,11 @@ const { // When these tests fail, they will throw AssertionErrors. Wrapping them in an // `expect().not.to.throw()` makes the error output unreadable. -it('Services have unique names', function() { +it('Services have unique names', function () { this.timeout(30000) checkNames() }) -it('Can collect the service definitions', function() { +it('Can collect the service definitions', function () { collectDefinitions() }) diff --git a/services/chocolatey/chocolatey.tester.js b/services/chocolatey/chocolatey.tester.js index 45eb272dfa41afb4264d56ba90efbb162e42175d..f7ac3e99100856c15f03aff8716e2038876a0a3e 100644 --- a/services/chocolatey/chocolatey.tester.js +++ b/services/chocolatey/chocolatey.tester.js @@ -14,12 +14,10 @@ const t = (module.exports = new ServiceTester({ // downloads -t.create('total downloads (valid)') - .get('/dt/scriptcs.json') - .expectBadge({ - label: 'downloads', - message: isMetric, - }) +t.create('total downloads (valid)').get('/dt/scriptcs.json').expectBadge({ + label: 'downloads', + message: isMetric, +}) t.create('total downloads (not found)') .get('/dt/not-a-real-package.json') @@ -27,12 +25,10 @@ t.create('total downloads (not found)') // version -t.create('version (valid)') - .get('/v/scriptcs.json') - .expectBadge({ - label: 'chocolatey', - message: isVPlusDottedVersionNClauses, - }) +t.create('version (valid)').get('/v/scriptcs.json').expectBadge({ + label: 'chocolatey', + message: isVPlusDottedVersionNClauses, +}) t.create('version (not found)') .get('/v/not-a-real-package.json') diff --git a/services/chrome-web-store/chrome-web-store-version.tester.js b/services/chrome-web-store/chrome-web-store-version.tester.js index 39208bcc0a1a1a301a20a347bb90103cc90bcaf4..09d49442d4059adf5d5b1609e19d1b26ee2de8cf 100644 --- a/services/chrome-web-store/chrome-web-store-version.tester.js +++ b/services/chrome-web-store/chrome-web-store-version.tester.js @@ -3,12 +3,10 @@ const { isVPlusDottedVersionAtLeastOne } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('Version') - .get('/alhjnofcnnpeaphgeakdhkebafjcpeae.json') - .expectBadge({ - label: 'chrome web store', - message: isVPlusDottedVersionAtLeastOne, - }) +t.create('Version').get('/alhjnofcnnpeaphgeakdhkebafjcpeae.json').expectBadge({ + label: 'chrome web store', + message: isVPlusDottedVersionAtLeastOne, +}) t.create('Version (not found)') .get('/invalid-name-of-addon.json') diff --git a/services/clojars/clojars-downloads.tester.js b/services/clojars/clojars-downloads.tester.js index 8331f433bcdf5ec940d174152e22a2bf10e44b81..94ec0aad260b4299b0feb85287643cfe6553b46a 100644 --- a/services/clojars/clojars-downloads.tester.js +++ b/services/clojars/clojars-downloads.tester.js @@ -3,12 +3,10 @@ const { isMetric } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('clojars downloads (valid)') - .get('/prismic.json') - .expectBadge({ - label: 'downloads', - message: isMetric, - }) +t.create('clojars downloads (valid)').get('/prismic.json').expectBadge({ + label: 'downloads', + message: isMetric, +}) t.create('clojars downloads (not found)') .get('/not-a-package.json') diff --git a/services/cocoapods/cocoapods-docs.service.js b/services/cocoapods/cocoapods-docs.service.js index 002ba6918ed4e5cd997100ab4210a0a0ff6bf366..457f6e8bd45b421144d1fbd98ad87a2a61edd113 100644 --- a/services/cocoapods/cocoapods-docs.service.js +++ b/services/cocoapods/cocoapods-docs.service.js @@ -8,9 +8,7 @@ const { BaseJsonService } = require('..') const schema = Joi.object({ cocoadocs: Joi.object({ - doc_percent: Joi.number() - .allow(null) - .required(), + doc_percent: Joi.number().allow(null).required(), }).required(), }).required() diff --git a/services/cocoapods/cocoapods-docs.tester.js b/services/cocoapods/cocoapods-docs.tester.js index 8c78313163c70dab87d9894427b543322e2baecc..7fe160e207cf376ffe74c732e2899674034f195d 100644 --- a/services/cocoapods/cocoapods-docs.tester.js +++ b/services/cocoapods/cocoapods-docs.tester.js @@ -3,12 +3,10 @@ const { isIntegerPercentage } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('doc percent (valid)') - .get('/AFNetworking.json') - .expectBadge({ - label: 'docs', - message: isIntegerPercentage, - }) +t.create('doc percent (valid)').get('/AFNetworking.json').expectBadge({ + label: 'docs', + message: isIntegerPercentage, +}) t.create('doc percent (null)') .get('/AFNetworking.json') diff --git a/services/cocoapods/cocoapods-platform.tester.js b/services/cocoapods/cocoapods-platform.tester.js index d8ffe1672363dc2cc0b8ee93f6f325a9cd5dd2f3..87a407e3d8134a42dfcdddaef85dc3622ee76ba6 100644 --- a/services/cocoapods/cocoapods-platform.tester.js +++ b/services/cocoapods/cocoapods-platform.tester.js @@ -7,12 +7,10 @@ const isPlatform = Joi.string().regex( /^(osx|ios|tvos|watchos)( \| (osx|ios|tvos|watchos))*$/ ) -t.create('platform (valid)') - .get('/AFNetworking.json') - .expectBadge({ - label: 'platform', - message: isPlatform, - }) +t.create('platform (valid)').get('/AFNetworking.json').expectBadge({ + label: 'platform', + message: isPlatform, +}) t.create('platform (not found)') .get('/not-a-package.json') diff --git a/services/cocoapods/cocoapods-version.tester.js b/services/cocoapods/cocoapods-version.tester.js index 628037601901a10e3df784340f65995159e28458..468ea4fa2ff8261963973d960d5041b7d59de048 100644 --- a/services/cocoapods/cocoapods-version.tester.js +++ b/services/cocoapods/cocoapods-version.tester.js @@ -3,12 +3,10 @@ const { isVPlusDottedVersionAtLeastOne } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('version (valid)') - .get('/AFNetworking.json') - .expectBadge({ - label: 'pod', - message: isVPlusDottedVersionAtLeastOne, - }) +t.create('version (valid)').get('/AFNetworking.json').expectBadge({ + label: 'pod', + message: isVPlusDottedVersionAtLeastOne, +}) t.create('version (not found)') .get('/not-a-package.json') diff --git a/services/codacy/codacy-coverage.tester.js b/services/codacy/codacy-coverage.tester.js index c159f424754f5871add37c5acdcfa1ba123dcd08..580018b2b49f04b6c0d37991a2d77e2e7b0e790c 100644 --- a/services/codacy/codacy-coverage.tester.js +++ b/services/codacy/codacy-coverage.tester.js @@ -3,12 +3,10 @@ const { isIntegerPercentage } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('Coverage') - .get('/59d607d0e311408885e418004068ea58.json') - .expectBadge({ - label: 'coverage', - message: isIntegerPercentage, - }) +t.create('Coverage').get('/59d607d0e311408885e418004068ea58.json').expectBadge({ + label: 'coverage', + message: isIntegerPercentage, +}) t.create('Coverage on branch') .get('/59d607d0e311408885e418004068ea58/master.json') diff --git a/services/codeclimate/codeclimate-analysis.tester.js b/services/codeclimate/codeclimate-analysis.tester.js index 52c8257c96900a13b2095952e70761790897694d..6d2d00a9afb7d7aa0421a27e1aa944a6c5829db7 100644 --- a/services/codeclimate/codeclimate-analysis.tester.js +++ b/services/codeclimate/codeclimate-analysis.tester.js @@ -7,14 +7,10 @@ const t = (module.exports = require('../tester').createServiceTester()) // Examples for this service can be found through the explore page: // https://codeclimate.com/explore -t.create('issues count') - .get('/issues/angular/angular.json') - .expectBadge({ - label: 'issues', - message: Joi.number() - .integer() - .positive(), - }) +t.create('issues count').get('/issues/angular/angular.json').expectBadge({ + label: 'issues', + message: Joi.number().integer().positive(), +}) t.create('technical debt percentage') .get('/tech-debt/angular/angular.json') diff --git a/services/codecov/codecov.spec.js b/services/codecov/codecov.spec.js index f0469acba6df025594c599762718af44a3b77540..ed54900d27360f73532146b4038c0c71fa25aacd 100644 --- a/services/codecov/codecov.spec.js +++ b/services/codecov/codecov.spec.js @@ -3,7 +3,7 @@ const { test, forCases, given } = require('sazerac') const Codecov = require('./codecov.service') -describe('Codecov', function() { +describe('Codecov', function () { test(Codecov.prototype.legacyTransform, () => { forCases([given({ json: {} }), given({ json: { commit: {} } })]).expect({ coverage: 'unknown', diff --git a/services/codefactor/codefactor-grade.service.js b/services/codefactor/codefactor-grade.service.js index 707661fb1b4856804577cef07c314be0e15a5511..1cfd832be725da8234ce4b9b9d3111eef9a38726 100644 --- a/services/codefactor/codefactor-grade.service.js +++ b/services/codefactor/codefactor-grade.service.js @@ -51,8 +51,9 @@ module.exports = class CodeFactorGrade extends BaseSvgScrapingService { async handle({ vcsType, user, repo, branch }) { const { message } = await this._requestSvg({ schema, - url: `https://codefactor.io/repository/${vcsType}/${user}/${repo}/badge/${branch || - ''}`, + url: `https://codefactor.io/repository/${vcsType}/${user}/${repo}/badge/${ + branch || '' + }`, errorMessages: { 404: 'repo or branch not found' }, }) return this.constructor.render({ grade: message }) diff --git a/services/codefactor/codefactor-grade.spec.js b/services/codefactor/codefactor-grade.spec.js index a35b08f61c5affc250f8dbef3fc77af96e978808..d9b1a80f0d9d509f4a7ccd4b3a6e64f4cde6f85e 100644 --- a/services/codefactor/codefactor-grade.spec.js +++ b/services/codefactor/codefactor-grade.spec.js @@ -3,7 +3,7 @@ const { test, given } = require('sazerac') const CodeFactorGrade = require('./codefactor-grade.service') -describe('CodeFactorGrade', function() { +describe('CodeFactorGrade', function () { test(CodeFactorGrade.render, () => { given({ grade: 'A' }).expect({ message: 'A', diff --git a/services/codefactor/codefactor-grade.tester.js b/services/codefactor/codefactor-grade.tester.js index fb5273761560251824d862e4f71430cf44a42602..1df7970214bb578d63cb7f15e54a9786ccf815a6 100644 --- a/services/codefactor/codefactor-grade.tester.js +++ b/services/codefactor/codefactor-grade.tester.js @@ -3,12 +3,10 @@ const t = (module.exports = require('../tester').createServiceTester()) const { isValidGrade } = require('./codefactor-helpers') -t.create('Grade') - .get('/github/google/guava.json') - .expectBadge({ - label: 'code quality', - message: isValidGrade, - }) +t.create('Grade').get('/github/google/guava.json').expectBadge({ + label: 'code quality', + message: isValidGrade, +}) t.create('Grade (branch)') .get('/github/pallets/flask/master.json') diff --git a/services/codeship/codeship.spec.js b/services/codeship/codeship.spec.js index 5f7ca4a41735b4d552a0a68c8ddfac040693a5b0..37fbe1cd75673d46f4da88a7e96b53ee7fd0c3f5 100644 --- a/services/codeship/codeship.spec.js +++ b/services/codeship/codeship.spec.js @@ -6,7 +6,7 @@ const Codeship = require('./codeship.service') const pending = { message: 'pending', label: undefined, color: undefined } const notBuilt = { message: 'not built', label: undefined, color: undefined } -describe('Codeship', function() { +describe('Codeship', function () { test(Codeship.render, () => { given({ status: 'testing' }).expect(pending) given({ status: 'waiting' }).expect(pending) diff --git a/services/codetally/codetally.service.js b/services/codetally/codetally.service.js index 22f5698a33c1a74d833b89ef5bfb61204f7352c6..0cadf807060c3120edfd98d4ca559ae431f59820 100644 --- a/services/codetally/codetally.service.js +++ b/services/codetally/codetally.service.js @@ -6,9 +6,7 @@ const { BaseJsonService } = require('..') const schema = Joi.object({ currency_sign: Joi.string().required(), amount: Joi.number().required(), - multiplier: Joi.string() - .allow('') - .required(), + multiplier: Joi.string().allow('').required(), currency_abbreviation: Joi.string().required(), }).required() diff --git a/services/color-formatters.spec.js b/services/color-formatters.spec.js index af632b51b0be02dc9c0e951c06baec5c5886034a..265b5094b957db947990f2aee0f6c68722795ee6 100644 --- a/services/color-formatters.spec.js +++ b/services/color-formatters.spec.js @@ -10,7 +10,7 @@ const { version, } = require('./color-formatters') -describe('Color formatters', function() { +describe('Color formatters', function () { const byPercentage = colorScale([Number.EPSILON, 80, 90, 100]) test(byPercentage, () => { @@ -32,7 +32,7 @@ describe('Color formatters', function() { ).should("return '%s', for parity with coveragePercentage()") }) - context('when reversed', function() { + context('when reversed', function () { test(colorScale([7, 30, 180, 365, 730], undefined, true), () => { given(3).expect('brightgreen') given(7).expect('green') diff --git a/services/conda/conda-base.js b/services/conda/conda-base.js index d2f2ec0c85d72f4ec96c9f54a8ca122b8fd4c6de..3b98b006d694313bfa9c71144f478e2fbe1106b8 100644 --- a/services/conda/conda-base.js +++ b/services/conda/conda-base.js @@ -6,9 +6,7 @@ const { BaseJsonService } = require('..') const condaSchema = Joi.object({ latest_version: Joi.string().required(), - conda_platforms: Joi.array() - .items(Joi.string()) - .required(), + conda_platforms: Joi.array().items(Joi.string()).required(), files: Joi.array() .items( Joi.object({ diff --git a/services/conda/conda-downloads.tester.js b/services/conda/conda-downloads.tester.js index 3d89629668df61f4a82a6ebcb1cd103c31951270..1d86806051437d539b2a4f7b2d5bca2bad6d6a08 100644 --- a/services/conda/conda-downloads.tester.js +++ b/services/conda/conda-downloads.tester.js @@ -3,12 +3,10 @@ const { isMetric } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('downloads') - .get('/d/conda-forge/zlib.json') - .expectBadge({ - label: 'conda|downloads', - message: isMetric, - }) +t.create('downloads').get('/d/conda-forge/zlib.json').expectBadge({ + label: 'conda|downloads', + message: isMetric, +}) t.create('downloads (skip prefix)') .get('/dn/conda-forge/zlib.json') diff --git a/services/conda/conda-platform.tester.js b/services/conda/conda-platform.tester.js index de7bfd6acf819b2259b44c0e7fec871fef07be52..be82e86ba17d560e303f07251b63f085e0b430ab 100644 --- a/services/conda/conda-platform.tester.js +++ b/services/conda/conda-platform.tester.js @@ -4,12 +4,10 @@ const Joi = require('@hapi/joi') const isCondaPlatform = Joi.string().regex(/^\w+-[\w\d]+( \| \w+-[\w\d]+)*$/) const t = (module.exports = require('../tester').createServiceTester()) -t.create('platform') - .get('/p/conda-forge/zlib.json') - .expectBadge({ - label: 'conda|platform', - message: isCondaPlatform, - }) +t.create('platform').get('/p/conda-forge/zlib.json').expectBadge({ + label: 'conda|platform', + message: isCondaPlatform, +}) t.create('platform (skip prefix)') .get('/pn/conda-forge/zlib.json') diff --git a/services/conda/conda-version.tester.js b/services/conda/conda-version.tester.js index 0bd049c80d01116983ff2d8ad18819edd6b12efa..4ffc6516a251e5546e97819622fdd643843eda42 100644 --- a/services/conda/conda-version.tester.js +++ b/services/conda/conda-version.tester.js @@ -3,16 +3,12 @@ const { isVPlusTripleDottedVersion } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('version') - .get('/v/conda-forge/zlib.json') - .expectBadge({ - label: 'conda|conda-forge', - message: isVPlusTripleDottedVersion, - }) +t.create('version').get('/v/conda-forge/zlib.json').expectBadge({ + label: 'conda|conda-forge', + message: isVPlusTripleDottedVersion, +}) -t.create('version (skip prefix)') - .get('/vn/conda-forge/zlib.json') - .expectBadge({ - label: 'conda-forge', - message: isVPlusTripleDottedVersion, - }) +t.create('version (skip prefix)').get('/vn/conda-forge/zlib.json').expectBadge({ + label: 'conda-forge', + message: isVPlusTripleDottedVersion, +}) diff --git a/services/continuousphp/continuousphp.spec.js b/services/continuousphp/continuousphp.spec.js index be92335ffab855a57ada25db85a96f8ecf5200a0..de11788c2f4c405276e6fbd9b33eb574c78d8357 100644 --- a/services/continuousphp/continuousphp.spec.js +++ b/services/continuousphp/continuousphp.spec.js @@ -3,7 +3,7 @@ const { test, given } = require('sazerac') const ContinuousPhp = require('./continuousphp.service') -describe('ContinuousPhp', function() { +describe('ContinuousPhp', function () { test(ContinuousPhp.render, () => { given({ status: 'unstable' }).expect({ label: 'build', diff --git a/services/contributor-count.spec.js b/services/contributor-count.spec.js index 25c266287ef2420b8907898edc6b37b6930e5e79..1ebdf4d31e32ba402f1f12a501bb786c7b3b4d57 100644 --- a/services/contributor-count.spec.js +++ b/services/contributor-count.spec.js @@ -3,7 +3,7 @@ const { test, given } = require('sazerac') const { renderContributorBadge } = require('./contributor-count') -describe('Contributor count helpers', function() { +describe('Contributor count helpers', function () { test(renderContributorBadge, () => { given({ label: 'maintainers', contributorCount: 1 }).expect({ label: 'maintainers', diff --git a/services/cookbook/cookbook.tester.js b/services/cookbook/cookbook.tester.js index 9290be89c87f9f8a3abdecf85490321ed60b71a2..9fa5eba654e401e556fe2704d4f762754fca97ea 100644 --- a/services/cookbook/cookbook.tester.js +++ b/services/cookbook/cookbook.tester.js @@ -3,12 +3,10 @@ const { isVPlusDottedVersionAtLeastOne } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('version') - .get('/chef-sugar.json') - .expectBadge({ - label: 'cookbook', - message: isVPlusDottedVersionAtLeastOne, - }) +t.create('version').get('/chef-sugar.json').expectBadge({ + label: 'cookbook', + message: isVPlusDottedVersionAtLeastOne, +}) t.create('version') .get('/chef-sugar.json') diff --git a/services/coveralls/coveralls.service.js b/services/coveralls/coveralls.service.js index a263803040d9c65f1e3e212543945414cddd9092..cb78f4e02cff99d2d7be670819b460999b052a0c 100644 --- a/services/coveralls/coveralls.service.js +++ b/services/coveralls/coveralls.service.js @@ -5,10 +5,7 @@ const { coveragePercentage } = require('../color-formatters') const { BaseJsonService } = require('..') const schema = Joi.object({ - covered_percent: Joi.number() - .min(0) - .max(100) - .required(), + covered_percent: Joi.number().min(0).max(100).required(), }).required() module.exports = class Coveralls extends BaseJsonService { @@ -75,8 +72,9 @@ module.exports = class Coveralls extends BaseJsonService { async fetch({ vcsType, user, repo, branch }) { // https://docs.coveralls.io/api-introduction#getting-data-from-coveralls - const url = `https://coveralls.io/${vcsType || - 'github'}/${user}/${repo}.json` + const url = `https://coveralls.io/${ + vcsType || 'github' + }/${user}/${repo}.json` const options = { qs: { // The API returns the latest result (across any branch) if no branch is explicitly specified, diff --git a/services/coverity/coverity-scan.service.js b/services/coverity/coverity-scan.service.js index ac8e95b5097f07b98cab3dee09ae57081a9b6e8d..344bb05d4488cf67edabe44998beb839ba2e6625 100644 --- a/services/coverity/coverity-scan.service.js +++ b/services/coverity/coverity-scan.service.js @@ -5,9 +5,7 @@ const { BaseJsonService } = require('..') const messageRegex = /passed|passed .* new defects|pending|failed/ const schema = Joi.object({ - message: Joi.string() - .regex(messageRegex) - .required(), + message: Joi.string().regex(messageRegex).required(), }).required() module.exports = class CoverityScan extends BaseJsonService { diff --git a/services/coverity/coverity-scan.tester.js b/services/coverity/coverity-scan.tester.js index 3801257acab810d916b90cba6a57460cd72291c2..e5b1c21e4e53445789f1bba98e628f31a8b7f128 100644 --- a/services/coverity/coverity-scan.tester.js +++ b/services/coverity/coverity-scan.tester.js @@ -18,20 +18,16 @@ t.create('unknown project id') t.create('404 response') .get('/1.json') .intercept(nock => - nock('https://scan.coverity.com/projects/1') - .get('/badge.json') - .reply(404) + nock('https://scan.coverity.com/projects/1').get('/badge.json').reply(404) ) .expectBadge({ label: 'coverity', message: 'project not found' }) t.create('passed') .get('/2.json') .intercept(nock => - nock('https://scan.coverity.com/projects/2') - .get('/badge.json') - .reply(200, { - message: 'passed', - }) + nock('https://scan.coverity.com/projects/2').get('/badge.json').reply(200, { + message: 'passed', + }) ) .expectBadge({ label: 'coverity', @@ -42,11 +38,9 @@ t.create('passed') t.create('passed with defects') .get('/2.json') .intercept(nock => - nock('https://scan.coverity.com/projects/2') - .get('/badge.json') - .reply(200, { - message: 'passed 51 new defects', - }) + nock('https://scan.coverity.com/projects/2').get('/badge.json').reply(200, { + message: 'passed 51 new defects', + }) ) .expectBadge({ label: 'coverity', @@ -57,11 +51,9 @@ t.create('passed with defects') t.create('pending') .get('/2.json') .intercept(nock => - nock('https://scan.coverity.com/projects/2') - .get('/badge.json') - .reply(200, { - message: 'pending', - }) + nock('https://scan.coverity.com/projects/2').get('/badge.json').reply(200, { + message: 'pending', + }) ) .expectBadge({ label: 'coverity', @@ -72,11 +64,9 @@ t.create('pending') t.create('failed') .get('/2.json') .intercept(nock => - nock('https://scan.coverity.com/projects/2') - .get('/badge.json') - .reply(200, { - message: 'failed', - }) + nock('https://scan.coverity.com/projects/2').get('/badge.json').reply(200, { + message: 'failed', + }) ) .expectBadge({ label: 'coverity', diff --git a/services/cpan/cpan-license.tester.js b/services/cpan/cpan-license.tester.js index c841b2b2fbb0f10b9339352556e886aaab3f183a..fb9f4dfa76dd0708f8037229c36a6686a9192ed4 100644 --- a/services/cpan/cpan-license.tester.js +++ b/services/cpan/cpan-license.tester.js @@ -2,16 +2,12 @@ const t = (module.exports = require('../tester').createServiceTester()) -t.create('license (valid)') - .get('/Config-Augeas.json') - .expectBadge({ - label: 'license', - message: 'lgpl_2_1', - }) +t.create('license (valid)').get('/Config-Augeas.json').expectBadge({ + label: 'license', + message: 'lgpl_2_1', +}) -t.create('license (not found)') - .get('/not-a-package.json') - .expectBadge({ - label: 'cpan', - message: 'not found', - }) +t.create('license (not found)').get('/not-a-package.json').expectBadge({ + label: 'cpan', + message: 'not found', +}) diff --git a/services/cpan/cpan-version.tester.js b/services/cpan/cpan-version.tester.js index 1a1e26fa8a5ef4a1b934e8c8e823403cf3960b2c..63006a1463676e8c9924ecefeb0f7535f5e52da4 100644 --- a/services/cpan/cpan-version.tester.js +++ b/services/cpan/cpan-version.tester.js @@ -3,16 +3,12 @@ const { isVPlusDottedVersionAtLeastOne } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('version (valid)') - .get('/Config-Augeas.json') - .expectBadge({ - label: 'cpan', - message: isVPlusDottedVersionAtLeastOne, - }) +t.create('version (valid)').get('/Config-Augeas.json').expectBadge({ + label: 'cpan', + message: isVPlusDottedVersionAtLeastOne, +}) -t.create('version (not found)') - .get('/not-a-package.json') - .expectBadge({ - label: 'cpan', - message: 'not found', - }) +t.create('version (not found)').get('/not-a-package.json').expectBadge({ + label: 'cpan', + message: 'not found', +}) diff --git a/services/cpan/cpan.js b/services/cpan/cpan.js index 818b0f80e412583d0861e28768b3751892be0433..25da1da8a821261cd514d977013d13a1480a8fde 100644 --- a/services/cpan/cpan.js +++ b/services/cpan/cpan.js @@ -5,10 +5,7 @@ const { BaseJsonService } = require('..') const schema = Joi.object({ version: Joi.string().required(), - license: Joi.array() - .items(Joi.string()) - .min(1) - .required(), + license: Joi.array().items(Joi.string()).min(1).required(), }).required() module.exports = class BaseCpanService extends BaseJsonService { diff --git a/services/cran/cran.tester.js b/services/cran/cran.tester.js index 92f65d1a7b7b80a77f34be992a82ed4ce00b1825..8218aa273eb97316ed13d0b0a5fd3725a34a6e4c 100644 --- a/services/cran/cran.tester.js +++ b/services/cran/cran.tester.js @@ -8,12 +8,10 @@ const t = (module.exports = new ServiceTester({ title: 'CRAN/METACRAN', })) -t.create('version (valid)') - .get('/v/devtools.json') - .expectBadge({ - label: 'cran', - message: isVPlusTripleDottedVersion, - }) +t.create('version (valid)').get('/v/devtools.json').expectBadge({ + label: 'cran', + message: isVPlusTripleDottedVersion, +}) t.create('version (not found)') .get('/v/some-bogus-package.json') diff --git a/services/crates/crates-downloads.tester.js b/services/crates/crates-downloads.tester.js index b56f956255a8822513787c3444651f2ecd013ed6..c68374a4033863df010e65e40088dd5b8bde9c1b 100644 --- a/services/crates/crates-downloads.tester.js +++ b/services/crates/crates-downloads.tester.js @@ -20,12 +20,10 @@ t.create('total downloads (with version)') message: isMetric, }) -t.create('downloads for version') - .get('/dv/libc.json') - .expectBadge({ - label: 'downloads@latest', - message: isMetric, - }) +t.create('downloads for version').get('/dv/libc.json').expectBadge({ + label: 'downloads@latest', + message: isMetric, +}) t.create('downloads for version (with version)') .get('/dv/libc/0.2.31.json') @@ -34,12 +32,10 @@ t.create('downloads for version (with version)') message: isMetric, }) -t.create('recent downloads') - .get('/dr/libc.json') - .expectBadge({ - label: 'recent downloads', - message: isMetric, - }) +t.create('recent downloads').get('/dr/libc.json').expectBadge({ + label: 'recent downloads', + message: isMetric, +}) t.create('recent downloads (with version)') .get('/dr/libc/0.2.31.json') diff --git a/services/crates/crates-version.spec.js b/services/crates/crates-version.spec.js index e1c13e3eca1085073cc3a12906bb9792fcf98342..97898f6b8a4a3ac8c4b9a054c9eb1a2b51236e51 100644 --- a/services/crates/crates-version.spec.js +++ b/services/crates/crates-version.spec.js @@ -5,13 +5,13 @@ const { expect } = require('chai') const { InvalidResponse } = require('..') const CratesVersion = require('./crates-version.service') -describe('CratesVersion', function() { +describe('CratesVersion', function () { test(CratesVersion.prototype.transform, () => { given({ version: { num: '1.0.0' } }).expect({ version: '1.0.0' }) given({ crate: { max_version: '1.1.0' } }).expect({ version: '1.1.0' }) }) - it('throws InvalidResponse on error response', function() { + it('throws InvalidResponse on error response', function () { expect(() => CratesVersion.prototype.transform({ errors: [{ detail: 'idk how...' }] }) ).to.throw(InvalidResponse) diff --git a/services/ctan/ctan.service.js b/services/ctan/ctan.service.js index 342bbfa924eef64ca2c78cf3770709b6c407eddf..821722c94cc7fc289471298ce36d9039e2189a61 100644 --- a/services/ctan/ctan.service.js +++ b/services/ctan/ctan.service.js @@ -6,9 +6,7 @@ const { renderVersionBadge } = require('../version') const { BaseJsonService } = require('..') const schema = Joi.object({ - license: Joi.array() - .items(Joi.string()) - .single(), + license: Joi.array().items(Joi.string()).single(), version: Joi.object({ number: Joi.string().required(), }).required(), diff --git a/services/ctan/ctan.tester.js b/services/ctan/ctan.tester.js index 90c558a5312555eb37550dd5a6f9a66a5f8be615..29268a604e2db2c6f8b5bb2dc969a993fccb680c 100644 --- a/services/ctan/ctan.tester.js +++ b/services/ctan/ctan.tester.js @@ -8,12 +8,10 @@ const t = (module.exports = new ServiceTester({ title: 'Comprehensive TEX Archive Network', })) -t.create('license') - .get('/l/novel.json') - .expectBadge({ - label: 'license', - message: 'lppl1.3c, ofl', - }) +t.create('license').get('/l/novel.json').expectBadge({ + label: 'license', + message: 'lppl1.3c, ofl', +}) t.create('license missing') .get('/l/novel.json') @@ -48,12 +46,10 @@ t.create('single license') message: 'knuth', }) -t.create('version') - .get('/v/novel.json') - .expectBadge({ - label: 'ctan', - message: isVPlusDottedVersionAtLeastOne, - }) +t.create('version').get('/v/novel.json').expectBadge({ + label: 'ctan', + message: isVPlusDottedVersionAtLeastOne, +}) t.create('version') .get('/v/novel.json') diff --git a/services/deprecation-helpers.spec.js b/services/deprecation-helpers.spec.js index 26bc307f9d7f5ccacd8469da0a6221a2a35c6702..63632cc7e0243d1ea4a2e94cd081be82c66cd1e6 100644 --- a/services/deprecation-helpers.spec.js +++ b/services/deprecation-helpers.spec.js @@ -4,12 +4,12 @@ const { expect } = require('chai') const { Deprecated } = require('../core/base-service/errors') const { enforceDeprecation } = require('./deprecation-helpers') -describe('enforceDeprecation', function() { - it('throws Deprecated for a date in the past', function() { +describe('enforceDeprecation', function () { + it('throws Deprecated for a date in the past', function () { expect(() => enforceDeprecation(new Date())).to.throw(Deprecated) }) - it('does not throw for a date in the future', function() { + it('does not throw for a date in the future', function () { expect(() => enforceDeprecation(new Date(Date.now() + 10000)) ).not.to.throw() diff --git a/services/docker/docker-size.service.js b/services/docker/docker-size.service.js index 0439181f3aec5a065c48e2df87be4a929b891273..b22ece06eee63aa6b0272685ca6d00c49e103ac6 100644 --- a/services/docker/docker-size.service.js +++ b/services/docker/docker-size.service.js @@ -27,9 +27,7 @@ const pagedSchema = Joi.object({ }).required() const queryParamSchema = Joi.object({ - sort: Joi.string() - .valid('date', 'semver') - .default('date'), + sort: Joi.string().valid('date', 'semver').default('date'), }).required() module.exports = class DockerSize extends BaseJsonService { diff --git a/services/docker/docker-size.spec.js b/services/docker/docker-size.spec.js index 10140ebf022a6a35ff50735915d838ef26658d98..56857c5fa7e61858e9a12b91a5b33a2cb79c9ec9 100644 --- a/services/docker/docker-size.spec.js +++ b/services/docker/docker-size.spec.js @@ -4,7 +4,7 @@ const { test, given } = require('sazerac') const DockerSize = require('./docker-size.service') const { sizeDataNoTagSemVerSort } = require('./docker-fixtures') -describe('DockerSize', function() { +describe('DockerSize', function () { test(DockerSize.prototype.transform, () => { given({ tag: '', diff --git a/services/docker/docker-version.service.js b/services/docker/docker-version.service.js index 3640d89c98c23621a12a8ba3830d40c7186f39b6..3cd4d2edf6aa4e506f7f0e863c303e64b2d00706 100644 --- a/services/docker/docker-version.service.js +++ b/services/docker/docker-version.service.js @@ -27,9 +27,7 @@ const buildSchema = Joi.object({ }).required() const queryParamSchema = Joi.object({ - sort: Joi.string() - .valid('date', 'semver') - .default('date'), + sort: Joi.string().valid('date', 'semver').default('date'), }).required() module.exports = class DockerVersion extends BaseJsonService { diff --git a/services/docker/docker-version.spec.js b/services/docker/docker-version.spec.js index 9be9cd9bc7d30f5b539b154d7a5e94c3416fde89..36c2fe50f0ce0d95d00d873af197db791b3db31b 100644 --- a/services/docker/docker-version.spec.js +++ b/services/docker/docker-version.spec.js @@ -11,7 +11,7 @@ const { versionDataWithTag, } = require('./docker-fixtures') -describe('DockerVersion', function() { +describe('DockerVersion', function () { test(DockerVersion.prototype.transform, () => { given({ tag: '', @@ -50,7 +50,7 @@ describe('DockerVersion', function() { }) }) - it('throws InvalidResponse error with latest tag and no amd64 architecture digests', function() { + it('throws InvalidResponse error with latest tag and no amd64 architecture digests', function () { expect(() => { DockerVersion.prototype.transform({ sort: 'date', diff --git a/services/docker/docker-version.tester.js b/services/docker/docker-version.tester.js index 011a66110d69607d7f23340953751eece10da577..46ebefdac650ab8813a293cbedb910c456dbcaa0 100644 --- a/services/docker/docker-version.tester.js +++ b/services/docker/docker-version.tester.js @@ -3,12 +3,10 @@ const { isSemVer } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('docker version (valid, library)') - .get('/_/alpine.json') - .expectBadge({ - label: 'version', - message: isSemVer, - }) +t.create('docker version (valid, library)').get('/_/alpine.json').expectBadge({ + label: 'version', + message: isSemVer, +}) t.create('docker version (valid, library with tag)') .get('/_/alpine/latest.json') diff --git a/services/drone/drone-build.spec.js b/services/drone/drone-build.spec.js index 06837dbad1f287d7eeba14f08c57726d17da17c9..dc0b914fa521ff00bbd05777a5963310deb20a44 100644 --- a/services/drone/drone-build.spec.js +++ b/services/drone/drone-build.spec.js @@ -5,10 +5,10 @@ const nock = require('nock') const { cleanUpNockAfterEach, defaultContext } = require('../test-helpers') const DroneBuild = require('./drone-build.service') -describe('DroneBuild', function() { +describe('DroneBuild', function () { cleanUpNockAfterEach() - it('Sends auth headers to cloud instance', async function() { + it('Sends auth headers to cloud instance', async function () { const token = 'abc123' const scope = nock('https://cloud.drone.io', { diff --git a/services/dub/dub-download.tester.js b/services/dub/dub-download.tester.js index a324ed0e4bc2f6484f0b5a2e6f8092ae106ea587..c2ce2779f201504271b061f4c1cbc6a35fe78eb5 100644 --- a/services/dub/dub-download.tester.js +++ b/services/dub/dub-download.tester.js @@ -12,13 +12,11 @@ const isDownloadsColor = Joi.equal( 'brightgreen' ) -t.create('total downloads (valid)') - .get('/dt/vibe-d.json') - .expectBadge({ - label: 'downloads', - message: isMetric, - color: isDownloadsColor, - }) +t.create('total downloads (valid)').get('/dt/vibe-d.json').expectBadge({ + label: 'downloads', + message: isMetric, + color: isDownloadsColor, +}) t.create('total downloads, specific version (valid)') .get('/dt/dub/1.16.0.json') @@ -37,29 +35,23 @@ t.create('total downloads, latest version (valid)') color: isDownloadsColor, }) -t.create('daily downloads (valid)') - .get('/dd/vibe-d.json') - .expectBadge({ - label: 'downloads', - message: isMetricOverTimePeriod, - color: isDownloadsColor, - }) - -t.create('weekly downloads (valid)') - .get('/dw/vibe-d.json') - .expectBadge({ - label: 'downloads', - message: isMetricOverTimePeriod, - color: isDownloadsColor, - }) - -t.create('monthly downloads (valid)') - .get('/dm/vibe-d.json') - .expectBadge({ - label: 'downloads', - message: isMetricOverTimePeriod, - color: isDownloadsColor, - }) +t.create('daily downloads (valid)').get('/dd/vibe-d.json').expectBadge({ + label: 'downloads', + message: isMetricOverTimePeriod, + color: isDownloadsColor, +}) + +t.create('weekly downloads (valid)').get('/dw/vibe-d.json').expectBadge({ + label: 'downloads', + message: isMetricOverTimePeriod, + color: isDownloadsColor, +}) + +t.create('monthly downloads (valid)').get('/dm/vibe-d.json').expectBadge({ + label: 'downloads', + message: isMetricOverTimePeriod, + color: isDownloadsColor, +}) t.create('total downloads (not found)') .get('/dt/not-a-package.json') diff --git a/services/dynamic-common.js b/services/dynamic-common.js index 80e25754fcb284d614550f5a69b371279229b5db..d291e611c9ecf77424199b15479830fa52db8ecc 100644 --- a/services/dynamic-common.js +++ b/services/dynamic-common.js @@ -15,9 +15,7 @@ const individualValueSchema = Joi.alternatives() const compoundValueSchema = Joi.alternatives().try( individualValueSchema, - Joi.array() - .items(individualValueSchema) - .required(), + Joi.array().items(individualValueSchema).required(), Joi.array().length(0) ) diff --git a/services/dynamic/dynamic-json.tester.js b/services/dynamic/dynamic-json.tester.js index bacbf7c2498ac162ec5bb479618cf9ecb7e91470..42eed630f046dedef95bd19acc089d7a869b59f6 100644 --- a/services/dynamic/dynamic-json.tester.js +++ b/services/dynamic/dynamic-json.tester.js @@ -130,7 +130,7 @@ t.create('request should set Accept header') .intercept(nock => nock('https://json-test') .get('/api.json') - .reply(200, function(uri, requestBody) { + .reply(200, function (uri, requestBody) { headers = this.req.headers return '{"name":"test"}' }) @@ -178,9 +178,7 @@ t.create('query with invalid token') t.create('JSON contains an array') .get('.json?url=https://example.test/json&query=$[0]') .intercept(nock => - nock('https://example.test') - .get('/json') - .reply(200, '["foo"]') + nock('https://example.test').get('/json').reply(200, '["foo"]') ) .expectBadge({ label: 'custom badge', @@ -190,9 +188,7 @@ t.create('JSON contains an array') t.create('JSON contains a string') .get('.json?url=https://example.test/json&query=$.foo,') .intercept(nock => - nock('https://example.test') - .get('/json') - .reply(200, '"foo"') + nock('https://example.test').get('/json').reply(200, '"foo"') ) .expectBadge({ label: 'custom badge', diff --git a/services/dynamic/dynamic-xml.spec.js b/services/dynamic/dynamic-xml.spec.js index ce5d209baf7337a0c5d0268aba70fc880e0d4913..7987164cacb2adae3774091e92bda654f0ce2945 100644 --- a/services/dynamic/dynamic-xml.spec.js +++ b/services/dynamic/dynamic-xml.spec.js @@ -22,17 +22,17 @@ const exampleXml = `<?xml version="1.0"?> </catalog> ` -describe('DynamicXml', function() { - describe('transform()', function() { - beforeEach(function() { +describe('DynamicXml', function () { + describe('transform()', function () { + beforeEach(function () { sinon.stub(xpath, 'select').returns(undefined) }) - afterEach(function() { + afterEach(function () { sinon.restore() }) - it('throws InvalidResponse on unsupported query', function() { + it('throws InvalidResponse on unsupported query', function () { expect(() => DynamicXml.prototype.transform({ pathExpression: '//book/title', diff --git a/services/dynamic/dynamic-xml.tester.js b/services/dynamic/dynamic-xml.tester.js index adca35606b4a6000644d20a51531173735c41160..a33457b763e469b29e74f41c9743f22d0f0c2a71 100644 --- a/services/dynamic/dynamic-xml.tester.js +++ b/services/dynamic/dynamic-xml.tester.js @@ -6,9 +6,7 @@ const { exampleXml } = require('./dynamic-response-fixtures') const exampleUrl = 'https://example.test/example.xml' const withExampleXml = nock => - nock('https://example.test') - .get('/example.xml') - .reply(200, exampleXml) + nock('https://example.test').get('/example.xml').reply(200, exampleXml) t.create('No URL specified') .get('.json?query=//name&label=Package Name') diff --git a/services/dynamic/dynamic-yaml.tester.js b/services/dynamic/dynamic-yaml.tester.js index cfcc4f3dd293dec2e5c8ee854f4960d09333f9e0..cb04be8bcf2e2e0cb2c617c945c84ae059fe2171 100644 --- a/services/dynamic/dynamic-yaml.tester.js +++ b/services/dynamic/dynamic-yaml.tester.js @@ -105,9 +105,7 @@ t.create('YAML from url | error color overrides user specified') t.create('YAML contains a string') .get('.json?url=https://example.test/yaml&query=$.foo,') .intercept(nock => - nock('https://example.test') - .get('/yaml') - .reply(200, '"foo"') + nock('https://example.test').get('/yaml').reply(200, '"foo"') ) .expectBadge({ label: 'custom badge', diff --git a/services/dynamic/json-path.spec.js b/services/dynamic/json-path.spec.js index decaf3877964ad6bf41fcdfc4c48cbdaf1b93ff8..ca30499f8ec3187723209549df927d582f44be33 100644 --- a/services/dynamic/json-path.spec.js +++ b/services/dynamic/json-path.spec.js @@ -6,9 +6,9 @@ const jsonPath = require('./json-path') chai.use(require('chai-as-promised')) -describe('JSON Path service factory', function() { - describe('fetch()', function() { - it('should throw error if it is not overridden', function() { +describe('JSON Path service factory', function () { + describe('fetch()', function () { + it('should throw error if it is not overridden', function () { class BaseService {} class JsonPathService extends jsonPath(BaseService) {} const jsonPathServiceInstance = new JsonPathService() diff --git a/services/eclipse-marketplace/eclipse-marketplace-downloads.tester.js b/services/eclipse-marketplace/eclipse-marketplace-downloads.tester.js index 42a4fd17716d3236e5994bb7d8c8af7c1f9f55d7..878fe844c08161c332621397ef3d5bfacdf7b163 100644 --- a/services/eclipse-marketplace/eclipse-marketplace-downloads.tester.js +++ b/services/eclipse-marketplace/eclipse-marketplace-downloads.tester.js @@ -9,12 +9,10 @@ const t = (module.exports = new ServiceTester({ pathPrefix: '/eclipse-marketplace', })) -t.create('total marketplace downloads') - .get('/dt/notepad4e.json') - .expectBadge({ - label: 'downloads', - message: isMetric, - }) +t.create('total marketplace downloads').get('/dt/notepad4e.json').expectBadge({ + label: 'downloads', + message: isMetric, +}) t.create('monthly marketplace downloads') .get('/dm/notepad4e.json') diff --git a/services/eclipse-marketplace/eclipse-marketplace-favorites.tester.js b/services/eclipse-marketplace/eclipse-marketplace-favorites.tester.js index e8c2f77b5a3f187b5c4cb4f77bf7bbee2bc491ee..79cf1e71cd3c005bccbeb696c88c948ee6de6fd4 100644 --- a/services/eclipse-marketplace/eclipse-marketplace-favorites.tester.js +++ b/services/eclipse-marketplace/eclipse-marketplace-favorites.tester.js @@ -3,14 +3,10 @@ const Joi = require('@hapi/joi') const t = (module.exports = require('../tester').createServiceTester()) -t.create('favorites count') - .get('/notepad4e.json') - .expectBadge({ - label: 'favorites', - message: Joi.number() - .integer() - .positive(), - }) +t.create('favorites count').get('/notepad4e.json').expectBadge({ + label: 'favorites', + message: Joi.number().integer().positive(), +}) t.create('favorites for unknown solution') .get('/this-does-not-exist.json') diff --git a/services/eclipse-marketplace/eclipse-marketplace-license.service.js b/services/eclipse-marketplace/eclipse-marketplace-license.service.js index 856e6d24d3f3bf8c6263915829f0ef3157af5005..7d38698746e304dd1e8ed804118ce1209294c602 100644 --- a/services/eclipse-marketplace/eclipse-marketplace-license.service.js +++ b/services/eclipse-marketplace/eclipse-marketplace-license.service.js @@ -6,9 +6,7 @@ const EclipseMarketplaceBase = require('./eclipse-marketplace-base') const licenseResponseSchema = Joi.object({ marketplace: Joi.object({ node: Joi.object({ - license: Joi.string() - .allow('') - .required(), + license: Joi.string().allow('').required(), }), }), }).required() diff --git a/services/eclipse-marketplace/eclipse-marketplace-license.tester.js b/services/eclipse-marketplace/eclipse-marketplace-license.tester.js index 1c3e6aa2ef697d75306121a1109d37fa1b60c27e..f7b9d8be1a6b5e0cd12e0e5ec47709419d48e54a 100644 --- a/services/eclipse-marketplace/eclipse-marketplace-license.tester.js +++ b/services/eclipse-marketplace/eclipse-marketplace-license.tester.js @@ -2,12 +2,10 @@ const t = (module.exports = require('../tester').createServiceTester()) -t.create('license') - .get('/notepad4e.json') - .expectBadge({ - label: 'license', - message: 'EPL 2.0', - }) +t.create('license').get('/notepad4e.json').expectBadge({ + label: 'license', + message: 'EPL 2.0', +}) t.create('unspecified license') .get('/notepad4e.json') diff --git a/services/eclipse-marketplace/eclipse-marketplace-update.tester.js b/services/eclipse-marketplace/eclipse-marketplace-update.tester.js index b59fc6b2493de07d76c7cfcee0c07791ab6b0b85..af1b8628d8eed756ef302a36bd703f996fb9acc7 100644 --- a/services/eclipse-marketplace/eclipse-marketplace-update.tester.js +++ b/services/eclipse-marketplace/eclipse-marketplace-update.tester.js @@ -3,12 +3,10 @@ const { isFormattedDate } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('last update date') - .get('/notepad4e.json') - .expectBadge({ - label: 'updated', - message: isFormattedDate, - }) +t.create('last update date').get('/notepad4e.json').expectBadge({ + label: 'updated', + message: isFormattedDate, +}) t.create('last update for unknown solution') .get('/this-does-not-exist.json') diff --git a/services/eclipse-marketplace/eclipse-marketplace-version.tester.js b/services/eclipse-marketplace/eclipse-marketplace-version.tester.js index 863c6863e52704a6ad3347325e2e91701b981e9a..b3e58b9bc816452371adfda7f2d0ad86a00df317 100644 --- a/services/eclipse-marketplace/eclipse-marketplace-version.tester.js +++ b/services/eclipse-marketplace/eclipse-marketplace-version.tester.js @@ -3,12 +3,10 @@ const { isVPlusDottedVersionAtLeastOne } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('marketplace version') - .get('/notepad4e.json') - .expectBadge({ - label: 'eclipse marketplace', - message: isVPlusDottedVersionAtLeastOne, - }) +t.create('marketplace version').get('/notepad4e.json').expectBadge({ + label: 'eclipse marketplace', + message: isVPlusDottedVersionAtLeastOne, +}) t.create('last update for unknown solution') .get('/this-does-not-exist.json') diff --git a/services/endpoint-common.js b/services/endpoint-common.js index 1cbe7b559a4bd7e42f9c8dc9a0ffc17cd15efd40..9c7bffb3c6cdfd1c12cb6ddd67f808708b9902e3 100644 --- a/services/endpoint-common.js +++ b/services/endpoint-common.js @@ -18,9 +18,7 @@ const optionalNumberWhenAnyLogoPresent = Joi.alternatives() const endpointSchema = Joi.object({ schemaVersion: 1, - label: Joi.string() - .allow('') - .required(), + label: Joi.string().allow('').required(), message: Joi.string().required(), color: Joi.string(), labelColor: Joi.string(), @@ -31,9 +29,7 @@ const endpointSchema = Joi.object({ logoWidth: optionalNumberWhenAnyLogoPresent, logoPosition: optionalNumberWhenAnyLogoPresent, style: Joi.string(), - cacheSeconds: Joi.number() - .integer() - .min(0), + cacheSeconds: Joi.number().integer().min(0), }) // `namedLogo` or `logoSvg`; not both. .oxor('namedLogo', 'logoSvg') diff --git a/services/endpoint/endpoint.tester.js b/services/endpoint/endpoint.tester.js index 43b9ca4fc78d2061362cee6fefc998dac3d7996c..3cd09a37440b14eaa1190dc644cba3897cbb3451 100644 --- a/services/endpoint/endpoint.tester.js +++ b/services/endpoint/endpoint.tester.js @@ -7,28 +7,24 @@ const t = (module.exports = require('../tester').createServiceTester()) t.create('Valid schema') .get('.json?url=https://example.com/badge') .intercept(nock => - nock('https://example.com/') - .get('/badge') - .reply(200, { - schemaVersion: 1, - label: '', - message: 'yo', - }) + nock('https://example.com/').get('/badge').reply(200, { + schemaVersion: 1, + label: '', + message: 'yo', + }) ) .expectBadge({ label: '', message: 'yo' }) t.create('color and labelColor') .get('.json?url=https://example.com/badge') .intercept(nock => - nock('https://example.com/') - .get('/badge') - .reply(200, { - schemaVersion: 1, - label: 'hey', - message: 'yo', - color: '#f0dcc3', - labelColor: '#e6e6fa', - }) + nock('https://example.com/').get('/badge').reply(200, { + schemaVersion: 1, + label: 'hey', + message: 'yo', + color: '#f0dcc3', + labelColor: '#e6e6fa', + }) ) .expectBadge({ label: 'hey', @@ -40,14 +36,12 @@ t.create('color and labelColor') t.create('style') .get('.json?url=https://example.com/badge') .intercept(nock => - nock('https://example.com/') - .get('/badge') - .reply(200, { - schemaVersion: 1, - label: 'hey', - message: 'yo', - color: '#99c', - }) + nock('https://example.com/').get('/badge').reply(200, { + schemaVersion: 1, + label: 'hey', + message: 'yo', + color: '#99c', + }) ) .expectBadge({ label: 'hey', @@ -60,14 +54,12 @@ t.create('style') t.create('named logo') .get('.svg?url=https://example.com/badge') .intercept(nock => - nock('https://example.com/') - .get('/badge') - .reply(200, { - schemaVersion: 1, - label: 'hey', - message: 'yo', - namedLogo: 'npm', - }) + nock('https://example.com/').get('/badge').reply(200, { + schemaVersion: 1, + label: 'hey', + message: 'yo', + namedLogo: 'npm', + }) ) .after((err, res, body) => { expect(err).not.to.be.ok @@ -77,15 +69,13 @@ t.create('named logo') t.create('named logo with color') .get('.svg?url=https://example.com/badge') .intercept(nock => - nock('https://example.com/') - .get('/badge') - .reply(200, { - schemaVersion: 1, - label: 'hey', - message: 'yo', - namedLogo: 'npm', - logoColor: 'blue', - }) + nock('https://example.com/').get('/badge').reply(200, { + schemaVersion: 1, + label: 'hey', + message: 'yo', + namedLogo: 'npm', + logoColor: 'blue', + }) ) .after((err, res, body) => { expect(err).not.to.be.ok @@ -100,14 +90,12 @@ const logoSvg = Buffer.from( t.create('custom svg logo') .get('.svg?url=https://example.com/badge') .intercept(nock => - nock('https://example.com/') - .get('/badge') - .reply(200, { - schemaVersion: 1, - label: 'hey', - message: 'yo', - logoSvg, - }) + nock('https://example.com/').get('/badge').reply(200, { + schemaVersion: 1, + label: 'hey', + message: 'yo', + logoSvg, + }) ) .after((err, res, body) => { expect(err).not.to.be.ok @@ -117,15 +105,13 @@ t.create('custom svg logo') t.create('logoWidth') .get('.json?url=https://example.com/badge') .intercept(nock => - nock('https://example.com/') - .get('/badge') - .reply(200, { - schemaVersion: 1, - label: 'hey', - message: 'yo', - logoSvg, - logoWidth: 30, - }) + nock('https://example.com/').get('/badge').reply(200, { + schemaVersion: 1, + label: 'hey', + message: 'yo', + logoSvg, + logoWidth: 30, + }) ) .expectBadge({ label: 'hey', @@ -136,11 +122,9 @@ t.create('logoWidth') t.create('Invalid schema)') .get('.json?url=https://example.com/badge') .intercept(nock => - nock('https://example.com/') - .get('/badge') - .reply(200, { - schemaVersion: -1, - }) + nock('https://example.com/').get('/badge').reply(200, { + schemaVersion: -1, + }) ) .expectBadge({ label: 'custom badge', @@ -150,15 +134,13 @@ t.create('Invalid schema)') t.create('Invalid schema)') .get('.json?url=https://example.com/badge') .intercept(nock => - nock('https://example.com/') - .get('/badge') - .reply(200, { - schemaVersion: 1, - label: 'hey', - message: 'yo', - extra: 'keys', - bogus: true, - }) + nock('https://example.com/').get('/badge').reply(200, { + schemaVersion: 1, + label: 'hey', + message: 'yo', + extra: 'keys', + bogus: true, + }) ) .expectBadge({ label: 'custom badge', @@ -168,114 +150,98 @@ t.create('Invalid schema)') t.create('User color overrides success color') .get('.json?url=https://example.com/badge&color=101010') .intercept(nock => - nock('https://example.com/') - .get('/badge') - .reply(200, { - schemaVersion: 1, - label: '', - message: 'yo', - color: 'blue', - }) + nock('https://example.com/').get('/badge').reply(200, { + schemaVersion: 1, + label: '', + message: 'yo', + color: 'blue', + }) ) .expectBadge({ label: '', message: 'yo', color: '#101010' }) t.create('User legacy color overrides success color') .get('.json?url=https://example.com/badge&colorB=101010') .intercept(nock => - nock('https://example.com/') - .get('/badge') - .reply(200, { - schemaVersion: 1, - label: '', - message: 'yo', - color: 'blue', - }) + nock('https://example.com/').get('/badge').reply(200, { + schemaVersion: 1, + label: '', + message: 'yo', + color: 'blue', + }) ) .expectBadge({ label: '', message: 'yo', color: '#101010' }) t.create('User color does not override error color') .get('.json?url=https://example.com/badge&color=101010') .intercept(nock => - nock('https://example.com/') - .get('/badge') - .reply(200, { - schemaVersion: 1, - isError: true, - label: 'something is', - message: 'not right', - color: 'red', - }) + nock('https://example.com/').get('/badge').reply(200, { + schemaVersion: 1, + isError: true, + label: 'something is', + message: 'not right', + color: 'red', + }) ) .expectBadge({ label: 'something is', message: 'not right', color: 'red' }) t.create('User legacy color does not override error color') .get('.json?url=https://example.com/badge&colorB=101010') .intercept(nock => - nock('https://example.com/') - .get('/badge') - .reply(200, { - schemaVersion: 1, - isError: true, - label: 'something is', - message: 'not right', - color: 'red', - }) + nock('https://example.com/').get('/badge').reply(200, { + schemaVersion: 1, + isError: true, + label: 'something is', + message: 'not right', + color: 'red', + }) ) .expectBadge({ label: 'something is', message: 'not right', color: 'red' }) t.create('cacheSeconds') .get('.json?url=https://example.com/badge') .intercept(nock => - nock('https://example.com/') - .get('/badge') - .reply(200, { - schemaVersion: 1, - label: '', - message: 'yo', - cacheSeconds: 500, - }) + nock('https://example.com/').get('/badge').reply(200, { + schemaVersion: 1, + label: '', + message: 'yo', + cacheSeconds: 500, + }) ) .expectHeader('cache-control', 'max-age=500') t.create('user can override service cacheSeconds') .get('.json?url=https://example.com/badge&cacheSeconds=1000') .intercept(nock => - nock('https://example.com/') - .get('/badge') - .reply(200, { - schemaVersion: 1, - label: '', - message: 'yo', - cacheSeconds: 500, - }) + nock('https://example.com/').get('/badge').reply(200, { + schemaVersion: 1, + label: '', + message: 'yo', + cacheSeconds: 500, + }) ) .expectHeader('cache-control', 'max-age=1000') t.create('user does not override longer service cacheSeconds') .get('.json?url=https://example.com/badge&cacheSeconds=450') .intercept(nock => - nock('https://example.com/') - .get('/badge') - .reply(200, { - schemaVersion: 1, - label: '', - message: 'yo', - cacheSeconds: 500, - }) + nock('https://example.com/').get('/badge').reply(200, { + schemaVersion: 1, + label: '', + message: 'yo', + cacheSeconds: 500, + }) ) .expectHeader('cache-control', 'max-age=500') t.create('cacheSeconds does not override longer Shields default') .get('.json?url=https://example.com/badge') .intercept(nock => - nock('https://example.com/') - .get('/badge') - .reply(200, { - schemaVersion: 1, - label: '', - message: 'yo', - cacheSeconds: 10, - }) + nock('https://example.com/').get('/badge').reply(200, { + schemaVersion: 1, + label: '', + message: 'yo', + cacheSeconds: 10, + }) ) .expectHeader('cache-control', 'max-age=300') @@ -288,9 +254,7 @@ t.create('Blocked domain') .expectBadge({ label: 'custom badge', message: 'domain is blocked' }) // https://github.com/badges/shields/issues/3780 -t.create('Invalid url') - .get('.json?url=https:/') - .expectBadge({ - label: 'custom badge', - message: 'invalid query parameter: url', - }) +t.create('Invalid url').get('.json?url=https:/').expectBadge({ + label: 'custom badge', + message: 'invalid query parameter: url', +}) diff --git a/services/f-droid/f-droid.service.js b/services/f-droid/f-droid.service.js index ae5f16f2592de317cddd79e55f9356967f40d56c..94519934e1945fe240cd26c310615f9d2e602408 100644 --- a/services/f-droid/f-droid.service.js +++ b/services/f-droid/f-droid.service.js @@ -6,9 +6,7 @@ const { version: versionColor } = require('../color-formatters') const { BaseYamlService, InvalidResponse } = require('..') const schema = Joi.object({ - CurrentVersion: Joi.alternatives() - .try(Joi.string(), Joi.number()) - .required(), + CurrentVersion: Joi.alternatives().try(Joi.string(), Joi.number()).required(), }).required() const queryParamSchema = Joi.object({ diff --git a/services/f-droid/f-droid.tester.js b/services/f-droid/f-droid.tester.js index 39203ca4953ab8dbfa408c20f1c77e24ad70b698..8544eed36efbedf5c5aae6fd619b7c09bc7301c1 100644 --- a/services/f-droid/f-droid.tester.js +++ b/services/f-droid/f-droid.tester.js @@ -108,98 +108,56 @@ const path = '/fdroid/fdroiddata/raw/master/metadata/axp.tool.apkextractor' t.create('Package is found with default metadata format') .get('/v/axp.tool.apkextractor.json') - .intercept(nock => - nock(base) - .get(`${path}.txt`) - .reply(200, testString) - ) + .intercept(nock => nock(base).get(`${path}.txt`).reply(200, testString)) .expectBadge({ label: 'f-droid', message: 'v1.4' }) t.create('Package is found with fallback yml matadata format') .get('/v/axp.tool.apkextractor.json') - .intercept(nock => - nock(base) - .get(`${path}.txt`) - .reply(404) - ) - .intercept(nock => - nock(base) - .get(`${path}.yml`) - .reply(200, testYmlString) - ) + .intercept(nock => nock(base).get(`${path}.txt`).reply(404)) + .intercept(nock => nock(base).get(`${path}.yml`).reply(200, testYmlString)) .expectBadge({ label: 'f-droid', message: 'v1.4' }) t.create('Trailing 0 in yml format') .get('/v/axp.tool.apkextractor.json') + .intercept(nock => nock(base).get(`${path}.txt`).reply(404)) .intercept(nock => - nock(base) - .get(`${path}.txt`) - .reply(404) - ) - .intercept(nock => - nock(base) - .get(`${path}.yml`) - .reply(200, "CurrentVersion: '1.4000'") + nock(base).get(`${path}.yml`).reply(200, "CurrentVersion: '1.4000'") ) .expectBadge({ label: 'f-droid', message: 'v1.4000' }) t.create('Package is found with yml matadata format') .get('/v/axp.tool.apkextractor.json?metadata_format=yml') - .intercept(nock => - nock(base) - .get(`${path}.yml`) - .reply(200, testYmlString) - ) + .intercept(nock => nock(base).get(`${path}.yml`).reply(200, testYmlString)) .expectBadge({ label: 'f-droid', message: 'v1.4' }) t.create('Package is not found with "metadata_format" query parameter') .get('/v/axp.tool.apkextractor.json?metadata_format=yml') - .intercept(nock => - nock(base) - .get(`${path}.yml`) - .reply(404) - ) + .intercept(nock => nock(base).get(`${path}.yml`).reply(404)) .expectBadge({ label: 'f-droid', message: 'app not found' }) t.create('Package is found yml matadata format with missing "CurrentVersion"') .get('/v/axp.tool.apkextractor.json?metadata_format=yml') .intercept(nock => - nock(base) - .get(`${path}.yml`) - .reply(200, 'Categories: System') + nock(base).get(`${path}.yml`).reply(200, 'Categories: System') ) .expectBadge({ label: 'f-droid', message: 'invalid response data' }) t.create('Package is found with bad yml matadata format') .get('/v/axp.tool.apkextractor.json?metadata_format=yml') .intercept(nock => - nock(base) - .get(`${path}.yml`) - .reply(200, '.CurrentVersion: 1.4') + nock(base).get(`${path}.yml`).reply(200, '.CurrentVersion: 1.4') ) .expectBadge({ label: 'f-droid', message: 'invalid response data' }) t.create('Package is not found') .get('/v/axp.tool.apkextractor.json') - .intercept(nock => - nock(base) - .get(`${path}.txt`) - .reply(404) - ) - .intercept(nock => - nock(base) - .get(`${path}.yml`) - .reply(404) - ) + .intercept(nock => nock(base).get(`${path}.txt`).reply(404)) + .intercept(nock => nock(base).get(`${path}.yml`).reply(404)) .expectBadge({ label: 'f-droid', message: 'app not found' }) t.create('The api changed') .get('/v/axp.tool.apkextractor.json?metadata_format=yml') - .intercept(nock => - nock(base) - .get(`${path}.yml`) - .reply(200, '') - ) + .intercept(nock => nock(base).get(`${path}.yml`).reply(200, '')) .expectBadge({ label: 'f-droid', message: 'invalid response data' }) t.create('Package is not found due invalid metadata format') diff --git a/services/gem/gem-downloads.tester.js b/services/gem/gem-downloads.tester.js index c42912ecaaecd5bef5117fa5e0078bf64634c390..bb3ccfed0681927b7b3cca127bfd5d1f3eee60d6 100644 --- a/services/gem/gem-downloads.tester.js +++ b/services/gem/gem-downloads.tester.js @@ -3,12 +3,10 @@ const { isMetric } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('total downloads (valid)') - .get('/dt/rails.json') - .expectBadge({ - label: 'downloads', - message: isMetric, - }) +t.create('total downloads (valid)').get('/dt/rails.json').expectBadge({ + label: 'downloads', + message: isMetric, +}) t.create('total downloads (not found)') .get('/dt/not-a-package.json') diff --git a/services/gem/gem-rank.service.js b/services/gem/gem-rank.service.js index e63470d4137ccb7122f1495003a15aa6eb261758..8855e553218a65004b1380a004b518dbd07c4f1b 100644 --- a/services/gem/gem-rank.service.js +++ b/services/gem/gem-rank.service.js @@ -10,10 +10,7 @@ const keywords = ['ruby'] const totalSchema = Joi.array() .items( Joi.object({ - total_ranking: Joi.number() - .integer() - .min(0) - .allow(null), + total_ranking: Joi.number().integer().min(0).allow(null), }) ) .min(1) @@ -21,10 +18,7 @@ const totalSchema = Joi.array() const dailySchema = Joi.array() .items( Joi.object({ - daily_ranking: Joi.number() - .integer() - .min(0) - .allow(null), + daily_ranking: Joi.number().integer().min(0).allow(null), }) ) .min(1) diff --git a/services/gem/gem-rank.tester.js b/services/gem/gem-rank.tester.js index 5a8bd5b4fc8a0e9add56d1b1ba4efb15fca84468..e0e80ae86b82f3b72890a81ef26510c44c13a8a4 100644 --- a/services/gem/gem-rank.tester.js +++ b/services/gem/gem-rank.tester.js @@ -8,19 +8,15 @@ const isOrdinalNumberDaily = Joi.string().regex( /^[1-9][0-9]*(áµ—Ê°|ˢᵗ|â¿áµˆ|ʳᵈ) daily$/ ) -t.create('total rank (valid)') - .get('/rt/rspec-puppet-facts.json') - .expectBadge({ - label: 'rank', - message: isOrdinalNumber, - }) +t.create('total rank (valid)').get('/rt/rspec-puppet-facts.json').expectBadge({ + label: 'rank', + message: isOrdinalNumber, +}) -t.create('daily rank (valid)') - .get('/rd/rails.json') - .expectBadge({ - label: 'rank', - message: isOrdinalNumberDaily, - }) +t.create('daily rank (valid)').get('/rd/rails.json').expectBadge({ + label: 'rank', + message: isOrdinalNumberDaily, +}) t.create('rank (not found)') .get('/rt/not-a-package.json') diff --git a/services/gem/gem-version.tester.js b/services/gem/gem-version.tester.js index 88caac14f49c45c4f9d9b1e3ff07389e60c79714..53a610a457947a8ae3595909ed7804719876145b 100644 --- a/services/gem/gem-version.tester.js +++ b/services/gem/gem-version.tester.js @@ -3,12 +3,10 @@ const { isVPlusDottedVersionAtLeastOne } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('version (valid)') - .get('/formatador.json') - .expectBadge({ - label: 'gem', - message: isVPlusDottedVersionAtLeastOne, - }) +t.create('version (valid)').get('/formatador.json').expectBadge({ + label: 'gem', + message: isVPlusDottedVersionAtLeastOne, +}) t.create('version (not found)') .get('/not-a-package.json') diff --git a/services/github/auth/acceptor.spec.js b/services/github/auth/acceptor.spec.js index 39a13ec47183ece6b8109b83d693f7657db32be3..cdd2222f2340f4ae0665427a82a154db2986e081 100644 --- a/services/github/auth/acceptor.spec.js +++ b/services/github/auth/acceptor.spec.js @@ -15,11 +15,11 @@ const acceptor = require('./acceptor') const fakeClientId = 'githubdabomb' const fakeShieldsSecret = 'letmeinplz' -describe('Github token acceptor', function() { +describe('Github token acceptor', function () { const oauthHelper = GithubConstellation._createOauthHelper({ private: { gh_client_id: fakeClientId }, }) - before(function() { + before(function () { // Make sure properties exist. // https://github.com/sinonjs/sinon/pull/1557 serverSecrets.shields_ips = undefined @@ -27,22 +27,22 @@ describe('Github token acceptor', function() { sinon.stub(serverSecrets, 'shields_ips').value([]) sinon.stub(serverSecrets, 'shields_secret').value(fakeShieldsSecret) }) - after(function() { + after(function () { sinon.restore() }) let port, baseUrl - beforeEach(async function() { + beforeEach(async function () { port = await portfinder.getPortPromise() baseUrl = `http://127.0.0.1:${port}` }) let camp - beforeEach(async function() { + beforeEach(async function () { camp = Camp.start({ port, hostname: '::' }) await new Promise(resolve => camp.on('listening', () => resolve())) }) - afterEach(async function() { + afterEach(async function () { if (camp) { await new Promise(resolve => camp.close(resolve)) camp = undefined @@ -50,7 +50,7 @@ describe('Github token acceptor', function() { }) let onTokenAccepted - beforeEach(function() { + beforeEach(function () { onTokenAccepted = sinon.stub() acceptor.setRoutes({ server: camp, @@ -59,7 +59,7 @@ describe('Github token acceptor', function() { }) }) - it('should start the OAuth process', async function() { + it('should start the OAuth process', async function () { const res = await got(`${baseUrl}/github-auth`, { followRedirect: false }) expect(res.statusCode).to.equal(302) @@ -72,9 +72,9 @@ describe('Github token acceptor', function() { expect(res.headers.location).to.equal(expectedLocationHeader) }) - describe('Finishing the OAuth process', function() { - context('no code is provided', function() { - it('should return an error', async function() { + describe('Finishing the OAuth process', function () { + context('no code is provided', function () { + it('should return an error', async function () { const res = await got(`${baseUrl}/github-auth/done`) expect(res.body).to.equal( 'GitHub OAuth authentication failed to provide a code.' @@ -85,9 +85,9 @@ describe('Github token acceptor', function() { const fakeCode = '123456789' const fakeAccessToken = 'abcdef' - context('a code is provided', function() { + context('a code is provided', function () { let scope - beforeEach(function() { + beforeEach(function () { nock.enableNetConnect(/127\.0\.0\.1/) scope = nock('https://github.com') @@ -101,24 +101,24 @@ describe('Github token acceptor', function() { }) }) - afterEach(function() { + afterEach(function () { // Make sure other tests will make live requests even when this test // fails. nock.enableNetConnect() }) - afterEach(function() { + afterEach(function () { if (scope) { scope.done() scope = null } }) - afterEach(function() { + afterEach(function () { nock.cleanAll() }) - it('should finish the OAuth process', async function() { + it('should finish the OAuth process', async function () { const form = new FormData() form.append('code', fakeCode) @@ -132,7 +132,7 @@ describe('Github token acceptor', function() { }) }) - it('should add a received token', async function() { + it('should add a received token', async function () { const fakeAccessToken = 'its-my-token' const form = new FormData() form.append('shieldsSecret', fakeShieldsSecret) diff --git a/services/github/auth/admin.spec.js b/services/github/auth/admin.spec.js index 575447d85f4dd6fad1ea486256a3bfb547a70b29..90a81e168c1ed17d16c6b691eedea5ca5c52002d 100644 --- a/services/github/auth/admin.spec.js +++ b/services/github/auth/admin.spec.js @@ -9,14 +9,14 @@ const got = require('../../../core/got-test-client') const GithubApiProvider = require('../github-api-provider') const { setRoutes } = require('./admin') -describe('GitHub admin route', function() { +describe('GitHub admin route', function () { const validCredentials = { username: '', password: '7'.repeat(40), } let sandbox - beforeEach(function() { + beforeEach(function () { sandbox = sinon.createSandbox() // Make this work when there is no `shields_secret` defined. serverSecrets.shields_secret = undefined @@ -24,35 +24,35 @@ describe('GitHub admin route', function() { .stub(serverSecrets, 'shields_secret') .value(validCredentials.password) }) - afterEach(function() { + afterEach(function () { sandbox.restore() }) let port, baseUrl - before(async function() { + before(async function () { port = await portfinder.getPortPromise() baseUrl = `http://127.0.0.1:${port}` }) let camp - before(async function() { + before(async function () { camp = Camp.start({ port, hostname: '::' }) await new Promise(resolve => camp.on('listening', () => resolve())) }) - after(async function() { + after(async function () { if (camp) { await new Promise(resolve => camp.close(resolve)) camp = undefined } }) - before(function() { + before(function () { const apiProvider = new GithubApiProvider({ withPooling: true }) setRoutes(apiProvider, camp) }) - context('the password is correct', function() { - it('returns a valid JSON response', async function() { + context('the password is correct', function () { + it('returns a valid JSON response', async function () { const { username, password } = validCredentials const { statusCode, body } = await got(`${baseUrl}/$github-auth/tokens`, { username, diff --git a/services/github/github-api-provider.integration.js b/services/github/github-api-provider.integration.js index d4e98eb0b69b9f3a81a1abc8bdb69431e5170c66..d7b43f274e443a825b965b37645f9097a4256a86 100644 --- a/services/github/github-api-provider.integration.js +++ b/services/github/github-api-provider.integration.js @@ -4,12 +4,12 @@ const { expect } = require('chai') const config = require('config').util.toObject() const GithubApiProvider = require('./github-api-provider') -describe('Github API provider', function() { +describe('Github API provider', function () { const baseUrl = process.env.GITHUB_URL || 'https://api.github.com' const reserveFraction = 0.333 let token - before(function() { + before(function () { token = config.private.gh_token if (!token) { throw Error('The integration tests require a gh_token to be set') @@ -18,8 +18,8 @@ describe('Github API provider', function() { let githubApiProvider - context('without token pool', function() { - before(function() { + context('without token pool', function () { + before(function () { githubApiProvider = new GithubApiProvider({ baseUrl, withPooling: false, @@ -28,7 +28,7 @@ describe('Github API provider', function() { }) }) - it('should be able to run 10 requests', async function() { + it('should be able to run 10 requests', async function () { this.timeout('20s') for (let i = 0; i < 10; ++i) { await githubApiProvider.requestAsPromise( @@ -40,9 +40,9 @@ describe('Github API provider', function() { }) }) - context('with token pool', function() { + context('with token pool', function () { let githubApiProvider - before(function() { + before(function () { githubApiProvider = new GithubApiProvider({ baseUrl, withPooling: true, @@ -62,14 +62,14 @@ describe('Github API provider', function() { headers.push(res.headers) } - before('should be able to run 10 requests', async function() { + before('should be able to run 10 requests', async function () { this.timeout('20s') for (let i = 0; i < 10; ++i) { await performOneRequest() } }) - it('should decrement the limit remaining with each request', function() { + it('should decrement the limit remaining with each request', function () { for (let i = 1; i < headers.length; ++i) { const current = headers[i] const previous = headers[i - 1] @@ -79,7 +79,7 @@ describe('Github API provider', function() { } }) - it.skip('should update the token with the final limit remaining and reset time', function() { + it.skip('should update the token with the final limit remaining and reset time', function () { const lastHeaders = headers.slice(-1)[0] const reserve = reserveFraction * +lastHeaders['x-ratelimit-limit'] const usesRemaining = +lastHeaders['x-ratelimit-remaining'] - reserve diff --git a/services/github/github-api-provider.spec.js b/services/github/github-api-provider.spec.js index f67e788424c7b0fb04d61da06778233e279cb9ef..cd2d173f8ea43fff2c2414d9bb9215fc6d6a501b 100644 --- a/services/github/github-api-provider.spec.js +++ b/services/github/github-api-provider.spec.js @@ -4,12 +4,12 @@ const { expect } = require('chai') const sinon = require('sinon') const GithubApiProvider = require('./github-api-provider') -describe('Github API provider', function() { +describe('Github API provider', function () { const baseUrl = 'https://github-api.example.com' const reserveFraction = 0.333 let mockStandardToken, mockSearchToken, mockGraphqlToken, provider - beforeEach(function() { + beforeEach(function () { provider = new GithubApiProvider({ baseUrl, reserveFraction }) mockStandardToken = { update: sinon.spy(), invalidate: sinon.spy() } @@ -22,11 +22,11 @@ describe('Github API provider', function() { sinon.stub(provider.graphqlTokens, 'next').returns(mockGraphqlToken) }) - context('a search API request', function() { + context('a search API request', function () { const mockRequest = (options, callback) => { callback() } - it('should obtain an appropriate token', function(done) { + it('should obtain an appropriate token', function (done) { provider.request(mockRequest, '/search', {}, (err, res, buffer) => { expect(err).to.be.undefined expect(provider.searchTokens.next).to.have.been.calledOnce @@ -37,11 +37,11 @@ describe('Github API provider', function() { }) }) - context('a graphql API request', function() { + context('a graphql API request', function () { const mockRequest = (options, callback) => { callback() } - it('should obtain an appropriate token', function(done) { + it('should obtain an appropriate token', function (done) { provider.request(mockRequest, '/graphql', {}, (err, res, buffer) => { expect(err).to.be.undefined expect(provider.searchTokens.next).not.to.have.been.called @@ -52,11 +52,11 @@ describe('Github API provider', function() { }) }) - context('a core API request', function() { + context('a core API request', function () { const mockRequest = (options, callback) => { callback() } - it('should obtain an appropriate token', function(done) { + it('should obtain an appropriate token', function (done) { provider.request(mockRequest, '/repo', {}, (err, res, buffer) => { expect(err).to.be.undefined expect(provider.searchTokens.next).not.to.have.been.called @@ -67,7 +67,7 @@ describe('Github API provider', function() { }) }) - context('a valid V3 API response', function() { + context('a valid V3 API response', function () { const rateLimit = 12500 const remaining = 7955 const nextReset = 123456789 @@ -85,7 +85,7 @@ describe('Github API provider', function() { callback(null, mockResponse, mockBuffer) } - it('should invoke the callback', function(done) { + it('should invoke the callback', function (done) { provider.request(mockRequest, '/foo', {}, (err, res, buffer) => { expect(err).to.equal(null) expect(Object.is(res, mockResponse)).to.be.true @@ -94,7 +94,7 @@ describe('Github API provider', function() { }) }) - it('should update the token with the expected values', function(done) { + it('should update the token with the expected values', function (done) { provider.request(mockRequest, '/foo', {}, (err, res, buffer) => { expect(err).to.equal(null) const expectedUsesRemaining = @@ -109,7 +109,7 @@ describe('Github API provider', function() { }) }) - context('a valid V4 API response', function() { + context('a valid V4 API response', function () { const rateLimit = 12500 const remaining = 7955 const nextReset = 123456789 @@ -133,7 +133,7 @@ describe('Github API provider', function() { callback(null, mockResponse, mockBuffer) } - it('should invoke the callback', function(done) { + it('should invoke the callback', function (done) { provider.request(mockRequest, '/graphql', {}, (err, res, buffer) => { expect(err).to.equal(null) expect(Object.is(res, mockResponse)).to.be.true @@ -142,7 +142,7 @@ describe('Github API provider', function() { }) }) - it('should update the token with the expected values', function(done) { + it('should update the token with the expected values', function (done) { provider.request(mockRequest, '/graphql', {}, (err, res, buffer) => { expect(err).to.equal(null) const expectedUsesRemaining = @@ -157,7 +157,7 @@ describe('Github API provider', function() { }) }) - context('an unauthorized response', function() { + context('an unauthorized response', function () { const mockResponse = { statusCode: 401 } const mockBuffer = Buffer.alloc(0) const mockRequest = (...args) => { @@ -165,7 +165,7 @@ describe('Github API provider', function() { callback(null, mockResponse, mockBuffer) } - it('should invoke the callback and update the token with the expected values', function(done) { + it('should invoke the callback and update the token with the expected values', function (done) { provider.request(mockRequest, '/foo', {}, (err, res, buffer) => { expect(err).to.equal(null) expect(mockStandardToken.invalidate).to.have.been.calledOnce @@ -175,13 +175,13 @@ describe('Github API provider', function() { }) }) - context('a connection error', function() { + context('a connection error', function () { const mockRequest = (...args) => { const callback = args.pop() callback(Error('connection timeout')) } - it('should pass the error to the callback', function(done) { + it('should pass the error to the callback', function (done) { provider.request(mockRequest, '/foo', {}, (err, res, buffer) => { expect(err).to.be.an.instanceof(Error) expect(err.message).to.equal('connection timeout') diff --git a/services/github/github-commit-activity.tester.js b/services/github/github-commit-activity.tester.js index 701d3723e18ceeb65625262342e7af0523e42eae..03dc477360a15d2786c0f65eb9a1b359e87063d6 100644 --- a/services/github/github-commit-activity.tester.js +++ b/services/github/github-commit-activity.tester.js @@ -3,19 +3,15 @@ const { isMetricOverTimePeriod } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('commit activity (1 year)') - .get('/y/eslint/eslint.json') - .expectBadge({ - label: 'commit activity', - message: isMetricOverTimePeriod, - }) +t.create('commit activity (1 year)').get('/y/eslint/eslint.json').expectBadge({ + label: 'commit activity', + message: isMetricOverTimePeriod, +}) -t.create('commit activity (1 month)') - .get('/m/eslint/eslint.json') - .expectBadge({ - label: 'commit activity', - message: isMetricOverTimePeriod, - }) +t.create('commit activity (1 month)').get('/m/eslint/eslint.json').expectBadge({ + label: 'commit activity', + message: isMetricOverTimePeriod, +}) t.create('commit activity (4 weeks)') .get('/4w/eslint/eslint.json') @@ -24,12 +20,10 @@ t.create('commit activity (4 weeks)') message: isMetricOverTimePeriod, }) -t.create('commit activity (1 week)') - .get('/w/eslint/eslint.json') - .expectBadge({ - label: 'commit activity', - message: isMetricOverTimePeriod, - }) +t.create('commit activity (1 week)').get('/w/eslint/eslint.json').expectBadge({ + label: 'commit activity', + message: isMetricOverTimePeriod, +}) t.create('commit activity (repo not found)') .get('/w/badges/helmets.json') diff --git a/services/github/github-common-release.js b/services/github/github-common-release.js index 63a91265d0aeda6ec9aebb6c5c6673b4f414b963..ca958deb52ea4419b043492b6a5d884cec77d559 100644 --- a/services/github/github-common-release.js +++ b/services/github/github-common-release.js @@ -66,9 +66,7 @@ function getLatestRelease({ releases, sort, includePrereleases }) { const queryParamSchema = Joi.object({ include_prereleases: Joi.equal(''), - sort: Joi.string() - .valid('date', 'semver') - .default('date'), + sort: Joi.string().valid('date', 'semver').default('date'), }).required() // Fetch the latest release as defined by query params diff --git a/services/github/github-common-release.spec.js b/services/github/github-common-release.spec.js index 28e40d731b33204f076a176a5f26ab48bd5b9847..0ecd46fbe4afcd9a2d755708acb74af8958dbaad 100644 --- a/services/github/github-common-release.spec.js +++ b/services/github/github-common-release.spec.js @@ -3,7 +3,7 @@ const { test, given } = require('sazerac') const { _getLatestRelease } = require('./github-common-release') -describe('GithubRelease', function() { +describe('GithubRelease', function () { test(_getLatestRelease, () => { const releaseFixture = [ { tag_name: 'cheese', prerelease: false }, // any old string diff --git a/services/github/github-contributors.tester.js b/services/github/github-contributors.tester.js index bc5cc3ace9887fdf60a59969e8baff1c5acbec82..15bebff1019e4ee402eef27cb34e94d9e171ad3e 100644 --- a/services/github/github-contributors.tester.js +++ b/services/github/github-contributors.tester.js @@ -3,12 +3,10 @@ const t = (module.exports = require('../tester').createServiceTester()) const { isMetric } = require('../test-validators') -t.create('Contributors') - .get('/contributors/badges/shields.json') - .expectBadge({ - label: 'contributors', - message: isMetric, - }) +t.create('Contributors').get('/contributors/badges/shields.json').expectBadge({ + label: 'contributors', + message: isMetric, +}) t.create('1 contributor') .get('/contributors/badges/shields-tests.json') diff --git a/services/github/github-deployments.spec.js b/services/github/github-deployments.spec.js index f9f492f358ba402cdd60d16c76b2c3194b05603b..a259a456faa2b5a0fb37f6064d4b4af2b3d5f908 100644 --- a/services/github/github-deployments.spec.js +++ b/services/github/github-deployments.spec.js @@ -3,7 +3,7 @@ const { test, given } = require('sazerac') const GithubDeployments = require('./github-deployments.service') -describe('GithubDeployments', function() { +describe('GithubDeployments', function () { test(GithubDeployments.render, () => { given({ state: 'SUCCESS', diff --git a/services/github/github-followers.tester.js b/services/github/github-followers.tester.js index 8ad5d8dbb29253e21523bae7b854b3052afb3ff9..c0bbfeb7e73c3d73661926bff75848a493013cbd 100644 --- a/services/github/github-followers.tester.js +++ b/services/github/github-followers.tester.js @@ -3,16 +3,12 @@ const { isMetric } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('Followers') - .get('/webcaetano.json') - .expectBadge({ - label: 'followers', - message: isMetric, - }) +t.create('Followers').get('/webcaetano.json').expectBadge({ + label: 'followers', + message: isMetric, +}) -t.create('Followers (user not found)') - .get('/PyvesB2.json') - .expectBadge({ - label: 'followers', - message: 'user not found', - }) +t.create('Followers (user not found)').get('/PyvesB2.json').expectBadge({ + label: 'followers', + message: 'user not found', +}) diff --git a/services/github/github-forks.tester.js b/services/github/github-forks.tester.js index 4b733328740c8e651606459765effdfa8c68ab10..9ebb77bb58e4263b476be8ab33137d4eda7dfa2a 100644 --- a/services/github/github-forks.tester.js +++ b/services/github/github-forks.tester.js @@ -14,9 +14,7 @@ t.create('Forks') ], }) -t.create('Forks (repo not found)') - .get('/badges/helmets.json') - .expectBadge({ - label: 'forks', - message: 'repo not found', - }) +t.create('Forks (repo not found)').get('/badges/helmets.json').expectBadge({ + label: 'forks', + message: 'repo not found', +}) diff --git a/services/github/github-go-mod.tester.js b/services/github/github-go-mod.tester.js index 9780d6c88ce8a46553bc36efc6073fbec2aab28e..39d9865e6651ef888390fd4bc77507f012800196 100644 --- a/services/github/github-go-mod.tester.js +++ b/services/github/github-go-mod.tester.js @@ -3,12 +3,10 @@ const { isVPlusDottedVersionAtLeastOne } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('Go version') - .get('/gohugoio/hugo.json') - .expectBadge({ - label: 'Go', - message: isVPlusDottedVersionAtLeastOne, - }) +t.create('Go version').get('/gohugoio/hugo.json').expectBadge({ + label: 'Go', + message: isVPlusDottedVersionAtLeastOne, +}) t.create('Go version (from branch)') .get('/gohugoio/hugo/master.json') diff --git a/services/github/github-hacktoberfest.spec.js b/services/github/github-hacktoberfest.spec.js index b62bbe765a61bbd91a6ce571e856010f33ba16be..4f594f062e6c55c9f4fd0637802614c4e5b9c4b0 100644 --- a/services/github/github-hacktoberfest.spec.js +++ b/services/github/github-hacktoberfest.spec.js @@ -3,7 +3,7 @@ const { test, given } = require('sazerac') const GitHubHacktoberfest = require('./github-hacktoberfest.service') -describe('GitHubHacktoberfest', function() { +describe('GitHubHacktoberfest', function () { test(GitHubHacktoberfest.render, () => { given({ daysLeft: -1, diff --git a/services/github/github-issue-detail.service.js b/services/github/github-issue-detail.service.js index 145028a46c0dec2a795507231c5225b03def184f..7e344a49fe48f9fba798f4892a930d88f912327c 100644 --- a/services/github/github-issue-detail.service.js +++ b/services/github/github-issue-detail.service.js @@ -21,9 +21,7 @@ const commonSchemaFields = { const stateMap = { schema: Joi.object({ ...commonSchemaFields, - state: Joi.string() - .allow('open', 'closed') - .required(), + state: Joi.string().allow('open', 'closed').required(), merged_at: Joi.string().allow(null), }).required(), transform: ({ json }) => ({ diff --git a/services/github/github-issue-detail.spec.js b/services/github/github-issue-detail.spec.js index 54ab92f12d46ff2a02ec741c209bd87b9fc05406..3d5ef086f30dd32e30f126a4ee9e0c1bcb44e624 100644 --- a/services/github/github-issue-detail.spec.js +++ b/services/github/github-issue-detail.spec.js @@ -8,7 +8,7 @@ const { InvalidResponse } = require('..') const GithubIssueDetail = require('./github-issue-detail.service') const { stateColor, commentsColor } = require('./github-helpers') -describe('GithubIssueDetail', function() { +describe('GithubIssueDetail', function () { test(GithubIssueDetail.render, () => { given({ property: 'state', @@ -182,8 +182,8 @@ describe('GithubIssueDetail', function() { }) }) - context('transform()', function() { - it('throws InvalidResponse error when issue has no labels', function() { + context('transform()', function () { + it('throws InvalidResponse error when issue has no labels', function () { try { GithubIssueDetail.prototype.transform({ property: 'label', diff --git a/services/github/github-issues.tester.js b/services/github/github-issues.tester.js index 5e88f6d124c01380d8e6d976782d5f102fd88f49..c8e380734fbd9c76f7c57643a2e74b8f409aeec0 100644 --- a/services/github/github-issues.tester.js +++ b/services/github/github-issues.tester.js @@ -50,12 +50,10 @@ t.create('GitHub closed issues raw') message: isMetric, }) -t.create('GitHub open issues') - .get('/issues/badges/shields.json') - .expectBadge({ - label: 'issues', - message: isMetricOpenIssues, - }) +t.create('GitHub open issues').get('/issues/badges/shields.json').expectBadge({ + label: 'issues', + message: isMetricOpenIssues, +}) t.create('GitHub open issues raw') .get('/issues-raw/badges/shields.json') diff --git a/services/github/github-labels.service.js b/services/github/github-labels.service.js index e12942f53f58e0748c3f6f44945f0489cc93e17a..056c2ffda4b3e977ff05e1e798d1b534351b188a 100644 --- a/services/github/github-labels.service.js +++ b/services/github/github-labels.service.js @@ -5,9 +5,7 @@ const { GithubAuthV3Service } = require('./github-auth-service') const { documentation, errorMessagesFor } = require('./github-helpers') const schema = Joi.object({ - color: Joi.string() - .hex() - .required(), + color: Joi.string().hex().required(), }).required() module.exports = class GithubLabels extends GithubAuthV3Service { diff --git a/services/github/github-labels.tester.js b/services/github/github-labels.tester.js index 1fdde71604af755cf8fca806bf0140cf7722be68..1cf89586cf731dc53f0a5e36308d2c0d88604284 100644 --- a/services/github/github-labels.tester.js +++ b/services/github/github-labels.tester.js @@ -2,12 +2,10 @@ const t = (module.exports = require('../tester').createServiceTester()) -t.create('labels') - .get('/badges/shields/bug.json') - .expectBadge({ - message: 'bug', - color: '#e11d21', - }) +t.create('labels').get('/badges/shields/bug.json').expectBadge({ + message: 'bug', + color: '#e11d21', +}) t.create('labels (repo or label not found)') .get('/badges/shields/somenonexistentlabelthatwouldneverexist.json') diff --git a/services/github/github-language-count.tester.js b/services/github/github-language-count.tester.js index 6de2a888f5bcfe738a1f2920d9878e36808d0857..1f9c7c2a7dd600c8c3042af1231a0572107a36eb 100644 --- a/services/github/github-language-count.tester.js +++ b/services/github/github-language-count.tester.js @@ -3,14 +3,10 @@ const Joi = require('@hapi/joi') const t = (module.exports = require('../tester').createServiceTester()) -t.create('language count') - .get('/badges/shields.json') - .expectBadge({ - label: 'languages', - message: Joi.number() - .integer() - .positive(), - }) +t.create('language count').get('/badges/shields.json').expectBadge({ + label: 'languages', + message: Joi.number().integer().positive(), +}) t.create('language count (empty repo)') .get('/pyvesb/emptyrepo.json') diff --git a/services/github/github-lerna-json.tester.js b/services/github/github-lerna-json.tester.js index 82119de29f5abe7371748429878bfc4e16337f2e..99b74ddb78db3fad90df28d0d3ba5e8cfb9bfb92 100644 --- a/services/github/github-lerna-json.tester.js +++ b/services/github/github-lerna-json.tester.js @@ -3,12 +3,10 @@ const { isSemver } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('Lerna version') - .get('/babel/babel.json') - .expectBadge({ - label: 'lerna', - message: isSemver, - }) +t.create('Lerna version').get('/babel/babel.json').expectBadge({ + label: 'lerna', + message: isSemver, +}) t.create('Lerna version (independent)') .get('/jneander/jneander.json') @@ -17,12 +15,10 @@ t.create('Lerna version (independent)') message: 'independent', }) -t.create('Lerna version (branch)') - .get('/babel/babel/master.json') - .expectBadge({ - label: 'lerna@master', - message: isSemver, - }) +t.create('Lerna version (branch)').get('/babel/babel/master.json').expectBadge({ + label: 'lerna@master', + message: isSemver, +}) t.create('Lerna version (lerna.json missing)') .get('/PyvesB/empty-repo.json') diff --git a/services/github/github-milestone-detail.service.js b/services/github/github-milestone-detail.service.js index 1cbbf6cd894e857446e0a5fb9fc776b2e6603179..8f39309327330c67be7094f1348c292e778d21d7 100644 --- a/services/github/github-milestone-detail.service.js +++ b/services/github/github-milestone-detail.service.js @@ -74,8 +74,9 @@ module.exports = class GithubMilestoneDetail extends GithubAuthV3Service { label = 'issues' break case 'progress': - milestoneMetric = `${milestone.closed_issues}/${milestone.open_issues + - milestone.closed_issues}` + milestoneMetric = `${milestone.closed_issues}/${ + milestone.open_issues + milestone.closed_issues + }` color = 'blue' break case 'progress-percent': diff --git a/services/github/github-package-json.tester.js b/services/github/github-package-json.tester.js index 9349b85924831327768d0ae830a704b95b729672..87e5137c9f13007e967979cb7c8146d4b64001dd 100644 --- a/services/github/github-package-json.tester.js +++ b/services/github/github-package-json.tester.js @@ -11,12 +11,10 @@ const t = (module.exports = new ServiceTester({ pathPrefix: '/github/package-json', })) -t.create('Package version') - .get('/v/badges/shields.json') - .expectBadge({ - label: 'version', - message: isSemver, - }) +t.create('Package version').get('/v/badges/shields.json').expectBadge({ + label: 'version', + message: isSemver, +}) t.create('Package version (repo not found)') .get('/v/badges/helmets.json') diff --git a/services/github/github-release.tester.js b/services/github/github-release.tester.js index 7042c1f7f835e77957411e22d18070c9af19ecc2..8996a2b2eaf9fa7ff02f863d02369da1af33468c 100644 --- a/services/github/github-release.tester.js +++ b/services/github/github-release.tester.js @@ -19,9 +19,7 @@ t.create('Prerelease') .expectBadge({ label: 'release', message: isSemver, - color: Joi.string() - .allow('blue', 'orange') - .required(), + color: Joi.string().allow('blue', 'orange').required(), }) t.create('Release (No releases)') diff --git a/services/github/github-repo-size.tester.js b/services/github/github-repo-size.tester.js index cc55e28378dbd74e548ec691f8ac5d2df712a151..5d1e43da211716901b247329dc16964c9ee09605 100644 --- a/services/github/github-repo-size.tester.js +++ b/services/github/github-repo-size.tester.js @@ -3,12 +3,10 @@ const { isFileSize } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('repository size') - .get('/badges/shields.json') - .expectBadge({ - label: 'repo size', - message: isFileSize, - }) +t.create('repository size').get('/badges/shields.json').expectBadge({ + label: 'repo size', + message: isFileSize, +}) t.create('repository size (repo not found)') .get('/badges/helmets.json') diff --git a/services/github/github-stars.tester.js b/services/github/github-stars.tester.js index 599c7aa469755d7316a02c883783c5d79fa6f7e3..fda46a39d1c276e4e5b43853395fdaa60393a781 100644 --- a/services/github/github-stars.tester.js +++ b/services/github/github-stars.tester.js @@ -14,12 +14,10 @@ t.create('Stars') ], }) -t.create('Stars (repo not found)') - .get('/badges/helmets.json') - .expectBadge({ - label: 'stars', - message: 'repo not found', - }) +t.create('Stars (repo not found)').get('/badges/helmets.json').expectBadge({ + label: 'stars', + message: 'repo not found', +}) // https://github.com/badges/shields/issues/4982 // It doesn't seem important that this work with trailing spaces, though if it diff --git a/services/github/github-tag.spec.js b/services/github/github-tag.spec.js index b03184199ec9ba845780ed0a9bab3eb4fde5bb6e..88ebf8b83889aa35f15f2adf513a01e670c28149 100644 --- a/services/github/github-tag.spec.js +++ b/services/github/github-tag.spec.js @@ -3,7 +3,7 @@ const { test, given } = require('sazerac') const { GithubTag } = require('./github-tag.service') -describe('GithubTag', function() { +describe('GithubTag', function () { test(GithubTag.getLatestTag, () => { const tagFixture = [ 'cheese', // any old string diff --git a/services/github/github-tag.tester.js b/services/github/github-tag.tester.js index 50f1e93c00a79e493e52b1b4bf50b6940eb7d69f..1bbff0eaf0b73ff18f9b0b56016137be20511ce6 100644 --- a/services/github/github-tag.tester.js +++ b/services/github/github-tag.tester.js @@ -19,9 +19,7 @@ t.create('Tag (inc pre-release)') .expectBadge({ label: 'tag', message: isSemver, - color: Joi.string() - .allow('blue', 'orange') - .required(), + color: Joi.string().allow('blue', 'orange').required(), }) t.create('Tag (no tags)') diff --git a/services/github/github-watchers.tester.js b/services/github/github-watchers.tester.js index 814c7d06982fbfc78ed32058cdeb1bb77d2e1e64..0713b5013388645210422975f7826381186ab599 100644 --- a/services/github/github-watchers.tester.js +++ b/services/github/github-watchers.tester.js @@ -7,18 +7,14 @@ t.create('Watchers') .get('/badges/shields.json') .expectBadge({ label: 'watchers', - message: Joi.number() - .integer() - .positive(), + message: Joi.number().integer().positive(), link: [ 'https://github.com/badges/shields', 'https://github.com/badges/shields/watchers', ], }) -t.create('Watchers (repo not found)') - .get('/badges/helmets.json') - .expectBadge({ - label: 'watchers', - message: 'repo not found', - }) +t.create('Watchers (repo not found)').get('/badges/helmets.json').expectBadge({ + label: 'watchers', + message: 'repo not found', +}) diff --git a/services/gitlab/gitlab-pipeline-status.tester.js b/services/gitlab/gitlab-pipeline-status.tester.js index 2f0e33da11b04ed7045d50daebfbdb108be7edab..3831990c9f427b56c7ca21b1d8d4399060e7a466 100644 --- a/services/gitlab/gitlab-pipeline-status.tester.js +++ b/services/gitlab/gitlab-pipeline-status.tester.js @@ -3,12 +3,10 @@ const { isBuildStatus } = require('../build-status') const t = (module.exports = require('../tester').createServiceTester()) -t.create('Pipeline status') - .get('/gitlab-org/gitlab.json') - .expectBadge({ - label: 'build', - message: isBuildStatus, - }) +t.create('Pipeline status').get('/gitlab-org/gitlab.json').expectBadge({ + label: 'build', + message: isBuildStatus, +}) t.create('Pipeline status (branch)') .get('/gitlab-org/gitlab/v10.7.6.json') diff --git a/services/gitter/gitter.tester.js b/services/gitter/gitter.tester.js index 84351df21234f300cfc5a1af2c12096ceafa7326..488c6224e28df255782f4f0e984676659872a900 100644 --- a/services/gitter/gitter.tester.js +++ b/services/gitter/gitter.tester.js @@ -2,9 +2,7 @@ const t = (module.exports = require('../tester').createServiceTester()) -t.create('on gitter') - .get('/nwjs/nw.js.json') - .expectBadge({ - label: 'chat', - message: 'on gitter', - }) +t.create('on gitter').get('/nwjs/nw.js.json').expectBadge({ + label: 'chat', + message: 'on gitter', +}) diff --git a/services/gratipay/gratipay.tester.js b/services/gratipay/gratipay.tester.js index 522ef69011de63718aa81ccfb71f4ef410756178..57a7130fa722d391daf6f82f99cbd2946d62fca3 100644 --- a/services/gratipay/gratipay.tester.js +++ b/services/gratipay/gratipay.tester.js @@ -7,9 +7,7 @@ const t = (module.exports = new ServiceTester({ title: 'Gratipay', })) -t.create('Receiving') - .get('/Gratipay.json') - .expectBadge({ - label: 'gratipay', - message: 'no longer available', - }) +t.create('Receiving').get('/Gratipay.json').expectBadge({ + label: 'gratipay', + message: 'no longer available', +}) diff --git a/services/hackage/hackage-version.tester.js b/services/hackage/hackage-version.tester.js index b1092ef402f20e9eef1d642040810c40b4266c4e..5349195ccd6da329c058cdc5daa2867554b57636 100644 --- a/services/hackage/hackage-version.tester.js +++ b/services/hackage/hackage-version.tester.js @@ -3,12 +3,10 @@ const { isVPlusDottedVersionAtLeastOne } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('hackage version (valid)') - .get('/lens.json') - .expectBadge({ - label: 'hackage', - message: isVPlusDottedVersionAtLeastOne, - }) +t.create('hackage version (valid)').get('/lens.json').expectBadge({ + label: 'hackage', + message: isVPlusDottedVersionAtLeastOne, +}) t.create('hackage version (not found)') .get('/not-a-package.json') diff --git a/services/hexpm/hexpm.service.js b/services/hexpm/hexpm.service.js index 457ee9ad9b5bed666adc961574fb619fb3b60f2e..9661e22dfc77e5d45a3d480744eea107221d8ca8 100644 --- a/services/hexpm/hexpm.service.js +++ b/services/hexpm/hexpm.service.js @@ -8,15 +8,9 @@ const { BaseJsonService } = require('..') const hexSchema = Joi.object({ downloads: Joi.object({ // these keys may or may not exist - all: Joi.number() - .integer() - .default(0), - week: Joi.number() - .integer() - .default(0), - day: Joi.number() - .integer() - .default(0), + all: Joi.number().integer().default(0), + week: Joi.number().integer().default(0), + day: Joi.number().integer().default(0), }).required(), meta: Joi.object({ licenses: Joi.array().required(), diff --git a/services/hexpm/hexpm.tester.js b/services/hexpm/hexpm.tester.js index 0ef89e35f11c01993679af6842a0e10f308313d4..8c1f1b4c26562f91f0950640692958840bf0d1b4 100644 --- a/services/hexpm/hexpm.tester.js +++ b/services/hexpm/hexpm.tester.js @@ -45,13 +45,11 @@ t.create('version (not found)') .get('/v/this-package-does-not-exist.json') .expectBadge({ label: 'hex', message: 'not found' }) -t.create('license') - .get('/l/cowboy.json') - .expectBadge({ - label: 'license', - message: Joi.string().required(), - color: 'blue', - }) +t.create('license').get('/l/cowboy.json').expectBadge({ + label: 'license', + message: Joi.string().required(), + color: 'blue', +}) t.create('license (multiple licenses)') .get('/l/cowboy.json') diff --git a/services/homebrew/homebrew-cask.tester.js b/services/homebrew/homebrew-cask.tester.js index 95deb03812edb9792d71e3c4b6af1ed1b2d8d00a..c192510cf7a4673e363bac80a08905567a017e2c 100644 --- a/services/homebrew/homebrew-cask.tester.js +++ b/services/homebrew/homebrew-cask.tester.js @@ -3,12 +3,10 @@ const { isVPlusTripleDottedVersion } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('homebrew cask (valid)') - .get('/iterm2.json') - .expectBadge({ - label: 'homebrew cask', - message: isVPlusTripleDottedVersion, - }) +t.create('homebrew cask (valid)').get('/iterm2.json').expectBadge({ + label: 'homebrew cask', + message: isVPlusTripleDottedVersion, +}) t.create('homebrew cask (valid)') .get('/iterm2.json') diff --git a/services/homebrew/homebrew.tester.js b/services/homebrew/homebrew.tester.js index 0abbddfa94b36ae0efac8d6dd9522da08ed1cc76..13fbd91b4e01fa34b01743f7a187e06b772248a2 100644 --- a/services/homebrew/homebrew.tester.js +++ b/services/homebrew/homebrew.tester.js @@ -3,12 +3,10 @@ const { isVPlusTripleDottedVersion } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('homebrew (valid)') - .get('/cake.json') - .expectBadge({ - label: 'homebrew', - message: isVPlusTripleDottedVersion, - }) +t.create('homebrew (valid)').get('/cake.json').expectBadge({ + label: 'homebrew', + message: isVPlusTripleDottedVersion, +}) t.create('homebrew (valid)') .get('/cake.json') diff --git a/services/hsts/hsts.tester.js b/services/hsts/hsts.tester.js index fffc9b1a62a36588c0f32c462a901b0574132be2..ce04eb25906bb063196f8e0d0c0f99324a7c9b16 100644 --- a/services/hsts/hsts.tester.js +++ b/services/hsts/hsts.tester.js @@ -3,13 +3,11 @@ const t = (module.exports = require('../tester').createServiceTester()) const label = 'hsts preloaded' -t.create('gets the hsts status of github') - .get('/github.com.json') - .expectBadge({ - label, - message: 'yes', - color: 'brightgreen', - }) +t.create('gets the hsts status of github').get('/github.com.json').expectBadge({ + label, + message: 'yes', + color: 'brightgreen', +}) t.create('gets the hsts status of httpforever') .get('/httpforever.com.json') diff --git a/services/itunes/itunes.tester.js b/services/itunes/itunes.tester.js index 54a5a8b568f5eb562179c3b4bfb8d44694537a4e..cc34225498118a52e71cf7e82aeed7c98d5ad61e 100644 --- a/services/itunes/itunes.tester.js +++ b/services/itunes/itunes.tester.js @@ -3,12 +3,10 @@ const { isVPlusDottedVersionAtLeastOne } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('iTunes version (valid)') - .get('/324684580.json') - .expectBadge({ - label: 'itunes app store', - message: isVPlusDottedVersionAtLeastOne, - }) +t.create('iTunes version (valid)').get('/324684580.json').expectBadge({ + label: 'itunes app store', + message: isVPlusDottedVersionAtLeastOne, +}) t.create('iTunes version (not found)') .get('/9.json') diff --git a/services/jenkins/jenkins-build.spec.js b/services/jenkins/jenkins-build.spec.js index 411436a8a671c83f4196c3bd1cc980c52cb37cbb..6223e51eaa6068f740489bc5c67e36f6d90c15ab 100644 --- a/services/jenkins/jenkins-build.spec.js +++ b/services/jenkins/jenkins-build.spec.js @@ -7,7 +7,7 @@ const { renderBuildStatusBadge } = require('../build-status') const { cleanUpNockAfterEach, defaultContext } = require('../test-helpers') const JenkinsBuild = require('./jenkins-build.service') -describe('JenkinsBuild', function() { +describe('JenkinsBuild', function () { test(JenkinsBuild.prototype.transform, () => { forCases([ given({ json: { color: 'red_anime' } }), @@ -58,7 +58,7 @@ describe('JenkinsBuild', function() { ) }) - describe('auth', function() { + describe('auth', function () { cleanUpNockAfterEach() const user = 'admin' @@ -77,7 +77,7 @@ describe('JenkinsBuild', function() { }, } - it('sends the auth information as configured', async function() { + it('sends the auth information as configured', async function () { const scope = nock('https://jenkins.ubuntu.com') .get('/server/job/curtin-vmtest-daily-x/api/json?tree=color') // This ensures that the expected credentials are actually being sent with the HTTP request. diff --git a/services/jenkins/jenkins-common.spec.js b/services/jenkins/jenkins-common.spec.js index 914690336cb3a3245170a3e0934b45adab664a00..8a639a1ee55fb2e05223871e58978a8a1007cae0 100644 --- a/services/jenkins/jenkins-common.spec.js +++ b/services/jenkins/jenkins-common.spec.js @@ -2,9 +2,9 @@ const { expect } = require('chai') const { buildRedirectUrl, buildUrl } = require('./jenkins-common') -describe('jenkins-common', function() { - describe('buildUrl', function() { - it('returns the json api url', function() { +describe('jenkins-common', function () { + describe('buildUrl', function () { + it('returns the json api url', function () { const actualResult = buildUrl({ jobUrl: 'https://ci.eclipse.org/jgit/job/jgit', }) @@ -14,7 +14,7 @@ describe('jenkins-common', function() { ) }) - it('returns the json api url including a plugin name', function() { + it('returns the json api url including a plugin name', function () { const actualResult = buildUrl({ jobUrl: 'https://ci.eclipse.org/jgit/job/jgit', plugin: 'cobertura', @@ -25,7 +25,7 @@ describe('jenkins-common', function() { ) }) - it('returns the json api url without the lastCompletedBuild element', function() { + it('returns the json api url without the lastCompletedBuild element', function () { const actualResult = buildUrl({ jobUrl: 'https://ci.eclipse.org/jgit/job/jgit', lastCompletedBuild: false, @@ -37,8 +37,8 @@ describe('jenkins-common', function() { }) }) - describe('buildRedirectUrl', function() { - it('returns the job url', function() { + describe('buildRedirectUrl', function () { + it('returns the job url', function () { const actualResult = buildRedirectUrl({ protocol: 'https', host: 'jenkins.sqlalchemy.org', @@ -50,7 +50,7 @@ describe('jenkins-common', function() { ) }) - it('returns the job url and adds missing /job prefixes', function() { + it('returns the job url and adds missing /job prefixes', function () { const actualResult = buildRedirectUrl({ protocol: 'https', host: 'jenkins.sqlalchemy.org', diff --git a/services/jenkins/jenkins-coverage.service.js b/services/jenkins/jenkins-coverage.service.js index be31e4b18365a58dc8e527b784433154535edadf..d31b215655bd3f7a258ae54d732289e7e3c28ffb 100644 --- a/services/jenkins/jenkins-coverage.service.js +++ b/services/jenkins/jenkins-coverage.service.js @@ -13,10 +13,7 @@ const formatMap = { jacoco: { schema: Joi.object({ instructionCoverage: Joi.object({ - percentage: Joi.number() - .min(0) - .max(100) - .required(), + percentage: Joi.number().min(0).max(100).required(), }).required(), }).required(), treeQueryParam: 'instructionCoverage[percentage]', @@ -30,10 +27,7 @@ const formatMap = { .items( Joi.object({ name: Joi.string().required(), - ratio: Joi.number() - .min(0) - .max(100) - .required(), + ratio: Joi.number().min(0).max(100).required(), }) ) .has(Joi.object({ name: 'Lines' })) @@ -57,10 +51,7 @@ const formatMap = { .items( Joi.object({ name: Joi.string().required(), - ratio: Joi.number() - .min(0) - .max(100) - .required(), + ratio: Joi.number().min(0).max(100).required(), }) ) .has(Joi.object({ name: 'Line' })) diff --git a/services/jenkins/jenkins-plugin-installs.service.js b/services/jenkins/jenkins-plugin-installs.service.js index 714120a0a5e11b7371a710613118432b8876f224..a61aa3076b033fbb8ae88cdcc4fc23f56fea9ead 100644 --- a/services/jenkins/jenkins-plugin-installs.service.js +++ b/services/jenkins/jenkins-plugin-installs.service.js @@ -117,9 +117,7 @@ module.exports = class JenkinsPluginInstalls extends BaseJsonService { }) } } else { - const latestDate = Object.keys(json.installations) - .sort() - .slice(-1)[0] + const latestDate = Object.keys(json.installations).sort().slice(-1)[0] installs = json.installations[latestDate] } diff --git a/services/jenkins/jenkins-plugin-installs.tester.js b/services/jenkins/jenkins-plugin-installs.tester.js index 2a245dfb2b992f6ecd3019c4c0d7d2cd5db41a53..ece5eaacf0f588aab9eaf7bce53d88131b529758 100644 --- a/services/jenkins/jenkins-plugin-installs.tester.js +++ b/services/jenkins/jenkins-plugin-installs.tester.js @@ -5,12 +5,10 @@ const t = (module.exports = require('../tester').createServiceTester()) // total installs -t.create('total installs | valid') - .get('/view-job-filters.json') - .expectBadge({ - label: 'installs', - message: isMetric, - }) +t.create('total installs | valid').get('/view-job-filters.json').expectBadge({ + label: 'installs', + message: isMetric, +}) t.create('total installs | not found') .get('/not-a-plugin.json') diff --git a/services/jetbrains/jetbrains-version.tester.js b/services/jetbrains/jetbrains-version.tester.js index eaafce0e65e2d028a9fb320e5d1a175f84e00b38..cf472ddafef78a2915c40a8c1eabcef019d622d2 100644 --- a/services/jetbrains/jetbrains-version.tester.js +++ b/services/jetbrains/jetbrains-version.tester.js @@ -17,12 +17,10 @@ t.create('version (plugin id from plugin.xml)') message: isVPlusDottedVersionNClauses, }) -t.create('version (number as a plugin id)') - .get('/7495.json') - .expectBadge({ - label: 'jetbrains plugin', - message: isVPlusDottedVersionNClauses, - }) +t.create('version (number as a plugin id)').get('/7495.json').expectBadge({ + label: 'jetbrains plugin', + message: isVPlusDottedVersionNClauses, +}) t.create('version') .get('/9435.json') diff --git a/services/jira/jira-issue.spec.js b/services/jira/jira-issue.spec.js index df5c5e7c86b48c329964fb61cd0ef5d47343f218..3b7cdfb3335e4f9da8d3be96e14f5df3de654258 100644 --- a/services/jira/jira-issue.spec.js +++ b/services/jira/jira-issue.spec.js @@ -6,10 +6,10 @@ const { cleanUpNockAfterEach, defaultContext } = require('../test-helpers') const JiraIssue = require('./jira-issue.service') const { user, pass, host, config } = require('./jira-test-helpers') -describe('JiraIssue', function() { +describe('JiraIssue', function () { cleanUpNockAfterEach() - it('sends the auth information as configured', async function() { + it('sends the auth information as configured', async function () { const scope = nock(`https://${host}`) .get(`/rest/api/2/issue/${encodeURIComponent('secure-234')}`) // This ensures that the expected credentials are actually being sent with the HTTP request. diff --git a/services/jira/jira-sprint.spec.js b/services/jira/jira-sprint.spec.js index d9696f3e8b780031a08da1f35e4f8e441e6d939c..0214f2da004bf79cadfd1192f4790ecf1e886777 100644 --- a/services/jira/jira-sprint.spec.js +++ b/services/jira/jira-sprint.spec.js @@ -13,10 +13,10 @@ const { sprintQueryString, } = require('./jira-test-helpers') -describe('JiraSprint', function() { +describe('JiraSprint', function () { cleanUpNockAfterEach() - it('sends the auth information as configured', async function() { + it('sends the auth information as configured', async function () { const scope = nock(`https://${host}`) .get('/jira/rest/api/2/search') .query(sprintQueryString) diff --git a/services/jitpack/jitpack-version.service.js b/services/jitpack/jitpack-version.service.js index f4d7464b768485261ebe123f2dd95d806b7ebd60..6d3932e8a673ebefed27b12641bc0f71c69f2307 100644 --- a/services/jitpack/jitpack-version.service.js +++ b/services/jitpack/jitpack-version.service.js @@ -6,9 +6,7 @@ const { BaseJsonService } = require('..') const schema = Joi.object({ version: Joi.string().required(), - status: Joi.string() - .valid('ok') - .required(), + status: Joi.string().valid('ok').required(), }).required() module.exports = class JitPackVersion extends BaseJsonService { diff --git a/services/jsdelivr/jsdelivr-hits-npm.tester.js b/services/jsdelivr/jsdelivr-hits-npm.tester.js index f1ce84c12e6ae98ba1bcf4bea5387efee4f120a5..84a41e36f1e8c304a43186123b79a4a51323b8a3 100644 --- a/services/jsdelivr/jsdelivr-hits-npm.tester.js +++ b/services/jsdelivr/jsdelivr-hits-npm.tester.js @@ -3,37 +3,25 @@ const { isMetricOverTimePeriod } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('jquery hits/day') - .timeout(10000) - .get('/hd/ky.json') - .expectBadge({ - label: 'jsdelivr', - message: isMetricOverTimePeriod, - }) +t.create('jquery hits/day').timeout(10000).get('/hd/ky.json').expectBadge({ + label: 'jsdelivr', + message: isMetricOverTimePeriod, +}) -t.create('jquery hits/week') - .timeout(10000) - .get('/hw/ky.json') - .expectBadge({ - label: 'jsdelivr', - message: isMetricOverTimePeriod, - }) +t.create('jquery hits/week').timeout(10000).get('/hw/ky.json').expectBadge({ + label: 'jsdelivr', + message: isMetricOverTimePeriod, +}) -t.create('jquery hits/month') - .timeout(10000) - .get('/hm/ky.json') - .expectBadge({ - label: 'jsdelivr', - message: isMetricOverTimePeriod, - }) +t.create('jquery hits/month').timeout(10000).get('/hm/ky.json').expectBadge({ + label: 'jsdelivr', + message: isMetricOverTimePeriod, +}) -t.create('jquery hits/year') - .timeout(25000) - .get('/hy/ky.json') - .expectBadge({ - label: 'jsdelivr', - message: isMetricOverTimePeriod, - }) +t.create('jquery hits/year').timeout(25000).get('/hy/ky.json').expectBadge({ + label: 'jsdelivr', + message: isMetricOverTimePeriod, +}) t.create('fake package') .timeout(10000) diff --git a/services/keybase/keybase-btc.tester.js b/services/keybase/keybase-btc.tester.js index 325203385b0600aa8e99984f65140b88c8df2635..2728d6625e71dc68bb7e915d0c3178bc7d5d81be 100644 --- a/services/keybase/keybase-btc.tester.js +++ b/services/keybase/keybase-btc.tester.js @@ -10,23 +10,17 @@ t.create('existing bitcoin address') message: withRegex(/^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$/), }) -t.create('unknown username') - .get('/skyplabsssssss.json') - .expectBadge({ - label: 'btc', - message: 'profile not found', - }) +t.create('unknown username').get('/skyplabsssssss.json').expectBadge({ + label: 'btc', + message: 'profile not found', +}) -t.create('invalid username') - .get('/s.json') - .expectBadge({ - label: 'btc', - message: 'invalid username', - }) +t.create('invalid username').get('/s.json').expectBadge({ + label: 'btc', + message: 'invalid username', +}) -t.create('missing bitcoin address') - .get('/test.json') - .expectBadge({ - label: 'btc', - message: 'no bitcoin addresses found', - }) +t.create('missing bitcoin address').get('/test.json').expectBadge({ + label: 'btc', + message: 'no bitcoin addresses found', +}) diff --git a/services/keybase/keybase-pgp.service.js b/services/keybase/keybase-pgp.service.js index 4cd402f532bde1a28e7e39f0690517a6d43b7c91..2f242832db235907ea27d2919e76a1eb01ea13e0 100644 --- a/services/keybase/keybase-pgp.service.js +++ b/services/keybase/keybase-pgp.service.js @@ -13,9 +13,7 @@ const keyFingerprintSchema = Joi.object({ Joi.object({ public_keys: { primary: { - key_fingerprint: Joi.string() - .hex() - .required(), + key_fingerprint: Joi.string().hex().required(), }, }, }) diff --git a/services/keybase/keybase-pgp.tester.js b/services/keybase/keybase-pgp.tester.js index 40d90d0a355c78756ce11810da3f7afd34cd9336..070aa09dd2c7d22c819d1858bdccaf4c97f2d9b8 100644 --- a/services/keybase/keybase-pgp.tester.js +++ b/services/keybase/keybase-pgp.tester.js @@ -7,28 +7,20 @@ t.create('existing key fingerprint') .get('/skyplabs.json') .expectBadge({ label: 'pgp', - message: Joi.string() - .hex() - .length(16), + message: Joi.string().hex().length(16), }) -t.create('unknown username') - .get('/skyplabsssssss.json') - .expectBadge({ - label: 'pgp', - message: 'profile not found', - }) +t.create('unknown username').get('/skyplabsssssss.json').expectBadge({ + label: 'pgp', + message: 'profile not found', +}) -t.create('invalid username') - .get('/s.json') - .expectBadge({ - label: 'pgp', - message: 'invalid username', - }) +t.create('invalid username').get('/s.json').expectBadge({ + label: 'pgp', + message: 'invalid username', +}) -t.create('missing key fingerprint') - .get('/skyp.json') - .expectBadge({ - label: 'pgp', - message: 'no key fingerprint found', - }) +t.create('missing key fingerprint').get('/skyp.json').expectBadge({ + label: 'pgp', + message: 'no key fingerprint found', +}) diff --git a/services/keybase/keybase-xlm.tester.js b/services/keybase/keybase-xlm.tester.js index 839e8348a402097cc6e7f5068fb55f37e4d39a97..79a277862b49eab97e7332e91f734f5514c414dd 100644 --- a/services/keybase/keybase-xlm.tester.js +++ b/services/keybase/keybase-xlm.tester.js @@ -10,23 +10,17 @@ t.create('existing stellar address') message: withRegex(/^(?!not found$)/), }) -t.create('unknown username') - .get('/skyplabsssssss.json') - .expectBadge({ - label: 'xlm', - message: 'profile not found', - }) +t.create('unknown username').get('/skyplabsssssss.json').expectBadge({ + label: 'xlm', + message: 'profile not found', +}) -t.create('invalid username') - .get('/s.json') - .expectBadge({ - label: 'xlm', - message: 'invalid username', - }) +t.create('invalid username').get('/s.json').expectBadge({ + label: 'xlm', + message: 'invalid username', +}) -t.create('missing stellar address') - .get('/test.json') - .expectBadge({ - label: 'xlm', - message: 'no stellar address found', - }) +t.create('missing stellar address').get('/test.json').expectBadge({ + label: 'xlm', + message: 'no stellar address found', +}) diff --git a/services/keybase/keybase-zec.tester.js b/services/keybase/keybase-zec.tester.js index 7d6bfbd7dd611954394637ab7fe640a280954499..5a2f065b366a34ba1efc717b4b948acf32eb8e80 100644 --- a/services/keybase/keybase-zec.tester.js +++ b/services/keybase/keybase-zec.tester.js @@ -10,23 +10,17 @@ t.create('existing zcash address') message: withRegex(/^(?!not found$)/), }) -t.create('unknown username') - .get('/skyplabsssssss.json') - .expectBadge({ - label: 'zec', - message: 'profile not found', - }) +t.create('unknown username').get('/skyplabsssssss.json').expectBadge({ + label: 'zec', + message: 'profile not found', +}) -t.create('invalid username') - .get('/s.json') - .expectBadge({ - label: 'zec', - message: 'invalid username', - }) +t.create('invalid username').get('/s.json').expectBadge({ + label: 'zec', + message: 'invalid username', +}) -t.create('missing zcash address') - .get('/test.json') - .expectBadge({ - label: 'zec', - message: 'no zcash addresses found', - }) +t.create('missing zcash address').get('/test.json').expectBadge({ + label: 'zec', + message: 'no zcash addresses found', +}) diff --git a/services/liberapay/liberapay-gives.tester.js b/services/liberapay/liberapay-gives.tester.js index 1faec4be96dfcddde8a887684c1717a9b4fefbb9..69e364aa6bd29a8df511176d156f058372c989e7 100644 --- a/services/liberapay/liberapay-gives.tester.js +++ b/services/liberapay/liberapay-gives.tester.js @@ -3,12 +3,10 @@ const t = (module.exports = require('../tester').createServiceTester()) const { isCurrencyOverTime } = require('./liberapay-base') -t.create('Giving (valid)') - .get('/Changaco.json') - .expectBadge({ - label: 'gives', - message: isCurrencyOverTime, - }) +t.create('Giving (valid)').get('/Changaco.json').expectBadge({ + label: 'gives', + message: isCurrencyOverTime, +}) t.create('Giving (not found)') .get('/does-not-exist.json') @@ -17,13 +15,11 @@ t.create('Giving (not found)') t.create('Giving (null)') .get('/Liberapay.json') .intercept(nock => - nock('https://liberapay.com') - .get('/Liberapay/public.json') - .reply(200, { - npatrons: 0, - giving: null, - receiving: null, - goal: null, - }) + nock('https://liberapay.com').get('/Liberapay/public.json').reply(200, { + npatrons: 0, + giving: null, + receiving: null, + goal: null, + }) ) .expectBadge({ label: 'liberapay', message: 'no public giving stats' }) diff --git a/services/liberapay/liberapay-goal.spec.js b/services/liberapay/liberapay-goal.spec.js index f0eee98de375e2c7a1eea3b02162b566db0069a9..87b8eb4755777e69061fa09f1c37439b58deb9b8 100644 --- a/services/liberapay/liberapay-goal.spec.js +++ b/services/liberapay/liberapay-goal.spec.js @@ -5,7 +5,7 @@ const { test, given } = require('sazerac') const { InvalidResponse } = require('..') const LiberapayGoal = require('./liberapay-goal.service') -describe('LiberapayGoal', function() { +describe('LiberapayGoal', function () { test(LiberapayGoal.prototype.transform, () => { given({ goal: {}, receiving: null }).expect({ percentAchieved: 0, @@ -15,7 +15,7 @@ describe('LiberapayGoal', function() { }) }) - it('throws InvalidResponse on missing goals', function() { + it('throws InvalidResponse on missing goals', function () { expect(() => LiberapayGoal.prototype.transform({ goal: null, receiving: null }) ) diff --git a/services/liberapay/liberapay-goal.tester.js b/services/liberapay/liberapay-goal.tester.js index 9fe34413883794c9db9a35ae3bb1c7e32a9df5cf..a05aabe9c6aa08d89dd8a9ab4f5e1209b8b2e928 100644 --- a/services/liberapay/liberapay-goal.tester.js +++ b/services/liberapay/liberapay-goal.tester.js @@ -3,12 +3,10 @@ const { isIntegerPercentage } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('Goal Progress (valid)') - .get('/Liberapay.json') - .expectBadge({ - label: 'goal progress', - message: isIntegerPercentage, - }) +t.create('Goal Progress (valid)').get('/Liberapay.json').expectBadge({ + label: 'goal progress', + message: isIntegerPercentage, +}) t.create('Goal Progress (not found)') .get('/does-not-exist.json') diff --git a/services/liberapay/liberapay-patrons.tester.js b/services/liberapay/liberapay-patrons.tester.js index d6e78b788cc21580ce00005af52ac70affc7dea2..5eee881d67bb27fae2294fce1463ca255ed26159 100644 --- a/services/liberapay/liberapay-patrons.tester.js +++ b/services/liberapay/liberapay-patrons.tester.js @@ -3,12 +3,10 @@ const { isMetric } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('Patrons (valid)') - .get('/Liberapay.json') - .expectBadge({ - label: 'patrons', - message: isMetric, - }) +t.create('Patrons (valid)').get('/Liberapay.json').expectBadge({ + label: 'patrons', + message: isMetric, +}) t.create('Patrons (not found)') .get('/does-not-exist.json') diff --git a/services/liberapay/liberapay-receives.tester.js b/services/liberapay/liberapay-receives.tester.js index 3ae69dfff644e88f7ac5ef2764489fab05beeffe..d2b7a71e4f51d2abac999eca5e5caad393367e50 100644 --- a/services/liberapay/liberapay-receives.tester.js +++ b/services/liberapay/liberapay-receives.tester.js @@ -3,12 +3,10 @@ const t = (module.exports = require('../tester').createServiceTester()) const { isCurrencyOverTime } = require('./liberapay-base') -t.create('Receiving (valid)') - .get('/Changaco.json') - .expectBadge({ - label: 'receives', - message: isCurrencyOverTime, - }) +t.create('Receiving (valid)').get('/Changaco.json').expectBadge({ + label: 'receives', + message: isCurrencyOverTime, +}) t.create('Receiving (not found)') .get('/does-not-exist.json') @@ -17,13 +15,11 @@ t.create('Receiving (not found)') t.create('Receiving (null)') .get('/Liberapay.json') .intercept(nock => - nock('https://liberapay.com') - .get('/Liberapay/public.json') - .reply(200, { - npatrons: 0, - giving: null, - receiving: null, - goal: null, - }) + nock('https://liberapay.com').get('/Liberapay/public.json').reply(200, { + npatrons: 0, + giving: null, + receiving: null, + goal: null, + }) ) .expectBadge({ label: 'liberapay', message: 'no public receiving stats' }) diff --git a/services/librariesio/librariesio-dependencies-helpers.spec.js b/services/librariesio/librariesio-dependencies-helpers.spec.js index d3c021a1fc6306a98f1cc1539263f18ec15bb393..e073352b1cbbc3320732029db570d14af1c0f82b 100644 --- a/services/librariesio/librariesio-dependencies-helpers.spec.js +++ b/services/librariesio/librariesio-dependencies-helpers.spec.js @@ -5,7 +5,7 @@ const { renderDependenciesBadge, } = require('./librariesio-dependencies-helpers') -describe('Libraries.io dependency helpers', function() { +describe('Libraries.io dependency helpers', function () { test(renderDependenciesBadge, () => { forCases([ given({ deprecatedCount: 10, outdatedCount: 0 }), diff --git a/services/librariesio/librariesio-dependencies.service.js b/services/librariesio/librariesio-dependencies.service.js index 009de28404d4e724c1ff7f0bda668fe3d983a28e..9b6c2fb833be3877d278a9a0c212a07de5122a34 100644 --- a/services/librariesio/librariesio-dependencies.service.js +++ b/services/librariesio/librariesio-dependencies.service.js @@ -11,12 +11,8 @@ const schema = Joi.object({ dependencies: Joi.array() .items( Joi.object({ - deprecated: Joi.boolean() - .allow(null) - .required(), - outdated: Joi.boolean() - .allow(null) - .required(), + deprecated: Joi.boolean().allow(null).required(), + outdated: Joi.boolean().allow(null).required(), }) ) .default([]), diff --git a/services/librariesio/librariesio-dependents.tester.js b/services/librariesio/librariesio-dependents.tester.js index e5cfcd29c2863c4cc55375bb053f7dda758024f6..a0b6a24d7ba28df0e84809fddd6375a40f7b24cf 100644 --- a/services/librariesio/librariesio-dependents.tester.js +++ b/services/librariesio/librariesio-dependents.tester.js @@ -3,13 +3,10 @@ const { isMetric } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('dependent count') - .timeout(10000) - .get('/npm/got.json') - .expectBadge({ - label: 'dependents', - message: isMetric, - }) +t.create('dependent count').timeout(10000).get('/npm/got.json').expectBadge({ + label: 'dependents', + message: isMetric, +}) t.create('dependent count (scoped npm package)') .timeout(10000) diff --git a/services/librariesio/librariesio-sourcerank.tester.js b/services/librariesio/librariesio-sourcerank.tester.js index 2a8450fa82e37105c2af4752722303fac2a0e568..c76d302dc520c443cc576e696f5c7e2f79f49a0f 100644 --- a/services/librariesio/librariesio-sourcerank.tester.js +++ b/services/librariesio/librariesio-sourcerank.tester.js @@ -3,13 +3,10 @@ const { anyInteger } = require('../validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('sourcerank') - .timeout(10000) - .get('/npm/got.json') - .expectBadge({ - label: 'sourcerank', - message: anyInteger, - }) +t.create('sourcerank').timeout(10000).get('/npm/got.json').expectBadge({ + label: 'sourcerank', + message: anyInteger, +}) t.create('sourcerank (scoped npm package)') .timeout(10000) diff --git a/services/licenses.spec.js b/services/licenses.spec.js index 233d0485a71569ada03c7ed83ce6245bd18a5bd3..58e95285b6496101cf4dd19f8516e7b34a46aadf 100644 --- a/services/licenses.spec.js +++ b/services/licenses.spec.js @@ -3,7 +3,7 @@ const { test, given, forCases } = require('sazerac') const { licenseToColor, renderLicenseBadge } = require('./licenses') -describe('license helpers', function() { +describe('license helpers', function () { test(licenseToColor, () => { forCases([given('MIT'), given('BSD')]).expect('green') forCases([given('MPL-2.0'), given('MPL')]).expect('orange') diff --git a/services/luarocks/luarocks-version-helpers.spec.js b/services/luarocks/luarocks-version-helpers.spec.js index 95478d6fa153fdd331e2f00df523a01d48872fa4..22064de414d52119c851a42bb366070712c85a15 100644 --- a/services/luarocks/luarocks-version-helpers.spec.js +++ b/services/luarocks/luarocks-version-helpers.spec.js @@ -7,7 +7,7 @@ const { latestVersion, } = require('./luarocks-version-helpers') -describe('LuaRocks-specific helpers', function() { +describe('LuaRocks-specific helpers', function () { test(compareVersionLists, () => { forCases([ given([1, 2], [1, 2]), diff --git a/services/luarocks/luarocks.tester.js b/services/luarocks/luarocks.tester.js index 19910f08fe75b71c564dcd2b00636cc38e5d54aa..f2f95d016f2e83a1794935b3a57e72335e4a6956 100644 --- a/services/luarocks/luarocks.tester.js +++ b/services/luarocks/luarocks.tester.js @@ -7,12 +7,10 @@ const isLuaVersion = Joi.string() .regex(/^v\d+\.\d+\.\d+-\d+$/) .required() -t.create('version') - .get('/mpeterv/luacheck.json') - .expectBadge({ - label: 'luarocks', - message: isLuaVersion, - }) +t.create('version').get('/mpeterv/luacheck.json').expectBadge({ + label: 'luarocks', + message: isLuaVersion, +}) t.create('specified version') .get('/mpeterv/luacheck/0.9.0-1.json') diff --git a/services/maintenance/maintenance.spec.js b/services/maintenance/maintenance.spec.js index c4a5b50504f6f529f378dd4d69e61ce74a76a4d5..460df7fa941ec9ebe1c6688988fab05d96e83665 100644 --- a/services/maintenance/maintenance.spec.js +++ b/services/maintenance/maintenance.spec.js @@ -3,7 +3,7 @@ const { test, given } = require('sazerac') const Maintenance = require('./maintenance.service') -describe('Maintenance', function() { +describe('Maintenance', function () { test(Maintenance.prototype.transform, () => { given({ maintained: 'no', diff --git a/services/matrix/matrix.service.js b/services/matrix/matrix.service.js index 8d63d665a17da635954cd65959c03172be4d7d7a..c030992242fdaacb7829e310ae0f5b4dd02b4dd2 100644 --- a/services/matrix/matrix.service.js +++ b/services/matrix/matrix.service.js @@ -23,9 +23,7 @@ const matrixStateSchema = Joi.array() }).required(), type: Joi.string().required(), sender: Joi.string().required(), - state_key: Joi.string() - .allow('') - .required(), + state_key: Joi.string().allow('').required(), }) ) .required() diff --git a/services/matrix/matrix.tester.js b/services/matrix/matrix.tester.js index 43035127b620a5628826914b9cb1137d2dc7ba23..b42a55c9f9730f64f73bb905b2fd197e858086d7 100644 --- a/services/matrix/matrix.tester.js +++ b/services/matrix/matrix.tester.js @@ -292,13 +292,11 @@ t.create('unknown alias') color: 'red', }) -t.create('invalid alias') - .get('/ALIASDUMMY.dumb.json') - .expectBadge({ - label: 'chat', - message: 'invalid alias', - color: 'red', - }) +t.create('invalid alias').get('/ALIASDUMMY.dumb.json').expectBadge({ + label: 'chat', + message: 'invalid alias', + color: 'red', +}) t.create('server uses a custom port') .get('/ALIAS:DUMMY.dumb:5555.json') diff --git a/services/maven-central/maven-central.service.js b/services/maven-central/maven-central.service.js index 6a4911ac01f363a16d03e5482e4718bc9fd30fc3..e1945815eb14ad749547bd500b0ce3231cabd849 100644 --- a/services/maven-central/maven-central.service.js +++ b/services/maven-central/maven-central.service.js @@ -8,10 +8,7 @@ const schema = Joi.object({ metadata: Joi.object({ versioning: Joi.object({ versions: Joi.object({ - version: Joi.array() - .items(Joi.string().required()) - .single() - .required(), + version: Joi.array().items(Joi.string().required()).single().required(), }).required(), }).required(), }).required(), diff --git a/services/maven-metadata/maven-metadata.service.js b/services/maven-metadata/maven-metadata.service.js index 66a2815735cb5a3c8aa4f17534abcdead7ced5b1..234a02cf932424898beb5d16661e7a21c3bdc980 100644 --- a/services/maven-metadata/maven-metadata.service.js +++ b/services/maven-metadata/maven-metadata.service.js @@ -13,10 +13,7 @@ const schema = Joi.object({ metadata: Joi.object({ versioning: Joi.object({ versions: Joi.object({ - version: Joi.array() - .items(Joi.string().required()) - .single() - .required(), + version: Joi.array().items(Joi.string().required()).single().required(), }).required(), }).required(), }).required(), diff --git a/services/microbadger/microbadger-base.js b/services/microbadger/microbadger-base.js index 949cd594447e5617afbc297370c7ad9428ae9a0a..13576aea35def831b0fd41e8537711be034c5148 100644 --- a/services/microbadger/microbadger-base.js +++ b/services/microbadger/microbadger-base.js @@ -7,9 +7,7 @@ const { BaseJsonService, NotFound } = require('..') const schema = Joi.object({ LayerCount: nonNegativeInteger, // DownloadSize may be missing in some cases - DownloadSize: Joi.number() - .integer() - .min(0), + DownloadSize: Joi.number().integer().min(0), Versions: Joi.array() .items( Joi.object({ @@ -21,9 +19,7 @@ const schema = Joi.object({ ) .required(), LayerCount: nonNegativeInteger, - DownloadSize: Joi.number() - .integer() - .min(0), + DownloadSize: Joi.number().integer().min(0), }) ) .required(), diff --git a/services/mozilla-observatory/mozilla-observatory.service.js b/services/mozilla-observatory/mozilla-observatory.service.js index 80e0d5cacdb9de41c67570eb465ebc2ec77f51cd..40f4b4e5f463334c66e9d927682806b056960a80 100644 --- a/services/mozilla-observatory/mozilla-observatory.service.js +++ b/services/mozilla-observatory/mozilla-observatory.service.js @@ -17,10 +17,7 @@ const schema = Joi.object({ score: Joi.alternatives() .conditional('state', { is: 'FINISHED', - then: Joi.number() - .integer() - .min(0) - .max(200), + then: Joi.number().integer().min(0).max(200), otherwise: Joi.valid(null), }) .required(), diff --git a/services/netlify/netlify.spec.js b/services/netlify/netlify.spec.js index f35e439cd185d76e832345d006cbae48023489c2..faee3111220d951a327f99bcab22cabaf941fb71 100644 --- a/services/netlify/netlify.spec.js +++ b/services/netlify/netlify.spec.js @@ -6,7 +6,7 @@ const Netlify = require('./netlify.service') const building = { message: 'building', label: undefined, color: 'yellow' } const notBuilt = { message: 'not built', label: undefined, color: undefined } -describe('Netlify', function() { +describe('Netlify', function () { test(Netlify.render, () => { given({ status: 'building' }).expect(building) given({ status: 'stopped' }).expect(notBuilt) diff --git a/services/nexus/nexus.spec.js b/services/nexus/nexus.spec.js index b9717ec124650ca0524d0aa93beb26ed9da8c6db..d06c051f2672c7bf7b7f0d8dd0c114808df3bc24 100644 --- a/services/nexus/nexus.spec.js +++ b/services/nexus/nexus.spec.js @@ -6,9 +6,9 @@ const { cleanUpNockAfterEach, defaultContext } = require('../test-helpers') const { InvalidResponse, NotFound } = require('..') const Nexus = require('./nexus.service') -describe('Nexus', function() { - context('transform2()', function() { - it('throws NotFound error when no versions exist', function() { +describe('Nexus', function () { + context('transform2()', function () { + it('throws NotFound error when no versions exist', function () { try { Nexus.prototype.transform2({ json: { data: [] } }) expect.fail('Expected to throw') @@ -18,7 +18,7 @@ describe('Nexus', function() { } }) - it('throws InvalidResponse error when no there is no latestRelease version', function() { + it('throws InvalidResponse error when no there is no latestRelease version', function () { try { Nexus.prototype.transform2({ repo: 'r', json: { data: [{}] } }) expect.fail('Expected to throw') @@ -28,7 +28,7 @@ describe('Nexus', function() { } }) - it('returns latestSnapshot value', function() { + it('returns latestSnapshot value', function () { const latestSnapshot = '7.0.1-SNAPSHOT' const { version } = Nexus.prototype.transform2({ repo: 's', @@ -39,7 +39,7 @@ describe('Nexus', function() { expect(version).to.equal(latestSnapshot) }) - it('returns version value when it is a snapshot', function() { + it('returns version value when it is a snapshot', function () { const latestSnapshot = '1.2.7-SNAPSHOT' const { version } = Nexus.prototype.transform2({ repo: 's', @@ -50,7 +50,7 @@ describe('Nexus', function() { expect(version).to.equal(latestSnapshot) }) - it('throws InvalidResponse error when no snapshot versions exist', function() { + it('throws InvalidResponse error when no snapshot versions exist', function () { try { Nexus.prototype.transform2({ repo: 's', json: { data: [{}] } }) expect.fail('Expected to throw') @@ -60,7 +60,7 @@ describe('Nexus', function() { } }) - it('throws InvalidResponse error when repository has no version data', function() { + it('throws InvalidResponse error when repository has no version data', function () { try { Nexus.prototype.transform2({ repo: 'developer', @@ -73,8 +73,8 @@ describe('Nexus', function() { } }) - context('transform3()', function() { - it('throws NotFound error when no items exist', function() { + context('transform3()', function () { + it('throws NotFound error when no items exist', function () { try { Nexus.prototype.transform3({ json: { items: [] } }) expect.fail('Expected to throw') @@ -84,7 +84,7 @@ describe('Nexus', function() { } }) - it('throws NotFound error when no snapshot items exist', function() { + it('throws NotFound error when no snapshot items exist', function () { try { Nexus.prototype.transform3({ repo: 's', @@ -99,7 +99,7 @@ describe('Nexus', function() { } }) - it('returns first item version', function() { + it('returns first item version', function () { const { version } = Nexus.prototype.transform3({ json: { items: [ @@ -114,7 +114,7 @@ describe('Nexus', function() { }) }) - describe('auth', function() { + describe('auth', function () { cleanUpNockAfterEach() const user = 'admin' @@ -133,7 +133,7 @@ describe('Nexus', function() { }, } - it('sends the auth information as configured', async function() { + it('sends the auth information as configured', async function () { const scope = nock('https://repository.jboss.org') .get('/nexus/service/local/lucene/search') .query({ g: 'jboss', a: 'jboss-client' }) diff --git a/services/node/node-current.spec.js b/services/node/node-current.spec.js index a0a9e46e4b605a4846e484908dd12fb8e5d4f66d..072bf7350dbaddd2b87b241ddaf5a2823cc1acee 100644 --- a/services/node/node-current.spec.js +++ b/services/node/node-current.spec.js @@ -3,8 +3,8 @@ const { test, given } = require('sazerac') const NodeVersion = require('./node-current.service') -describe('node static renderStaticPreview', function() { - it('should have parity with render()', async function() { +describe('node static renderStaticPreview', function () { + it('should have parity with render()', async function () { const nodeVersionRange = '>= 6.0.0' const expectedNoTag = await NodeVersion.renderStaticPreview({ diff --git a/services/node/node-lts.spec.js b/services/node/node-lts.spec.js index 7dfc5ad0bc8cd66a4afc9a9263f9afbdb637769d..f1ca6f100297e5091c1f3cc595d3e87157ccb0ac 100644 --- a/services/node/node-lts.spec.js +++ b/services/node/node-lts.spec.js @@ -3,8 +3,8 @@ const { test, given } = require('sazerac') const NodeVersion = require('./node-lts.service') -describe('node-lts renderStaticPreview', function() { - it('should have parity with render()', async function() { +describe('node-lts renderStaticPreview', function () { + it('should have parity with render()', async function () { const nodeVersionRange = '>= 6.0.0' const expectedNoTag = await NodeVersion.renderStaticPreview({ diff --git a/services/node/node-version-color.js b/services/node/node-version-color.js index 9208bcbce059311dcca47d9b3e1e7c74740fa718..f9f96fef05c80fa8e0f788d70628a21d4a2e0300 100644 --- a/services/node/node-version-color.js +++ b/services/node/node-version-color.js @@ -28,7 +28,7 @@ function getVersion(version) { function ltsVersionsScraper(versions) { const currentDate = moment().format(dateFormat) - return Object.keys(versions).filter(function(version) { + return Object.keys(versions).filter(function (version) { const data = versions[version] return data.lts && data.lts < currentDate && data.end > currentDate }) @@ -52,10 +52,10 @@ async function getLtsVersions() { async function versionColorForRangeLts(range) { const ltsVersions = await getLtsVersions() try { - const matchesAll = ltsVersions.reduce(function(satisfies, version) { + const matchesAll = ltsVersions.reduce(function (satisfies, version) { return satisfies && semver.satisfies(version, range) }, true) - const matchesSome = ltsVersions.reduce(function(satisfies, version) { + const matchesSome = ltsVersions.reduce(function (satisfies, version) { return satisfies || semver.satisfies(version, range) }, false) if (matchesAll) { diff --git a/services/node/testUtils/test-utils.js b/services/node/testUtils/test-utils.js index bc0512539d5199ecd7b712d48882ba6bd095becf..c08bdca8efc97f78517e97d577b486656b1f3aca 100644 --- a/services/node/testUtils/test-utils.js +++ b/services/node/testUtils/test-utils.js @@ -108,15 +108,9 @@ const mockReleaseSchedule = () => nock => { }, v10: { start: '2018-04-24', - lts: currentDate - .clone() - .subtract(6, 'month') - .format(dateFormat), + lts: currentDate.clone().subtract(6, 'month').format(dateFormat), maintenance: '2020-04-30', - end: currentDate - .clone() - .add(1, 'month') - .format(dateFormat), + end: currentDate.clone().add(1, 'month').format(dateFormat), codename: 'Dubnium', }, v11: { @@ -126,15 +120,9 @@ const mockReleaseSchedule = () => nock => { }, v12: { start: '2019-04-23', - lts: currentDate - .clone() - .subtract(1, 'month') - .format(dateFormat), + lts: currentDate.clone().subtract(1, 'month').format(dateFormat), maintenance: '2020-10-20', - end: currentDate - .clone() - .add(6, 'month') - .format(dateFormat), + end: currentDate.clone().add(6, 'month').format(dateFormat), codename: 'Erbium', }, v13: { @@ -144,15 +132,9 @@ const mockReleaseSchedule = () => nock => { }, v14: { start: '2020-04-21', - lts: currentDate - .clone() - .add(4, 'month') - .format(dateFormat), + lts: currentDate.clone().add(4, 'month').format(dateFormat), maintenance: '2021-10-19', - end: currentDate - .clone() - .add(12, 'month') - .format(dateFormat), + end: currentDate.clone().add(12, 'month').format(dateFormat), codename: '', }, } diff --git a/services/nodeping/nodeping-uptime.service.js b/services/nodeping/nodeping-uptime.service.js index 8f744667376af25def310cf6fdd2619684cecd86..4c22abbeeac51cc19e661a4e66934cb40b102715 100644 --- a/services/nodeping/nodeping-uptime.service.js +++ b/services/nodeping/nodeping-uptime.service.js @@ -7,15 +7,10 @@ const { BaseJsonService } = require('..') const colorFormatter = colorScale([99, 99.5, 100]) const rowSchema = Joi.object().keys({ - uptime: Joi.number() - .precision(3) - .min(0) - .max(100), + uptime: Joi.number().precision(3).min(0).max(100), }) -const schema = Joi.array() - .items(rowSchema) - .min(1) +const schema = Joi.array().items(rowSchema).min(1) /* * this is the checkUuid for the NodePing.com (as used on the [example page](https://nodeping.com/reporting.html#results)) diff --git a/services/npm/npm-base.js b/services/npm/npm-base.js index 3ca60ccc524087e8fd4182761eeb4335de2b74f4..1f3b69ea55eef6a53db6c0ec857eca9a2c8e19e6 100644 --- a/services/npm/npm-base.js +++ b/services/npm/npm-base.js @@ -29,9 +29,7 @@ const packageDataSchema = Joi.object({ // https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html#including-declarations-in-your-npm-package // > Note that the "typings" field is synonymous with "types" typings: Joi.string(), - files: Joi.array() - .items(Joi.string()) - .default([]), + files: Joi.array().items(Joi.string()).default([]), }).required() const queryParamSchema = Joi.object({ diff --git a/services/npm/npm-base.spec.js b/services/npm/npm-base.spec.js index 45a0e3c8e55d41e2bac8cf7c16485714cbf9539c..710dee6217b2ee4e1a9eb9b3eb963c87a10d4695 100644 --- a/services/npm/npm-base.spec.js +++ b/services/npm/npm-base.spec.js @@ -6,9 +6,9 @@ const { cleanUpNockAfterEach, defaultContext } = require('../test-helpers') // use NPM Version as an example implementation of NpmBase for this test const NpmVersion = require('./npm-version.service') -describe('npm', function() { - describe('auth', function() { - it('sends the auth information as configured', async function() { +describe('npm', function () { + describe('auth', function () { + it('sends the auth information as configured', async function () { cleanUpNockAfterEach() const token = 'abc123' diff --git a/services/npm/npm-downloads.service.js b/services/npm/npm-downloads.service.js index 7620b8c96efb3f56566e44daf65470b2a8cf28d3..56b693ab58042be88f5d8861fb226e23ea23466d 100644 --- a/services/npm/npm-downloads.service.js +++ b/services/npm/npm-downloads.service.js @@ -33,9 +33,7 @@ const intervalMap = { query: 'range/1000-01-01:3000-01-01', // https://github.com/npm/registry/blob/master/docs/download-counts.md#output-1 schema: Joi.object({ - downloads: Joi.array() - .items(pointResponseSchema) - .required(), + downloads: Joi.array().items(pointResponseSchema).required(), }).required(), transform: json => json.downloads diff --git a/services/npm/npm-downloads.spec.js b/services/npm/npm-downloads.spec.js index 0e610057f166cc3fbaf7efd4d65e2a800e3ed0bc..4c94a7d2c16fcea6e3b4aa88897532d393b4a5de 100644 --- a/services/npm/npm-downloads.spec.js +++ b/services/npm/npm-downloads.spec.js @@ -3,7 +3,7 @@ const { test, given } = require('sazerac') const NpmDownloads = require('./npm-downloads.service') -describe('NpmDownloads', function() { +describe('NpmDownloads', function () { test(NpmDownloads._intervalMap.dt.transform, () => { given({ downloads: [ diff --git a/services/npm/npm-downloads.tester.js b/services/npm/npm-downloads.tester.js index b7ac2bf82ce3a56d1f6ca3fdfd7cfa7d060720a9..e3a9c46d7eee884df36f0a1c682c70489b24b3b6 100644 --- a/services/npm/npm-downloads.tester.js +++ b/services/npm/npm-downloads.tester.js @@ -3,25 +3,21 @@ const { isMetricOverTimePeriod, isMetric } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('weekly downloads of left-pad') - .get('/dw/left-pad.json') - .expectBadge({ - label: 'downloads', - message: isMetricOverTimePeriod, - color: 'brightgreen', - }) +t.create('weekly downloads of left-pad').get('/dw/left-pad.json').expectBadge({ + label: 'downloads', + message: isMetricOverTimePeriod, + color: 'brightgreen', +}) t.create('weekly downloads of @cycle/core') .get('/dw/@cycle/core.json') .expectBadge({ label: 'downloads', message: isMetricOverTimePeriod }) -t.create('total downloads of left-pad') - .get('/dt/left-pad.json') - .expectBadge({ - label: 'downloads', - message: isMetric, - color: 'brightgreen', - }) +t.create('total downloads of left-pad').get('/dt/left-pad.json').expectBadge({ + label: 'downloads', + message: isMetric, + color: 'brightgreen', +}) t.create('total downloads of @cycle/core') .get('/dt/@cycle/core.json') diff --git a/services/npm/npm-type-definitions.spec.js b/services/npm/npm-type-definitions.spec.js index f72b0d098cba3596b2633ac78763a482bf0378c4..98cefb2e5331049c692ed6ada8e3321d40c6d71f 100644 --- a/services/npm/npm-type-definitions.spec.js +++ b/services/npm/npm-type-definitions.spec.js @@ -3,7 +3,7 @@ const { test, given, forCases } = require('sazerac') const NpmTypeDefinitions = require('./npm-type-definitions.service') -describe('NPM type definitions badge', function() { +describe('NPM type definitions badge', function () { test(NpmTypeDefinitions.transform, () => { forCases([ given({ devDependencies: { typescript: '^2.4.7' }, files: [] }), diff --git a/services/nuget/nuget-helpers.spec.js b/services/nuget/nuget-helpers.spec.js index bdfb08148c760e9cadeff4890fb670844512edfb..6cd4b752bdee9f7a455ae43b3dc20acaae67cfac 100644 --- a/services/nuget/nuget-helpers.spec.js +++ b/services/nuget/nuget-helpers.spec.js @@ -3,7 +3,7 @@ const { test, given } = require('sazerac') const { renderVersionBadge, odataToObject } = require('./nuget-helpers') -describe('NuGet helpers', function() { +describe('NuGet helpers', function () { test(renderVersionBadge, () => { given({ version: '1.2-beta' }).expect({ label: undefined, diff --git a/services/nuget/nuget.tester.js b/services/nuget/nuget.tester.js index 4d8e6e1685541af5c870b590ba6a6e824ac5d7f4..6bdbf3d663ec17e1da5d122a3ffd3450e665c622 100644 --- a/services/nuget/nuget.tester.js +++ b/services/nuget/nuget.tester.js @@ -33,9 +33,7 @@ t.create('total downloads (not found)') t.create('total downloads (unexpected second response)') .get('/dt/Microsoft.AspNetCore.Mvc.json') .intercept(nock => - nock('https://api.nuget.org') - .get('/v3/index.json') - .reply(200, queryIndex) + nock('https://api.nuget.org').get('/v3/index.json').reply(200, queryIndex) ) .intercept(nock => nock('https://api-v2v3search-0.nuget.org') @@ -58,9 +56,7 @@ t.create('version (valid)') t.create('version (yellow badge)') .get('/v/Microsoft.AspNetCore.Mvc.json') .intercept(nock => - nock('https://api.nuget.org') - .get('/v3/index.json') - .reply(200, queryIndex) + nock('https://api.nuget.org').get('/v3/index.json').reply(200, queryIndex) ) .intercept(nock => nock('https://api-v2v3search-0.nuget.org') @@ -78,9 +74,7 @@ t.create('version (yellow badge)') t.create('version (orange badge)') .get('/v/Microsoft.AspNetCore.Mvc.json') .intercept(nock => - nock('https://api.nuget.org') - .get('/v3/index.json') - .reply(200, queryIndex) + nock('https://api.nuget.org').get('/v3/index.json').reply(200, queryIndex) ) .intercept(nock => nock('https://api-v2v3search-0.nuget.org') @@ -98,9 +92,7 @@ t.create('version (orange badge)') t.create('version (blue badge)') .get('/v/Microsoft.AspNetCore.Mvc.json') .intercept(nock => - nock('https://api.nuget.org') - .get('/v3/index.json') - .reply(200, queryIndex) + nock('https://api.nuget.org').get('/v3/index.json').reply(200, queryIndex) ) .intercept(nock => nock('https://api-v2v3search-0.nuget.org') @@ -119,9 +111,7 @@ t.create('version (blue badge)') t.create('version (build metadata with -)') .get('/v/MongoFramework.json') .intercept(nock => - nock('https://api.nuget.org') - .get('/v3/index.json') - .reply(200, queryIndex) + nock('https://api.nuget.org').get('/v3/index.json').reply(200, queryIndex) ) .intercept(nock => nock('https://api-v2v3search-0.nuget.org') @@ -141,9 +131,7 @@ t.create('version (not found)') t.create('version (unexpected second response)') .get('/v/Microsoft.AspNetCore.Mvc.json') .intercept(nock => - nock('https://api.nuget.org') - .get('/v3/index.json') - .reply(200, queryIndex) + nock('https://api.nuget.org').get('/v3/index.json').reply(200, queryIndex) ) .intercept(nock => nock('https://api-v2v3search-0.nuget.org') @@ -166,9 +154,7 @@ t.create('version (pre) (valid)') t.create('version (pre) (yellow badge)') .get('/vpre/Microsoft.AspNetCore.Mvc.json') .intercept(nock => - nock('https://api.nuget.org') - .get('/v3/index.json') - .reply(200, queryIndex) + nock('https://api.nuget.org').get('/v3/index.json').reply(200, queryIndex) ) .intercept(nock => nock('https://api-v2v3search-0.nuget.org') @@ -186,9 +172,7 @@ t.create('version (pre) (yellow badge)') t.create('version (pre) (orange badge)') .get('/vpre/Microsoft.AspNetCore.Mvc.json') .intercept(nock => - nock('https://api.nuget.org') - .get('/v3/index.json') - .reply(200, queryIndex) + nock('https://api.nuget.org').get('/v3/index.json').reply(200, queryIndex) ) .intercept(nock => nock('https://api-v2v3search-0.nuget.org') @@ -206,9 +190,7 @@ t.create('version (pre) (orange badge)') t.create('version (pre) (blue badge)') .get('/vpre/Microsoft.AspNetCore.Mvc.json') .intercept(nock => - nock('https://api.nuget.org') - .get('/v3/index.json') - .reply(200, queryIndex) + nock('https://api.nuget.org').get('/v3/index.json').reply(200, queryIndex) ) .intercept(nock => nock('https://api-v2v3search-0.nuget.org') @@ -230,9 +212,7 @@ t.create('version (pre) (not found)') t.create('version (pre) (unexpected second response)') .get('/vpre/Microsoft.AspNetCore.Mvc.json') .intercept(nock => - nock('https://api.nuget.org') - .get('/v3/index.json') - .reply(200, queryIndex) + nock('https://api.nuget.org').get('/v3/index.json').reply(200, queryIndex) ) .intercept(nock => nock('https://api-v2v3search-0.nuget.org') diff --git a/services/nycrc/nycrc.service.js b/services/nycrc/nycrc.service.js index fb38a764698fb7e5e35b88b4ee65d51563d69e11..70f6329081b3ab8d466a7c255a547db08eaa8fc3 100644 --- a/services/nycrc/nycrc.service.js +++ b/services/nycrc/nycrc.service.js @@ -9,39 +9,21 @@ const { fetchJsonFromRepo } = require('../github/github-common-fetch') const { InvalidParameter, InvalidResponse, NotFound } = require('..') const nycrcSchema = Joi.object({ - branches: Joi.number() - .min(0) - .max(100), - lines: Joi.number() - .min(0) - .max(100), - functions: Joi.number() - .min(0) - .max(100), + branches: Joi.number().min(0).max(100), + lines: Joi.number().min(0).max(100), + functions: Joi.number().min(0).max(100), }).required() const pkgJSONSchema = Joi.object({ c8: Joi.object({ - branches: Joi.number() - .min(0) - .max(100), - lines: Joi.number() - .min(0) - .max(100), - functions: Joi.number() - .min(0) - .max(100), + branches: Joi.number().min(0).max(100), + lines: Joi.number().min(0).max(100), + functions: Joi.number().min(0).max(100), }).optional(), nyc: Joi.object({ - branches: Joi.number() - .min(0) - .max(100), - lines: Joi.number() - .min(0) - .max(100), - functions: Joi.number() - .min(0) - .max(100), + branches: Joi.number().min(0).max(100), + lines: Joi.number().min(0).max(100), + functions: Joi.number().min(0).max(100), }).optional(), }).required() diff --git a/services/offset-earth/offset-earth-carbon.service.js b/services/offset-earth/offset-earth-carbon.service.js index 6be74160ecbc9d43d8b05a46f1312e74497e310f..2a0d588af75f8a7b39ccf5f57643e9e2365b8619 100644 --- a/services/offset-earth/offset-earth-carbon.service.js +++ b/services/offset-earth/offset-earth-carbon.service.js @@ -6,9 +6,7 @@ const { floorCount } = require('../color-formatters') const { BaseJsonService } = require('..') const apiSchema = Joi.object({ - total: Joi.number() - .positive() - .required(), + total: Joi.number().positive().required(), }).required() module.exports = class OffsetEarthCarbonOffset extends BaseJsonService { diff --git a/services/offset-earth/offset-earth-carbon.tester.js b/services/offset-earth/offset-earth-carbon.tester.js index b7f066dc807f1c89f1f91639a9b5e841786b82b2..965c4b6937f1ee786c06490a29bd66b8b4b5e4ee 100644 --- a/services/offset-earth/offset-earth-carbon.tester.js +++ b/services/offset-earth/offset-earth-carbon.tester.js @@ -10,10 +10,8 @@ t.create('request for existing username') message: withRegex(/[\d.]+ tonnes/), }) -t.create('invalid username') - .get('/non-existent-username.json') - .expectBadge({ - label: 'carbon offset', - message: 'username not found', - color: 'red', - }) +t.create('invalid username').get('/non-existent-username.json').expectBadge({ + label: 'carbon offset', + message: 'username not found', + color: 'red', +}) diff --git a/services/offset-earth/offset-earth-trees.tester.js b/services/offset-earth/offset-earth-trees.tester.js index 1b8537049f802a73bca8b3355b32de15df2486cd..7a7ae2b820b70d434f534c676ff796e09df1474d 100644 --- a/services/offset-earth/offset-earth-trees.tester.js +++ b/services/offset-earth/offset-earth-trees.tester.js @@ -3,12 +3,10 @@ const t = (module.exports = require('../tester').createServiceTester()) const { isMetric } = require('../test-validators') -t.create('request for existing username') - .get('/offsetearth.json') - .expectBadge({ - label: 'trees', - message: isMetric, - }) +t.create('request for existing username').get('/offsetearth.json').expectBadge({ + label: 'trees', + message: isMetric, +}) t.create('request for existing username') .get('/offsetearth.json') diff --git a/services/opencollective/opencollective-all.tester.js b/services/opencollective/opencollective-all.tester.js index c4584349f92e45f0fa6ec0dfd9a7adbc02daba75..8ba66a063abce255649cbd68a2cd1c2c85936c6b 100644 --- a/services/opencollective/opencollective-all.tester.js +++ b/services/opencollective/opencollective-all.tester.js @@ -6,18 +6,16 @@ const t = (module.exports = require('../tester').createServiceTester()) t.create('renders correctly') .get('/shields.json') .intercept(nock => - nock('https://opencollective.com/') - .get('/shields.json') - .reply(200, { - slug: 'shields', - currency: 'USD', - image: - 'https://opencollective-production.s3-us-west-1.amazonaws.com/44dcbb90-1ee9-11e8-a4c3-7bb1885c0b6e.png', - balance: 105494, - yearlyIncome: 157371, - backersCount: 35, - contributorsCount: 276, - }) + nock('https://opencollective.com/').get('/shields.json').reply(200, { + slug: 'shields', + currency: 'USD', + image: + 'https://opencollective-production.s3-us-west-1.amazonaws.com/44dcbb90-1ee9-11e8-a4c3-7bb1885c0b6e.png', + balance: 105494, + yearlyIncome: 157371, + backersCount: 35, + contributorsCount: 276, + }) ) .expectBadge({ label: 'backers and sponsors', diff --git a/services/opencollective/opencollective-backers.tester.js b/services/opencollective/opencollective-backers.tester.js index fbdaf1bfbef765cd5dfb2c0f4ce23a4a9900e985..e9d2c0601b9103d97c040e02cb4bafb546b427ec 100644 --- a/services/opencollective/opencollective-backers.tester.js +++ b/services/opencollective/opencollective-backers.tester.js @@ -77,12 +77,10 @@ t.create('renders correctly') color: 'brightgreen', }) -t.create('gets amount of backers') - .get('/shields.json') - .expectBadge({ - label: 'backers', - message: nonNegativeInteger, - }) +t.create('gets amount of backers').get('/shields.json').expectBadge({ + label: 'backers', + message: nonNegativeInteger, +}) t.create('handles not found correctly') .get('/nonexistent-collective.json') diff --git a/services/opencollective/opencollective-base.js b/services/opencollective/opencollective-base.js index 4ccd303c29bc752ebb18b00da1ef0ab3626587d4..55704c5b3923ec0a8d67a8a5346e35028c5c6ab2 100644 --- a/services/opencollective/opencollective-base.js +++ b/services/opencollective/opencollective-base.js @@ -67,8 +67,9 @@ module.exports = class OpencollectiveBase extends BaseJsonService { schema, // https://developer.opencollective.com/#/api/collectives?id=get-members // https://developer.opencollective.com/#/api/collectives?id=get-members-per-tier - url: `https://opencollective.com/${collective}/members/${userType || - 'all'}.json${tierId ? `?TierId=${tierId}` : ''}`, + url: `https://opencollective.com/${collective}/members/${ + userType || 'all' + }.json${tierId ? `?TierId=${tierId}` : ''}`, errorMessages: { 404: 'collective not found', }, diff --git a/services/opencollective/opencollective-sponsors.tester.js b/services/opencollective/opencollective-sponsors.tester.js index 68d740f5c9b86df4dbce8fe178d4f50174471943..8784501370aadce001279afd109ac3a92b079f82 100644 --- a/services/opencollective/opencollective-sponsors.tester.js +++ b/services/opencollective/opencollective-sponsors.tester.js @@ -68,12 +68,10 @@ t.create('renders correctly') message: '10', color: 'brightgreen', }) -t.create('gets amount of sponsors') - .get('/shields.json') - .expectBadge({ - label: 'sponsors', - message: nonNegativeInteger, - }) +t.create('gets amount of sponsors').get('/shields.json').expectBadge({ + label: 'sponsors', + message: nonNegativeInteger, +}) t.create('handles not found correctly') .get('/nonexistent-collective.json') diff --git a/services/opm/opm-version.tester.js b/services/opm/opm-version.tester.js index 18e9c2cef0d8f2b0aa5f40b24d1ef314bf56a091..d6b1f145c852d079ee0c8a92290a36333f502f95 100644 --- a/services/opm/opm-version.tester.js +++ b/services/opm/opm-version.tester.js @@ -7,12 +7,10 @@ const isValidVersion = Joi.string() .regex(/^v[\d+.]+$/) .required() -t.create('version') - .get('/openresty/lua-resty-lrucache.json') - .expectBadge({ - label: 'opm', - message: isValidVersion, - }) +t.create('version').get('/openresty/lua-resty-lrucache.json').expectBadge({ + label: 'opm', + message: isValidVersion, +}) t.create('unknown module') .get('/openresty/does-not-exist.json') diff --git a/services/osslifecycle/osslifecycle.tester.js b/services/osslifecycle/osslifecycle.tester.js index df50a2dd993cc0813581ee7bbfb9c7fa18525900..1060e54eb1045895016cb150a1444dbdc32ee800 100644 --- a/services/osslifecycle/osslifecycle.tester.js +++ b/services/osslifecycle/osslifecycle.tester.js @@ -7,13 +7,11 @@ const t = (module.exports = new ServiceTester({ title: 'OSS Lifecycle', })) -t.create('osslifecycle active status') - .get('/netflix/sureal.json') - .expectBadge({ - label: 'oss lifecycle', - message: 'active', - color: 'brightgreen', - }) +t.create('osslifecycle active status').get('/netflix/sureal.json').expectBadge({ + label: 'oss lifecycle', + message: 'active', + color: 'brightgreen', +}) t.create('osslifecycle maintenance status') .get('/Teevity/ice.json') @@ -31,13 +29,11 @@ t.create('osslifecycle archived status') color: 'red', }) -t.create('osslifecycle other status') - .get('/Netflix/metacat.json') - .expectBadge({ - label: 'oss lifecycle', - message: 'private', - color: 'lightgrey', - }) +t.create('osslifecycle other status').get('/Netflix/metacat.json').expectBadge({ + label: 'oss lifecycle', + message: 'private', + color: 'lightgrey', +}) t.create('osslifecycle status (branch)') .get('/Netflix/osstracker/documentation.json') @@ -62,9 +58,7 @@ t.create('oss metadata in unexpected format') message: 'metadata in unexpected format', }) -t.create('oss metadata not found') - .get('/PyvesB/empty-repo.json') - .expectBadge({ - label: 'oss lifecycle', - message: 'not found', - }) +t.create('oss metadata not found').get('/PyvesB/empty-repo.json').expectBadge({ + label: 'oss lifecycle', + message: 'not found', +}) diff --git a/services/package-json-helpers.js b/services/package-json-helpers.js index 2906132870f0a5929492c19edb7efbfa1ba9affe..3fe7339de4adda231f6cdee9c1562d8b85429ca3 100644 --- a/services/package-json-helpers.js +++ b/services/package-json-helpers.js @@ -7,9 +7,7 @@ const isDependencyMap = Joi.object() .pattern( /./, // This accepts a semver range, a URL, and many other possible values. - Joi.string() - .min(1) - .required() + Joi.string().min(1).required() ) .default({}) diff --git a/services/package-json-helpers.spec.js b/services/package-json-helpers.spec.js index 628d02197c99825e4914c0ce91cd390cbcbe722c..7d6437b0e01850d83ef15172320e0e46f188321b 100644 --- a/services/package-json-helpers.spec.js +++ b/services/package-json-helpers.spec.js @@ -3,7 +3,7 @@ const { test, given } = require('sazerac') const { getDependencyVersion } = require('./package-json-helpers') -describe('Contributor count helpers', function() { +describe('Contributor count helpers', function () { test(getDependencyVersion, () => { given({ wantedDependency: 'left-pad', diff --git a/services/packagecontrol/packagecontrol.service.js b/services/packagecontrol/packagecontrol.service.js index c02f0caa4b395b061982f246691a051f08c42b82..5203d363fb69cb42d189868aaf6a1ec38cc6389d 100644 --- a/services/packagecontrol/packagecontrol.service.js +++ b/services/packagecontrol/packagecontrol.service.js @@ -15,9 +15,7 @@ const schema = Joi.object({ data: Joi.array() .items( Joi.object({ - totals: Joi.array() - .items(nonNegativeInteger) - .required(), + totals: Joi.array().items(nonNegativeInteger).required(), }).required() ) .required(), diff --git a/services/packagecontrol/packagecontrol.tester.js b/services/packagecontrol/packagecontrol.tester.js index 4b29a5ad9ee9c6a447e0dff0e73683dc8b570904..305811406aea1cef487faf2ed996cae9dfb68dfb 100644 --- a/services/packagecontrol/packagecontrol.tester.js +++ b/services/packagecontrol/packagecontrol.tester.js @@ -8,37 +8,27 @@ const t = (module.exports = new ServiceTester({ title: 'Package Control', })) -t.create('monthly downloads') - .get('/dm/GitGutter.json') - .expectBadge({ - label: 'downloads', - message: isMetricOverTimePeriod, - }) +t.create('monthly downloads').get('/dm/GitGutter.json').expectBadge({ + label: 'downloads', + message: isMetricOverTimePeriod, +}) -t.create('weekly downloads') - .get('/dw/GitGutter.json') - .expectBadge({ - label: 'downloads', - message: isMetricOverTimePeriod, - }) +t.create('weekly downloads').get('/dw/GitGutter.json').expectBadge({ + label: 'downloads', + message: isMetricOverTimePeriod, +}) -t.create('daily downloads') - .get('/dd/GitGutter.json') - .expectBadge({ - label: 'downloads', - message: isMetricOverTimePeriod, - }) +t.create('daily downloads').get('/dd/GitGutter.json').expectBadge({ + label: 'downloads', + message: isMetricOverTimePeriod, +}) -t.create('total downloads') - .get('/dt/GitGutter.json') - .expectBadge({ - label: 'downloads', - message: isMetric, - }) +t.create('total downloads').get('/dt/GitGutter.json').expectBadge({ + label: 'downloads', + message: isMetric, +}) -t.create('package not found') - .get('/dt/does-not-exist.json') - .expectBadge({ - label: 'downloads', - message: 'not found', - }) +t.create('package not found').get('/dt/does-not-exist.json').expectBadge({ + label: 'downloads', + message: 'not found', +}) diff --git a/services/packagist/packagist-base.js b/services/packagist/packagist-base.js index 7bcdc2dfcb5d666b826a33cf2e760e32f64ed3ee..07cddd86197c0071008b76f7d966ea652f34c38b 100644 --- a/services/packagist/packagist-base.js +++ b/services/packagist/packagist-base.js @@ -16,9 +16,7 @@ const packageSchema = Joi.object() .required() const allVersionsSchema = Joi.object({ - packages: Joi.object() - .pattern(/^/, packageSchema) - .required(), + packages: Joi.object().pattern(/^/, packageSchema).required(), }).required() const keywords = ['PHP'] diff --git a/services/packagist/packagist-license.service.js b/services/packagist/packagist-license.service.js index d785fe8f3996025f81a4d6f5b22c783b16ca0d66..4511cd349687e064670973bfc17eb61f562aa2af 100644 --- a/services/packagist/packagist-license.service.js +++ b/services/packagist/packagist-license.service.js @@ -20,9 +20,7 @@ const packageSchema = Joi.object() .required() const schema = Joi.object({ - packages: Joi.object() - .pattern(/^/, packageSchema) - .required(), + packages: Joi.object().pattern(/^/, packageSchema).required(), }).required() const queryParamSchema = Joi.object({ diff --git a/services/packagist/packagist-license.spec.js b/services/packagist/packagist-license.spec.js index 315b6cf9e9785444d2f6fed3645c3e4b12d06774..04f0238432700d61556d4438e80773271f293b31 100644 --- a/services/packagist/packagist-license.spec.js +++ b/services/packagist/packagist-license.spec.js @@ -4,8 +4,8 @@ const { expect } = require('chai') const { NotFound } = require('..') const PackagistLicense = require('./packagist-license.service') -describe('PackagistLicense', function() { - it('should throw NotFound when default branch is missing', function() { +describe('PackagistLicense', function () { + it('should throw NotFound when default branch is missing', function () { const json = { packages: { 'doctrine/orm': {}, diff --git a/services/packagist/packagist-stars.tester.js b/services/packagist/packagist-stars.tester.js index 5f0eb1587bac946e416de452ec3fd2d5b5186e47..e8b40b69af4f41fc71ebb3345e1a398d0dc88a28 100644 --- a/services/packagist/packagist-stars.tester.js +++ b/services/packagist/packagist-stars.tester.js @@ -3,12 +3,10 @@ const { isMetric } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('Stars (valid package)') - .get('/guzzlehttp/guzzle.json') - .expectBadge({ - label: 'stars', - message: isMetric, - }) +t.create('Stars (valid package)').get('/guzzlehttp/guzzle.json').expectBadge({ + label: 'stars', + message: isMetric, +}) t.create('Stars (invalid package)') .get('/frodo/is-not-a-package.json') diff --git a/services/packagist/packagist-version.service.js b/services/packagist/packagist-version.service.js index 8d4c88e6abbb93f23a0c0fe233472fa9bf6fe1fb..c22055f67e7f123bf7e3f2e357ee4bd90223df29 100644 --- a/services/packagist/packagist-version.service.js +++ b/services/packagist/packagist-version.service.js @@ -25,9 +25,7 @@ const packageSchema = Joi.object() .required() const schema = Joi.object({ - packages: Joi.object() - .pattern(/^/, packageSchema) - .required(), + packages: Joi.object().pattern(/^/, packageSchema).required(), }).required() const queryParamSchema = Joi.object({ diff --git a/services/packagist/packagist-version.tester.js b/services/packagist/packagist-version.tester.js index eff84fc48717d8db252cdb9e8c511126abc67212..cb7115fa3a33a645428e6d45a66f3bb064fdb41e 100644 --- a/services/packagist/packagist-version.tester.js +++ b/services/packagist/packagist-version.tester.js @@ -20,20 +20,16 @@ const t = (module.exports = new ServiceTester({ */ const isPackagistVersion = Joi.string().regex(/^v?[0-9]+.[0-9]+.[0-9]+[\S]*$/) -t.create('version (valid)') - .get('/v/symfony/symfony.json') - .expectBadge({ - label: 'packagist', - message: isPackagistVersion, - }) +t.create('version (valid)').get('/v/symfony/symfony.json').expectBadge({ + label: 'packagist', + message: isPackagistVersion, +}) -t.create('version (no releases)') - .get('/v/wsg/hello.json') - .expectBadge({ - label: 'packagist', - message: 'no released version found', - color: 'red', - }) +t.create('version (no releases)').get('/v/wsg/hello.json').expectBadge({ + label: 'packagist', + message: 'no released version found', + color: 'red', +}) t.create('version (invalid package name)') .get('/v/frodo/is-not-a-package.json') diff --git a/services/php-version.spec.js b/services/php-version.spec.js index ca2390e2be115ceb66e514213314a4dbd9f852c7..607f302ef7eb21e0ef57a213bc8cea06b9d8fc08 100644 --- a/services/php-version.spec.js +++ b/services/php-version.spec.js @@ -16,7 +16,7 @@ const phpReleases = [ '7.2', ] -describe('Text PHP version', function() { +describe('Text PHP version', function () { test(minorVersion, () => { given('7').expect('7.0') given('7.1').expect('7.1') @@ -48,7 +48,7 @@ describe('Text PHP version', function() { }) }) -describe('Composer version comparison', function() { +describe('Composer version comparison', function () { test(compare, () => { // composer version scheme ordering given('0.9.0', '1.0.0-alpha').expect(-1) diff --git a/services/pkgreview/package-rating.service.js b/services/pkgreview/package-rating.service.js index 39b0fb9f1f6c19e1e870519c8018853a72bea4a9..bcffe3f85ee7f574f2397fffed48aaaf09a6bfac 100644 --- a/services/pkgreview/package-rating.service.js +++ b/services/pkgreview/package-rating.service.js @@ -9,12 +9,7 @@ const { BaseJsonService } = require('..') const pkgReviewColor = colorScale([2, 3, 4]) const schema = Joi.object({ - rating: Joi.number() - .min(0) - .max(1) - .precision(1) - .required() - .allow(null), + rating: Joi.number().min(0).max(1).precision(1).required().allow(null), reviewsCount: nonNegativeInteger, }).required() diff --git a/services/poeditor/poeditor.service.js b/services/poeditor/poeditor.service.js index e5bc71d794c30c3d76a5a0cce64eb4b0f9e1789c..a0bcb72ee1a18263b84d47a282827641125dd30b 100644 --- a/services/poeditor/poeditor.service.js +++ b/services/poeditor/poeditor.service.js @@ -26,10 +26,7 @@ const schema = Joi.object({ .items({ name: Joi.string().required(), code: Joi.string().required(), - percentage: Joi.number() - .min(0) - .max(100) - .required(), + percentage: Joi.number().min(0).max(100).required(), }) .required(), }), diff --git a/services/powershellgallery/powershellgallery.tester.js b/services/powershellgallery/powershellgallery.tester.js index 778d9fd487c115ae768c02b45b2d7c4dab821ea4..684c465c80bd3d086bd399d82f00f732af3d1a66 100644 --- a/services/powershellgallery/powershellgallery.tester.js +++ b/services/powershellgallery/powershellgallery.tester.js @@ -17,23 +17,19 @@ const t = new ServiceTester({ }) module.exports = t -t.create('total downloads (valid)') - .get('/dt/ACMESharp.json') - .expectBadge({ - label: 'downloads', - message: isMetric, - }) +t.create('total downloads (valid)').get('/dt/ACMESharp.json').expectBadge({ + label: 'downloads', + message: isMetric, +}) t.create('total downloads (not found)') .get('/dt/not-a-real-package.json') .expectBadge({ label: 'downloads', message: 'not found' }) -t.create('version (valid)') - .get('/v/ACMESharp.json') - .expectBadge({ - label: 'powershell gallery', - message: isVPlusDottedVersionNClauses, - }) +t.create('version (valid)').get('/v/ACMESharp.json').expectBadge({ + label: 'powershell gallery', + message: isVPlusDottedVersionNClauses, +}) t.create('version (not found)') .get('/v/not-a-real-package.json') @@ -54,12 +50,10 @@ t.create('version (legacy redirect: vpre)') .get('/vpre/ACMESharp.svg') .expectRedirect('/powershellgallery/v/ACMESharp.svg?include_prereleases') -t.create('platform (valid') - .get('/p/DNS.1.1.1.1.json') - .expectBadge({ - label: 'platform', - message: isPlatform, - }) +t.create('platform (valid').get('/p/DNS.1.1.1.1.json').expectBadge({ + label: 'platform', + message: isPlatform, +}) t.create('platform (no tags)') .get('/p/ACMESharp.json') diff --git a/services/pub/pub.service.js b/services/pub/pub.service.js index f68e4a97605ac1fad22a8077aa630abfb2855050..3420b548a90462c71b0797c05b5d907830d5e55d 100644 --- a/services/pub/pub.service.js +++ b/services/pub/pub.service.js @@ -5,9 +5,7 @@ const { latest, renderVersionBadge } = require('../version') const { BaseJsonService, redirector } = require('..') const schema = Joi.object({ - versions: Joi.array() - .items(Joi.string()) - .required(), + versions: Joi.array().items(Joi.string()).required(), }).required() const queryParamSchema = Joi.object({ diff --git a/services/pub/pub.tester.js b/services/pub/pub.tester.js index 74c9db3b203ceb5d9e93b028e72866f47ed6a9dd..613447fff620d7240d8f64b1b5ba48a94518db03 100644 --- a/services/pub/pub.tester.js +++ b/services/pub/pub.tester.js @@ -8,12 +8,10 @@ const t = (module.exports = new ServiceTester({ pathPrefix: '/pub', })) -t.create('package version') - .get('/v/box2d.json') - .expectBadge({ - label: 'pub', - message: isVPlusTripleDottedVersion, - }) +t.create('package version').get('/v/box2d.json').expectBadge({ + label: 'pub', + message: isVPlusTripleDottedVersion, +}) t.create('package pre-release version') .get('/v/box2d.json?include_prereleases') @@ -22,12 +20,10 @@ t.create('package pre-release version') message: isVPlusTripleDottedVersion, }) -t.create('package not found') - .get('/v/does-not-exist.json') - .expectBadge({ - label: 'pub', - message: 'not found', - }) +t.create('package not found').get('/v/does-not-exist.json').expectBadge({ + label: 'pub', + message: 'not found', +}) t.create('package version (legacy redirect: vpre)') .get('/vpre/box2d.svg') diff --git a/services/puppetforge/puppetforge-base.js b/services/puppetforge/puppetforge-base.js index db48d825d10d84c150f177ee238726876ff4cd71..e3abd555f5f96fb20fec4b565313ee650cff2dd5 100644 --- a/services/puppetforge/puppetforge-base.js +++ b/services/puppetforge/puppetforge-base.js @@ -11,23 +11,16 @@ const usersSchema = Joi.object({ const modulesSchema = Joi.object({ endorsement: Joi.string().allow(null), - feedback_score: Joi.number() - .integer() - .min(0) - .allow(null), + feedback_score: Joi.number().integer().min(0).allow(null), downloads: nonNegativeInteger, current_release: Joi.alternatives( Joi.object({ - pdk: Joi.boolean() - .valid(true) - .required(), + pdk: Joi.boolean().valid(true).required(), version: semver, metadata: Joi.object({ 'pdk-version': semver }).required(), }).required(), Joi.object({ - pdk: Joi.boolean() - .valid(false) - .required(), + pdk: Joi.boolean().valid(false).required(), version: semver, }).required() ), diff --git a/services/puppetforge/puppetforge-module-downloads.tester.js b/services/puppetforge/puppetforge-module-downloads.tester.js index ddfd0293bb37272d032565f303e858c83f178760..f7383969f3d12d057e39073fdcaa18d35f42dbee 100644 --- a/services/puppetforge/puppetforge-module-downloads.tester.js +++ b/services/puppetforge/puppetforge-module-downloads.tester.js @@ -3,12 +3,10 @@ const { isMetric } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('module downloads') - .get('/camptocamp/openssl.json') - .expectBadge({ - label: 'downloads', - message: isMetric, - }) +t.create('module downloads').get('/camptocamp/openssl.json').expectBadge({ + label: 'downloads', + message: isMetric, +}) t.create('module downloads (not found)') .get('/notarealuser/notarealpackage.json') diff --git a/services/puppetforge/puppetforge-module-feedback.tester.js b/services/puppetforge/puppetforge-module-feedback.tester.js index c8412b8025089761169e39bf642e932d55ace228..1178ab33de086b54c0463877a011660c14db5082 100644 --- a/services/puppetforge/puppetforge-module-feedback.tester.js +++ b/services/puppetforge/puppetforge-module-feedback.tester.js @@ -3,12 +3,10 @@ const { isPercentage } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('module feedback') - .get('/camptocamp/openssl.json') - .expectBadge({ - label: 'score', - message: isPercentage, - }) +t.create('module feedback').get('/camptocamp/openssl.json').expectBadge({ + label: 'score', + message: isPercentage, +}) t.create('module feedback (no ratings)') .get('/camptocamp/openssl.json') diff --git a/services/puppetforge/puppetforge-module-pdk-version.tester.js b/services/puppetforge/puppetforge-module-pdk-version.tester.js index f4a94e7116489e4e331b1225b137ceee1876fd48..d38efaeb00fa9c814fcf9b1e0448d235d2545a6c 100644 --- a/services/puppetforge/puppetforge-module-pdk-version.tester.js +++ b/services/puppetforge/puppetforge-module-pdk-version.tester.js @@ -3,12 +3,10 @@ const { isSemver } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('PDK version') - .get('/tragiccode/azure_key_vault.json') - .expectBadge({ - label: 'pdk version', - message: isSemver, - }) +t.create('PDK version').get('/tragiccode/azure_key_vault.json').expectBadge({ + label: 'pdk version', + message: isSemver, +}) t.create("PDK version (library doesn't use the PDK)") .get('/puppet/yum.json') diff --git a/services/puppetforge/puppetforge-module-version.tester.js b/services/puppetforge/puppetforge-module-version.tester.js index 5a9720912d22b4bc282992430897a3bf4e9e557e..a06132f1c5513d4ad9e8a4809f299abd403ac41d 100644 --- a/services/puppetforge/puppetforge-module-version.tester.js +++ b/services/puppetforge/puppetforge-module-version.tester.js @@ -3,12 +3,10 @@ const { isSemver } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('module version') - .get('/camptocamp/openssl.json') - .expectBadge({ - label: 'puppetforge', - message: isSemver, - }) +t.create('module version').get('/camptocamp/openssl.json').expectBadge({ + label: 'puppetforge', + message: isSemver, +}) t.create('module version (not found)') .get('/notarealuser/notarealpackage.json') diff --git a/services/puppetforge/puppetforge-user-module-count.tester.js b/services/puppetforge/puppetforge-user-module-count.tester.js index a5f871194b6dd59429c5035e73c3fac8352740ff..1a970d83abb667d0783af016db6baf7846aed203 100644 --- a/services/puppetforge/puppetforge-user-module-count.tester.js +++ b/services/puppetforge/puppetforge-user-module-count.tester.js @@ -3,16 +3,12 @@ const { isMetric } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('modules by user') - .get('/camptocamp.json') - .expectBadge({ - label: 'modules', - message: isMetric, - }) +t.create('modules by user').get('/camptocamp.json').expectBadge({ + label: 'modules', + message: isMetric, +}) -t.create('modules by user') - .get('/not-a-real-user.json') - .expectBadge({ - label: 'modules', - message: 'not found', - }) +t.create('modules by user').get('/not-a-real-user.json').expectBadge({ + label: 'modules', + message: 'not found', +}) diff --git a/services/puppetforge/puppetforge-user-release-count.tester.js b/services/puppetforge/puppetforge-user-release-count.tester.js index 13ba3ef1ed079e3818a948a9bc33275b16349427..75ec3023d2b89d32e6055ec940fa42bada74ddcb 100644 --- a/services/puppetforge/puppetforge-user-release-count.tester.js +++ b/services/puppetforge/puppetforge-user-release-count.tester.js @@ -3,16 +3,12 @@ const { isMetric } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('releases by user') - .get('/camptocamp.json') - .expectBadge({ - label: 'releases', - message: isMetric, - }) +t.create('releases by user').get('/camptocamp.json').expectBadge({ + label: 'releases', + message: isMetric, +}) -t.create('releases by user') - .get('/not-a-real-user.json') - .expectBadge({ - label: 'releases', - message: 'not found', - }) +t.create('releases by user').get('/not-a-real-user.json').expectBadge({ + label: 'releases', + message: 'not found', +}) diff --git a/services/pypi/pypi-base.js b/services/pypi/pypi-base.js index f77b7cf5fcbcbebc1b667bc36ca6b4f12dcae015..faab58bae3a9de8cbe5f6e6a546ab199d20ff2d8 100644 --- a/services/pypi/pypi-base.js +++ b/services/pypi/pypi-base.js @@ -8,9 +8,7 @@ const schema = Joi.object({ version: Joi.string().required(), // https://github.com/badges/shields/issues/2022 license: Joi.string().allow(''), - classifiers: Joi.array() - .items(Joi.string()) - .required(), + classifiers: Joi.array().items(Joi.string()).required(), }).required(), releases: Joi.object() .pattern( diff --git a/services/pypi/pypi-helpers.spec.js b/services/pypi/pypi-helpers.spec.js index e121639229ba4984a16925132cd9db52a67c243d..5edf443b96816d86324b4dd5e328b1e864a3f002 100644 --- a/services/pypi/pypi-helpers.spec.js +++ b/services/pypi/pypi-helpers.spec.js @@ -36,8 +36,8 @@ const classifiersFixture = { }, } -describe('PyPI helpers', function() { - test(parseClassifiers, function() { +describe('PyPI helpers', function () { + test(parseClassifiers, function () { given( classifiersFixture, /^Programming Language :: Python :: ([\d.]+)$/ @@ -62,7 +62,7 @@ describe('PyPI helpers', function() { given(classifiersFixture, /^(?!.*)*$/).expect([]) }) - test(parseDjangoVersionString, function() { + test(parseDjangoVersionString, function () { given('1').expect({ major: 1, minor: 0 }) given('1.0').expect({ major: 1, minor: 0 }) given('7.2').expect({ major: 7, minor: 2 }) @@ -71,7 +71,7 @@ describe('PyPI helpers', function() { given('foo').expect({ major: 0, minor: 0 }) }) - test(sortDjangoVersions, function() { + test(sortDjangoVersions, function () { // Each of these includes a different variant: 2.0, 2, and 2.0rc1. given(['2.0', '1.9', '10', '1.11', '2.1', '2.11']).expect([ '1.9', diff --git a/services/pypi/pypi-implementation.tester.js b/services/pypi/pypi-implementation.tester.js index 9a6d54fbc916ff1b31a0daff3e8168f6de45b2aa..726d4d2912c589c762d3e7c8af7ba2175baf3dc3 100644 --- a/services/pypi/pypi-implementation.tester.js +++ b/services/pypi/pypi-implementation.tester.js @@ -14,9 +14,7 @@ t.create('implementation (not specified)') .get('/chai/1.1.2.json') .expectBadge({ label: 'implementation', message: 'cpython' }) -t.create('implementation (invalid)') - .get('/not-a-package.json') - .expectBadge({ - label: 'implementation', - message: 'package or version not found', - }) +t.create('implementation (invalid)').get('/not-a-package.json').expectBadge({ + label: 'implementation', + message: 'package or version not found', +}) diff --git a/services/pypi/pypi-python-versions.service.js b/services/pypi/pypi-python-versions.service.js index 8a4b4168ac531d760a564653956f31a6ebf73230..29a4c4583ef9e0d127714f670fa0b6bbb0d422bd 100644 --- a/services/pypi/pypi-python-versions.service.js +++ b/services/pypi/pypi-python-versions.service.js @@ -38,9 +38,7 @@ module.exports = class PypiPythonVersions extends PypiBase { }) if (versionSet.size) { return { - message: Array.from(versionSet) - .sort() - .join(' | '), + message: Array.from(versionSet).sort().join(' | '), color: 'blue', } } else { diff --git a/services/pypi/pypi-version.tester.js b/services/pypi/pypi-version.tester.js index 9e0fc375754f80201c801f3f16b7a09f60ec064b..bbc2da7ef4e2199eec38bfd0814da2320854bbc4 100644 --- a/services/pypi/pypi-version.tester.js +++ b/services/pypi/pypi-version.tester.js @@ -18,20 +18,16 @@ const isPsycopg2Version = Joi.string().regex(/^v([0-9][.]?)+$/) We'll run this test against a project that follows SemVer... */ -t.create('version (semver)') - .get('/requests.json') - .expectBadge({ - label: 'pypi', - message: isSemver, - }) +t.create('version (semver)').get('/requests.json').expectBadge({ + label: 'pypi', + message: isSemver, +}) // ..whereas this project does not folow SemVer -t.create('version (not semver)') - .get('/psycopg2.json') - .expectBadge({ - label: 'pypi', - message: isPsycopg2Version, - }) +t.create('version (not semver)').get('/psycopg2.json').expectBadge({ + label: 'pypi', + message: isPsycopg2Version, +}) t.create('version (invalid)') .get('/not-a-package.json') diff --git a/services/redmine/redmine.service.js b/services/redmine/redmine.service.js index b4a95e97e656a103343a7dfc24a5022cd9fe1978..c406dc311e93c2d9cd3b4c56235deacaef8d9cc9 100644 --- a/services/redmine/redmine.service.js +++ b/services/redmine/redmine.service.js @@ -7,9 +7,7 @@ const { BaseXmlService } = require('..') const schema = Joi.object({ 'redmine-plugin': Joi.object({ - 'ratings-average': Joi.number() - .min(0) - .required(), + 'ratings-average': Joi.number().min(0).required(), }).required(), }) diff --git a/services/repology/repology-repositories.tester.js b/services/repology/repology-repositories.tester.js index 69a0a09ed379f38b3b643ec2cd4640a996fbd823..b300adc44e05e8c5359adf81412601e5ca7ca01e 100644 --- a/services/repology/repology-repositories.tester.js +++ b/services/repology/repology-repositories.tester.js @@ -3,12 +3,10 @@ const t = (module.exports = require('../tester').createServiceTester()) const { nonNegativeInteger } = require('../validators') -t.create('Existing project') - .get('/starship.json') - .expectBadge({ - label: 'repositories', - message: nonNegativeInteger, - }) +t.create('Existing project').get('/starship.json').expectBadge({ + label: 'repositories', + message: nonNegativeInteger, +}) t.create('Non-existent project') .get('/invalidprojectthatshouldnotexist.json') diff --git a/services/resharper/resharper.tester.js b/services/resharper/resharper.tester.js index 171d19c42185ecd94c340e242296fc5ad1d6107b..bc31157ade833b768c7757c662524505b31f5c5a 100644 --- a/services/resharper/resharper.tester.js +++ b/services/resharper/resharper.tester.js @@ -14,12 +14,10 @@ const t = (module.exports = new ServiceTester({ // downloads -t.create('total downloads (valid)') - .get('/dt/ReSharper.Nuke.json') - .expectBadge({ - label: 'downloads', - message: isMetric, - }) +t.create('total downloads (valid)').get('/dt/ReSharper.Nuke.json').expectBadge({ + label: 'downloads', + message: isMetric, +}) t.create('total downloads (not found)') .get('/dt/not-a-real-package.json') @@ -27,12 +25,10 @@ t.create('total downloads (not found)') // version -t.create('version (valid)') - .get('/v/ReSharper.Nuke.json') - .expectBadge({ - label: 'resharper', - message: isVPlusDottedVersionNClauses, - }) +t.create('version (valid)').get('/v/ReSharper.Nuke.json').expectBadge({ + label: 'resharper', + message: isVPlusDottedVersionNClauses, +}) t.create('version (not found)') .get('/v/not-a-real-package.json') diff --git a/services/scrutinizer/scrutinizer-build.tester.js b/services/scrutinizer/scrutinizer-build.tester.js index 5547c9f4778da739aa59efb05b220c0f2714b27f..7730006c57d9d588d6f14145d2fc660a290281a5 100644 --- a/services/scrutinizer/scrutinizer-build.tester.js +++ b/services/scrutinizer/scrutinizer-build.tester.js @@ -59,12 +59,10 @@ t.create('build private project') message: 'not authorized to access project', }) -t.create('build nonexistent project') - .get('/gp/foo.json') - .expectBadge({ - label: 'build', - message: 'project not found', - }) +t.create('build nonexistent project').get('/gp/foo.json').expectBadge({ + label: 'build', + message: 'project not found', +}) t.create('build nonexistent branch') .get('/g/phpmyadmin/phpmyadmin/super-fake/not-real-branch.json') diff --git a/services/scrutinizer/scrutinizer-coverage.spec.js b/services/scrutinizer/scrutinizer-coverage.spec.js index 1ff20e22b7fa22b92a8881a05e708985f0cc6fb4..c0308172d42de20bf5e006355d05c1736be2e2b4 100644 --- a/services/scrutinizer/scrutinizer-coverage.spec.js +++ b/services/scrutinizer/scrutinizer-coverage.spec.js @@ -5,7 +5,7 @@ const { test, given } = require('sazerac') const { InvalidResponse, NotFound } = require('..') const [ScrutinizerCoverage] = require('./scrutinizer-coverage.service') -describe('ScrutinizerCoverage', function() { +describe('ScrutinizerCoverage', function () { test(ScrutinizerCoverage.render, () => { given({ coverage: 39 }).expect({ message: '39%', @@ -25,8 +25,8 @@ describe('ScrutinizerCoverage', function() { }) }) - context('transform()', function() { - it('throws NotFound error when there is no coverage data', function() { + context('transform()', function () { + it('throws NotFound error when there is no coverage data', function () { try { ScrutinizerCoverage.prototype.transform({ branch: 'master', @@ -50,7 +50,7 @@ describe('ScrutinizerCoverage', function() { expect(e.prettyMessage).to.equal('coverage not found') } }) - it('throws InvalidResponse error when branch is missing statistics', function() { + it('throws InvalidResponse error when branch is missing statistics', function () { expect(() => ScrutinizerCoverage.prototype.transform({ branch: 'gh-pages', diff --git a/services/scrutinizer/scrutinizer-coverage.tester.js b/services/scrutinizer/scrutinizer-coverage.tester.js index bfe306b34d8a02b6f1acdb2000444a508eeac8dd..ee2ca663b1d3be0feeafdb9b34ea0d0522fd025a 100644 --- a/services/scrutinizer/scrutinizer-coverage.tester.js +++ b/services/scrutinizer/scrutinizer-coverage.tester.js @@ -8,12 +8,10 @@ const t = (module.exports = new ServiceTester({ pathPrefix: '/scrutinizer/coverage', })) -t.create('code coverage (GitHub)') - .get('/g/filp/whoops.json') - .expectBadge({ - label: 'coverage', - message: isIntegerPercentage, - }) +t.create('code coverage (GitHub)').get('/g/filp/whoops.json').expectBadge({ + label: 'coverage', + message: isIntegerPercentage, +}) t.create('code coverage branch (GitHub)') .get('/g/PHPMailer/PHPMailer/master.json') @@ -36,9 +34,7 @@ t.create('code coverage private project') message: 'not authorized to access project', }) -t.create('code coverage nonexistent project') - .get('/gp/foo.json') - .expectBadge({ - label: 'coverage', - message: 'project not found', - }) +t.create('code coverage nonexistent project').get('/gp/foo.json').expectBadge({ + label: 'coverage', + message: 'project not found', +}) diff --git a/services/scrutinizer/scrutinizer-quality.tester.js b/services/scrutinizer/scrutinizer-quality.tester.js index e1e685f3ce123aadf2294b4f32863c8266166715..849da9e2bc7d57961f1e495df52b1642da2df6a9 100644 --- a/services/scrutinizer/scrutinizer-quality.tester.js +++ b/services/scrutinizer/scrutinizer-quality.tester.js @@ -10,12 +10,10 @@ const t = (module.exports = new ServiceTester({ const isQualityNumber = Joi.number().positive() -t.create('code quality (GitHub)') - .get('/g/filp/whoops.json') - .expectBadge({ - label: 'code quality', - message: isQualityNumber, - }) +t.create('code quality (GitHub)').get('/g/filp/whoops.json').expectBadge({ + label: 'code quality', + message: isQualityNumber, +}) t.create('code quality branch (GitHub)') .get('/g/PHPMailer/PHPMailer/master.json') @@ -38,12 +36,10 @@ t.create('code quality private project') message: 'not authorized to access project', }) -t.create('code quality nonexistent project') - .get('/gp/foo.json') - .expectBadge({ - label: 'code quality', - message: 'project not found', - }) +t.create('code quality nonexistent project').get('/gp/foo.json').expectBadge({ + label: 'code quality', + message: 'project not found', +}) t.create('code quality data missing for default branch') .get('/g/filp/whoops.json') diff --git a/services/snyk/snyk-vulnerability-github.tester.js b/services/snyk/snyk-vulnerability-github.tester.js index 23305db826bb12ca896c17fbfb24ffa4e1a4e7fa..ab96aa5c56cb8b176be1865183700cdc64219b7a 100644 --- a/services/snyk/snyk-vulnerability-github.tester.js +++ b/services/snyk/snyk-vulnerability-github.tester.js @@ -7,13 +7,10 @@ const { zeroVulnerabilitiesSvg, } = require('./snyk-test-helpers') -t.create('valid repo') - .get('/snyk/snyk.json') - .timeout(20000) - .expectBadge({ - label: 'vulnerabilities', - message: Joi.number().required(), - }) +t.create('valid repo').get('/snyk/snyk.json').timeout(20000).expectBadge({ + label: 'vulnerabilities', + message: Joi.number().required(), +}) t.create('non existent repo') .get('/badges/not-real.json') diff --git a/services/sonar/sonar-documented-api-density.spec.js b/services/sonar/sonar-documented-api-density.spec.js index e27a25dc1377cf049fdd0f7674087d92691ed43a..f2dc4821d210111a9ee51145a6d34e62a8391068 100644 --- a/services/sonar/sonar-documented-api-density.spec.js +++ b/services/sonar/sonar-documented-api-density.spec.js @@ -3,7 +3,7 @@ const { test, given } = require('sazerac') const SonarDocumentedApiDensity = require('./sonar-documented-api-density.service') -describe('SonarDocumentedApiDensity', function() { +describe('SonarDocumentedApiDensity', function () { test(SonarDocumentedApiDensity.render, () => { given({ density: 0 }).expect({ message: '0%', diff --git a/services/sonar/sonar-fortify-rating.spec.js b/services/sonar/sonar-fortify-rating.spec.js index 90b5b11a80b50b9894da57d18a552d0c374f87fc..2121c484f55a05470f6fd296f4c804cff03ffea9 100644 --- a/services/sonar/sonar-fortify-rating.spec.js +++ b/services/sonar/sonar-fortify-rating.spec.js @@ -17,10 +17,10 @@ const config = { }, } -describe('SonarFortifyRating', function() { +describe('SonarFortifyRating', function () { cleanUpNockAfterEach() - it('sends the auth information as configured', async function() { + it('sends the auth information as configured', async function () { const scope = nock('http://sonar.petalslink.com') .get('/api/measures/component') .query({ diff --git a/services/sonar/sonar-helpers.js b/services/sonar/sonar-helpers.js index 15c5e2373e3d8d33e5e88689efb52ce0fe8db716..605c92ae828b6645bdde3a52f0e254b3e92d1a7d 100644 --- a/services/sonar/sonar-helpers.js +++ b/services/sonar/sonar-helpers.js @@ -45,9 +45,7 @@ const queryParamSchema = Joi.object({ const queryParamWithFormatSchema = Joi.object({ sonarVersion: sonarVersionSchema, server: optionalUrl.required(), - format: Joi.string() - .allow('short', 'long') - .optional(), + format: Joi.string().allow('short', 'long').optional(), }).required() const keywords = ['sonarcloud', 'sonarqube'] diff --git a/services/sonar/sonar-quality-gate.spec.js b/services/sonar/sonar-quality-gate.spec.js index fd214ec46ddb83ec8b61049e2a60d8ee43580878..a7da68177b2cfb007f324c7243ca7362c3cfded6 100644 --- a/services/sonar/sonar-quality-gate.spec.js +++ b/services/sonar/sonar-quality-gate.spec.js @@ -3,7 +3,7 @@ const { test, given } = require('sazerac') const SonarQualityGate = require('./sonar-quality-gate.service') -describe('SonarQualityGate', function() { +describe('SonarQualityGate', function () { test(SonarQualityGate.render, () => { given({ qualityState: 'OK' }).expect({ message: 'passed', diff --git a/services/sonar/sonar-tech-debt.spec.js b/services/sonar/sonar-tech-debt.spec.js index 534df84a6162bcdba66fb80a422e272dcc22ccec..b5c8678e6226a61a0363fb6989db70b79939b1d3 100644 --- a/services/sonar/sonar-tech-debt.spec.js +++ b/services/sonar/sonar-tech-debt.spec.js @@ -3,7 +3,7 @@ const { test, given } = require('sazerac') const SonarTechDebt = require('./sonar-tech-debt.service') -describe('SonarTechDebt', function() { +describe('SonarTechDebt', function () { test(SonarTechDebt.render, () => { given({ debt: 0 }).expect({ label: undefined, diff --git a/services/sonar/sonar-tests.spec.js b/services/sonar/sonar-tests.spec.js index b2043ef5c7215c132f252d179178ba58215c62da..f16dc6137a3326c7f49a65070d26e792c382c8cb 100644 --- a/services/sonar/sonar-tests.spec.js +++ b/services/sonar/sonar-tests.spec.js @@ -3,7 +3,7 @@ const { test, given } = require('sazerac') const SonarTests = require('./sonar-tests.service')[1] -describe('SonarTests', function() { +describe('SonarTests', function () { test(SonarTests.render, () => { given({ value: 0, metric: 'test_failures' }).expect({ label: 'test failures', diff --git a/services/sonar/sonar-tests.tester.js b/services/sonar/sonar-tests.tester.js index cc929b0f206e16c9447e7b7c39cd21a00e9301f4..1f5f413272d3998d74a1180c7881bb97fffe0ddd 100644 --- a/services/sonar/sonar-tests.tester.js +++ b/services/sonar/sonar-tests.tester.js @@ -16,9 +16,7 @@ const { const { isIntegerPercentage, isMetric } = require('../test-validators') const isMetricAllowZero = Joi.alternatives( isMetric, - Joi.number() - .valid(0) - .required() + Joi.number().valid(0).required() ) // The service tests targeting the legacy SonarQube API are mocked diff --git a/services/sonar/sonar-violations.spec.js b/services/sonar/sonar-violations.spec.js index 6983c6da97e2fa7df90d2c8470f321ea37f53775..3509ac0fd33bc4e7d39724c4ab6df8f4ba01437f 100644 --- a/services/sonar/sonar-violations.spec.js +++ b/services/sonar/sonar-violations.spec.js @@ -4,7 +4,7 @@ const { test, given } = require('sazerac') const { metric } = require('../text-formatters') const SonarViolations = require('./sonar-violations.service') -describe('SonarViolations', function() { +describe('SonarViolations', function () { test(SonarViolations.render, () => { given({ metricName: 'violations', violations: 1003 }).expect({ message: metric(1003), diff --git a/services/sourceforge/sourceforge-open-tickets.tester.js b/services/sourceforge/sourceforge-open-tickets.tester.js index 3636eb9aeaa47a0e589f2c1c8ddc9d01d8a4ce4e..807a6c38e8bc32fe005e296478d4599e4eacc85f 100644 --- a/services/sourceforge/sourceforge-open-tickets.tester.js +++ b/services/sourceforge/sourceforge-open-tickets.tester.js @@ -19,9 +19,7 @@ t.create('feature requests') }) .timeout(10000) -t.create('invalid project') - .get('/invalid/bugs.json') - .expectBadge({ - label: 'open tickets', - message: 'project not found', - }) +t.create('invalid project').get('/invalid/bugs.json').expectBadge({ + label: 'open tickets', + message: 'project not found', +}) diff --git a/services/sourceforge/sourceforge.tester.js b/services/sourceforge/sourceforge.tester.js index 4dfa19bccd6717fec24d3ee7d9470321963f459b..6ccd13192dc9a476186636fd25fc32651f49eab8 100644 --- a/services/sourceforge/sourceforge.tester.js +++ b/services/sourceforge/sourceforge.tester.js @@ -3,12 +3,10 @@ const { isMetric, isMetricOverTimePeriod } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('total downloads') - .get('/dt/sevenzip.json') - .expectBadge({ - label: 'downloads', - message: isMetric, - }) +t.create('total downloads').get('/dt/sevenzip.json').expectBadge({ + label: 'downloads', + message: isMetric, +}) t.create('total downloads (with subdirs)') .get('/dt/smartmontools/smartmontools/7.1.json') @@ -17,37 +15,27 @@ t.create('total downloads (with subdirs)') message: isMetric, }) -t.create('monthly downloads') - .get('/dm/sevenzip.json') - .expectBadge({ - label: 'downloads', - message: isMetricOverTimePeriod, - }) - -t.create('weekly downloads') - .get('/dw/sevenzip.json') - .expectBadge({ - label: 'downloads', - message: isMetricOverTimePeriod, - }) - -t.create('daily downloads') - .get('/dd/sevenzip.json') - .expectBadge({ - label: 'downloads', - message: isMetricOverTimePeriod, - }) - -t.create('downloads folder') - .get('/dm/arianne/stendhal.json') - .expectBadge({ - label: 'downloads', - message: isMetricOverTimePeriod, - }) - -t.create('invalid project') - .get('/dd/invalid.json') - .expectBadge({ - label: 'sourceforge', - message: 'project not found', - }) +t.create('monthly downloads').get('/dm/sevenzip.json').expectBadge({ + label: 'downloads', + message: isMetricOverTimePeriod, +}) + +t.create('weekly downloads').get('/dw/sevenzip.json').expectBadge({ + label: 'downloads', + message: isMetricOverTimePeriod, +}) + +t.create('daily downloads').get('/dd/sevenzip.json').expectBadge({ + label: 'downloads', + message: isMetricOverTimePeriod, +}) + +t.create('downloads folder').get('/dm/arianne/stendhal.json').expectBadge({ + label: 'downloads', + message: isMetricOverTimePeriod, +}) + +t.create('invalid project').get('/dd/invalid.json').expectBadge({ + label: 'sourceforge', + message: 'project not found', +}) diff --git a/services/sourcegraph/sourcegraph.service.js b/services/sourcegraph/sourcegraph.service.js index 0b2b5b82e8d634ac92d84cc95a96677eb2f94396..1b54d235a005e8e75fdae5c7c7482139ac1840e3 100644 --- a/services/sourcegraph/sourcegraph.service.js +++ b/services/sourcegraph/sourcegraph.service.js @@ -5,9 +5,7 @@ const { BaseJsonService } = require('..') const projectsCountRegex = /^\s[0-9]*(\.[0-9]k)?\sprojects$/ const schema = Joi.object({ - value: Joi.string() - .regex(projectsCountRegex) - .required(), + value: Joi.string().regex(projectsCountRegex).required(), }).required() module.exports = class Sourcegraph extends BaseJsonService { diff --git a/services/spack/spack.tester.js b/services/spack/spack.tester.js index e7ba5d63645a99d17aa5f0e3536318cf26d2fbc4..f72dd327272cb7554c2ac3b62f3119bed263fa09 100644 --- a/services/spack/spack.tester.js +++ b/services/spack/spack.tester.js @@ -3,12 +3,10 @@ const { isVPlusDottedVersionAtLeastOne } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('version (valid)') - .get('/adios2.json') - .expectBadge({ - label: 'spack', - message: isVPlusDottedVersionAtLeastOne, - }) +t.create('version (valid)').get('/adios2.json').expectBadge({ + label: 'spack', + message: isVPlusDottedVersionAtLeastOne, +}) t.create('version (not found)') .get('/not-a-package.json') diff --git a/services/spiget/spiget-base.js b/services/spiget/spiget-base.js index 078f633666d9eabb01414ae833b1c787630be53d..ad4302d3d1dd8e842fc0c9ed09c9c55cb3382358 100644 --- a/services/spiget/spiget-base.js +++ b/services/spiget/spiget-base.js @@ -8,9 +8,7 @@ const resourceSchema = Joi.object({ file: Joi.object({ type: Joi.string().required(), size: Joi.number().required(), - sizeUnit: Joi.string() - .allow('') - .required(), + sizeUnit: Joi.string().allow('').required(), }).required(), testedVersions: Joi.array(), rating: Joi.object({ diff --git a/services/spiget/spiget-download-size.tester.js b/services/spiget/spiget-download-size.tester.js index a5c943d64222afb9f35109510b9f3d8b9fdf6a73..5b8904d63f07b22748a3751fa639a844ed7afa58 100644 --- a/services/spiget/spiget-download-size.tester.js +++ b/services/spiget/spiget-download-size.tester.js @@ -7,16 +7,12 @@ t.create('EssentialsX (id 9089)') .get('/9089.json') .expectBadge({ label: 'size', message: isFileSize }) -t.create('Advanced Achievements (id 6239)') - .get('/6239.json') - .expectBadge({ - lavel: 'size', - message: 'resource hosted externally', - }) +t.create('Advanced Achievements (id 6239)').get('/6239.json').expectBadge({ + lavel: 'size', + message: 'resource hosted externally', +}) -t.create('Invalid Resource (id 1)') - .get('/1.json') - .expectBadge({ - label: 'size', - message: 'not found', - }) +t.create('Invalid Resource (id 1)').get('/1.json').expectBadge({ + label: 'size', + message: 'not found', +}) diff --git a/services/spiget/spiget-downloads.tester.js b/services/spiget/spiget-downloads.tester.js index fb2f7a2d8a67116f4925dfd62b2d9da320d21dd8..e24e7f5d9f75d6a07d328309143559925da53e9f 100644 --- a/services/spiget/spiget-downloads.tester.js +++ b/services/spiget/spiget-downloads.tester.js @@ -3,16 +3,12 @@ const { isMetric } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('EssentialsX (id 9089)') - .get('/9089.json') - .expectBadge({ - label: 'downloads', - message: isMetric, - }) +t.create('EssentialsX (id 9089)').get('/9089.json').expectBadge({ + label: 'downloads', + message: isMetric, +}) -t.create('Invalid Resource (id 1)') - .get('/1.json') - .expectBadge({ - label: 'downloads', - message: 'not found', - }) +t.create('Invalid Resource (id 1)').get('/1.json').expectBadge({ + label: 'downloads', + message: 'not found', +}) diff --git a/services/spiget/spiget-latest-version.tester.js b/services/spiget/spiget-latest-version.tester.js index c088f072c62d9c77ce4ebfe07917f2bc3f895741..a14abc1aaabb7653cba64ab33304c1066bd009a7 100644 --- a/services/spiget/spiget-latest-version.tester.js +++ b/services/spiget/spiget-latest-version.tester.js @@ -12,9 +12,7 @@ t.create('EssentialsX (id 9089)') message: withRegex(/^(?!not found$)/), }) -t.create('Invalid Resource (id 1)') - .get('/1.json') - .expectBadge({ - label: 'spiget', - message: 'not found', - }) +t.create('Invalid Resource (id 1)').get('/1.json').expectBadge({ + label: 'spiget', + message: 'not found', +}) diff --git a/services/spiget/spiget-rating.tester.js b/services/spiget/spiget-rating.tester.js index fd238c0adbd950a423e9191c358f80f63d78168b..efe5a6b52dd815f5ce3115d23c21367585a85272 100644 --- a/services/spiget/spiget-rating.tester.js +++ b/services/spiget/spiget-rating.tester.js @@ -3,19 +3,15 @@ const { isStarRating, withRegex } = require('../test-validators') const t = (module.exports = require('../tester').createServiceTester()) -t.create('Stars - EssentialsX (id 9089)') - .get('/stars/9089.json') - .expectBadge({ - label: 'rating', - message: isStarRating, - }) +t.create('Stars - EssentialsX (id 9089)').get('/stars/9089.json').expectBadge({ + label: 'rating', + message: isStarRating, +}) -t.create('Stars - Invalid Resource (id 1)') - .get('/stars/1.json') - .expectBadge({ - label: 'rating', - message: 'not found', - }) +t.create('Stars - Invalid Resource (id 1)').get('/stars/1.json').expectBadge({ + label: 'rating', + message: 'not found', +}) t.create('Rating - EssentialsX (id 9089)') .get('/rating/9089.json') @@ -24,9 +20,7 @@ t.create('Rating - EssentialsX (id 9089)') message: withRegex(/^(\d*\.\d+)(\/5 \()(\d+)(\))$/), }) -t.create('Rating - Invalid Resource (id 1)') - .get('/rating/1.json') - .expectBadge({ - label: 'rating', - message: 'not found', - }) +t.create('Rating - Invalid Resource (id 1)').get('/rating/1.json').expectBadge({ + label: 'rating', + message: 'not found', +}) diff --git a/services/spiget/spiget-tested-versions.tester.js b/services/spiget/spiget-tested-versions.tester.js index 7389e9283c996c51ae0e99937ee99fc72d6e2264..8ab77790e4664144e872459c12dacbbbc8ec45db 100644 --- a/services/spiget/spiget-tested-versions.tester.js +++ b/services/spiget/spiget-tested-versions.tester.js @@ -12,12 +12,10 @@ t.create('EssentialsX - multiple versions supported - (id 9089)') message: multipleVersions, }) -t.create('Invalid Resource (id 1)') - .get('/1.json') - .expectBadge({ - label: 'tested versions', - message: 'not found', - }) +t.create('Invalid Resource (id 1)').get('/1.json').expectBadge({ + label: 'tested versions', + message: 'not found', +}) t.create('Nock - single version supported') .get('/1.json') diff --git a/services/stackexchange/stackexchange-reputation.service.js b/services/stackexchange/stackexchange-reputation.service.js index 0d00d8c4bf65e00a62328e706054ce405f9a1268..060b1f7577e4635f19a3771daf4faff61e92c3fa 100644 --- a/services/stackexchange/stackexchange-reputation.service.js +++ b/services/stackexchange/stackexchange-reputation.service.js @@ -10,9 +10,7 @@ const reputationSchema = Joi.object({ .length(1) .items( Joi.object({ - reputation: Joi.number() - .min(0) - .required(), + reputation: Joi.number().min(0).required(), }) ) .required(), diff --git a/services/stackexchange/stackexchange-reputation.tester.js b/services/stackexchange/stackexchange-reputation.tester.js index 18a1f8144af7463ca8e90fc5124590fca50da496..b6e3b4a7d4cff11078406326c024c4786b681acb 100644 --- a/services/stackexchange/stackexchange-reputation.tester.js +++ b/services/stackexchange/stackexchange-reputation.tester.js @@ -14,9 +14,7 @@ t.create('Reputation for StackOverflow user 22656') message: isMetric, }) -t.create('Reputation for Tex user 22656') - .get('/tex/r/226.json') - .expectBadge({ - label: 'tex reputation', - message: isMetric, - }) +t.create('Reputation for Tex user 22656').get('/tex/r/226.json').expectBadge({ + label: 'tex reputation', + message: isMetric, +}) diff --git a/services/stackexchange/stackexchange-taginfo.service.js b/services/stackexchange/stackexchange-taginfo.service.js index 9736e85bffdabd7561e713059d29f6f3081d53f1..1bc7f7a1e904f92a88ec2ce1a6650c9f75ea2d99 100644 --- a/services/stackexchange/stackexchange-taginfo.service.js +++ b/services/stackexchange/stackexchange-taginfo.service.js @@ -9,9 +9,7 @@ const tagSchema = Joi.object({ .length(1) .items( Joi.object({ - count: Joi.number() - .min(0) - .required(), + count: Joi.number().min(0).required(), }) ) .required(), diff --git a/services/steam/steam-workshop.service.js b/services/steam/steam-workshop.service.js index d53598d2768c38104b5fde6aeab71e8ed282dd53..8c438fdfb183b33e858ad76f8cac04dfe5749c78 100644 --- a/services/steam/steam-workshop.service.js +++ b/services/steam/steam-workshop.service.js @@ -42,11 +42,7 @@ const steamCollectionNotFoundSchema = Joi.object({ collectiondetails: Joi.array() .items( Joi.object({ - result: Joi.number() - .integer() - .min(9) - .max(9) - .required(), + result: Joi.number().integer().min(9).max(9).required(), }).required() ) .required(), @@ -65,27 +61,13 @@ const steamFileSchema = Joi.object({ publishedfiledetails: Joi.array() .items( Joi.object({ - file_size: Joi.number() - .integer() - .required(), - time_created: Joi.number() - .integer() - .required(), - subscriptions: Joi.number() - .integer() - .required(), - favorited: Joi.number() - .integer() - .required(), - lifetime_subscriptions: Joi.number() - .integer() - .required(), - lifetime_favorited: Joi.number() - .integer() - .required(), - views: Joi.number() - .integer() - .required(), + file_size: Joi.number().integer().required(), + time_created: Joi.number().integer().required(), + subscriptions: Joi.number().integer().required(), + favorited: Joi.number().integer().required(), + lifetime_subscriptions: Joi.number().integer().required(), + lifetime_favorited: Joi.number().integer().required(), + views: Joi.number().integer().required(), }) ) .min(1) @@ -101,11 +83,7 @@ const steamFileNotFoundSchema = Joi.object({ publishedfiledetails: Joi.array() .items( Joi.object({ - result: Joi.number() - .integer() - .min(9) - .max(9) - .required(), + result: Joi.number().integer().min(9).max(9).required(), }).required() ) .min(1) diff --git a/services/suggest.integration.js b/services/suggest.integration.js index 86d47c9e0a9b8c1a8404e68aeeb2d9b56040a1a1..23e6948a33cda3d58ea680740aa5c6c8f171afbf 100644 --- a/services/suggest.integration.js +++ b/services/suggest.integration.js @@ -8,11 +8,11 @@ const got = require('../core/got-test-client') const { setRoutes } = require('./suggest') const GithubApiProvider = require('./github/github-api-provider') -describe('Badge suggestions for', function() { +describe('Badge suggestions for', function () { const githubApiBaseUrl = process.env.GITHUB_URL || 'https://api.github.com' let token, apiProvider - before(function() { + before(function () { token = config.private.gh_token if (!token) { throw Error('The integration tests require a gh_token to be set') @@ -25,17 +25,17 @@ describe('Badge suggestions for', function() { }) let port, baseUrl - before(async function() { + before(async function () { port = await portfinder.getPortPromise() baseUrl = `http://127.0.0.1:${port}` }) let camp - before(async function() { + before(async function () { camp = Camp.start({ port, hostname: '::' }) await new Promise(resolve => camp.on('listening', () => resolve())) }) - after(async function() { + after(async function () { if (camp) { await new Promise(resolve => camp.close(resolve)) camp = undefined @@ -43,12 +43,12 @@ describe('Badge suggestions for', function() { }) const origin = 'https://example.test' - before(function() { + before(function () { setRoutes([origin], apiProvider, camp) }) - describe('GitHub', function() { - context('with an existing project', function() { - it('returns the expected suggestions', async function() { + describe('GitHub', function () { + context('with an existing project', function () { + it('returns the expected suggestions', async function () { const { statusCode, body } = await got( `${baseUrl}/$suggest/v1?url=${encodeURIComponent( 'https://github.com/atom/atom' @@ -116,8 +116,8 @@ describe('Badge suggestions for', function() { }) }) - context('with a non-existent project', function() { - it('returns the expected suggestions', async function() { + context('with a non-existent project', function () { + it('returns the expected suggestions', async function () { this.timeout(5000) const { statusCode, body } = await got( @@ -188,9 +188,9 @@ describe('Badge suggestions for', function() { }) }) - describe('GitLab', function() { - context('with an existing project', function() { - it('returns the expected suggestions', async function() { + describe('GitLab', function () { + context('with an existing project', function () { + it('returns the expected suggestions', async function () { const { statusCode, body } = await got( `${baseUrl}/$suggest/v1?url=${encodeURIComponent( 'https://gitlab.com/gitlab-org/gitlab' @@ -231,8 +231,8 @@ describe('Badge suggestions for', function() { }) }) - context('with an nonexisting project', function() { - it('returns the expected suggestions', async function() { + context('with an nonexisting project', function () { + it('returns the expected suggestions', async function () { const { statusCode, body } = await got( `${baseUrl}/$suggest/v1?url=${encodeURIComponent( 'https://gitlab.com/gitlab-org/not-gitlab' diff --git a/services/suggest.spec.js b/services/suggest.spec.js index a071528c7c9f8894fecfd5b849ccfaaad4490a8b..6fcbe5dd113c1a43a4673b5cb4b2025b250ab672 100644 --- a/services/suggest.spec.js +++ b/services/suggest.spec.js @@ -8,7 +8,7 @@ const got = require('../core/got-test-client') const { setRoutes, githubLicense } = require('./suggest') const GithubApiProvider = require('./github/github-api-provider') -describe('Badge suggestions', function() { +describe('Badge suggestions', function () { const githubApiBaseUrl = 'https://api.github.test' const apiProvider = new GithubApiProvider({ baseUrl: githubApiBaseUrl, @@ -16,9 +16,9 @@ describe('Badge suggestions', function() { withPooling: false, }) - describe('GitHub license', function() { - context('When html_url included in response', function() { - it('Should link to it', async function() { + describe('GitHub license', function () { + context('When html_url included in response', function () { + it('Should link to it', async function () { const scope = nock(githubApiBaseUrl) .get('/repos/atom/atom/license') .reply(200, { @@ -46,8 +46,8 @@ describe('Badge suggestions', function() { }) }) - context('When html_url not included in response', function() { - it('Should link to the repo', async function() { + context('When html_url not included in response', function () { + it('Should link to the repo', async function () { const scope = nock(githubApiBaseUrl) .get('/repos/atom/atom/license') .reply(200, { @@ -69,19 +69,19 @@ describe('Badge suggestions', function() { }) }) - describe('Scoutcamp integration', function() { + describe('Scoutcamp integration', function () { let port, baseUrl - before(async function() { + before(async function () { port = await portfinder.getPortPromise() baseUrl = `http://127.0.0.1:${port}` }) let camp - before(async function() { + before(async function () { camp = Camp.start({ port, hostname: '::' }) await new Promise(resolve => camp.on('listening', () => resolve())) }) - after(async function() { + after(async function () { if (camp) { await new Promise(resolve => camp.close(resolve)) camp = undefined @@ -89,12 +89,12 @@ describe('Badge suggestions', function() { }) const origin = 'https://example.test' - before(function() { + before(function () { setRoutes([origin], apiProvider, camp) }) - context('without an origin header', function() { - it('returns the expected suggestions', async function() { + context('without an origin header', function () { + it('returns the expected suggestions', async function () { const scope = nock(githubApiBaseUrl) .get('/repos/atom/atom/license') .reply(200, { diff --git a/services/symfony/symfony-insight-base.js b/services/symfony/symfony-insight-base.js index e521536216e2c231cecf789f305388427e4cf899..708acd0667f9b3703378a526fcb46353832c4ed3 100644 --- a/services/symfony/symfony-insight-base.js +++ b/services/symfony/symfony-insight-base.js @@ -26,10 +26,7 @@ const schema = Joi.object({ // the xml nodes to always be parsed as an array. Currently, if the response // only contains a single violation then it will be parsed as an object, // otherwise it will be parsed as an array. - violation: Joi.array() - .items(violationSchema) - .single() - .required(), + violation: Joi.array().items(violationSchema).single().required(), }), }), }).required(), diff --git a/services/symfony/symfony-insight-base.spec.js b/services/symfony/symfony-insight-base.spec.js index d7d4af6b4fd2c10bd11c3e6abc327e839079f412..19cc1cc41c561c2bec69d023cb970d1da6e42633 100644 --- a/services/symfony/symfony-insight-base.spec.js +++ b/services/symfony/symfony-insight-base.spec.js @@ -4,9 +4,9 @@ const { expect } = require('chai') const { NotFound } = require('..') const { SymfonyInsightBase } = require('./symfony-insight-base') -describe('SymfonyInsightBase', function() { - context('transform()', function() { - it('throws NotFound error when there is no coverage data', function() { +describe('SymfonyInsightBase', function () { + context('transform()', function () { + it('throws NotFound error when there is no coverage data', function () { try { SymfonyInsightBase.prototype.transform({ data: { project: {} }, diff --git a/services/symfony/symfony-insight.spec.js b/services/symfony/symfony-insight.spec.js index acc48a3e7133aee1db4618a7377fa400ac006d40..d2c0b1032482977aa45015c880ce2afd0c3a7439 100644 --- a/services/symfony/symfony-insight.spec.js +++ b/services/symfony/symfony-insight.spec.js @@ -32,7 +32,7 @@ const { // // In most other cases, do not follow this pattern. Instead, write a .spec file // with sazerac tests of the transform and render functions. -describe('SymfonyInsight[Grade|Stars|Violation]', function() { +describe('SymfonyInsight[Grade|Stars|Violation]', function () { cleanUpNockAfterEach() function createMock() { @@ -41,7 +41,7 @@ describe('SymfonyInsight[Grade|Stars|Violation]', function() { .basicAuth({ user, pass: token }) } - it('401 not authorized grade', async function() { + it('401 not authorized grade', async function () { const scope = createMock().reply(401) expect( await SymfonyInsightGrade.invoke(defaultContext, config, { projectUuid }) @@ -65,9 +65,9 @@ describe('SymfonyInsight[Grade|Stars|Violation]', function() { throw Error(`Oops, what are those doing there: ${rest.join(', ')}`) } - describe(description, function() { + describe(description, function () { if (expectedGradeBadge) { - it('grade', async function() { + it('grade', async function () { const scope = createMock().reply(200, response) expect( await SymfonyInsightGrade.invoke(defaultContext, config, { @@ -79,7 +79,7 @@ describe('SymfonyInsight[Grade|Stars|Violation]', function() { } if (expectedStarsBadge) { - it('stars', async function() { + it('stars', async function () { const scope = createMock().reply(200, response) expect( await SymfonyInsightStars.invoke(defaultContext, config, { @@ -91,7 +91,7 @@ describe('SymfonyInsight[Grade|Stars|Violation]', function() { } if (expectedViolationsBadge) { - it('violations', async function() { + it('violations', async function () { const scope = createMock().reply(200, response) expect( await SymfonyInsightViolations.invoke(defaultContext, config, { diff --git a/services/teamcity/teamcity-build.spec.js b/services/teamcity/teamcity-build.spec.js index 06aee3668f8dbdb050774ebe3632d9bc050e8030..b19b6148801ddcdd2f2a787ddbc7149ec681398a 100644 --- a/services/teamcity/teamcity-build.spec.js +++ b/services/teamcity/teamcity-build.spec.js @@ -6,10 +6,10 @@ const { cleanUpNockAfterEach, defaultContext } = require('../test-helpers') const TeamCityBuild = require('./teamcity-build.service') const { user, pass, host, config } = require('./teamcity-test-helpers') -describe('TeamCityBuild', function() { +describe('TeamCityBuild', function () { cleanUpNockAfterEach() - it('sends the auth information as configured', async function() { + it('sends the auth information as configured', async function () { const scope = nock(`https://${host}`) .get(`/app/rest/builds/${encodeURIComponent('buildType:(id:bt678)')}`) // This ensures that the expected credentials are actually being sent with the HTTP request. diff --git a/services/teamcity/teamcity-coverage.spec.js b/services/teamcity/teamcity-coverage.spec.js index c193caede9c090b4fce358cea9f7e63348145533..b6bcd35fb7a3e0ed9f657f21239e34c688a21508 100644 --- a/services/teamcity/teamcity-coverage.spec.js +++ b/services/teamcity/teamcity-coverage.spec.js @@ -6,10 +6,10 @@ const { cleanUpNockAfterEach, defaultContext } = require('../test-helpers') const TeamCityCoverage = require('./teamcity-coverage.service') const { user, pass, host, config } = require('./teamcity-test-helpers') -describe('TeamCityCoverage', function() { +describe('TeamCityCoverage', function () { cleanUpNockAfterEach() - it('sends the auth information as configured', async function() { + it('sends the auth information as configured', async function () { const scope = nock(`https://${host}`) .get( `/app/rest/builds/${encodeURIComponent( diff --git a/services/teamcity/teamcity-coverage.tester.js b/services/teamcity/teamcity-coverage.tester.js index 9be283712febfd0e46c2299689b5f270793b8808..a259d150512ecbe446275268874f1b6ffeea7bde 100644 --- a/services/teamcity/teamcity-coverage.tester.js +++ b/services/teamcity/teamcity-coverage.tester.js @@ -7,12 +7,10 @@ t.create('invalid buildId') .get('/btABC999.json') .expectBadge({ label: 'coverage', message: 'build not found' }) -t.create('valid buildId') - .get('/ReactJSNet_PullRequests.json') - .expectBadge({ - label: 'coverage', - message: isIntegerPercentage, - }) +t.create('valid buildId').get('/ReactJSNet_PullRequests.json').expectBadge({ + label: 'coverage', + message: isIntegerPercentage, +}) t.create('specified instance valid buildId') .get('/ReactJSNet_PullRequests.json?server=https://teamcity.jetbrains.com') diff --git a/services/test-helpers.js b/services/test-helpers.js index aa8edee4f6c817e8123ada6ca33cad146bbfa5ae..cc3013135d4ac9ad048f3c262d580dedae53b30c 100644 --- a/services/test-helpers.js +++ b/services/test-helpers.js @@ -6,7 +6,7 @@ const runnerConfig = require('config').util.toObject() const { promisify } = require('../core/base-service/legacy-request-handler') function cleanUpNockAfterEach() { - afterEach(function() { + afterEach(function () { nock.restore() nock.cleanAll() nock.enableNetConnect() diff --git a/services/test-results.spec.js b/services/test-results.spec.js index feb9a5771e8f3dcc30d7651685e6f3baf36c90d8..5953f51954a31eba51faaad68988d9c91df47ba6 100644 --- a/services/test-results.spec.js +++ b/services/test-results.spec.js @@ -6,7 +6,7 @@ const { renderTestResultBadge, } = require('./test-results') -describe('Test result helpers', function() { +describe('Test result helpers', function () { function renderBothStyles(props) { const { message: standardMessage, color } = renderTestResultBadge(props) const compactMessage = renderTestResultMessage({ diff --git a/services/text-formatters.spec.js b/services/text-formatters.spec.js index 0326cfe87be01d45cf4683bc4986a19601675f5c..a5827b88866b598377d0fa7906234035847e9793 100644 --- a/services/text-formatters.spec.js +++ b/services/text-formatters.spec.js @@ -14,7 +14,7 @@ const { formatRelativeDate, } = require('./text-formatters') -describe('Text formatters', function() { +describe('Text formatters', function () { test(starRating, () => { given(4.9).expect('★★★★★') given(3.7).expect('★★★¾☆') @@ -94,12 +94,12 @@ describe('Text formatters', function() { .expect('june 2016') }) - context('in october', function() { + context('in october', function () { let clock - beforeEach(function() { + beforeEach(function () { clock = sinon.useFakeTimers(new Date(2017, 9, 15).getTime()) }) - afterEach(function() { + afterEach(function () { clock.restore() }) @@ -110,12 +110,12 @@ describe('Text formatters', function() { }) }) - context('in october', function() { + context('in october', function () { let clock - beforeEach(function() { + beforeEach(function () { clock = sinon.useFakeTimers(new Date(2018, 9, 29).getTime()) }) - afterEach(function() { + afterEach(function () { clock.restore() }) diff --git a/services/travis/travis-build.tester.js b/services/travis/travis-build.tester.js index 6bb0d988e917209cf222466003d10bfc160cb37a..a1a07f3b4516167504c0c74565480666727381b3 100644 --- a/services/travis/travis-build.tester.js +++ b/services/travis/travis-build.tester.js @@ -27,9 +27,7 @@ t.create('unknown repo') t.create('invalid svg response') .get('/foo/bar.json') .intercept(nock => - nock('https://api.travis-ci.org') - .get('/foo/bar.svg') - .reply(200) + nock('https://api.travis-ci.org').get('/foo/bar.svg').reply(200) ) .expectBadge({ label: 'build', message: 'unparseable svg response' }) @@ -56,8 +54,6 @@ t.create('unknown repo') t.create('invalid svg response') .get('/com/foo/bar.json') .intercept(nock => - nock('https://api.travis-ci.com') - .get('/foo/bar.svg') - .reply(200) + nock('https://api.travis-ci.com').get('/foo/bar.svg').reply(200) ) .expectBadge({ label: 'build', message: 'unparseable svg response' }) diff --git a/services/twitch/twitch.spec.js b/services/twitch/twitch.spec.js index 67567ddc218aa56ae8ef3540c56e6a44af6bcd35..e87ceba61f1e524e9621bc73a979511c4a6ddf62 100644 --- a/services/twitch/twitch.spec.js +++ b/services/twitch/twitch.spec.js @@ -5,8 +5,8 @@ const nock = require('nock') const { cleanUpNockAfterEach, defaultContext } = require('../test-helpers') const TwitchStatus = require('./twitch.service') -describe('TwitchStatus', function() { - describe('auth', function() { +describe('TwitchStatus', function () { + describe('auth', function () { cleanUpNockAfterEach() const user = 'admin' @@ -19,7 +19,7 @@ describe('TwitchStatus', function() { }, } - it('sends the auth information as configured', async function() { + it('sends the auth information as configured', async function () { const tokenNock = nock('https://id.twitch.tv') .post('/oauth2/token') // This ensures that the expected credentials are actually being sent with the HTTP request. diff --git a/services/uptimerobot/uptimerobot-base.js b/services/uptimerobot/uptimerobot-base.js index 641237ac587bfea1bdd6c64630b87e12c5cc31db..739e51c6800b7c05fa271e4cbaebeb8e89418cea 100644 --- a/services/uptimerobot/uptimerobot-base.js +++ b/services/uptimerobot/uptimerobot-base.js @@ -26,10 +26,7 @@ const singleMonitorResponse = Joi.alternatives( errorResponse, Joi.object({ stat: Joi.equal('ok').required(), - monitors: Joi.array() - .length(1) - .items(monitor) - .required(), + monitors: Joi.array().length(1).items(monitor).required(), }).required() ) @@ -37,10 +34,7 @@ const singleMonitorResponseWithUptime = Joi.alternatives( errorResponse, Joi.object({ stat: Joi.equal('ok').required(), - monitors: Joi.array() - .length(1) - .items(monitorWithUptime) - .required(), + monitors: Joi.array().length(1).items(monitorWithUptime).required(), }).required() ) diff --git a/services/uptimerobot/uptimerobot-ratio.tester.js b/services/uptimerobot/uptimerobot-ratio.tester.js index c3b9912be27ff0a692bd4994d2786581b0ce13cf..049fc9c05ac05c769a37b9a4f6f3a0bc130fbac4 100644 --- a/services/uptimerobot/uptimerobot-ratio.tester.js +++ b/services/uptimerobot/uptimerobot-ratio.tester.js @@ -50,9 +50,7 @@ t.create('Uptime Robot: Percentage (service unavailable)') t.create('Uptime Robot: Percentage (unexpected response, valid json)') .get('/m778918918-3e92c097147760ee39d02d36.json') .intercept(nock => - nock('https://api.uptimerobot.com') - .post('/v2/getMonitors') - .reply(200, '[]') + nock('https://api.uptimerobot.com').post('/v2/getMonitors').reply(200, '[]') ) .expectBadge({ label: 'uptime', message: 'invalid response data' }) diff --git a/services/uptimerobot/uptimerobot-status.tester.js b/services/uptimerobot/uptimerobot-status.tester.js index da6d6d1847ca007b03acc414a368f16ad71f6004..cd5b6a91464bbd017cda33e62f5710ad2460cd05 100644 --- a/services/uptimerobot/uptimerobot-status.tester.js +++ b/services/uptimerobot/uptimerobot-status.tester.js @@ -51,9 +51,7 @@ t.create('Uptime Robot: Status (service unavailable)') t.create('Uptime Robot: Status (unexpected response, valid json)') .get('/m778918918-3e92c097147760ee39d02d36.json') .intercept(nock => - nock('https://api.uptimerobot.com') - .post('/v2/getMonitors') - .reply(200, '[]') + nock('https://api.uptimerobot.com').post('/v2/getMonitors').reply(200, '[]') ) .expectBadge({ label: 'status', message: 'invalid response data' }) diff --git a/services/vaadin-directory/vaadin-directory-base.js b/services/vaadin-directory/vaadin-directory-base.js index 17776c985cce710a2b565c639a32064839b643ff..d312afbc788e2538db753f503d2dffdad3881ee3 100644 --- a/services/vaadin-directory/vaadin-directory-base.js +++ b/services/vaadin-directory/vaadin-directory-base.js @@ -6,9 +6,7 @@ const { BaseJsonService } = require('..') const schema = Joi.object({ ratingCount: nonNegativeInteger, - averageRating: Joi.number() - .min(0) - .required(), + averageRating: Joi.number().min(0).required(), latestAvailableRelease: Joi.object({ publicationDate: Joi.date().required(), name: Joi.string().required(), diff --git a/services/vaadin-directory/vaadin-directory-rating-count.tester.js b/services/vaadin-directory/vaadin-directory-rating-count.tester.js index f6b602e757930696005603aa6e2900f12044dbd7..4ed7471a6dc289a7b00234d8b39f0e793945ae96 100644 --- a/services/vaadin-directory/vaadin-directory-rating-count.tester.js +++ b/services/vaadin-directory/vaadin-directory-rating-count.tester.js @@ -17,9 +17,7 @@ t.create('rating count of component') message: Joi.string().regex(/^\d+?\stotal$/), }) -t.create('not found') - .get('/rating-count/does-not-exist.json') - .expectBadge({ - label: 'rating count', - message: 'not found', - }) +t.create('not found').get('/rating-count/does-not-exist.json').expectBadge({ + label: 'rating count', + message: 'not found', +}) diff --git a/services/vaadin-directory/vaadin-directory-rating.tester.js b/services/vaadin-directory/vaadin-directory-rating.tester.js index 48d762dfacb7d9e0fa10ff7d5df6aacd53330a7a..3cbbe9401cd2de0eb37ade69347856fc7958bcd1 100644 --- a/services/vaadin-directory/vaadin-directory-rating.tester.js +++ b/services/vaadin-directory/vaadin-directory-rating.tester.js @@ -25,9 +25,7 @@ t.create('rating of the component (eg: 4.2/5)') message: Joi.string().regex(/^\d\.\d\/5$/), }) -t.create('not found') - .get('/rating/does-not-exist.json') - .expectBadge({ - label: 'rating', - message: 'not found', - }) +t.create('not found').get('/rating/does-not-exist.json').expectBadge({ + label: 'rating', + message: 'not found', +}) diff --git a/services/vaadin-directory/vaadin-directory-status.tester.js b/services/vaadin-directory/vaadin-directory-status.tester.js index 52f5773e1d47f00ed1183472712a086aad8fe44b..7faf476ea401c49de369758902c594145d3ceac6 100644 --- a/services/vaadin-directory/vaadin-directory-status.tester.js +++ b/services/vaadin-directory/vaadin-directory-status.tester.js @@ -10,9 +10,7 @@ t.create('publish status of the component') message: Joi.equal('published', 'unpublished'), }) -t.create('not found') - .get('/does-not-exist.json') - .expectBadge({ - label: 'vaadin directory', - message: 'not found', - }) +t.create('not found').get('/does-not-exist.json').expectBadge({ + label: 'vaadin directory', + message: 'not found', +}) diff --git a/services/vaadin-directory/vaadin-directory-version.tester.js b/services/vaadin-directory/vaadin-directory-version.tester.js index e498041c09c17897cbab6b643e91dc08cb53b19d..51d6c61269e7a702987543f588423832366de2f2 100644 --- a/services/vaadin-directory/vaadin-directory-version.tester.js +++ b/services/vaadin-directory/vaadin-directory-version.tester.js @@ -17,9 +17,7 @@ t.create('latest version of the component (can have v prefixed or without)') message: isSemver, }) -t.create('not found') - .get('/v/does-not-exist.json') - .expectBadge({ - label: 'vaadin directory', - message: 'not found', - }) +t.create('not found').get('/v/does-not-exist.json').expectBadge({ + label: 'vaadin directory', + message: 'not found', +}) diff --git a/services/validators.js b/services/validators.js index 1da1625598fd66324d45e46e99df0fff87a3e808..ce64ea29df6f60d8c3d307573cb7d9f2878b5983 100644 --- a/services/validators.js +++ b/services/validators.js @@ -1,30 +1,20 @@ 'use strict' const { semver, semverRange } = require('joi-extension-semver') -const Joi = require('@hapi/joi') - .extend(semver) - .extend(semverRange) +const Joi = require('@hapi/joi').extend(semver).extend(semverRange) -const optionalNonNegativeInteger = Joi.number() - .integer() - .min(0) +const optionalNonNegativeInteger = Joi.number().integer().min(0) module.exports = { optionalNonNegativeInteger, nonNegativeInteger: optionalNonNegativeInteger.required(), - anyInteger: Joi.number() - .integer() - .required(), + anyInteger: Joi.number().integer().required(), - semver: Joi.semver() - .valid() - .required(), + semver: Joi.semver().valid().required(), - semverRange: Joi.semverRange() - .valid() - .required(), + semverRange: Joi.semverRange().valid().required(), optionalDottedVersionNClausesWithOptionalSuffix: Joi.string().regex( /^\d+(\.\d+)*([-+].*)?$/ diff --git a/services/version.spec.js b/services/version.spec.js index 37ec4c5663919394d140196e8118313af4b359c8..f447f43ac87f3515c0f3e0be92ffd4c85d458491 100644 --- a/services/version.spec.js +++ b/services/version.spec.js @@ -4,7 +4,7 @@ const { test, given } = require('sazerac') const { latest, slice, rangeStart, renderVersionBadge } = require('./version') const includePre = true -describe('Version helpers', function() { +describe('Version helpers', function () { test(latest, () => { // semver-compatible versions. given(['1.0.0', '1.0.2', '1.0.1']).expect('1.0.2') diff --git a/services/visual-studio-app-center/visual-studio-app-center-releases-osversion.tester.js b/services/visual-studio-app-center/visual-studio-app-center-releases-osversion.tester.js index c8a2adf01da871f23573febdc83f05e8e1bdb723..e2a590794892ab01785a507eb6bf806ad32f62c8 100644 --- a/services/visual-studio-app-center/visual-studio-app-center-releases-osversion.tester.js +++ b/services/visual-studio-app-center/visual-studio-app-center-releases-osversion.tester.js @@ -30,9 +30,7 @@ t.create('Invalid user, invalid project, valid API token') message: 'project not found', }) -t.create('Invalid API Token') - .get('/invalid/invalid/invalid.json') - .expectBadge({ - label: 'min version', - message: 'invalid token', - }) +t.create('Invalid API Token').get('/invalid/invalid/invalid.json').expectBadge({ + label: 'min version', + message: 'invalid token', +}) diff --git a/services/visual-studio-app-center/visual-studio-app-center-releases-size.tester.js b/services/visual-studio-app-center/visual-studio-app-center-releases-size.tester.js index be651b227f9d9a60d8b6578727c16ea0dea94d03..e3b2964e9b743a7e9fd1537ac34db3299cd273be 100644 --- a/services/visual-studio-app-center/visual-studio-app-center-releases-size.tester.js +++ b/services/visual-studio-app-center/visual-studio-app-center-releases-size.tester.js @@ -40,9 +40,7 @@ t.create('Invalid user, invalid project, valid API token') message: 'project not found', }) -t.create('Invalid API Token') - .get('/invalid/invalid/invalid.json') - .expectBadge({ - label: 'size', - message: 'invalid token', - }) +t.create('Invalid API Token').get('/invalid/invalid/invalid.json').expectBadge({ + label: 'size', + message: 'invalid token', +}) diff --git a/services/visual-studio-app-center/visual-studio-app-center-releases-version.tester.js b/services/visual-studio-app-center/visual-studio-app-center-releases-version.tester.js index 15932ef87c60f7f1cbf9d534966a3c11c70c2cc0..47dd1b650e12db7c77b9126674148986daeffe4f 100644 --- a/services/visual-studio-app-center/visual-studio-app-center-releases-version.tester.js +++ b/services/visual-studio-app-center/visual-studio-app-center-releases-version.tester.js @@ -30,9 +30,7 @@ t.create('Invalid user, invalid project, valid API token') message: 'project not found', }) -t.create('Invalid API Token') - .get('/invalid/invalid/invalid.json') - .expectBadge({ - label: 'release', - message: 'invalid token', - }) +t.create('Invalid API Token').get('/invalid/invalid/invalid.json').expectBadge({ + label: 'release', + message: 'invalid token', +}) diff --git a/services/w3c/w3c-validation-helper.spec.js b/services/w3c/w3c-validation-helper.spec.js index b5c98ed85283ff9afce8c9da7f0bbacc74c7ab61..819f1afd539690181b1cd308eb2b8ce42c060f53 100644 --- a/services/w3c/w3c-validation-helper.spec.js +++ b/services/w3c/w3c-validation-helper.spec.js @@ -8,8 +8,8 @@ const { getSchema, } = require('./w3c-validation-helper') -describe('w3c-validation-helper', function() { - describe('presetRegex', function() { +describe('w3c-validation-helper', function () { + describe('presetRegex', function () { function testing(preset) { return presetRegex.test(preset) } @@ -61,8 +61,8 @@ describe('w3c-validation-helper', function() { }) }) - describe('getColor', function() { - it('returns "brightgreen" if no messages are provided', function() { + describe('getColor', function () { + it('returns "brightgreen" if no messages are provided', function () { const messageTypes = {} const actualResult = getColor(messageTypes) @@ -70,7 +70,7 @@ describe('w3c-validation-helper', function() { expect(actualResult).to.equal('brightgreen') }) - it('returns "yellow" if only warning messages are provided', function() { + it('returns "yellow" if only warning messages are provided', function () { const messageTypes = { warning: 1 } const actualResult = getColor(messageTypes) @@ -78,7 +78,7 @@ describe('w3c-validation-helper', function() { expect(actualResult).to.equal('yellow') }) - it('returns "red" if only error messages are provided', function() { + it('returns "red" if only error messages are provided', function () { const messageTypes = { error: 1 } const actualResult = getColor(messageTypes) @@ -86,7 +86,7 @@ describe('w3c-validation-helper', function() { expect(actualResult).to.equal('red') }) - it('returns "red" if both warning and error messages are provided', function() { + it('returns "red" if both warning and error messages are provided', function () { const messageTypes = { warning: 3, error: 4 } const actualResult = getColor(messageTypes) @@ -95,8 +95,8 @@ describe('w3c-validation-helper', function() { }) }) - describe('getMessage', function() { - it('returns "validate" if no messages are provided', function() { + describe('getMessage', function () { + it('returns "validate" if no messages are provided', function () { const messageTypes = {} const actualResult = getMessage(messageTypes) @@ -104,7 +104,7 @@ describe('w3c-validation-helper', function() { expect(actualResult).to.equal('validated') }) - it('returns "1 error" if 1 error message is provided', function() { + it('returns "1 error" if 1 error message is provided', function () { const messageTypes = { error: 1 } const actualResult = getMessage(messageTypes) @@ -112,7 +112,7 @@ describe('w3c-validation-helper', function() { expect(actualResult).to.equal('1 error') }) - it('returns "2 errors" if 2 error messages are provided', function() { + it('returns "2 errors" if 2 error messages are provided', function () { const messageTypes = { error: 2 } const actualResult = getMessage(messageTypes) @@ -120,7 +120,7 @@ describe('w3c-validation-helper', function() { expect(actualResult).to.equal('2 errors') }) - it('returns "1 warning" if 1 warning message is provided', function() { + it('returns "1 warning" if 1 warning message is provided', function () { const messageTypes = { warning: 1 } const actualResult = getMessage(messageTypes) @@ -128,7 +128,7 @@ describe('w3c-validation-helper', function() { expect(actualResult).to.equal('1 warning') }) - it('returns "2 warnings" if 2 warning messages are provided', function() { + it('returns "2 warnings" if 2 warning messages are provided', function () { const messageTypes = { warning: 2 } const actualResult = getMessage(messageTypes) @@ -136,7 +136,7 @@ describe('w3c-validation-helper', function() { expect(actualResult).to.equal('2 warnings') }) - it('returns "1 error, 1 warning" if 1 error and 1 warning message is provided', function() { + it('returns "1 error, 1 warning" if 1 error and 1 warning message is provided', function () { const messageTypes = { warning: 1, error: 1 } const actualResult = getMessage(messageTypes) @@ -144,7 +144,7 @@ describe('w3c-validation-helper', function() { expect(actualResult).to.equal('1 error, 1 warning') }) - it('returns "2 errors, 2 warnings" if 2 error and 2 warning message is provided', function() { + it('returns "2 errors, 2 warnings" if 2 error and 2 warning message is provided', function () { const messageTypes = { error: 2, warning: 2 } const actualResult = getMessage(messageTypes) @@ -153,7 +153,7 @@ describe('w3c-validation-helper', function() { }) }) - describe('getSchema', function() { + describe('getSchema', function () { function execution(preset) { return getSchema(preset) } @@ -162,7 +162,7 @@ describe('w3c-validation-helper', function() { forCases([given(undefined), given(null), given('')]).expect(undefined) }) - it('returns 3 schemas associated to the "HTML,SVG 1.1,MathML 3.0" preset', function() { + it('returns 3 schemas associated to the "HTML,SVG 1.1,MathML 3.0" preset', function () { const preset = 'HTML,SVG 1.1,MathML 3.0' const actualResult = getSchema(preset) @@ -172,7 +172,7 @@ describe('w3c-validation-helper', function() { ) }) - it('returns 3 schemas associated to the "HTML,SVG 1.1,MathML 3.0,ITS 2.0" preset', function() { + it('returns 3 schemas associated to the "HTML,SVG 1.1,MathML 3.0,ITS 2.0" preset', function () { const preset = 'HTML,SVG 1.1,MathML 3.0,ITS 2.0' const actualResult = getSchema(preset) @@ -182,7 +182,7 @@ describe('w3c-validation-helper', function() { ) }) - it('returns 3 schemas associated to the "HTML, SVG 1.1, MathML 3.0, RDFa Lite 1.1" preset', function() { + it('returns 3 schemas associated to the "HTML, SVG 1.1, MathML 3.0, RDFa Lite 1.1" preset', function () { const preset = 'HTML, SVG 1.1, MathML 3.0, RDFa Lite 1.1' const actualResult = getSchema(preset) @@ -192,7 +192,7 @@ describe('w3c-validation-helper', function() { ) }) - it('returns 3 schemas associated to the "HTML 4.01 Strict, URL/ XHTML 1.0 Strict, URL" preset', function() { + it('returns 3 schemas associated to the "HTML 4.01 Strict, URL/ XHTML 1.0 Strict, URL" preset', function () { const preset = 'HTML 4.01 Strict, URL/ XHTML 1.0 Strict, URL' const actualResult = getSchema(preset) @@ -202,7 +202,7 @@ describe('w3c-validation-helper', function() { ) }) - it('returns 3 schemas associated to the "HTML 4.01 Transitional, URL/ XHTML 1.0 Transitional, URL" preset', function() { + it('returns 3 schemas associated to the "HTML 4.01 Transitional, URL/ XHTML 1.0 Transitional, URL" preset', function () { const preset = 'HTML 4.01 Transitional, URL/ XHTML 1.0 Transitional, URL' const actualResult = getSchema(preset) @@ -212,7 +212,7 @@ describe('w3c-validation-helper', function() { ) }) - it('returns 3 schemas associated to the "HTML 4.01 Frameset, URL/ XHTML 1.0 Frameset, URL" preset', function() { + it('returns 3 schemas associated to the "HTML 4.01 Frameset, URL/ XHTML 1.0 Frameset, URL" preset', function () { const preset = 'HTML 4.01 Frameset, URL/ XHTML 1.0 Frameset, URL' const actualResult = getSchema(preset) @@ -222,7 +222,7 @@ describe('w3c-validation-helper', function() { ) }) - it('returns 3 schemas associated to the "XHTML, SVG 1.1, MathML 3.0" preset', function() { + it('returns 3 schemas associated to the "XHTML, SVG 1.1, MathML 3.0" preset', function () { const preset = 'XHTML, SVG 1.1, MathML 3.0' const actualResult = getSchema(preset) @@ -232,7 +232,7 @@ describe('w3c-validation-helper', function() { ) }) - it('returns 3 schemas associated to the "XHTML, SVG 1.1, MathML 3.0, RDFa Lite 1.1" preset', function() { + it('returns 3 schemas associated to the "XHTML, SVG 1.1, MathML 3.0, RDFa Lite 1.1" preset', function () { const preset = 'XHTML, SVG 1.1, MathML 3.0, RDFa Lite 1.1' const actualResult = getSchema(preset) @@ -242,7 +242,7 @@ describe('w3c-validation-helper', function() { ) }) - it('returns 3 schemas associated to the "XHTML 1.0 Strict, URL, Ruby, SVG 1.1, MathML 3.0" preset', function() { + it('returns 3 schemas associated to the "XHTML 1.0 Strict, URL, Ruby, SVG 1.1, MathML 3.0" preset', function () { const preset = 'XHTML 1.0 Strict, URL, Ruby, SVG 1.1, MathML 3.0' const actualResult = getSchema(preset) @@ -252,7 +252,7 @@ describe('w3c-validation-helper', function() { ) }) - it('returns 3 schemas associated to the "SVG 1.1, URL, XHTML, MathML 3.0" preset', function() { + it('returns 3 schemas associated to the "SVG 1.1, URL, XHTML, MathML 3.0" preset', function () { const preset = 'SVG 1.1, URL, XHTML, MathML 3.0' const actualResult = getSchema(preset) diff --git a/services/w3c/w3c-validation.service.js b/services/w3c/w3c-validation.service.js index 8a467336fd271116e90fe5f823369a757ace07f9..21a15d651703dfe6a736d187aa66d6613ca92acc 100644 --- a/services/w3c/w3c-validation.service.js +++ b/services/w3c/w3c-validation.service.js @@ -27,9 +27,7 @@ const schema = Joi.object({ const queryParamSchema = Joi.object({ targetUrl: optionalUrl.required(), - preset: Joi.string() - .regex(presetRegex) - .allow(''), + preset: Joi.string().regex(presetRegex).allow(''), }).required() module.exports = class W3cValidation extends BaseJsonService { diff --git a/services/website-status.spec.js b/services/website-status.spec.js index b27771fcecacd3e4032dfccb61af92a5e07c1f46..d87f33a4a0003eee869706aad6e3509e83370b21 100644 --- a/services/website-status.spec.js +++ b/services/website-status.spec.js @@ -3,7 +3,7 @@ const { test, given } = require('sazerac') const { renderWebsiteStatus } = require('./website-status') -describe('Website status helpers', function() { +describe('Website status helpers', function () { const customOptions = { upMessage: 'groovy', upColor: 'papayawhip', diff --git a/services/website/website.tester.js b/services/website/website.tester.js index 3e9ae21bd05b74f505fa9baf96554cb4307ccee6..d4b795807f70fd9ae83657aaf62a2d385a6ac206 100644 --- a/services/website/website.tester.js +++ b/services/website/website.tester.js @@ -23,20 +23,12 @@ t.create('custom online label, online message and online color') .get( '/website.json?url=http://online.com&up_message=up&down_message=down&up_color=green&down_color=grey' ) - .intercept(nock => - nock('http://online.com') - .head('/') - .reply(200) - ) + .intercept(nock => nock('http://online.com').head('/').reply(200)) .expectBadge({ label: 'website', message: 'up', color: 'green' }) t.create('custom offline message and offline color') .get( '/website.json?url=http://offline.com&up_message=up&down_message=down&up_color=green&down_color=grey' ) - .intercept(nock => - nock('http://offline.com') - .head('/') - .reply(500) - ) + .intercept(nock => nock('http://offline.com').head('/').reply(500)) .expectBadge({ label: 'website', message: 'down', color: 'grey' }) diff --git a/services/wheelmap/wheelmap.spec.js b/services/wheelmap/wheelmap.spec.js index d406aeceb559ced3f7cb6d137dcaf211375d441d..41b80594b4afa29498d23e3c529eca14a6dd44c4 100644 --- a/services/wheelmap/wheelmap.spec.js +++ b/services/wheelmap/wheelmap.spec.js @@ -5,7 +5,7 @@ const nock = require('nock') const { cleanUpNockAfterEach, defaultContext } = require('../test-helpers') const Wheelmap = require('./wheelmap.service') -describe('Wheelmap', function() { +describe('Wheelmap', function () { cleanUpNockAfterEach() const token = 'abc123' @@ -23,7 +23,7 @@ describe('Wheelmap', function() { } } - it('node with accessibility', async function() { + it('node with accessibility', async function () { const nodeId = '26699541' const scope = createMock({ nodeId, wheelchair: 'yes' }) expect( @@ -32,7 +32,7 @@ describe('Wheelmap', function() { scope.done() }) - it('node with limited accessibility', async function() { + it('node with limited accessibility', async function () { const nodeId = '2034868974' const scope = createMock({ nodeId, wheelchair: 'limited' }) expect( @@ -41,7 +41,7 @@ describe('Wheelmap', function() { scope.done() }) - it('node without accessibility', async function() { + it('node without accessibility', async function () { const nodeId = '-147495158' const scope = createMock({ nodeId, wheelchair: 'no' }) expect( @@ -50,7 +50,7 @@ describe('Wheelmap', function() { scope.done() }) - it('node not found', async function() { + it('node not found', async function () { const nodeId = '0' const scope = createMock({ nodeId }) expect( diff --git a/services/wordpress/wordpress-downloads.tester.js b/services/wordpress/wordpress-downloads.tester.js index a455dbc8aea751c6f31a3242688f1929eabd9192..21b48fcd085945bcd726652a1c6ddd91c61da88f 100644 --- a/services/wordpress/wordpress-downloads.tester.js +++ b/services/wordpress/wordpress-downloads.tester.js @@ -23,19 +23,15 @@ t.create('Plugin Downloads - Active') message: isMetric, }) -t.create('Plugin Downloads - Day') - .get('/plugin/dd/akismet.json') - .expectBadge({ - label: 'downloads', - message: isMetricOverTimePeriod, - }) +t.create('Plugin Downloads - Day').get('/plugin/dd/akismet.json').expectBadge({ + label: 'downloads', + message: isMetricOverTimePeriod, +}) -t.create('Plugin Downloads - Week') - .get('/plugin/dw/akismet.json') - .expectBadge({ - label: 'downloads', - message: isMetricOverTimePeriod, - }) +t.create('Plugin Downloads - Week').get('/plugin/dw/akismet.json').expectBadge({ + label: 'downloads', + message: isMetricOverTimePeriod, +}) t.create('Plugin Downloads - Month') .get('/plugin/dm/akismet.json') @@ -44,12 +40,10 @@ t.create('Plugin Downloads - Month') message: isMetricOverTimePeriod, }) -t.create('Plugin Downloads - Year') - .get('/plugin/dy/akismet.json') - .expectBadge({ - label: 'downloads', - message: isMetricOverTimePeriod, - }) +t.create('Plugin Downloads - Year').get('/plugin/dy/akismet.json').expectBadge({ + label: 'downloads', + message: isMetricOverTimePeriod, +}) t.create('Theme Downloads - Total') .get('/theme/dt/twentyseventeen.json') diff --git a/services/wordpress/wordpress-version-color.spec.js b/services/wordpress/wordpress-version-color.spec.js index f13412e5ec53f22cdfcfd3eed690a87de83b0e0d..d7d9d8cb8635fb6baa450292e016607e9621fbf1 100644 --- a/services/wordpress/wordpress-version-color.spec.js +++ b/services/wordpress/wordpress-version-color.spec.js @@ -6,8 +6,8 @@ const { versionColorForWordpressVersion, } = require('./wordpress-version-color') -describe('toSemver() function', function() { - it('coerces versions', function() { +describe('toSemver() function', function () { + it('coerces versions', function () { expect(toSemver('1.1.1')).to.equal('1.1.1') expect(toSemver('4.2')).to.equal('4.2.0') expect(toSemver('1.0.0-beta')).to.equal('1.0.0-beta') @@ -16,8 +16,8 @@ describe('toSemver() function', function() { }) }) -describe('versionColorForWordpressVersion()', function() { - it('generates correct colours for given versions', async function() { +describe('versionColorForWordpressVersion()', function () { + it('generates correct colours for given versions', async function () { this.timeout(5e3) expect(await versionColorForWordpressVersion('11.2.0')).to.equal( diff --git a/services/wordpress/wordpress-version.tester.js b/services/wordpress/wordpress-version.tester.js index 8668672523664f0d79b6324af1f14fdf92228cfb..e8fc1a94de078be16fcdeb43142227d92020bb86 100644 --- a/services/wordpress/wordpress-version.tester.js +++ b/services/wordpress/wordpress-version.tester.js @@ -8,30 +8,22 @@ const t = (module.exports = new ServiceTester({ title: 'WordPress Version Tests', })) -t.create('Plugin Version') - .get('/plugin/v/akismet.json') - .expectBadge({ - label: 'plugin', - message: isVPlusDottedVersionAtLeastOne, - }) +t.create('Plugin Version').get('/plugin/v/akismet.json').expectBadge({ + label: 'plugin', + message: isVPlusDottedVersionAtLeastOne, +}) -t.create('Theme Version') - .get('/theme/v/twentyseventeen.json') - .expectBadge({ - label: 'theme', - message: isVPlusDottedVersionAtLeastOne, - }) +t.create('Theme Version').get('/theme/v/twentyseventeen.json').expectBadge({ + label: 'theme', + message: isVPlusDottedVersionAtLeastOne, +}) -t.create('Plugin Version | Not Found') - .get('/plugin/v/100.json') - .expectBadge({ - label: 'plugin', - message: 'not found', - }) +t.create('Plugin Version | Not Found').get('/plugin/v/100.json').expectBadge({ + label: 'plugin', + message: 'not found', +}) -t.create('Theme Version | Not Found') - .get('/theme/v/100.json') - .expectBadge({ - label: 'theme', - message: 'not found', - }) +t.create('Theme Version | Not Found').get('/theme/v/100.json').expectBadge({ + label: 'theme', + message: 'not found', +})