From d78a422013b30f3dc0b01a6a3aa572b7af6bedee Mon Sep 17 00:00:00 2001 From: Tierney Cyren Date: Wed, 6 Nov 2024 12:28:30 +0000 Subject: [PATCH] fix: run linter Signed-off-by: Tierney Cyren --- core/index.js | 12 +++--- core/test/combos.js | 2 +- core/test/parseOptions.js | 66 +++++++++++++++++------------- core/test/schedule.js | 51 +++++++++++------------ core/test/versions.js | 72 ++++++++++++++++----------------- core/util/prod/optionsParser.js | 2 +- core/util/prod/schedule.js | 8 ++-- core/util/prod/versions.js | 6 +-- 8 files changed, 115 insertions(+), 104 deletions(-) diff --git a/core/index.js b/core/index.js index de42aa3a..88f625f0 100644 --- a/core/index.js +++ b/core/index.js @@ -1,19 +1,19 @@ const { DateTime } = require('luxon'); const semver = require('semver'); const parsefiles = require('@nodevu/parsefiles'); -const optionsParser = require('./util/prod/optionsParser') -const versionFetcher = require('./util/prod/versions') -const scheduleFetcher = require('./util/prod/schedule') +const optionsParser = require('./util/prod/optionsParser'); +const versionFetcher = require('./util/prod/versions'); +const scheduleFetcher = require('./util/prod/schedule'); async function core(options) { // parse our user's options and set up our fetch/DateTime implementations const parsedOptions = optionsParser(options); const now = DateTime.fromISO(parsedOptions.now); - + // collect and configure our data sources - const versions = await versionFetcher(parsedOptions) - const schedule = await scheduleFetcher(parsedOptions) + const versions = await versionFetcher(parsedOptions); + const schedule = await scheduleFetcher(parsedOptions); // instantiate our data object, to be expanded upon const data = {}; diff --git a/core/test/combos.js b/core/test/combos.js index 30429f69..0968e8f1 100644 --- a/core/test/combos.js +++ b/core/test/combos.js @@ -1,7 +1,7 @@ const assert = require('node:assert'); const nodevu = require('../index'); const { describe, it, beforeEach } = require('test'); -const { fetch: undiciFetch } = require('undici') +const { fetch: undiciFetch } = require('undici'); const beforeEachTemplate = require('../util/dev/beforeEachTemplate'); diff --git a/core/test/parseOptions.js b/core/test/parseOptions.js index 8b3b3335..822815b2 100644 --- a/core/test/parseOptions.js +++ b/core/test/parseOptions.js @@ -1,55 +1,65 @@ const { deepStrictEqual } = require('node:assert'); const { describe, it, beforeEach } = require('test'); -const { fetch: undiciFetch } = require('undici') -const { DateTime } = require('luxon') +const { fetch: undiciFetch } = require('undici'); +const { DateTime } = require('luxon'); const nodevu = require('../index'); -const parseOptions = require('../util/prod/optionsParser') +const parseOptions = require('../util/prod/optionsParser'); describe('the parseOptions module should return all correct defaults', async () => { it('should return the default date', async () => { - const now = DateTime.now() + const now = DateTime.now(); const defaultParsedOptions = parseOptions({}); - deepStrictEqual(defaultParsedOptions.now.day, now.day) - deepStrictEqual(defaultParsedOptions.now.hour, now.hour) - deepStrictEqual(defaultParsedOptions.now.minute, now.minute) - deepStrictEqual(defaultParsedOptions.now.month, now.month) - }) + deepStrictEqual(defaultParsedOptions.now.day, now.day); + deepStrictEqual(defaultParsedOptions.now.hour, now.hour); + deepStrictEqual(defaultParsedOptions.now.minute, now.minute); + deepStrictEqual(defaultParsedOptions.now.month, now.month); + }); it('defaultParsedOptions.fetch should be globalThis.fetch when no options are passed', async () => { const defaultParsedOptions = parseOptions({}); - deepStrictEqual(defaultParsedOptions.fetch, globalThis.fetch) - }) + deepStrictEqual(defaultParsedOptions.fetch, globalThis.fetch); + }); it('should return the origin index.json for url.index', async () => { const defaultParsedOptions = parseOptions({}); - deepStrictEqual(defaultParsedOptions.urls.index, 'https://nodejs.org/dist/index.json') - }) + deepStrictEqual( + defaultParsedOptions.urls.index, + 'https://nodejs.org/dist/index.json', + ); + }); it('should return the origin schedule.json for url.schedule', async () => { const defaultParsedOptions = parseOptions({}); - deepStrictEqual(defaultParsedOptions.urls.schedule, 'https://raw.githubusercontent.com/nodejs/Release/master/schedule.json') - }) -}) + deepStrictEqual( + defaultParsedOptions.urls.schedule, + 'https://raw.githubusercontent.com/nodejs/Release/master/schedule.json', + ); + }); +}); describe('the parseOptions module should still work when defaults are changed', async () => { it('should still work when a custom date is passed', async () => { - const currentNow = DateTime.now() + const currentNow = DateTime.now(); const defaultParsedOptions = parseOptions({ now: currentNow }); - deepStrictEqual(defaultParsedOptions.now, currentNow) - }) + deepStrictEqual(defaultParsedOptions.now, currentNow); + }); it('defaultParsedOptions.fetch should be globalThis.fetch when no options are passed', async () => { const defaultParsedOptions = parseOptions({ fetch: undiciFetch }); - deepStrictEqual(defaultParsedOptions.fetch, undiciFetch) - }) + deepStrictEqual(defaultParsedOptions.fetch, undiciFetch); + }); it('should return the origin index.json for url.index', async () => { - const defaultParsedOptions = parseOptions({ urls: { index: 'https://example.com'}}); - deepStrictEqual(defaultParsedOptions.urls.index, 'https://example.com') - }) + const defaultParsedOptions = parseOptions({ + urls: { index: 'https://example.com' }, + }); + deepStrictEqual(defaultParsedOptions.urls.index, 'https://example.com'); + }); it('should return the origin schedule.json for url.schedule', async () => { - const defaultParsedOptions = parseOptions({ urls: { schedule: 'https://example.com'}}); - deepStrictEqual(defaultParsedOptions.urls.schedule, 'https://example.com') - }) -}) \ No newline at end of file + const defaultParsedOptions = parseOptions({ + urls: { schedule: 'https://example.com' }, + }); + deepStrictEqual(defaultParsedOptions.urls.schedule, 'https://example.com'); + }); +}); diff --git a/core/test/schedule.js b/core/test/schedule.js index d505601b..c36bbfd1 100644 --- a/core/test/schedule.js +++ b/core/test/schedule.js @@ -1,17 +1,17 @@ const { deepStrictEqual } = require('node:assert'); const { describe, it } = require('test'); -const { fetch: undiciFetch } = require('undici') +const { fetch: undiciFetch } = require('undici'); const { DateTime } = require('luxon'); const nodevu = require('../index'); -const schedule = require('../util/prod/schedule') -const optionsParser = require('../util/prod/optionsParser') +const schedule = require('../util/prod/schedule'); +const optionsParser = require('../util/prod/optionsParser'); // checks that verify the result of data returned -function check (data) { +function check(data) { for (const [line, metadata] of Object.entries(data)) { for (const [metadataKey, metadataValue] of Object.entries(metadata)) { - deepStrictEqual(typeof metadataKey, 'string') - deepStrictEqual(typeof metadataValue, 'string') + deepStrictEqual(typeof metadataKey, 'string'); + deepStrictEqual(typeof metadataValue, 'string'); } } } @@ -20,33 +20,34 @@ function check (data) { const options = { fetch: globalThis.fetch, urls: { - schedule: 'https://raw.githubusercontent.com/nodejs/Release/master/schedule.json' - } -} + schedule: + 'https://raw.githubusercontent.com/nodejs/Release/master/schedule.json', + }, +}; describe('under normal condiditons, schedule should work', async () => { it('should work with default options', async () => { - const data = await schedule(options) - check(data) - }) + const data = await schedule(options); + check(data); + }); it('should work with Undici fetch', async () => { - options.fetch = undiciFetch - const data = await schedule(options) - check(data) - }) -}) + options.fetch = undiciFetch; + const data = await schedule(options); + check(data); + }); +}); describe('schedule should work with optionsParser', async () => { it('should work with the default output of optionsParser', async () => { - const parsedOptions = optionsParser({}) - const data = await schedule(parsedOptions) - }) + const parsedOptions = optionsParser({}); + const data = await schedule(parsedOptions); + }); it('should work with a different fetch pased to optionsParser', async () => { const parsedOptions = optionsParser({ - fetch: undiciFetch - }) - const data = await schedule(parsedOptions) - }) -}) \ No newline at end of file + fetch: undiciFetch, + }); + const data = await schedule(parsedOptions); + }); +}); diff --git a/core/test/versions.js b/core/test/versions.js index d6a9437e..e095582a 100644 --- a/core/test/versions.js +++ b/core/test/versions.js @@ -1,59 +1,59 @@ const { deepStrictEqual } = require('node:assert'); const { describe, it } = require('test'); -const { fetch: undiciFetch } = require('undici') +const { fetch: undiciFetch } = require('undici'); const { DateTime } = require('luxon'); const nodevu = require('../index'); -const versions = require('../util/prod/versions') -const optionsParser = require('../util/prod/optionsParser') +const versions = require('../util/prod/versions'); +const optionsParser = require('../util/prod/optionsParser'); // checks that verify the result of data returned -function check (data) { - deepStrictEqual(typeof data[0].version, 'string') - deepStrictEqual(typeof data[0].date, 'string') - deepStrictEqual(Array.isArray(data[0].files), true) - deepStrictEqual(typeof data[0].npm, 'string') - deepStrictEqual(typeof data[0].v8, 'string') - deepStrictEqual(typeof data[0].uv, 'string') - deepStrictEqual(typeof data[0].zlib, 'string') - deepStrictEqual(typeof data[0].openssl, 'string') - deepStrictEqual(typeof data[0].modules, 'string') - deepStrictEqual(typeof data[0].lts, 'boolean') - deepStrictEqual(typeof data[0].security, 'boolean') +function check(data) { + deepStrictEqual(typeof data[0].version, 'string'); + deepStrictEqual(typeof data[0].date, 'string'); + deepStrictEqual(Array.isArray(data[0].files), true); + deepStrictEqual(typeof data[0].npm, 'string'); + deepStrictEqual(typeof data[0].v8, 'string'); + deepStrictEqual(typeof data[0].uv, 'string'); + deepStrictEqual(typeof data[0].zlib, 'string'); + deepStrictEqual(typeof data[0].openssl, 'string'); + deepStrictEqual(typeof data[0].modules, 'string'); + deepStrictEqual(typeof data[0].lts, 'boolean'); + deepStrictEqual(typeof data[0].security, 'boolean'); } // set up options object that would normally be passed to the module const options = { fetch: globalThis.fetch, urls: { - index: 'https://nodejs.org/dist/index.json' - } -} + index: 'https://nodejs.org/dist/index.json', + }, +}; describe('under normal condiditons, versions should work', async () => { it('should work with default options', async () => { - const data = await versions(options) - check (data) - }) + const data = await versions(options); + check(data); + }); it('should work with Undici fetch', async () => { - options.fetch = undiciFetch - const data = await versions(options) - check(data) - }) -}) + options.fetch = undiciFetch; + const data = await versions(options); + check(data); + }); +}); describe('versions should work with optionsParser', async () => { it('should work with the default output of optionsParser', async () => { - const parsedOptions = optionsParser({}) - const data = await versions(parsedOptions) - check(data) - }) + const parsedOptions = optionsParser({}); + const data = await versions(parsedOptions); + check(data); + }); it('should work with a different fetch pased to optionsParser', async () => { const parsedOptions = optionsParser({ - fetch: undiciFetch - }) - const data = await versions(parsedOptions) - check(data) - }) -}) \ No newline at end of file + fetch: undiciFetch, + }); + const data = await versions(parsedOptions); + check(data); + }); +}); diff --git a/core/util/prod/optionsParser.js b/core/util/prod/optionsParser.js index 634b4ac9..8324436f 100644 --- a/core/util/prod/optionsParser.js +++ b/core/util/prod/optionsParser.js @@ -37,4 +37,4 @@ function parseOptions(options) { return parsedOptions; } -module.exports = parseOptions; \ No newline at end of file +module.exports = parseOptions; diff --git a/core/util/prod/schedule.js b/core/util/prod/schedule.js index 3495371c..0a0435ba 100644 --- a/core/util/prod/schedule.js +++ b/core/util/prod/schedule.js @@ -1,4 +1,4 @@ -async function schedule (options) { +async function schedule(options) { // parse our options and set up fetch if a custom fetch is passed const fetch = options.fetch; const url = options.urls.schedule; @@ -6,8 +6,8 @@ async function schedule (options) { // fetch the url, get the json from the fetched URL that we're going to use const raw = await fetch(url); const schedule = await raw.json(); - - return schedule + + return schedule; } -module.exports = schedule \ No newline at end of file +module.exports = schedule; diff --git a/core/util/prod/versions.js b/core/util/prod/versions.js index e1a8ab00..51102d2c 100644 --- a/core/util/prod/versions.js +++ b/core/util/prod/versions.js @@ -1,4 +1,4 @@ -async function versions (options) { +async function versions(options) { // parse our options and set up fetch if a custom fetch is passed const fetch = options.fetch; const url = options.urls.index; @@ -7,7 +7,7 @@ async function versions (options) { const raw = await fetch(url); const versions = await raw.json(); - return versions + return versions; } -module.exports = versions \ No newline at end of file +module.exports = versions;