From c58c84be8d5b31e39f50b20170d6dc3273441204 Mon Sep 17 00:00:00 2001 From: Gadi Cohen Date: Mon, 12 Aug 2024 13:12:49 +0100 Subject: [PATCH] chore(deps): upgrade prettier, rerun prettier -w . $ yarn prettier -w . yarn run v1.22.22 $ /home/dragon/www/npm/node-yahoo-finance2/node_modules/.bin/prettier -w . bin/yahoo-finance.js 71ms jest.config.ts 72ms (unchanged) package.json 4ms (unchanged) renovate.json 2ms (unchanged) scripts/timeseries.ts 32ms src/check.ts 4ms (unchanged) src/env-browser.ts 3ms (unchanged) src/env-node.ts 2ms (unchanged) src/env-test.ts 4ms (unchanged) src/index-browser.ts 5ms src/index-common.ts 6ms (unchanged) src/index-node.ts 3ms (unchanged) src/index-test.ts 2ms (unchanged) src/lib/commonTypes.ts 2ms (unchanged) src/lib/cookieJar.ts 7ms src/lib/csv2json.spec.ts 6ms (unchanged) src/lib/csv2json.ts 10ms src/lib/datetime.spec.ts 3ms (unchanged) src/lib/datetime.ts 17ms src/lib/errors.ts 9ms src/lib/fetchDevel.js 13ms src/lib/getCrumb.spec.ts 13ms src/lib/getCrumb.ts 32ms src/lib/moduleCommon.ts 3ms (unchanged) src/lib/moduleExec.spec.ts 29ms src/lib/moduleExec.ts 14ms src/lib/notices.ts 8ms (unchanged) src/lib/options.ts 12ms src/lib/queue.ts 7ms src/lib/setGlobalConfig.spec.ts 10ms src/lib/setGlobalConfig.ts 6ms src/lib/validateAndCoerceTypes.spec.ts 25ms src/lib/validateAndCoerceTypes.ts 8ms src/lib/yahooFinanceFetch.spec.ts 23ms src/lib/yahooFinanceFetch.ts 14ms src/lib/yahooFinanceTypes.spec.ts 23ms src/lib/yahooFinanceTypes.ts 14ms src/modules/autoc.spec.ts 2ms (unchanged) src/modules/autoc.ts 1ms src/modules/chart.spec.ts 24ms src/modules/chart.ts 59ms src/modules/dailyGainers.spec.ts 11ms src/modules/dailyGainers.ts 17ms src/modules/fundamentalsTimeSeries.spec.ts 16ms src/modules/fundamentalsTimeSeries.ts 20ms src/modules/historical.spec.ts 12ms src/modules/historical.ts 22ms src/modules/insights.spec.ts 3ms src/modules/insights.ts 22ms src/modules/options.spec.ts 6ms src/modules/options.ts 14ms src/modules/quote.spec.ts 13ms src/modules/quote.ts 46ms src/modules/quoteSummary-iface.ts 123ms src/modules/quoteSummary.spec.ts 18ms src/modules/quoteSummary.ts 9ms src/modules/recommendationsBySymbol.spec.ts 6ms src/modules/recommendationsBySymbol.ts 6ms src/modules/screener.spec.ts 3ms src/modules/screener.ts 15ms src/modules/search.spec.ts 2ms src/modules/search.ts 15ms src/modules/trendingSymbols.spec.ts 3ms src/modules/trendingSymbols.ts 5ms src/other/quoteCombine.spec.ts 7ms (unchanged) src/other/quoteCombine.ts 6ms src/typings/jest.d.ts 2ms (unchanged) tests-modules/cjs/jest.config.js 3ms (unchanged) tests-modules/cjs/package.json 2ms (unchanged) tests-modules/cjs/tests/tests.spec.js 2ms (unchanged) tests-modules/esm/jest.config.js 2ms (unchanged) tests-modules/esm/package.json 1ms (unchanged) tests-modules/esm/tests/tests.spec.js 2ms (unchanged) tests/console.js 3ms (unchanged) tests/marketTimes.js 14ms (unchanged) tests/reporter.js 3ms (unchanged) tests/setupTests.js 1ms (unchanged) tests/summary-reporter.js 2ms (unchanged) tests/testSymbols.ts 4ms tests/testYf.ts 1ms (unchanged) tests/updateJson.js 2ms (unchanged) tsconfig.json 2ms (unchanged) x.js 2ms (unchanged) Done in 1.64s. --- bin/yahoo-finance.js | 2 +- package.json | 4 +- scripts/timeseries.ts | 4 +- src/index-browser.ts | 2 +- src/lib/cookieJar.ts | 2 +- src/lib/csv2json.ts | 2 +- src/lib/datetime.ts | 2 +- src/lib/errors.ts | 2 +- src/lib/fetchDevel.js | 4 +- src/lib/getCrumb.spec.ts | 16 +-- src/lib/getCrumb.ts | 54 ++++---- src/lib/moduleExec.spec.ts | 18 +-- src/lib/moduleExec.ts | 6 +- src/lib/options.ts | 4 +- src/lib/queue.ts | 2 +- src/lib/setGlobalConfig.spec.ts | 10 +- src/lib/setGlobalConfig.ts | 4 +- src/lib/validateAndCoerceTypes.spec.ts | 4 +- src/lib/validateAndCoerceTypes.ts | 6 +- src/lib/yahooFinanceFetch.spec.ts | 12 +- src/lib/yahooFinanceFetch.ts | 6 +- src/lib/yahooFinanceTypes.spec.ts | 22 +-- src/lib/yahooFinanceTypes.ts | 30 ++-- src/modules/autoc.ts | 2 +- src/modules/chart.spec.ts | 26 ++-- src/modules/chart.ts | 62 ++++----- src/modules/dailyGainers.spec.ts | 2 +- src/modules/dailyGainers.ts | 16 +-- src/modules/fundamentalsTimeSeries.spec.ts | 34 ++--- src/modules/fundamentalsTimeSeries.ts | 26 ++-- src/modules/historical.spec.ts | 20 +-- src/modules/historical.ts | 38 ++--- src/modules/insights.spec.ts | 2 +- src/modules/insights.ts | 50 +++---- src/modules/options.spec.ts | 10 +- src/modules/options.ts | 30 ++-- src/modules/quote.spec.ts | 10 +- src/modules/quote.ts | 14 +- src/modules/quoteSummary-iface.ts | 146 ++++++++++---------- src/modules/quoteSummary.spec.ts | 6 +- src/modules/quoteSummary.ts | 8 +- src/modules/recommendationsBySymbol.spec.ts | 4 +- src/modules/recommendationsBySymbol.ts | 16 +-- src/modules/screener.spec.ts | 6 +- src/modules/screener.ts | 16 +-- src/modules/search.spec.ts | 2 +- src/modules/search.ts | 36 ++--- src/modules/trendingSymbols.spec.ts | 4 +- src/modules/trendingSymbols.ts | 14 +- src/other/quoteCombine.ts | 8 +- tests/testSymbols.ts | 4 +- yarn.lock | 16 +-- 52 files changed, 425 insertions(+), 421 deletions(-) diff --git a/bin/yahoo-finance.js b/bin/yahoo-finance.js index 826d8c54..ac35e7cf 100755 --- a/bin/yahoo-finance.js +++ b/bin/yahoo-finance.js @@ -27,7 +27,7 @@ if (moduleName === "--help" || moduleName === "-h") { console.log(); console.log("Run the quoteSummary module with two submodules:"); console.log( - '$ yahoo-finance.js quoteSummary AAPL \'{"modules":["assetProfile", "secFilings"]}\'' + '$ yahoo-finance.js quoteSummary AAPL \'{"modules":["assetProfile", "secFilings"]}\'', ); console.log(); console.log("Available modules:"); diff --git a/package.json b/package.json index 42d27e55..0d8d654a 100644 --- a/package.json +++ b/package.json @@ -73,11 +73,11 @@ "@typescript-eslint/eslint-plugin": "5.62.0", "@typescript-eslint/parser": "5.62.0", "eslint": "8.57.0", - "eslint-config-prettier": "8.10.0", + "eslint-config-prettier": "^9.1.0", "globby": "13.2.2", "jest": "29.7.0", "jest-tobetype": "1.2.3", - "prettier": "2.8.8", + "prettier": "^3.3.3", "semantic-release": "19.0.5", "ts-jest": "29.1.2", "ts-node": "10.9.2", diff --git a/scripts/timeseries.ts b/scripts/timeseries.ts index d647f56a..1bf5d4e7 100644 --- a/scripts/timeseries.ts +++ b/scripts/timeseries.ts @@ -44,10 +44,10 @@ async function main() { for (const entry of har.log.entries) { const json = await getTimeseriesJSON(); const refererHeader = entry.request.headers.find( - (header) => header.name === "Referer" + (header) => header.name === "Referer", ); const typeParam = entry.request.queryString.find( - (header) => header.name === "type" + (header) => header.name === "type", ); if (!refererHeader) { diff --git a/src/index-browser.ts b/src/index-browser.ts index fef7db60..c483a9b4 100644 --- a/src/index-browser.ts +++ b/src/index-browser.ts @@ -8,7 +8,7 @@ console.warn( "⚠️ WARNING! This package (i.e. `yahoo-finance2`) is being used in the browser.", "Trying to use this may not work because of CORS. Be aware of that (and don't file issues for help with that).", "You can use a proxy to make CORS errors disappear, but we will not help you with that.", - "Please read the README (https://github.com/gadicc/node-yahoo-finance2) for more details." + "Please read the README (https://github.com/gadicc/node-yahoo-finance2) for more details.", ); export default yahooFinance; diff --git a/src/lib/cookieJar.ts b/src/lib/cookieJar.ts index fbfa6fe7..724bb462 100644 --- a/src/lib/cookieJar.ts +++ b/src/lib/cookieJar.ts @@ -3,7 +3,7 @@ import { Cookie, CookieJar } from "tough-cookie"; export class ExtendedCookieJar extends CookieJar { async setFromSetCookieHeaders( setCookieHeader: string | Array, - url: string + url: string, ) { let cookies; // console.log("setFromSetCookieHeaders", setCookieHeader); diff --git a/src/lib/csv2json.ts b/src/lib/csv2json.ts index f73120d7..327a6764 100644 --- a/src/lib/csv2json.ts +++ b/src/lib/csv2json.ts @@ -7,7 +7,7 @@ function camelize(str: string): string { .map((str, i) => i === 0 ? str.toLowerCase() - : str[0].toUpperCase() + str.substr(1).toLowerCase() + : str[0].toUpperCase() + str.substr(1).toLowerCase(), ) .join(""); } diff --git a/src/lib/datetime.ts b/src/lib/datetime.ts index 4c4d5243..039868c4 100644 --- a/src/lib/datetime.ts +++ b/src/lib/datetime.ts @@ -89,7 +89,7 @@ export const isTime = (value: string, strictTimeZone?: boolean): boolean => { */ export const isDateTime = ( value: string, - strictTimeZone?: boolean + strictTimeZone?: boolean, ): boolean => { const dateTime: string[] = value.split(DATE_TIME_SEPARATOR); return ( diff --git a/src/lib/errors.ts b/src/lib/errors.ts index 89f1f26c..5122b93a 100644 --- a/src/lib/errors.ts +++ b/src/lib/errors.ts @@ -33,7 +33,7 @@ export class FailedYahooValidationError extends Error { constructor( message: string, - { result, errors }: { result: any; errors?: null | ValidationError[] } + { result, errors }: { result: any; errors?: null | ValidationError[] }, ) { super(message); this.result = result; diff --git a/src/lib/fetchDevel.js b/src/lib/fetchDevel.js index d244d39b..b7e1687a 100644 --- a/src/lib/fetchDevel.js +++ b/src/lib/fetchDevel.js @@ -39,7 +39,7 @@ async function fetchDevel(url, fetchOptions) { // Use query2 for all our tests / fixtures / cache url = url.replace( /^https:\/\/query1.finance.yahoo.com/, - "https://query2.finance.yahoo.com" + "https://query2.finance.yahoo.com", ); // Remove crumb param to have consistent cacheable URLs @@ -56,7 +56,7 @@ async function fetchDevel(url, fetchOptions) { */ const destUrl = new URL( "./" + (fetchOptions.devel === true ? urlHash(url) : fetchOptions.devel), - BASE_URL + BASE_URL, ); const filename = destUrl.toString(); diff --git a/src/lib/getCrumb.spec.ts b/src/lib/getCrumb.spec.ts index b43b497b..138ea070 100644 --- a/src/lib/getCrumb.spec.ts +++ b/src/lib/getCrumb.spec.ts @@ -28,7 +28,7 @@ describe("getCrumb", () => { logger, "https://finance.yahoo.com/quote/AAPL", "getCrumb-quote-AAPL.json", - true + true, ); expect(crumb).toBe("mloUP8q7ZPH"); }); @@ -48,7 +48,7 @@ describe("getCrumb", () => { fetch, { devel: true }, logger, - "https://finance.yahoo.com/quote/AAPL" + "https://finance.yahoo.com/quote/AAPL", ); expect(crumb).toBe("mloUP8q7ZPH"); @@ -59,7 +59,7 @@ describe("getCrumb", () => { fetch, { devel: true }, logger, - "https://finance.yahoo.com/quote/AAPL" + "https://finance.yahoo.com/quote/AAPL", ); expect(crumb).toBe("mloUP8q7ZPH"); }); @@ -75,8 +75,8 @@ describe("getCrumb", () => { logger, "https://finance.yahoo.com/quote/AAPL", "getCrumb-quote-AAPL-no-cookies.fake.json", - true - ) + true, + ), ).rejects.toThrowError(/No set-cookie/); }); @@ -142,7 +142,7 @@ describe("getCrumb", () => { logger, "https://finance.yahoo.com/quote/AAPL", "getCrumb-quote-AAPL-pre-consent-VPN-UK.json", - true + true, ); expect(crumb).toBe("mloUP8q7ZPH"); // consoleSilent(); @@ -168,7 +168,7 @@ describe("getCrumb", () => { { devel: true }, logger, "https://finance.yahoo.com/quote/TSLA", - _getCrumb as any + _getCrumb as any, ); getCrumb( @@ -177,7 +177,7 @@ describe("getCrumb", () => { { devel: true }, logger, "https://finance.yahoo.com/quote/TSLA", - _getCrumb as any + _getCrumb as any, ); expect(_getCrumb).toHaveBeenCalledTimes(1); diff --git a/src/lib/getCrumb.ts b/src/lib/getCrumb.ts index 71d19be6..2ad3fbae 100644 --- a/src/lib/getCrumb.ts +++ b/src/lib/getCrumb.ts @@ -11,7 +11,7 @@ let crumb: string | null = null; const parseHtmlEntities = (str: string) => str.replace(/&#x([0-9A-Fa-f]{1,3});/gi, (_, numStr) => - String.fromCharCode(parseInt(numStr, 16)) + String.fromCharCode(parseInt(numStr, 16)), ); type CrumbOptions = RequestInit & { devel?: boolean | string }; @@ -22,7 +22,7 @@ export async function _getCrumb( logger: Logger, url = "https://finance.yahoo.com/quote/AAPL", develOverride = "getCrumb-quote-AAPL.json", - noCache = false + noCache = false, ): Promise { if (!crumb) { const cookies = await cookieJar.getCookies(CONFIG_FAKE_URL); @@ -43,7 +43,7 @@ export async function _getCrumb( async function processSetCookieHeader( header: string[] | undefined, - url: string + url: string, ) { if (header) { await cookieJar.setFromSetCookieHeaders(header, url); @@ -104,24 +104,24 @@ export async function _getCrumb( }; logger.debug( "fetch", - consentLocation /*, collectConsentFetchOptions */ + consentLocation /*, collectConsentFetchOptions */, ); const collectConsentResponse = await fetch( consentLocation, - collectConsentFetchOptions + collectConsentFetchOptions, ); const collectConsentBody = await collectConsentResponse.text(); const collectConsentResponseParams = [ ...collectConsentBody.matchAll( - //g + //g, ), ] .map( ([, name, value]) => - `${name}=${encodeURIComponent(parseHtmlEntities(value))}&` + `${name}=${encodeURIComponent(parseHtmlEntities(value))}&`, ) .join("") + "agree=agree&agree=agree"; @@ -139,22 +139,22 @@ export async function _getCrumb( }; logger.debug( "fetch", - consentLocation /*, collectConsentSubmitFetchOptions */ + consentLocation /*, collectConsentSubmitFetchOptions */, ); const collectConsentSubmitResponse = await fetch( consentLocation, - collectConsentSubmitFetchOptions + collectConsentSubmitFetchOptions, ); // Set-Cookie: CFC=AQABCAFkWkdkjEMdLwQ9&s=AQAAAClxdtC-&g=ZFj24w; Expires=Wed, 8 May 2024 01:18:54 GMT; Domain=consent.yahoo.com; Path=/; Secure if ( !(await processSetCookieHeader( collectConsentSubmitResponse.headers.raw()["set-cookie"], - consentLocation + consentLocation, )) ) throw new Error( - "No set-cookie header on collectConsentSubmitResponse, please report." + "No set-cookie header on collectConsentSubmitResponse, please report.", ); // https://guce.yahoo.com/copyConsent?sessionId=3_cc-session_04da10ea-1025-4676-8175-60d2508bfc6c&lang=en-GB @@ -162,7 +162,7 @@ export async function _getCrumb( collectConsentSubmitResponse.headers.get("location"); if (!collectConsentSubmitResponseLocation) throw new Error( - "collectConsentSubmitResponse unexpectedly did not return a Location header, please report." + "collectConsentSubmitResponse unexpectedly did not return a Location header, please report.", ); const copyConsentFetchOptions: typeof fetchOptions = { @@ -170,7 +170,7 @@ export async function _getCrumb( headers: { ...fetchOptions.headers, cookie: await cookieJar.getCookieString( - collectConsentSubmitResponseLocation + collectConsentSubmitResponseLocation, ), }, devel: "getCrumb-quote-AAPL-copyConsent", @@ -178,28 +178,28 @@ export async function _getCrumb( logger.debug( "fetch", - collectConsentSubmitResponseLocation /*, copyConsentFetchOptions */ + collectConsentSubmitResponseLocation /*, copyConsentFetchOptions */, ); const copyConsentResponse = await fetch( collectConsentSubmitResponseLocation, - copyConsentFetchOptions + copyConsentFetchOptions, ); if ( !(await processSetCookieHeader( copyConsentResponse.headers.raw()["set-cookie"], - collectConsentSubmitResponseLocation + collectConsentSubmitResponseLocation, )) ) throw new Error( - "No set-cookie header on copyConsentResponse, please report." + "No set-cookie header on copyConsentResponse, please report.", ); const copyConsentResponseLocation = copyConsentResponse.headers.get("location"); if (!copyConsentResponseLocation) throw new Error( - "collectConsentSubmitResponse unexpectedly did not return a Location header, please report." + "collectConsentSubmitResponse unexpectedly did not return a Location header, please report.", ); const finalResponseFetchOptions: typeof fetchOptions = { @@ -207,7 +207,7 @@ export async function _getCrumb( headers: { ...fetchOptions.headers, cookie: await cookieJar.getCookieString( - collectConsentSubmitResponseLocation + collectConsentSubmitResponseLocation, ), }, devel: "getCrumb-quote-AAPL-consent-final-redirect.html", @@ -220,15 +220,15 @@ export async function _getCrumb( logger, copyConsentResponseLocation, "getCrumb-quote-AAPL-consent-final-redirect.html", - noCache + noCache, ); } } else { console.error( - "We expected a redirect to guce.yahoo.com, but got " + location + "We expected a redirect to guce.yahoo.com, but got " + location, ); console.error( - "We'll try to continue anyway - you can safely ignore this if the request succeeds" + "We'll try to continue anyway - you can safely ignore this if the request succeeds", ); // throw new Error( // "Unsupported redirect to " + location + ", please report."); @@ -247,7 +247,7 @@ export async function _getCrumb( ); */ throw new Error( - "No set-cookie header present in Yahoo's response. Something must have changed, please report." + "No set-cookie header present in Yahoo's response. Something must have changed, please report.", ); } @@ -311,7 +311,7 @@ export async function _getCrumb( "Failed to get crumb, status " + getCrumbResponse.status + ", statusText: " + - getCrumbResponse.statusText + getCrumbResponse.statusText, ); } @@ -319,7 +319,7 @@ export async function _getCrumb( crumb = crumbFromGetCrumb; if (!crumb) throw new Error( - "Could not find crumb. Yahoo's API may have changed; please report." + "Could not find crumb. Yahoo's API may have changed; please report.", ); logger.debug("New crumb: " + crumb); @@ -328,7 +328,7 @@ export async function _getCrumb( key: "crumb", value: crumb, }), - CONFIG_FAKE_URL + CONFIG_FAKE_URL, ); promise = null; @@ -349,7 +349,7 @@ export default function getCrumb( fetchOptionsBase: CrumbOptions, logger: Logger, url = "https://finance.yahoo.com/quote/AAPL", - __getCrumb = _getCrumb + __getCrumb = _getCrumb, ) { showNotice("yahooSurvey"); diff --git a/src/lib/moduleExec.spec.ts b/src/lib/moduleExec.spec.ts index 5343f4cd..dcdb203c 100644 --- a/src/lib/moduleExec.spec.ts +++ b/src/lib/moduleExec.spec.ts @@ -19,7 +19,7 @@ describe("moduleExecTypebox", () => { it("accepts a string", async () => { await expect( - yf.chart("AAPL", periodOpts, { devel: "chart-AAPL.json" }) + yf.chart("AAPL", periodOpts, { devel: "chart-AAPL.json" }), ).resolves.toBeDefined(); }); @@ -37,7 +37,7 @@ describe("moduleExecTypebox", () => { it("accepts empty queryOptions", async () => { await expect( - yf.search("AAPL", undefined, { devel: "search-AAPL.json" }) + yf.search("AAPL", undefined, { devel: "search-AAPL.json" }), ).resolves.toBeDefined(); }); @@ -55,7 +55,7 @@ describe("moduleExecTypebox", () => { expect( fakeConsole.log.mock.calls.length + fakeConsole.error.mock.calls.length + - fakeConsole.dir.mock.calls.length + fakeConsole.dir.mock.calls.length, ).toBe(1); yf._opts.validation.logOptionsErrors = false; }); @@ -73,7 +73,7 @@ describe("moduleExecTypebox", () => { expect( fakeConsole.log.mock.calls.length + fakeConsole.error.mock.calls.length + - fakeConsole.dir.mock.calls.length + fakeConsole.dir.mock.calls.length, ).toBe(0); }); }); @@ -83,7 +83,7 @@ describe("moduleExecTypebox", () => { it("throws on unexpected input", async () => { yf._opts.validation.logErrors = false; await expect( - yf.search("AAPL", {}, { devel: "search-badResult.fake.json" }) + yf.search("AAPL", {}, { devel: "search-badResult.fake.json" }), ).rejects.toThrow(FailedYahooValidationError); yf._opts.validation.logErrors = true; }); @@ -103,8 +103,8 @@ describe("moduleExecTypebox", () => { { devel: "search-badResult.fake.json", validateResult: false, - } - ) + }, + ), ).resolves.toBeDefined(); console = realConsole; @@ -203,7 +203,7 @@ describe("moduleExecTypebox", () => { result: { schema: Type.Any(), }, - }) + }), ).rejects.toThrow(); }); it("should pass a string symbol when symbol assertion is enabled", () => { @@ -218,7 +218,7 @@ describe("moduleExecTypebox", () => { result: { schema: Type.Any(), }, - }) + }), ).not.toThrow(); }); }); diff --git a/src/lib/moduleExec.ts b/src/lib/moduleExec.ts index 60f51463..2ce76970 100644 --- a/src/lib/moduleExec.ts +++ b/src/lib/moduleExec.ts @@ -104,7 +104,7 @@ interface ModuleExecOptions { async function moduleExec( this: { [key: string]: any }, - opts: ModuleExecOptions + opts: ModuleExecOptions, ) { const queryOpts = opts.query; const moduleOpts = opts.moduleOptions; @@ -116,7 +116,7 @@ async function moduleExec( if (typeof symbol !== "string") throw new Error( `yahooFinance.${moduleName}() expects a single string symbol as its ` + - `query, not a(n) ${typeof symbol}: ${JSON.stringify(symbol)}` + `query, not a(n) ${typeof symbol}: ${JSON.stringify(symbol)}`, ); } @@ -149,7 +149,7 @@ async function moduleExec( queryOptions, moduleOpts, queryOpts.fetchType, - queryOpts.needsCrumb ?? false + queryOpts.needsCrumb ?? false, ); if (queryOpts.fetchType === "csv") { diff --git a/src/lib/options.ts b/src/lib/options.ts index 330f310b..2faa4b3a 100644 --- a/src/lib/options.ts +++ b/src/lib/options.ts @@ -24,7 +24,7 @@ const ValidationOptionsSchema = Type.Object({ default: process.env.NODE_ENV === "test", description: "Use this property to throw when properties beyond what is explicitly specified in the schema are provided. It is an internal option and subject to change, use at your own risk", - }) + }), ), }); @@ -38,7 +38,7 @@ export const YahooFinanceOptionsSchema = Type.Object( validation: Type.Optional(ValidationOptionsSchema), logger: Type.Optional(LoggerSchema), }, - { title: "YahooFinanceOptions" } + { title: "YahooFinanceOptions" }, ); /* diff --git a/src/lib/queue.ts b/src/lib/queue.ts index f58f4547..7d232984 100644 --- a/src/lib/queue.ts +++ b/src/lib/queue.ts @@ -16,7 +16,7 @@ export const QueueOptionsSchema = Type.Object( { additionalProperties: false, title: "QueueOptions", - } + }, ); export type QueueOptions = Static; diff --git a/src/lib/setGlobalConfig.spec.ts b/src/lib/setGlobalConfig.spec.ts index 42a412fe..53c67e8b 100644 --- a/src/lib/setGlobalConfig.spec.ts +++ b/src/lib/setGlobalConfig.spec.ts @@ -29,7 +29,7 @@ describe("setGlobalConfig", () => { consoleSilent(); expect(() => yf.setGlobalConfig({ queue: { concurrency: "" } })).toThrow( - /Validation called with invalid options/ + /Validation called with invalid options/, ); consoleRestore(); @@ -45,7 +45,7 @@ describe("setGlobalConfig", () => { error() {}, warn: "yeh this won't work", }, - }) + }), ).toThrow(/Validation called with invalid options/); expect(() => @@ -55,13 +55,13 @@ describe("setGlobalConfig", () => { debug() {}, error() {}, }, - }) + }), ).toThrow(/Validation called with invalid options/); expect(() => yf.setGlobalConfig({ logger: {}, - }) + }), ).toThrow(/Validation called with invalid options/); consoleRestore(); @@ -72,7 +72,7 @@ describe("setGlobalConfig", () => { expect(() => yf.setGlobalConfig({ cookieJar: "not a cookie jar", - }) + }), ).toThrow(/cookieJar must be an instance of ExtendedCookieJar/); consoleRestore(); }); diff --git a/src/lib/setGlobalConfig.ts b/src/lib/setGlobalConfig.ts index 6882e310..3f3080bd 100644 --- a/src/lib/setGlobalConfig.ts +++ b/src/lib/setGlobalConfig.ts @@ -8,7 +8,7 @@ import { ExtendedCookieJar } from "./cookieJar.js"; export default function setGlobalConfig( this: ModuleThis, - _config: YahooFinanceOptions + _config: YahooFinanceOptions, ): void { const parsed = validateAndCoerceTypes({ data: _config, @@ -32,7 +32,7 @@ export default function setGlobalConfig( type Obj = Record; function mergeObjects(original: Obj, objToMerge: Obj) { const ownKeys: (keyof typeof objToMerge)[] = Reflect.ownKeys( - objToMerge + objToMerge, ) as string[]; for (const key of ownKeys) { if (typeof objToMerge[key] === "object") { diff --git a/src/lib/validateAndCoerceTypes.spec.ts b/src/lib/validateAndCoerceTypes.spec.ts index b9e94b9a..8b788409 100644 --- a/src/lib/validateAndCoerceTypes.spec.ts +++ b/src/lib/validateAndCoerceTypes.spec.ts @@ -29,7 +29,7 @@ describe("validateAndCoerceTypebox", () => { } expect(error).toMatchInlineSnapshot( - `[FailedYahooValidationError: Failed Yahoo Schema validation]` + `[FailedYahooValidationError: Failed Yahoo Schema validation]`, ); expect(JSON.stringify(error?.errors?.[0], null, 2)).toMatchInlineSnapshot(` @@ -419,7 +419,7 @@ describe("validateAndCoerceTypebox", () => { describe("_internalThrowOnAddtionalProperties", () => { const schema = Type.Object( { name: Type.String() }, - { additionalProperties: Type.Any() } + { additionalProperties: Type.Any() }, ); const testCase = { name: "Gadi", aTotallyUnrelatedKey: "foo" }; diff --git a/src/lib/validateAndCoerceTypes.ts b/src/lib/validateAndCoerceTypes.ts index b48105a5..60060e12 100644 --- a/src/lib/validateAndCoerceTypes.ts +++ b/src/lib/validateAndCoerceTypes.ts @@ -10,7 +10,7 @@ import { ValidationOptions } from "./options"; const handleResultError = ( e: TransformDecodeError | TransformDecodeCheckError, - options: ValidationOptions + options: ValidationOptions, ) => { const title = e.schema.title; if (options.logErrors) { @@ -48,11 +48,11 @@ const handleResultError = ( const handleOptionsError = ( e: TransformDecodeCheckError | TransformDecodeError, - { logOptionsErrors }: ValidationOptions + { logOptionsErrors }: ValidationOptions, ) => { if (logOptionsErrors) { console.error( - `[yahooFinance] Invalid options ("${JSON.stringify(e.error, null, 2)}")` + `[yahooFinance] Invalid options ("${JSON.stringify(e.error, null, 2)}")`, ); } throw new InvalidOptionsError("Validation called with invalid options"); diff --git a/src/lib/yahooFinanceFetch.spec.ts b/src/lib/yahooFinanceFetch.spec.ts index 6b6671af..dc07de78 100644 --- a/src/lib/yahooFinanceFetch.spec.ts +++ b/src/lib/yahooFinanceFetch.spec.ts @@ -32,14 +32,14 @@ describe("yahooFinanceFetch", () => { const url = "https://query2.finance.yahoo.com/v1/finance/search"; return expect( - yahooFinanceFetch(url, {}, { devel: "search-noOpts.json" }) + yahooFinanceFetch(url, {}, { devel: "search-noOpts.json" }), ).rejects.toBeInstanceOf(errors.BadRequestError); }); it("throws if no environmennt set", () => { // @ts-ignore: we're explicityly testing for a bad runtime context return expect(_yahooFinanceFetch("")).rejects.toBeInstanceOf( - errors.NoEnvironmentError + errors.NoEnvironmentError, ); }); @@ -49,8 +49,8 @@ describe("yahooFinanceFetch", () => { yahooFinanceFetch( "https://query2.finance.yahoo.com/nonExistingURL-CACHED", {}, - { devel: "pageWith404andJson.fake.json" } - ) + { devel: "pageWith404andJson.fake.json" }, + ), ).rejects.toBeInstanceOf(errors.HTTPError); }); @@ -59,8 +59,8 @@ describe("yahooFinanceFetch", () => { yahooFinanceFetch( "https://query2.finance.yahoo.com/nonExistingURL-CACHED", {}, - { devel: "pageWithUnknownError.json" } - ) + { devel: "pageWithUnknownError.json" }, + ), ).rejects.toBeInstanceOf(Error); }); diff --git a/src/lib/yahooFinanceFetch.ts b/src/lib/yahooFinanceFetch.ts index 56aa3126..8344ed44 100644 --- a/src/lib/yahooFinanceFetch.ts +++ b/src/lib/yahooFinanceFetch.ts @@ -64,11 +64,11 @@ async function yahooFinanceFetch( params: Record = {}, moduleOpts: YahooFinanceFetchModuleOptions = {}, func = "json", - needsCrumb = false + needsCrumb = false, ) { if (!(this && this._env)) throw new errors.NoEnvironmentError( - "yahooFinanceFetch called without this._env set" + "yahooFinanceFetch called without this._env set", ); // TODO: adds func type to json schema which is not supported @@ -100,7 +100,7 @@ async function yahooFinanceFetch( this._opts.cookieJar, fetchFunc, fetchOptionsBase, - this._opts.logger + this._opts.logger, ); if (crumb) params.crumb = crumb; } diff --git a/src/lib/yahooFinanceTypes.spec.ts b/src/lib/yahooFinanceTypes.spec.ts index abfcf60b..152846a1 100644 --- a/src/lib/yahooFinanceTypes.spec.ts +++ b/src/lib/yahooFinanceTypes.spec.ts @@ -116,7 +116,7 @@ describe("YahooFinanceDate", () => { const testCase = "2024-02-29"; expect(Value.Check(YahooFinanceDate, testCase)).toBe(true); expect(Value.Decode(YahooFinanceDate, testCase)).toMatchInlineSnapshot( - `2024-02-29T00:00:00.000Z` + `2024-02-29T00:00:00.000Z`, ); }); @@ -124,7 +124,7 @@ describe("YahooFinanceDate", () => { const testCase = "2024-05-04T13:24:41.100Z"; expect(Value.Check(YahooFinanceDate, testCase)).toBe(true); expect(Value.Decode(YahooFinanceDate, testCase)).toMatchInlineSnapshot( - `2024-05-04T13:24:41.100Z` + `2024-05-04T13:24:41.100Z`, ); }); @@ -132,7 +132,7 @@ describe("YahooFinanceDate", () => { const testCase = "2024-05-04"; expect(Value.Check(YahooFinanceDate, testCase)).toBe(true); expect(Value.Decode(YahooFinanceDate, testCase)).toMatchInlineSnapshot( - `2024-05-04T00:00:00.000Z` + `2024-05-04T00:00:00.000Z`, ); }); @@ -169,7 +169,7 @@ describe("YahooDateInMs", () => { const testCase = 1612313997000; expect(Value.Check(YahooDateInMs, testCase)).toBe(true); expect(Value.Decode(YahooDateInMs, testCase)).toMatchInlineSnapshot( - `2021-02-03T00:59:57.000Z` + `2021-02-03T00:59:57.000Z`, ); }); }); @@ -186,8 +186,8 @@ describe("Test building block type encoding", () => { expect( Value.Encode( EmptyObjectCoerceToNull, - Value.Decode(EmptyObjectCoerceToNull, testCase) - ) + Value.Decode(EmptyObjectCoerceToNull, testCase), + ), ).toMatchInlineSnapshot(`{}`); }); it("Should encode RawNumber correctly", () => { @@ -204,14 +204,14 @@ describe("Test building block type encoding", () => { expect( Value.Encode( TwoNumberRangeString, - Value.Decode(TwoNumberRangeString, testCase) - ) + Value.Decode(TwoNumberRangeString, testCase), + ), ).toBe("10 - 20"); }); it("Should encode the epoch timestamp back to seconds", () => { const testCase = 1000; expect( - Value.Encode(EpochTimestamp, Value.Decode(EpochTimestamp, testCase)) + Value.Encode(EpochTimestamp, Value.Decode(EpochTimestamp, testCase)), ).toBe(testCase); }); @@ -227,13 +227,13 @@ describe("Test building block type encoding", () => { it("Should encode the ISOStringDate back to a valid ISOString", () => { const testCase = new Date(1000).toISOString(); expect( - Value.Encode(ISOStringDate, Value.Decode(ISOStringDate, testCase)) + Value.Encode(ISOStringDate, Value.Decode(ISOStringDate, testCase)), ).toBe(testCase); }); it("Should encode the YahooDateInMs back to MS", () => { const testCase = +new Date(1000); expect( - Value.Encode(YahooDateInMs, Value.Decode(YahooDateInMs, testCase)) + Value.Encode(YahooDateInMs, Value.Decode(YahooDateInMs, testCase)), ).toBe(testCase); }); }); diff --git a/src/lib/yahooFinanceTypes.ts b/src/lib/yahooFinanceTypes.ts index 8ac4df14..ec2b8099 100644 --- a/src/lib/yahooFinanceTypes.ts +++ b/src/lib/yahooFinanceTypes.ts @@ -9,7 +9,7 @@ FormatRegistry.Set("year", isYear); // Strictly must be empty export const EmptyObjectCoerceToNull = Type.Transform( - Type.Object({}, { maxProperties: 0, title: "EmptyObjectCoerceToNull" }) + Type.Object({}, { maxProperties: 0, title: "EmptyObjectCoerceToNull" }), ) .Decode(() => null) .Encode(() => ({})); @@ -22,8 +22,8 @@ export const RawNumber = Type.Transform( }, { title: "RawNumber", - } - ) + }, + ), ) .Decode((v) => v.raw) .Encode((v) => ({ raw: v })); @@ -31,7 +31,7 @@ export const RawNumber = Type.Transform( export const TwoNumberRangeString = Type.Transform( Type.RegExp(/^(-?\d+(?:\.\d+)?) - (-?\d+(?:\.\d+)?)$/g, { title: "TwoNumberRangeString", - }) + }), ) .Decode((value) => { // Split the two numbers allowing for negatives on either side @@ -45,7 +45,7 @@ export const TwoNumberRangeString = Type.Transform( if (isNaN(low) || isNaN(high)) { throw new Error( - `Unable to decode number range from: ${value}. Decoded value for low is: ${low}, decoded value for high is: ${high}` + `Unable to decode number range from: ${value}. Decoded value for low is: ${low}, decoded value for high is: ${high}`, ); } return { low, high }; @@ -57,7 +57,7 @@ const TwoNumberRange = Type.Object( low: Type.Number(), high: Type.Number(), }, - { title: "TwoNumberRange" } + { title: "TwoNumberRange" }, ); export const EpochTimestamp = Type.Transform(Type.Number()) @@ -69,8 +69,8 @@ export const RawDateObject = Type.Transform( { raw: EpochTimestamp, }, - { title: "RawDateObject" } - ) + { title: "RawDateObject" }, + ), ) .Decode((v) => v.raw) .Encode((v) => ({ @@ -84,15 +84,15 @@ export const ISOStringDate = Type.Transform( Type.String({ format: "year" }), Type.String({ format: "date-time" }), ], - { title: "ISOStringDate" } - ) + { title: "ISOStringDate" }, + ), ) .Decode((v) => new Date(v)) .Encode((v) => v.toISOString()); export const YahooFinanceDate = Type.Union( [Type.Date(), EpochTimestamp, RawDateObject, ISOStringDate], - { title: "YahooFinanceDate" } + { title: "YahooFinanceDate" }, ); /** @@ -108,7 +108,7 @@ export const NullableYahooFinanceDate = Type.Union( [YahooFinanceDate, Type.Null(), EmptyObjectCoerceToNull], { title: "NullableYahooFinanceDate", - } + }, ); /** @@ -128,7 +128,7 @@ export const YahooNumber = Type.Union([RawNumber, Type.Number()], { * - 1612313997000 */ export const YahooDateInMs = Type.Transform( - Type.Number({ title: "YahooDateInMs" }) + Type.Number({ title: "YahooDateInMs" }), ) .Decode((v) => new Date(v)) .Encode((v) => +v); @@ -144,7 +144,7 @@ export const NullableYahooNumber = Type.Union( [RawNumber, EmptyObjectCoerceToNull, Type.Number(), Type.Null()], { title: "NullableYahooNumber", - } + }, ); /** @@ -157,5 +157,5 @@ export const YahooTwoNumberRange = Type.Union( [TwoNumberRange, TwoNumberRangeString], { title: "YahooTwoNumberRange", - } + }, ); diff --git a/src/modules/autoc.ts b/src/modules/autoc.ts index ae6cf085..f14c8d08 100644 --- a/src/modules/autoc.ts +++ b/src/modules/autoc.ts @@ -2,6 +2,6 @@ export default async function autoc(): Promise { throw new Error( "Yahoo decomissioned their autoc server sometime before 20 Nov 2021 " + "(see https://github.com/gadicc/node-yahoo-finance2/issues/337])). " + - "Use `search` instead (just like they do)." + "Use `search` instead (just like they do).", ); } diff --git a/src/modules/chart.spec.ts b/src/modules/chart.spec.ts index a18b95ab..8d6ceecd 100644 --- a/src/modules/chart.spec.ts +++ b/src/modules/chart.spec.ts @@ -30,7 +30,7 @@ describe("chart", () => { }, { devel: `chart-${symbol}-2020-01-01-to-2020-01-03.json`, - } + }, ); }); @@ -44,13 +44,13 @@ describe("chart", () => { }, { devel: `chart-WSU.DE-2023-08-04-to-2023-08-09.json`, - } + }, ); }); it("throws if period1,period2 are the same", async () => { await expect( - yf.chart("TSLA", { period1: "2022-02-22", period2: "2022-02-22" }) + yf.chart("TSLA", { period1: "2022-02-22", period2: "2022-02-22" }), ).rejects.toThrow(/cannot share the same value/); }); @@ -70,7 +70,7 @@ describe("chart", () => { // it leads to these kind of results). Nevertheless, let's be prepared. // So the .fake.json result is from query period1=period2="2021-11-23". { period1: "2021-11-23", period2: "2021-11-24", interval: "1h" }, - { devel: "chart-TSLA-2021-11-23-to-2021-11-23-interval-1h.fake.json" } + { devel: "chart-TSLA-2021-11-23-to-2021-11-23-interval-1h.fake.json" }, ); }); @@ -83,7 +83,7 @@ describe("chart", () => { await yf.chart( "TSLA", { period1: "2021-11-22", period2: "2021-11-23", interval: "30m" }, - { devel: "chart-TSLA-2021-11-22-to-2021-11-23-interval-30m.json" } + { devel: "chart-TSLA-2021-11-22-to-2021-11-23-interval-30m.json" }, ); }); }); @@ -94,8 +94,8 @@ describe("chart", () => { yf.chart( "FAKE", { period1: "2021-11-23" }, - { devel: "chart-notimestamp-quotes-length.fake.json" } - ) + { devel: "chart-notimestamp-quotes-length.fake.json" }, + ), ).rejects.toMatchObject({ message: /No timestamp with quotes.length !== 1/, }); @@ -106,8 +106,8 @@ describe("chart", () => { yf.chart( "FAKE", { period1: "2021-11-23" }, - { devel: "chart-notimestamp-weird-quote.fake.json" } - ) + { devel: "chart-notimestamp-weird-quote.fake.json" }, + ), ).rejects.toMatchObject({ message: /No timestamp with unexpected quote/, }); @@ -122,7 +122,7 @@ describe("chart", () => { .chart( "AAPL", { period1: "2020-01-01" }, - { devel: `weirdJsonResult.fake.json` } + { devel: `weirdJsonResult.fake.json` }, ) .finally(consoleRestore); }).rejects.toMatchObject({ message: /Unexpected/ }); @@ -166,7 +166,7 @@ describe("chart", () => { const result = await yf.chart( symbol, { ...queryOpts /* default, i.e. return: "array" */ }, - fetchOpts + fetchOpts, ); // More comprehensive tests below. @@ -177,7 +177,7 @@ describe("chart", () => { const result = await yf.chart( symbol, { ...queryOpts, return: "array" }, - fetchOpts + fetchOpts, ); expect(result.timestamp).not.toBeDefined(); @@ -210,7 +210,7 @@ describe("chart", () => { const result = await yf.chart( symbol, { ...queryOpts, return: "object" }, - fetchOpts + fetchOpts, ); // @ts-ignore diff --git a/src/modules/chart.ts b/src/modules/chart.ts index d1f87279..b1bb47f3 100644 --- a/src/modules/chart.ts +++ b/src/modules/chart.ts @@ -19,7 +19,7 @@ const ChartMetaTradingPeriod = Type.Object( { additionalProperties: Type.Any(), title: "ChartMetaTradingPeriod", - } + }, ); const ChartMetaTradingPeriods = Type.Object( @@ -31,7 +31,7 @@ const ChartMetaTradingPeriods = Type.Object( { additionalProperties: Type.Any(), title: "ChartMetaTradingPeriods", - } + }, ); const ChartResultArrayQuote = Type.Object( @@ -47,7 +47,7 @@ const ChartResultArrayQuote = Type.Object( { additionalProperties: Type.Any(), title: "ChartResultArrayQuote", - } + }, ); const ChartEventDividend = Type.Object( @@ -58,7 +58,7 @@ const ChartEventDividend = Type.Object( { additionalProperties: Type.Any(), title: "ChartEventDividend", - } + }, ); const ChartEventDividends = Type.Object( @@ -66,7 +66,7 @@ const ChartEventDividends = Type.Object( { additionalProperties: ChartEventDividend, title: "ChartEventDividends", - } + }, ); const ChartEventSplit = Type.Object( @@ -78,7 +78,7 @@ const ChartEventSplit = Type.Object( }, { additionalProperties: Type.Any(), - } + }, ); const ChartEventsArray = Type.Object( { @@ -88,7 +88,7 @@ const ChartEventsArray = Type.Object( { additionalProperties: Type.Any(), title: "ChartEventsArray", - } + }, ); const ChartMeta = Type.Object( @@ -115,7 +115,7 @@ const ChartMeta = Type.Object( }, { additionalProperties: Type.Any(), - } + }, ), tradingPeriods: Type.Optional(ChartMetaTradingPeriods), dataGranularity: Type.String(), // "1d", @@ -125,7 +125,7 @@ const ChartMeta = Type.Object( { additionalProperties: Type.Any(), title: "ChartMeta", - } + }, ); const ChartResultArraySchema = Type.Object( @@ -134,7 +134,7 @@ const ChartResultArraySchema = Type.Object( events: Type.Optional(ChartEventsArray), quotes: Type.Array(ChartResultArrayQuote), }, - { title: "ChartResultArray" } + { title: "ChartResultArray" }, ); const ChartEventSplits = Type.Object( @@ -142,7 +142,7 @@ const ChartEventSplits = Type.Object( { additionalProperties: ChartEventSplit, title: "ChartEventSplits", - } + }, ); const ChartIndicatorQuote = Type.Object( @@ -156,7 +156,7 @@ const ChartIndicatorQuote = Type.Object( { additionalProperties: Type.Any(), title: "ChartIndicatorQuote", - } + }, ); const ChartIndicatorAdjclose = Type.Object( @@ -166,7 +166,7 @@ const ChartIndicatorAdjclose = Type.Object( { additionalProperties: Type.Any(), title: "ChartIndicatorAdjClose", - } + }, ); const ChartEventsObject = Type.Object( @@ -176,7 +176,7 @@ const ChartEventsObject = Type.Object( }, { additionalProperties: Type.Any(), - } + }, ); const ChartIndicatorsObject = Type.Object( @@ -187,7 +187,7 @@ const ChartIndicatorsObject = Type.Object( { additionalProperties: Type.Any(), title: "ChartIndicatorObject", - } + }, ); const ChartResultObjectSchema = Type.Object( { @@ -199,14 +199,14 @@ const ChartResultObjectSchema = Type.Object( { additionalProperties: Type.Any(), title: "ChartResultObject", - } + }, ); const ChartOptionsSchema = Type.Object( { period1: Type.Union([Type.Date(), Type.String(), YahooNumber]), period2: Type.Optional( - Type.Union([Type.Date(), Type.String(), YahooNumber]) + Type.Union([Type.Date(), Type.String(), YahooNumber]), ), useYfid: Type.Optional(Type.Boolean()), // true interval: Type.Optional( @@ -224,18 +224,18 @@ const ChartOptionsSchema = Type.Object( Type.Literal("1wk"), Type.Literal("1mo"), Type.Literal("3mo"), - ]) + ]), ), includePrePost: Type.Optional(Type.Boolean()), // true events: Type.Optional(Type.String()), // 'history', lang: Type.Optional(Type.String()), // "en-US" return: Type.Optional( - Type.Union([Type.Literal("array"), Type.Literal("object")]) + Type.Union([Type.Literal("array"), Type.Literal("object")]), ), }, { title: "ChartOptions", - } + }, ); const ChartOptionsWithReturnArraySchema = Type.Composite( @@ -247,7 +247,7 @@ const ChartOptionsWithReturnArraySchema = Type.Composite( ], { title: "ChartOptionsWithReturnArray", - } + }, ); const ChartOptionsWithReturnObjectSchema = Type.Composite( @@ -259,7 +259,7 @@ const ChartOptionsWithReturnObjectSchema = Type.Composite( ], { title: "ChartOptionsWithReturnObject", - } + }, ); type ChartOptions = Static; @@ -289,28 +289,28 @@ export default function chart( this: ModuleThis, symbol: string, queryOptionsOverrides: ChartOptionsWithReturnObject, - moduleOptions?: ModuleOptionsWithValidateTrue + moduleOptions?: ModuleOptionsWithValidateTrue, ): Promise; export default function chart( this: ModuleThis, symbol: string, queryOptionsOverrides: ChartOptionsWithReturnArray, - moduleOptions?: ModuleOptionsWithValidateTrue + moduleOptions?: ModuleOptionsWithValidateTrue, ): Promise; export default function chart( this: ModuleThis, symbol: string, queryOptionsOverrides: ChartOptions, - moduleOptions?: ModuleOptionsWithValidateFalse + moduleOptions?: ModuleOptionsWithValidateFalse, ): Promise; export default async function chart( this: ModuleThis, symbol: string, queryOptionsOverrides: ChartOptions, - moduleOptions?: ModuleOptions + moduleOptions?: ModuleOptions, ): Promise { const returnAs = queryOptionsOverrides?.return || "array"; @@ -333,14 +333,14 @@ export default async function chart( queryOptions[fieldName] = Math.floor(value.getTime() / 1000); else typeof value === "string"; queryOptions[fieldName] = Math.floor( - new Date(value as string).getTime() / 1000 + new Date(value as string).getTime() / 1000, ); } if (queryOptions.period1 === queryOptions.period2) { throw new Error( "yahooFinance.chart() options `period1` and `period2` " + - "cannot share the same value." + "cannot share the same value.", ); } @@ -365,13 +365,13 @@ export default async function chart( if (!chart.timestamp) { if (chart.indicators.quote.length !== 1) throw new Error( - "No timestamp with quotes.length !== 1, please report with your query" + "No timestamp with quotes.length !== 1, please report with your query", ); if (Object.keys(chart.indicators.quote[0]).length !== 0) // i.e. {} throw new Error( "No timestamp with unexpected quote, please report with your query" + - JSON.stringify(chart.indicators.quote[0]) + JSON.stringify(chart.indicators.quote[0]), ); chart.indicators.quote.pop(); } @@ -412,7 +412,7 @@ export default async function chart( quoteSize: result.indicators.quote[0].high.length, }); throw new Error( - "Timestamp count mismatch, please report this with the query you used" + "Timestamp count mismatch, please report this with the query you used", ); } diff --git a/src/modules/dailyGainers.spec.ts b/src/modules/dailyGainers.spec.ts index 7220ccd0..14f27913 100644 --- a/src/modules/dailyGainers.spec.ts +++ b/src/modules/dailyGainers.spec.ts @@ -13,7 +13,7 @@ describe("dailyGainers", () => { it("throws on weird result", () => { const devel = "weirdJsonResult.fake.json"; return expect(yf.dailyGainers({}, { devel })).rejects.toThrow( - /^Unexpected result/ + /^Unexpected result/, ); }); }); diff --git a/src/modules/dailyGainers.ts b/src/modules/dailyGainers.ts index 308588e3..ac19a1b9 100644 --- a/src/modules/dailyGainers.ts +++ b/src/modules/dailyGainers.ts @@ -15,7 +15,7 @@ const DailyGainersCriterum = Type.Object( labelsSelected: Type.Array(YahooNumber), dependentValues: Type.Array(Type.Any()), }, - { title: "DailyGainersCriterium" } + { title: "DailyGainersCriterium" }, ); const DailyGainersQuote = Type.Object( @@ -107,7 +107,7 @@ const DailyGainersQuote = Type.Object( dividendYield: Type.Optional(YahooNumber), dividendRate: Type.Optional(YahooNumber), }, - { title: "DailyGainersQuote" } + { title: "DailyGainersQuote" }, ); const DailyGainersOptionsSchema = Type.Object( @@ -116,7 +116,7 @@ const DailyGainersOptionsSchema = Type.Object( region: Type.Optional(Type.String()), count: Type.Optional(YahooNumber), }, - { title: "DailyGainersOptions" } + { title: "DailyGainersOptions" }, ); const DailyGainersCriteriaMeta = Type.Object( @@ -129,7 +129,7 @@ const DailyGainersCriteriaMeta = Type.Object( criteria: Type.Array(DailyGainersCriterum), topOperator: Type.String(), }, - { title: "DailyGainersCriteriaMeta" } + { title: "DailyGainersCriteriaMeta" }, ); const DailyGainersResultSchema = Type.Object( @@ -152,7 +152,7 @@ const DailyGainersResultSchema = Type.Object( isPremium: Type.Boolean(), iconUrl: Type.String(), }, - { title: "DailyGainersResult" } + { title: "DailyGainersResult" }, ); type DailyGainersResult = Static; @@ -168,19 +168,19 @@ const queryOptionsDefaults = { export default function dailyGainers( this: ModuleThis, queryOptionsOverrides?: DailyGainersOptions, - moduleOptions?: ModuleOptionsWithValidateTrue + moduleOptions?: ModuleOptionsWithValidateTrue, ): Promise; export default function dailyGainers( this: ModuleThis, queryOptionsOverrides?: DailyGainersOptions, - moduleOptions?: ModuleOptionsWithValidateFalse + moduleOptions?: ModuleOptionsWithValidateFalse, ): Promise; export default function dailyGainers( this: ModuleThis, queryOptionsOverrides?: DailyGainersOptions, - moduleOptions?: ModuleOptions + moduleOptions?: ModuleOptions, ): Promise { return this._moduleExec({ moduleName: "dailyGainers", diff --git a/src/modules/fundamentalsTimeSeries.spec.ts b/src/modules/fundamentalsTimeSeries.spec.ts index 095a7a3e..8bc05c36 100644 --- a/src/modules/fundamentalsTimeSeries.spec.ts +++ b/src/modules/fundamentalsTimeSeries.spec.ts @@ -17,7 +17,7 @@ describe("fundamentalsTimeSeries", () => { }, { devel: `fundamentalsTimeSeries-${symbol}-financials-quarterly.json`, - } + }, ); // console.log(`${symbol} fetched ${res.length} reports.`); }); @@ -33,7 +33,7 @@ describe("fundamentalsTimeSeries", () => { }, { devel: `fundamentalsTimeSeries-AAPL-all-quarterly.json`, - } + }, ); expect(res).toHaveLength(5); }); @@ -49,7 +49,7 @@ describe("fundamentalsTimeSeries", () => { }, { devel: `fundamentalsTimeSeries-AAPL-financials-quarterly.json`, - } + }, ); expect(res).toHaveLength(5); expect(res[0]).toHaveProperty("totalRevenue"); @@ -66,7 +66,7 @@ describe("fundamentalsTimeSeries", () => { }, { devel: `fundamentalsTimeSeries-AAPL-balance-sheet-quarterly.json`, - } + }, ); expect(res).toHaveLength(5); expect(res[0]).toHaveProperty("netDebt"); @@ -83,7 +83,7 @@ describe("fundamentalsTimeSeries", () => { }, { devel: `fundamentalsTimeSeries-AAPL-cash-flow-quarterly.json`, - } + }, ); expect(res).toHaveLength(5); expect(res[0]).toHaveProperty("freeCashFlow"); @@ -100,7 +100,7 @@ describe("fundamentalsTimeSeries", () => { }, { devel: `fundamentalsTimeSeries-AAPL-all-annual.json`, - } + }, ); expect(res).toHaveLength(4); }); @@ -116,7 +116,7 @@ describe("fundamentalsTimeSeries", () => { }, { devel: `fundamentalsTimeSeries-AAPL-financials-annual.json`, - } + }, ); expect(res).toHaveLength(4); expect(res[0]).toHaveProperty("totalRevenue"); @@ -133,7 +133,7 @@ describe("fundamentalsTimeSeries", () => { }, { devel: `fundamentalsTimeSeries-AAPL-balance-sheet-annual.json`, - } + }, ); expect(res).toHaveLength(4); expect(res[0]).toHaveProperty("netDebt"); @@ -150,7 +150,7 @@ describe("fundamentalsTimeSeries", () => { }, { devel: `fundamentalsTimeSeries-AAPL-cash-flow-annual.json`, - } + }, ); expect(res).toHaveLength(4); expect(res[0]).toHaveProperty("freeCashFlow"); @@ -162,7 +162,7 @@ describe("fundamentalsTimeSeries", () => { period1: "2020-01-01", period2: "2020-01-01", module: "financials", - }) + }), ).rejects.toThrow(/cannot share the same value/); }); @@ -172,7 +172,7 @@ describe("fundamentalsTimeSeries", () => { period1: "invalid", period2: "2021-01-01", module: "financials", - }) + }), ).rejects.toThrow(/invalid date provided/); await expect( @@ -180,7 +180,7 @@ describe("fundamentalsTimeSeries", () => { period1: "2020-01-011", period2: "invalid", module: "financials", - }) + }), ).rejects.toThrow(/invalid date provided/); }); @@ -191,7 +191,7 @@ describe("fundamentalsTimeSeries", () => { period2: "2021-01-01", type: "invalid", module: "financials", - }) + }), ).rejects.toThrow(/option type invalid/); }); @@ -201,7 +201,7 @@ describe("fundamentalsTimeSeries", () => { period1: "2020-01-01", period2: "2021-01-01", module: "invalid", - }) + }), ).rejects.toThrow(/option module invalid/); }); @@ -210,7 +210,7 @@ describe("fundamentalsTimeSeries", () => { yf.fundamentalsTimeSeries("TSLA", { period1: "2020-01-01", period2: "2021-01-01", - }) + }), ).rejects.toThrow(/called with invalid options/); }); @@ -219,8 +219,8 @@ describe("fundamentalsTimeSeries", () => { yf.fundamentalsTimeSeries( "EURGBP=X", { period1: 1567728000, period2: 1570665600, module: "financials" }, - { devel: "fundamentalsTimeSeries-EURGBP-unexpected-results.fake.json" } - ) + { devel: "fundamentalsTimeSeries-EURGBP-unexpected-results.fake.json" }, + ), ).rejects.toThrow(/Unexpected result/); }); }); diff --git a/src/modules/fundamentalsTimeSeries.ts b/src/modules/fundamentalsTimeSeries.ts index 29e946ef..5b920c99 100644 --- a/src/modules/fundamentalsTimeSeries.ts +++ b/src/modules/fundamentalsTimeSeries.ts @@ -24,14 +24,14 @@ const FundamentalsTimeSeriesResultSchema = Type.Object( { additionalProperties: Type.Unknown(), title: "FundamentalsTimeSeriesResult", - } + }, ); const FundamentalsTimeSeriesOptionsSchema = Type.Object( { period1: Type.Union([YahooFinanceDate, YahooNumber, Type.String()]), period2: Type.Optional( - Type.Union([YahooFinanceDate, YahooNumber, Type.String()]) + Type.Union([YahooFinanceDate, YahooNumber, Type.String()]), ), type: Type.Optional(Type.String()), merge: Type.Optional(Type.Boolean()), // This returns a completely different format that will break the transformer @@ -42,7 +42,7 @@ const FundamentalsTimeSeriesOptionsSchema = Type.Object( }, { title: "FundamentalsTimeSeriesOptions", - } + }, ); type FundamentalsTimeSeriesOptions = Static< @@ -50,7 +50,7 @@ type FundamentalsTimeSeriesOptions = Static< >; const FundamentalsTimeSeriesResultsSchema = Type.Array( - FundamentalsTimeSeriesResultSchema + FundamentalsTimeSeriesResultSchema, ); type FundamentalsTimeSeriesResult = Static< @@ -72,21 +72,21 @@ export default function fundamentalsTimeSeries( this: ModuleThis, symbol: string, queryOptionsOverrides: FundamentalsTimeSeriesOptions, - moduleOptions?: ModuleOptionsWithValidateTrue + moduleOptions?: ModuleOptionsWithValidateTrue, ): Promise; export default function fundamentalsTimeSeries( this: ModuleThis, symbol: string, queryOptionsOverrides: FundamentalsTimeSeriesOptions, - moduleOptions?: ModuleOptionsWithValidateFalse + moduleOptions?: ModuleOptionsWithValidateFalse, ): Promise; export default function fundamentalsTimeSeries( this: ModuleThis, symbol: string, queryOptionsOverrides: FundamentalsTimeSeriesOptions, - moduleOptions?: ModuleOptions + moduleOptions?: ModuleOptions, ): Promise { return this._moduleExec({ moduleName: "options", @@ -124,7 +124,7 @@ export default function fundamentalsTimeSeries( * @returns Query parameters. */ export const processQuery = function ( - queryOptions: FundamentalsTimeSeriesOptions + queryOptions: FundamentalsTimeSeriesOptions, ): Partial { // Convert dates if (!queryOptions.period2) queryOptions.period2 = new Date(); @@ -143,7 +143,7 @@ export const processQuery = function ( fieldName + "' invalid date provided: '" + value + - "'" + "'", ); queryOptions[fieldName] = Math.floor(timestamp / 1000); @@ -154,17 +154,17 @@ export const processQuery = function ( if (queryOptions.period1 === queryOptions.period2) { throw new Error( "yahooFinance.fundamentalsTimeSeries() options `period1` and `period2` " + - "cannot share the same value." + "cannot share the same value.", ); } else if (!FundamentalsTimeSeries_Types.includes(queryOptions.type || "")) { throw new Error( - "yahooFinance.fundamentalsTimeSeries() option type invalid." + "yahooFinance.fundamentalsTimeSeries() option type invalid.", ); } else if ( !FundamentalsTimeSeries_Modules.includes(queryOptions.module || "") ) { throw new Error( - "yahooFinance.fundamentalsTimeSeries() option module invalid." + "yahooFinance.fundamentalsTimeSeries() option module invalid.", ); } @@ -177,7 +177,7 @@ export const processQuery = function ( return previous.concat(keys); } else return previous; }, - [] as Array + [] as Array, ); const queryType = queryOptions.type + keys.join(`,${queryOptions.type}`); diff --git a/src/modules/historical.spec.ts b/src/modules/historical.spec.ts index 8d6d8571..fb39561a 100644 --- a/src/modules/historical.spec.ts +++ b/src/modules/historical.spec.ts @@ -22,23 +22,23 @@ describe("historical", () => { period1: "2020-01-01", period2: "2020-01-03", }, - { devel: `historical-${symbol}-2020-01-01-to-2020-01-03.json` } + { devel: `historical-${symbol}-2020-01-01-to-2020-01-03.json` }, ); }); it("throws if period1,period2 are the same", async () => { await expect( - yf.historical("TSLA", { period1: "2022-02-22", period2: "2022-02-22" }) + yf.historical("TSLA", { period1: "2022-02-22", period2: "2022-02-22" }), ).rejects.toThrow(/cannot share the same value/); }); it("throws if period{1,2} gets an invalid string for new Date()", async () => { await expect(yf.historical("TSLA", { period1: "invalid" })).rejects.toThrow( - /invalid date provided/ + /invalid date provided/, ); await expect( - yf.historical("TSLA", { period1: "2022-02-022", period2: "invalid" }) + yf.historical("TSLA", { period1: "2022-02-022", period2: "invalid" }), ).rejects.toThrow(/invalid date provided/); }); @@ -50,7 +50,7 @@ describe("historical", () => { period2: "2022-01-31", events: "dividends", }, - { devel: "historical-MSFT-dividends-2021-02-01-to-2022-01-31.csv" } + { devel: "historical-MSFT-dividends-2021-02-01-to-2022-01-31.csv" }, ); }); @@ -62,7 +62,7 @@ describe("historical", () => { period2: "2022-01-31", events: "split", }, - { devel: "historical-NVDA-split-2021-02-01-to-2022-01-31.csv" } + { devel: "historical-NVDA-split-2021-02-01-to-2022-01-31.csv" }, ); }); @@ -94,7 +94,7 @@ describe("historical", () => { }, // Not a "fake" but seems fixed in newer Yahoo requests // so let's test against our previously saved cache. - { devel: "historical-EURGBP-nulls.saved.fake.json" } + { devel: "historical-EURGBP-nulls.saved.fake.json" }, ); await expect(createHistoricalPromise()).resolves.toBeDefined(); @@ -116,9 +116,9 @@ describe("historical", () => { .historical( "EURGBP=X", { period1: 1567728000, period2: 1570665600 }, - { devel: "historical-EURGBP-nulls.fake.json" } + { devel: "historical-EURGBP-nulls.fake.json" }, ) - .finally(consoleRestore) + .finally(consoleRestore), ).rejects.toThrow("SOME (but not all) null values"); }); }); @@ -132,7 +132,7 @@ describe("historical", () => { events: "dividends", interval: "1d", }, - { devel: "historical-dividends-TSLA-no-dividends.json" } + { devel: "historical-dividends-TSLA-no-dividends.json" }, ); // Enough to check that this doesn't throw. }); diff --git a/src/modules/historical.ts b/src/modules/historical.ts index f43628db..d2f6df68 100644 --- a/src/modules/historical.ts +++ b/src/modules/historical.ts @@ -20,7 +20,7 @@ const HistoricalRowHistory = Type.Object( { additionalProperties: Type.Any(), title: "HistoricalRowHistory", - } + }, ); const HistoricalRowDividend = Type.Object( @@ -28,7 +28,7 @@ const HistoricalRowDividend = Type.Object( date: YahooFinanceDate, dividends: YahooNumber, }, - { title: "HistoricalRowDividend" } + { title: "HistoricalRowDividend" }, ); const HistoricalRowStockSplit = Type.Object( @@ -36,22 +36,26 @@ const HistoricalRowStockSplit = Type.Object( date: YahooFinanceDate, stockSplits: Type.String(), }, - { title: "HistoricalRowStockSplit" } + { title: "HistoricalRowStockSplit" }, ); const HistoricalOptionsSchema = Type.Object( { period1: Type.Union([Type.Date(), Type.String(), Type.Number()]), period2: Type.Optional( - Type.Union([Type.Date(), Type.String(), Type.Number()]) + Type.Union([Type.Date(), Type.String(), Type.Number()]), ), interval: Type.Optional( - Type.Union([Type.Literal("1d"), Type.Literal("1wk"), Type.Literal("1mo")]) + Type.Union([ + Type.Literal("1d"), + Type.Literal("1wk"), + Type.Literal("1mo"), + ]), ), events: Type.Optional(Type.String()), includeAdjustedClose: Type.Optional(Type.Boolean()), }, - { title: "HistoricalOptions" } + { title: "HistoricalOptions" }, ); const HistoricalOptionsEventsHistorySchema = Type.Composite( @@ -61,7 +65,7 @@ const HistoricalOptionsEventsHistorySchema = Type.Composite( events: Type.Optional(Type.Literal("history")), }), ], - { title: "HistoricalOptionsEventsHistory" } + { title: "HistoricalOptionsEventsHistory" }, ); const HistoricalOptionsEventsDividendsSchema = Type.Composite( @@ -71,7 +75,7 @@ const HistoricalOptionsEventsDividendsSchema = Type.Composite( events: Type.Literal("dividends"), }), ], - { title: "HistoricalOptionsEventsDividends" } + { title: "HistoricalOptionsEventsDividends" }, ); const HistoricalOptionsEventsSplitSchema = Type.Composite( @@ -81,7 +85,7 @@ const HistoricalOptionsEventsSplitSchema = Type.Composite( events: Type.Literal("split"), }), ], - { title: "HistoricalOptionsEventsSplit" } + { title: "HistoricalOptionsEventsSplit" }, ); const HistoricalHistoryResultSchema = Type.Array(HistoricalRowHistory, { @@ -121,35 +125,35 @@ export default function historical( this: ModuleThis, symbol: string, queryOptionsOverrides: HistoricalOptionsEventsHistory, - moduleOptions?: ModuleOptionsWithValidateTrue + moduleOptions?: ModuleOptionsWithValidateTrue, ): Promise; export default function historical( this: ModuleThis, symbol: string, queryOptionsOverrides: HistoricalOptionsEventsDividends, - moduleOptions?: ModuleOptionsWithValidateTrue + moduleOptions?: ModuleOptionsWithValidateTrue, ): Promise; export default function historical( this: ModuleThis, symbol: string, queryOptionsOverrides: HistoricalOptionsEventsSplit, - moduleOptions?: ModuleOptionsWithValidateTrue + moduleOptions?: ModuleOptionsWithValidateTrue, ): Promise; export default function historical( this: ModuleThis, symbol: string, queryOptionsOverrides: HistoricalOptions, - moduleOptions?: ModuleOptionsWithValidateFalse + moduleOptions?: ModuleOptionsWithValidateFalse, ): Promise; export default function historical( this: ModuleThis, symbol: string, queryOptionsOverrides: HistoricalOptions, - moduleOptions?: ModuleOptions + moduleOptions?: ModuleOptions, ): Promise { let schema; if ( @@ -190,7 +194,7 @@ export default function historical( fieldName + "' invalid date provided: '" + value + - "'" + "'", ); queryOptions[fieldName] = Math.floor(timestamp / 1000); @@ -200,7 +204,7 @@ export default function historical( if (queryOptions.period1 === queryOptions.period2) { throw new Error( "yahooFinance.historical() options `period1` and `period2` " + - "cannot share the same value." + "cannot share the same value.", ); } @@ -240,7 +244,7 @@ export default function historical( throw new Error( "Historical returned a result with SOME (but not " + "all) null values. Please report this, and provide the " + - "query that caused it." + "query that caused it.", ); } else { // All fields (except "date") are null: silently skip (no-op) diff --git a/src/modules/insights.spec.ts b/src/modules/insights.spec.ts index a7f6eeee..2421068e 100644 --- a/src/modules/insights.spec.ts +++ b/src/modules/insights.spec.ts @@ -25,7 +25,7 @@ describe("insights", () => { it("throws on weird result", () => { const devel = "weirdJsonResult.fake.json"; return expect(yf.insights("A", {}, { devel })).rejects.toThrow( - /^Unexpected result/ + /^Unexpected result/, ); }); }); diff --git a/src/modules/insights.ts b/src/modules/insights.ts index 0ad36a46..5b73a7cc 100644 --- a/src/modules/insights.ts +++ b/src/modules/insights.ts @@ -14,7 +14,7 @@ import { const InsightsDirection = Type.Union( [Type.Literal("Bearish"), Type.Literal("Bullish"), Type.Literal("Neutral")], - { title: "InsightsDirection" } + { title: "InsightsDirection" }, ); const InsightsOutlookSchema = Type.Object( @@ -33,7 +33,7 @@ const InsightsOutlookSchema = Type.Object( { additionalProperties: Type.Any(), title: "InsightsOutlook", - } + }, ); const InsightsInstrumentInfo = Type.Object( @@ -47,7 +47,7 @@ const InsightsInstrumentInfo = Type.Object( }, { additionalProperties: Type.Any(), - } + }, ), technicalEvents: Type.Object( { @@ -59,7 +59,7 @@ const InsightsInstrumentInfo = Type.Object( }, { additionalProperties: Type.Any(), - } + }, ), valuation: Type.Object( { @@ -71,13 +71,13 @@ const InsightsInstrumentInfo = Type.Object( }, { additionalProperties: Type.Any(), - } + }, ), }, { additionalProperties: Type.Any(), title: "InsightsInstrumentInfo", - } + }, ); const InsightsCompanySnapshot = Type.Object( @@ -94,7 +94,7 @@ const InsightsCompanySnapshot = Type.Object( }, { additionalProperties: Type.Any(), - } + }, ), sector: Type.Object( { @@ -107,10 +107,10 @@ const InsightsCompanySnapshot = Type.Object( }, { additionalProperties: Type.Any(), - } + }, ), }, - { title: "InsightsCompanySnapshot", additionalProperties: Type.Any() } + { title: "InsightsCompanySnapshot", additionalProperties: Type.Any() }, ); const InsightsEventSchema = Type.Object( @@ -123,7 +123,7 @@ const InsightsEventSchema = Type.Object( startDate: YahooFinanceDate, endDate: YahooFinanceDate, }, - { title: "InsightsEvent", additionalProperties: Type.Any() } + { title: "InsightsEvent", additionalProperties: Type.Any() }, ); const InsightsReport = Type.Object( { @@ -140,25 +140,25 @@ const InsightsReport = Type.Object( Type.Literal("Maintained"), Type.Literal("Decreased"), Type.Literal("-"), - ]) + ]), ), investmentRating: Type.Optional( Type.Union([ Type.Literal("Bullish"), Type.Literal("Neutral"), Type.Literal("Bearish"), - ]) + ]), ), tickers: Type.Optional(Type.Array(Type.String())), }, - { title: "InsightsReport", additionalProperties: Type.Any() } + { title: "InsightsReport", additionalProperties: Type.Any() }, ); const InsightsSigDev = Type.Object( { headline: Type.String(), date: YahooFinanceDate, }, - { title: "InsightsSigDev", additionalProperties: Type.Any() } + { title: "InsightsSigDev", additionalProperties: Type.Any() }, ); const InsightsUpsell = Type.Object( { @@ -168,7 +168,7 @@ const InsightsUpsell = Type.Object( companyName: Type.Optional(Type.String()), upsellReportType: Type.Optional(Type.String()), }, - { title: "InsightsUpsell", additionalProperties: Type.Any() } + { title: "InsightsUpsell", additionalProperties: Type.Any() }, ); const InsightsResearchReport = Type.Object( { @@ -182,10 +182,10 @@ const InsightsResearchReport = Type.Object( Type.Literal("Bullish"), Type.Literal("Neutral"), Type.Literal("Bearish"), - ]) + ]), ), }, - { title: "InsightsResearchReport" } + { title: "InsightsResearchReport" }, ); const InsightsSecReport = Type.Object( { @@ -200,7 +200,7 @@ const InsightsSecReport = Type.Object( { title: "InsightsSecReport", additionalProperties: Type.Any(), - } + }, ); const InsightsResultSchema = Type.Object( @@ -217,7 +217,7 @@ const InsightsResultSchema = Type.Object( Type.Literal("SELL"), Type.Literal("HOLD"), ]), - }) + }), ), events: Type.Optional(Type.Array(InsightsEventSchema)), reports: Type.Optional(Type.Array(InsightsReport)), @@ -226,14 +226,14 @@ const InsightsResultSchema = Type.Object( upsellSearchDD: Type.Optional( Type.Object({ researchReports: InsightsResearchReport, - }) + }), ), secReports: Type.Optional(Type.Array(InsightsSecReport)), }, { additionalProperties: Type.Any(), title: "InsightsResult", - } + }, ); type InsightsResult = Static; @@ -295,7 +295,7 @@ const InsightsOptionsSchema = Type.Object( region: Type.Optional(Type.String()), reportsCount: Type.Optional(YahooNumber), }, - { title: "InsightsOptions" } + { title: "InsightsOptions" }, ); type InsightsOptions = Static; @@ -311,21 +311,21 @@ export default function trendingSymbols( this: ModuleThis, symbol: string, queryOptionsOverrides?: InsightsOptions, - moduleOptions?: ModuleOptionsWithValidateTrue + moduleOptions?: ModuleOptionsWithValidateTrue, ): Promise; export default function trendingSymbols( this: ModuleThis, symbol: string, queryOptionsOverrides?: InsightsOptions, - moduleOptions?: ModuleOptionsWithValidateFalse + moduleOptions?: ModuleOptionsWithValidateFalse, ): Promise; export default function trendingSymbols( this: ModuleThis, symbol: string, queryOptionsOverrides?: InsightsOptions, - moduleOptions?: ModuleOptions + moduleOptions?: ModuleOptions, ): Promise { return this._moduleExec({ moduleName: "insights", diff --git a/src/modules/options.spec.ts b/src/modules/options.spec.ts index 8a89c6fe..2ad88224 100644 --- a/src/modules/options.spec.ts +++ b/src/modules/options.spec.ts @@ -27,7 +27,7 @@ describe("options", () => { it("throws on weird result", () => { const devel = "weirdJsonResult.fake.json"; return expect(yf.options("A", {}, { devel })).rejects.toThrow( - /^Unexpected result/ + /^Unexpected result/, ); }); @@ -38,25 +38,25 @@ describe("options", () => { it("accepts a Date", () => { return expect( - yf.options("AAPL", { date: new Date("2022-03-01") }, devel) + yf.options("AAPL", { date: new Date("2022-03-01") }, devel), ).resolves.not.toThrow(); }); it("accepts a number", () => { return expect( - yf.options("AAPL", { date: 1646092800 /* 2022-03-01 */ }, devel) + yf.options("AAPL", { date: 1646092800 /* 2022-03-01 */ }, devel), ).resolves.not.toThrow(); }); it("accepts a string", () => { return expect( - yf.options("AAPL", { date: "2022-03-01T00:00:00.000Z" }, devel) + yf.options("AAPL", { date: "2022-03-01T00:00:00.000Z" }, devel), ).resolves.not.toThrow(); }); it("throws on invalid", () => { return expect( - yf.options("AAPL", { date: "something yfDate can't parse" }) + yf.options("AAPL", { date: "something yfDate can't parse" }), ).rejects.toThrow("Validation called with invalid options"); }); }); diff --git a/src/modules/options.ts b/src/modules/options.ts index 5b12bbb5..4c0b10b4 100644 --- a/src/modules/options.ts +++ b/src/modules/options.ts @@ -42,7 +42,7 @@ const QuoteCryptoCurrency = Type.Composite( startDate: Type.Optional(YahooFinanceDate), // new Date(1367103600 * 1000) }), ], - { title: "QuoteCryptoCurrency" } + { title: "QuoteCryptoCurrency" }, ); const QuoteCurrency = Type.Composite( @@ -52,7 +52,7 @@ const QuoteCurrency = Type.Composite( quoteType: Type.Literal("CURRENCY"), }), ], - { title: "QuoteCurrency" } + { title: "QuoteCurrency" }, ); const QuoteEtf = Type.Composite([ @@ -71,7 +71,7 @@ const QuoteEquity = Type.Composite( dividendYield: Type.Optional(Type.Number()), }), ], - { title: "QuoteEquity" } + { title: "QuoteEquity" }, ); const QuoteFuture = Type.Composite( @@ -88,7 +88,7 @@ const QuoteFuture = Type.Composite( ], { title: "QuoteFuture", - } + }, ); const QuoteIndex = Type.Composite( @@ -100,7 +100,7 @@ const QuoteIndex = Type.Composite( ], { title: "QuoteIndex", - } + }, ); const QuoteOption = Type.Composite( @@ -117,7 +117,7 @@ const QuoteOption = Type.Composite( ], { title: "QuoteOption", - } + }, ); const QuoteMutualfund = Type.Composite( @@ -129,7 +129,7 @@ const QuoteMutualfund = Type.Composite( ], { title: "QuoteMutualFund", - } + }, ); const QuoteSchema = Type.Union( @@ -145,7 +145,7 @@ const QuoteSchema = Type.Union( ], { title: "Quote", - } + }, ); const CallOrPut = Type.Object( @@ -169,7 +169,7 @@ const CallOrPut = Type.Object( { additionalProperties: Type.Any(), title: "CallOrPut", - } + }, ); const Option = Type.Object( @@ -182,7 +182,7 @@ const Option = Type.Object( { additionalProperties: Type.Any(), title: "Option", - } + }, ); const OptionsResultSchema = Type.Object( @@ -197,7 +197,7 @@ const OptionsResultSchema = Type.Object( { additionalProperties: Type.Any(), title: "OptionsResult", - } + }, ); const OptionsOptionsSchema = Type.Object( @@ -209,7 +209,7 @@ const OptionsOptionsSchema = Type.Object( }, { title: "OptionsOptions", - } + }, ); type OptionsOptions = Static; @@ -225,21 +225,21 @@ export default function options( this: ModuleThis, symbol: string, queryOptionsOverrides: OptionsOptions, - moduleOptions?: ModuleOptionsWithValidateTrue + moduleOptions?: ModuleOptionsWithValidateTrue, ): Promise; export default function options( this: ModuleThis, symbol: string, queryOptionsOverrides: OptionsOptions, - moduleOptions?: ModuleOptionsWithValidateFalse + moduleOptions?: ModuleOptionsWithValidateFalse, ): Promise; export default function options( this: ModuleThis, symbol: string, queryOptionsOverrides: OptionsOptions, - moduleOptions?: ModuleOptions + moduleOptions?: ModuleOptions, ): Promise { return this._moduleExec({ moduleName: "options", diff --git a/src/modules/quote.spec.ts b/src/modules/quote.spec.ts index e77613d0..e62315f7 100644 --- a/src/modules/quote.spec.ts +++ b/src/modules/quote.spec.ts @@ -44,7 +44,7 @@ describe("quote", () => { it("allows blank options", async () => { await expect(() => - yf.quote("AAPL", undefined, { devel: "quote-AAPL.json" }) + yf.quote("AAPL", undefined, { devel: "quote-AAPL.json" }), ).not.toThrow(); }); @@ -66,7 +66,7 @@ describe("quote", () => { if (process.env.FETCH_DEVEL !== "nocache") it("throws on unexpected result", async () => { await expect( - yf.quote("AAPL", {}, { devel: "weirdJsonResult.fake.json" }) + yf.quote("AAPL", {}, { devel: "weirdJsonResult.fake.json" }), ).rejects.toThrow(/Unexpected result/); }); @@ -92,7 +92,7 @@ describe("quote", () => { const results = await yf.quote( ["AAPL", "BABA"], { return: "array" }, - { devel } + { devel }, ); expect(results.length).toBe(2); expect(results[0].symbol).toBe("AAPL"); @@ -104,7 +104,7 @@ describe("quote", () => { const results = await yf.quote( ["AAPL", "BABA"], { return: "object" }, - { devel } + { devel }, ); expect(Object.keys(results).length).toBe(2); expect(results.AAPL.symbol).toBe("AAPL"); @@ -116,7 +116,7 @@ describe("quote", () => { const results = await yf.quote( ["AAPL", "BABA"], { return: "map" }, - { devel } + { devel }, ); expect(results.size).toBe(2); expect(results.get("AAPL").symbol).toBe("AAPL"); diff --git a/src/modules/quote.ts b/src/modules/quote.ts index b3c47683..d7239456 100644 --- a/src/modules/quote.ts +++ b/src/modules/quote.ts @@ -122,7 +122,7 @@ export const QuoteBase = Type.Object( }, { additionalProperties: Type.Any(), - } + }, ); /* @@ -290,21 +290,21 @@ export default function quote( this: ModuleThis, query: string[], queryOptionsOverrides?: QuoteOptionsWithReturnArray, - moduleOptions?: ModuleOptionsWithValidateTrue + moduleOptions?: ModuleOptionsWithValidateTrue, ): Promise; export default function quote( this: ModuleThis, query: string[], queryOptionsOverrides?: QuoteOptionsWithReturnMap, - moduleOptions?: ModuleOptionsWithValidateTrue + moduleOptions?: ModuleOptionsWithValidateTrue, ): Promise; export default function quote( this: ModuleThis, query: string[], queryOptionsOverrides?: QuoteOptionsWithReturnObject, - moduleOptions?: ModuleOptionsWithValidateTrue + moduleOptions?: ModuleOptionsWithValidateTrue, ): Promise; /* --- everything else --- */ @@ -313,21 +313,21 @@ export default function quote( this: ModuleThis, query: string, queryOptionsOverrides?: QuoteOptions, - moduleOptions?: ModuleOptionsWithValidateTrue + moduleOptions?: ModuleOptionsWithValidateTrue, ): Promise; export default function quote( this: ModuleThis, query: string | string[], queryOptionsOverrides?: QuoteOptions, - moduleOptions?: ModuleOptionsWithValidateFalse + moduleOptions?: ModuleOptionsWithValidateFalse, ): Promise; export default async function quote( this: ModuleThis, query: string | string[], queryOptionsOverrides?: QuoteOptions, - moduleOptions?: ModuleOptions + moduleOptions?: ModuleOptions, ): Promise { const symbols = typeof query === "string" ? query : query.join(","); const returnAs = queryOptionsOverrides && queryOptionsOverrides.return; diff --git a/src/modules/quoteSummary-iface.ts b/src/modules/quoteSummary-iface.ts index 6414b5fa..3227660f 100644 --- a/src/modules/quoteSummary-iface.ts +++ b/src/modules/quoteSummary-iface.ts @@ -104,7 +104,7 @@ const UpgradeDowngradeHistoryHistory = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryUpgradeDowngradeHistoryHistory", - } + }, ); const UpgradeDowngradeHistory = Type.Object( @@ -115,7 +115,7 @@ const UpgradeDowngradeHistory = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryUpgradeDowngradeHistory", - } + }, ); const TopHoldingsSectorWeighting = Type.Object( @@ -135,7 +135,7 @@ const TopHoldingsSectorWeighting = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryTopHoldingsSectorWeighting", - } + }, ); const TopHoldingsBondRating = Type.Object( @@ -153,7 +153,7 @@ const TopHoldingsBondRating = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryTopHoldingsBondRating", - } + }, ); const TopHoldingsEquityHoldings = Type.Object( @@ -174,7 +174,7 @@ const TopHoldingsEquityHoldings = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryTopHoldingsEquityHoldings", - } + }, ); const TopHoldingsHolding = Type.Object( @@ -186,7 +186,7 @@ const TopHoldingsHolding = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryTopHoldingsHolding", - } + }, ); const TopHoldings = Type.Object( @@ -207,7 +207,7 @@ const TopHoldings = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryTopHoldings", - } + }, ); const SummaryProfile = Type.Object( @@ -242,7 +242,7 @@ const SummaryProfile = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummarySummaryProfile", - } + }, ); const SummaryDetail = Type.Object( @@ -309,7 +309,7 @@ const SummaryDetail = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummarySummaryDetail", - } + }, ); // May consider switching this to string, as we keep finding more and more. @@ -340,7 +340,7 @@ const FilingType = Type.Union( ], { title: "QuoteSummaryFilingType", - } + }, ); const Filing = Type.Object( @@ -358,14 +358,14 @@ const Filing = Type.Object( type: Type.String(), url: Type.String(), downloadUrl: Type.Optional(Type.String()), - }) - ) + }), + ), ), }, { additionalProperties: Type.Any(), title: "QuoteSummaryFiling", - } + }, ); const SECFilings = Type.Object( @@ -376,7 +376,7 @@ const SECFilings = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummarySECFilings", - } + }, ); const RecommendationTrendTrend = Type.Object( @@ -391,7 +391,7 @@ const RecommendationTrendTrend = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryRecommendationTrendTrend", - } + }, ); const RecommendationTrend = Type.Object( @@ -402,7 +402,7 @@ const RecommendationTrend = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryRecommendationTrend", - } + }, ); const QuoteType = Type.Object( @@ -424,7 +424,7 @@ const QuoteType = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryQuoteType", - } + }, ); const Price = Type.Object( @@ -478,7 +478,7 @@ const Price = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryPrice", - } + }, ); const NetSharePurchaseActivity = Type.Object( @@ -499,7 +499,7 @@ const NetSharePurchaseActivity = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryNetSharePurchaseActivity", - } + }, ); const MajorHoldersBreakdown = Type.Object( @@ -513,7 +513,7 @@ const MajorHoldersBreakdown = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryMajorHoldersBreakdown", - } + }, ); enum EnumOwnership { @@ -558,7 +558,7 @@ const Transaction = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryTransaction", - } + }, ); const InsiderTransactions = Type.Object( @@ -569,7 +569,7 @@ const InsiderTransactions = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryInsiderTransactions", - } + }, ); const Holder = Type.Object( @@ -589,7 +589,7 @@ const Holder = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryHolder", - } + }, ); const Holders = Type.Object( @@ -600,7 +600,7 @@ const Holders = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryHolders", - } + }, ); const Trend = Type.Object( @@ -612,7 +612,7 @@ const Trend = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryTrend", - } + }, ); const Estimate = Type.Object( @@ -623,7 +623,7 @@ const Estimate = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryEstimate", - } + }, ); const IndexTrend = Type.Object( @@ -637,7 +637,7 @@ const IndexTrend = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryIndexTrend", - } + }, ); const IncomeStatementHistoryElement = Type.Object( @@ -670,7 +670,7 @@ const IncomeStatementHistoryElement = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryIncomeStatementHistoryElement", - } + }, ); const IncomeStatementHistory = Type.Object( @@ -681,14 +681,14 @@ const IncomeStatementHistory = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryIncomeStatementHistory", - } + }, ); const FundProfileBrokerage = Type.Object( {}, { title: "QuoteSummaryFundProfileBrokerage", - } + }, ); const FundProfileFeesExpensesInvestment = Type.Object( @@ -703,7 +703,7 @@ const FundProfileFeesExpensesInvestment = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryFundProfileFeesExpensesInvestment", - } + }, ); const FundProfileFeesExpensesInvestmentCat = Type.Composite( @@ -716,7 +716,7 @@ const FundProfileFeesExpensesInvestmentCat = Type.Composite( { title: "QuoteSummaryFundProfileFeesExpensesInvestmentCat", additionalProperties: Type.Any(), - } + }, ); const FundProfileManagementInfo = Type.Object( @@ -728,7 +728,7 @@ const FundProfileManagementInfo = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryFundProfileManagementInfo", - } + }, ); const FundProfile = Type.Object( @@ -741,7 +741,7 @@ const FundProfile = Type.Object( managementInfo: Type.Optional(FundProfileManagementInfo), feesExpensesInvestment: Type.Optional(FundProfileFeesExpensesInvestment), feesExpensesInvestmentCat: Type.Optional( - FundProfileFeesExpensesInvestmentCat + FundProfileFeesExpensesInvestmentCat, ), brokerages: Type.Optional(Type.Array(FundProfileBrokerage)), initInvestment: Type.Optional(YahooNumber), @@ -754,7 +754,7 @@ const FundProfile = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryFundProfile", - } + }, ); const FundPerformanceRiskOverviewStatsRow = Type.Object( @@ -771,7 +771,7 @@ const FundPerformanceRiskOverviewStatsRow = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryFundPerformanceRiskOverviewStatsRow", - } + }, ); const FundPerformanceRiskOverviewStatsCat = Type.Object( @@ -781,7 +781,7 @@ const FundPerformanceRiskOverviewStatsCat = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryFundPerformanceRiskOverviewStatsCat", - } + }, ); const FundPerformanceRiskOverviewStats = Type.Object( @@ -792,7 +792,7 @@ const FundPerformanceRiskOverviewStats = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryFundPerformanceRiskOverviewStats", - } + }, ); const FundPerformanceReturnsRow = Type.Object( @@ -807,7 +807,7 @@ const FundPerformanceReturnsRow = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryFundPerformanceReturnsRow", - } + }, ); const FundPerformanceReturns = Type.Object( @@ -818,7 +818,7 @@ const FundPerformanceReturns = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryFundPerformanceReturns", - } + }, ); const FundPerformancePerformanceOverviewCat = Type.Object( @@ -829,7 +829,7 @@ const FundPerformancePerformanceOverviewCat = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryFundPerformancePerformanceOverviewCat", - } + }, ); const FundPerformancePerformanceOverview = Type.Object( @@ -850,7 +850,7 @@ const FundPerformancePerformanceOverview = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryFundPerformancePerformanceOverview", - } + }, ); const PeriodRange = Type.Object( @@ -867,7 +867,7 @@ const PeriodRange = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryPeriodRange", - } + }, ); const FundPerformanceTrailingReturns = Type.Composite( @@ -880,12 +880,12 @@ const FundPerformanceTrailingReturns = Type.Composite( }, { additionalProperties: Type.Any(), - } + }, ), ], { title: "QuoteSummaryFundPerformanceTrailingReturns", - } + }, ); const FundPerformance = Type.Object( @@ -906,7 +906,7 @@ const FundPerformance = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryFundPerformance", - } + }, ); const OwnershipList = Type.Object( @@ -922,7 +922,7 @@ const OwnershipList = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryOwnershipList", - } + }, ); const Ownership = Type.Object( @@ -933,7 +933,7 @@ const Ownership = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryOwnership", - } + }, ); const FinancialData = Type.Object( @@ -972,7 +972,7 @@ const FinancialData = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryFinancialData", - } + }, ); const RevenueEstimate = Type.Object( @@ -987,7 +987,7 @@ const RevenueEstimate = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryRevenueEstimate", - } + }, ); const EpsTrend = Type.Object( @@ -1001,7 +1001,7 @@ const EpsTrend = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryEpsTrend", - } + }, ); const EpsRevisions = Type.Object( @@ -1014,7 +1014,7 @@ const EpsRevisions = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryEpsRevisions", - } + }, ); const EarningsEstimate = Type.Object( @@ -1029,7 +1029,7 @@ const EarningsEstimate = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryEarningsEstimate", - } + }, ); const EarningsTrendTrend = Type.Object( @@ -1046,7 +1046,7 @@ const EarningsTrendTrend = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryEarningsTrendTrend", - } + }, ); const EarningsTrend = Type.Object( @@ -1057,7 +1057,7 @@ const EarningsTrend = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryEarningsTrend", - } + }, ); const EarningsHistoryHistory = Type.Object( @@ -1073,7 +1073,7 @@ const EarningsHistoryHistory = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryEarningsHistoryHistory", - } + }, ); const EarningsHistory = Type.Object( @@ -1084,7 +1084,7 @@ const EarningsHistory = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryEarningsHistory", - } + }, ); const Yearly = Type.Object( @@ -1096,7 +1096,7 @@ const Yearly = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryYearly", - } + }, ); const FinancialsChartQuarterly = Type.Object( @@ -1108,7 +1108,7 @@ const FinancialsChartQuarterly = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryFinancialsChartQuarterly", - } + }, ); const FinancialsChart = Type.Object( @@ -1119,7 +1119,7 @@ const FinancialsChart = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryFinancialsChart", - } + }, ); const EarningsChartQuarterly = Type.Object( @@ -1131,7 +1131,7 @@ const EarningsChartQuarterly = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryEarningsChartQuarterly", - } + }, ); const EarningsChart = Type.Object( @@ -1145,7 +1145,7 @@ const EarningsChart = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryEarningsChart", - } + }, ); const QuoteSummaryEarnings = Type.Object( @@ -1158,7 +1158,7 @@ const QuoteSummaryEarnings = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryEarnings", - } + }, ); const DefaultKeyStatistics = Type.Object( @@ -1218,7 +1218,7 @@ const DefaultKeyStatistics = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryDefaultKeyStatistics", - } + }, ); const CashflowStatement = Type.Object( @@ -1249,7 +1249,7 @@ const CashflowStatement = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryCashflowStatement", - } + }, ); const CashflowStatementHistory = Type.Object( { @@ -1259,7 +1259,7 @@ const CashflowStatementHistory = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryCashflowStatementHistory", - } + }, ); const CalendarEventsEarnings = Type.Object( @@ -1275,7 +1275,7 @@ const CalendarEventsEarnings = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSumamryCalendarEventsEarnings", - } + }, ); const CalendarEvents = Type.Object( @@ -1288,7 +1288,7 @@ const CalendarEvents = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryCalendarEvents", - } + }, ); const BalanceSheetStatement = Type.Object( @@ -1328,7 +1328,7 @@ const BalanceSheetStatement = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryBalanceSheetStatement", - } + }, ); const BalanceSheetHistory = Type.Object( @@ -1339,7 +1339,7 @@ const BalanceSheetHistory = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryBalanceSheetHistory", - } + }, ); const CompanyOfficer = Type.Object( @@ -1357,7 +1357,7 @@ const CompanyOfficer = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryCompanyOfficer", - } + }, ); const AssetProfile = Type.Object( @@ -1399,7 +1399,7 @@ const AssetProfile = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryAssetProfile", - } + }, ); export const QuoteSummaryResult = Type.Object( @@ -1435,5 +1435,5 @@ export const QuoteSummaryResult = Type.Object( { additionalProperties: Type.Any(), title: "QuoteSummaryResult", - } + }, ); diff --git a/src/modules/quoteSummary.spec.ts b/src/modules/quoteSummary.spec.ts index b193b83d..8498bb2a 100644 --- a/src/modules/quoteSummary.spec.ts +++ b/src/modules/quoteSummary.spec.ts @@ -53,7 +53,7 @@ describe("quoteSummary", () => { if (process.env.FETCH_DEVEL !== "nocache") it("throws on invalid result", async () => { await expect( - yf.quoteSummary("AAPL", {}, { devel: "weirdJsonResult.fake.json" }) + yf.quoteSummary("AAPL", {}, { devel: "weirdJsonResult.fake.json" }), ).rejects.toThrow(/Unexpected result/); }); }); @@ -168,7 +168,7 @@ describe("quoteSummary", () => { { modules: ["secFilings"], }, - { devel: "quoteSummary-secFilings-AAPL-new.json" } + { devel: "quoteSummary-secFilings-AAPL-new.json" }, ); }); }); @@ -218,7 +218,7 @@ describe("quoteSummary", () => { "summaryProfile", ], }, - { devel: "quoteSummary-other-BMW.DE.json" } + { devel: "quoteSummary-other-BMW.DE.json" }, ); }); }); diff --git a/src/modules/quoteSummary.ts b/src/modules/quoteSummary.ts index dc5292e4..7244e2b8 100644 --- a/src/modules/quoteSummary.ts +++ b/src/modules/quoteSummary.ts @@ -87,7 +87,7 @@ type QuoteSummaryResult = Static; const QuoteSummaryOptions = Type.Object({ formatted: Type.Optional(Type.Boolean()), modules: Type.Optional( - Type.Union([Type.Array(QuoteSummaryModules), Type.Literal("all")]) + Type.Union([Type.Array(QuoteSummaryModules), Type.Literal("all")]), ), }); @@ -100,21 +100,21 @@ export default function quoteSummary( this: ModuleThis, symbol: string, queryOptionsOverrides?: QuoteSummaryOptions, - moduleOptions?: ModuleOptionsWithValidateTrue + moduleOptions?: ModuleOptionsWithValidateTrue, ): Promise; export default function quoteSummary( this: ModuleThis, symbol: string, queryOptionsOverrides?: QuoteSummaryOptions, - moduleOptions?: ModuleOptionsWithValidateFalse + moduleOptions?: ModuleOptionsWithValidateFalse, ): Promise; export default function quoteSummary( this: ModuleThis, symbol: string, queryOptionsOverrides?: QuoteSummaryOptions, - moduleOptions?: ModuleOptions + moduleOptions?: ModuleOptions, ): Promise { return this._moduleExec({ moduleName: "quoteSummary", diff --git a/src/modules/recommendationsBySymbol.spec.ts b/src/modules/recommendationsBySymbol.spec.ts index 631f1004..7c858ca0 100644 --- a/src/modules/recommendationsBySymbol.spec.ts +++ b/src/modules/recommendationsBySymbol.spec.ts @@ -34,7 +34,7 @@ describe("recommendationsBySymbol", () => { const results = await yf.recommendationsBySymbol( ["AAPL", "BMW.DE"], {}, - { devel } + { devel }, ); expect(results.length).toBe(2); expect(results[0].symbol).toBe("AAPL"); @@ -52,7 +52,7 @@ describe("recommendationsBySymbol", () => { it("throws on weird result", () => { const devel = "weirdJsonResult.fake.json"; return expect( - yf.recommendationsBySymbol("AAPL", {}, { devel }) + yf.recommendationsBySymbol("AAPL", {}, { devel }), ).rejects.toThrow(/^Unexpected result/); }); }); diff --git a/src/modules/recommendationsBySymbol.ts b/src/modules/recommendationsBySymbol.ts index a1ba1b98..e1484af4 100644 --- a/src/modules/recommendationsBySymbol.ts +++ b/src/modules/recommendationsBySymbol.ts @@ -17,18 +17,18 @@ const RecommendationsBySymbolResponse = Type.Object( }, { additionalProperties: Type.Any(), - } - ) + }, + ), ), symbol: Type.String(), }, { additionalProperties: Type.Any(), - } + }, ); const RecommendationsBySymbolResponseArray = Type.Array( - RecommendationsBySymbolResponse + RecommendationsBySymbolResponse, ); const RecommendationsBySymbolOptions = Type.Object({}); @@ -51,28 +51,28 @@ export default function recommendationsBySymbol( this: ModuleThis, query: string, queryOptionsOverrides?: RecommendationsBySymbolOptions, - moduleOptions?: ModuleOptionsWithValidateTrue + moduleOptions?: ModuleOptionsWithValidateTrue, ): Promise; export default function recommendationsBySymbol( this: ModuleThis, query: string | string[], queryOptionsOverrides?: RecommendationsBySymbolOptions, - moduleOptions?: ModuleOptionsWithValidateTrue + moduleOptions?: ModuleOptionsWithValidateTrue, ): Promise; export default function recommendationsBySymbol( this: ModuleThis, query: string | string[], queryOptionsOverrides?: RecommendationsBySymbolOptions, - moduleOptions?: ModuleOptionsWithValidateFalse + moduleOptions?: ModuleOptionsWithValidateFalse, ): Promise; export default function recommendationsBySymbol( this: ModuleThis, query: string | string[], queryOptionsOverrides?: RecommendationsBySymbolOptions, - moduleOptions?: ModuleOptions + moduleOptions?: ModuleOptions, ): Promise { const symbols = typeof query === "string" ? query : query.join(","); diff --git a/src/modules/screener.spec.ts b/src/modules/screener.spec.ts index f1e8ead5..aa762448 100644 --- a/src/modules/screener.spec.ts +++ b/src/modules/screener.spec.ts @@ -12,15 +12,15 @@ describe("screener", () => { { scrIds: predefined_screener }, { devel: `screener-${predefined_screener}.json`, - } + }, ); - } + }, ); if (process.env.FETCH_DEVEL !== "nocache") it("throws on weird result", () => { const devel = "weirdJsonResult.fake.json"; return expect( - yf.screener({ scrIds: "aggressive_small_caps" }, { devel }) + yf.screener({ scrIds: "aggressive_small_caps" }, { devel }), ).rejects.toThrow(/^Unexpected result/); }); }); diff --git a/src/modules/screener.ts b/src/modules/screener.ts index 5dad6017..7bfa0c6b 100644 --- a/src/modules/screener.ts +++ b/src/modules/screener.ts @@ -21,7 +21,7 @@ const ScreenerCriterum = Type.Object( }, { title: "ScreenerCriterum", - } + }, ); const ScreenerCriteriaMeta = Type.Object( @@ -36,7 +36,7 @@ const ScreenerCriteriaMeta = Type.Object( }, { title: "ScreenerCriteriaMeta", - } + }, ); const ScreenerQuote = Type.Object( @@ -138,7 +138,7 @@ const ScreenerQuote = Type.Object( }, { title: "ScreenerQuote", - } + }, ); const ScreenerResult = Type.Object( @@ -163,7 +163,7 @@ const ScreenerResult = Type.Object( }, { title: "ScreenerResult", - } + }, ); const PredefinedScreenerModules = Type.Union( @@ -186,7 +186,7 @@ const PredefinedScreenerModules = Type.Union( ], { title: "ScreenerPredefinedScreenerModules", - } + }, ); type ScreenerResult = Static; @@ -210,19 +210,19 @@ const ScreenerOptions = Type.Object({ export default function screener( this: ModuleThis, queryOptionsOverrides?: ScreenerOptions, - moduleOptions?: ModuleOptionsWithValidateTrue + moduleOptions?: ModuleOptionsWithValidateTrue, ): Promise; export default function screener( this: ModuleThis, queryOptionsOverrides?: ScreenerOptions, - moduleOptions?: ModuleOptionsWithValidateFalse + moduleOptions?: ModuleOptionsWithValidateFalse, ): Promise; export default function screener( this: ModuleThis, queryOptionsOverrides?: ScreenerOptions, - moduleOptions?: ModuleOptions + moduleOptions?: ModuleOptions, ): Promise { return this._moduleExec({ moduleName: "screener", diff --git a/src/modules/search.spec.ts b/src/modules/search.spec.ts index b8e1bef8..d20bd47b 100644 --- a/src/modules/search.spec.ts +++ b/src/modules/search.spec.ts @@ -23,6 +23,6 @@ describe("search", () => { async (testSearch) => { const devel = `search-${testSearch}.json`; await yf.search(testSearch, {}, { devel }); - } + }, ); }); diff --git a/src/modules/search.ts b/src/modules/search.ts index 608959e4..804cc6e5 100644 --- a/src/modules/search.ts +++ b/src/modules/search.ts @@ -26,7 +26,7 @@ const SearchQuoteYahoo = Type.Object( }, { additionalProperties: Type.Any(), - } + }, ); const SearchQuoteYahooEquity = Type.Composite( @@ -39,7 +39,7 @@ const SearchQuoteYahooEquity = Type.Composite( ], { title: "SearchQuoteYahooEntity", - } + }, ); const SearchQuoteYahooOption = Type.Composite( @@ -52,7 +52,7 @@ const SearchQuoteYahooOption = Type.Composite( ], { title: "SearchQuoteYahooOption", - } + }, ); const SearchQuoteYahooETF = Type.Composite( @@ -65,7 +65,7 @@ const SearchQuoteYahooETF = Type.Composite( ], { title: "SearchQuoteYahooETF", - } + }, ); const SearchQuoteYahooFund = Type.Composite( @@ -78,7 +78,7 @@ const SearchQuoteYahooFund = Type.Composite( ], { title: "SearchQuoteYahooFund", - } + }, ); const SearchQuoteYahooIndex = Type.Composite( @@ -91,7 +91,7 @@ const SearchQuoteYahooIndex = Type.Composite( ], { title: "SearchQuoteYahooIndex", - } + }, ); const SearchQuoteYahooCurrency = Type.Composite( @@ -104,7 +104,7 @@ const SearchQuoteYahooCurrency = Type.Composite( ], { title: "SearchQuoteYahooCurrency", - } + }, ); const SearchQuoteYahooCryptocurrency = Type.Composite([ @@ -125,7 +125,7 @@ const SearchQuoteYahooFuture = Type.Composite( ], { title: "SearchQuoteYahooFuture", - } + }, ); const SearchQuoteNonYahoo = Type.Object( @@ -138,7 +138,7 @@ const SearchQuoteNonYahoo = Type.Object( { additionalProperties: Type.Any(), title: "SearchQuoteNonYahoo", - } + }, ); const SearchNewsThumbnailResolution = Type.Object( @@ -150,7 +150,7 @@ const SearchNewsThumbnailResolution = Type.Object( }, { title: "SearchNewsThumbnailResolution", - } + }, ); const SearchNews = Type.Object( @@ -164,14 +164,14 @@ const SearchNews = Type.Object( thumbnail: Type.Optional( Type.Object({ resolutions: Type.Array(SearchNewsThumbnailResolution), - }) + }), ), relatedTickers: Type.Optional(Type.Array(Type.String())), // [ "AAPL" ] }, { additionalProperties: Type.Any(), title: "SearchNews", - } + }, ); type SearchResult = Static; @@ -190,7 +190,7 @@ const SearchResultSchema = Type.Object( SearchQuoteYahooCryptocurrency, SearchQuoteNonYahoo, SearchQuoteYahooFuture, - ]) + ]), ), news: Type.Array(SearchNews), nav: Type.Array(Type.Any()), @@ -224,7 +224,7 @@ const SearchResultSchema = Type.Object( { additionalProperties: Type.Any(), title: "SearchResults", - } + }, ); const SearchOptionsSchema = Type.Object( @@ -244,7 +244,7 @@ const SearchOptionsSchema = Type.Object( { title: "SearchOptions", additionalProperties: false, - } + }, ); type SearchOptions = Static; @@ -267,21 +267,21 @@ export default function search( this: ModuleThis, query: string, queryOptionsOverrides?: SearchOptions, - moduleOptions?: ModuleOptionsWithValidateTrue + moduleOptions?: ModuleOptionsWithValidateTrue, ): Promise; export default function search( this: ModuleThis, query: string, queryOptionsOverrides?: SearchOptions, - moduleOptions?: ModuleOptionsWithValidateFalse + moduleOptions?: ModuleOptionsWithValidateFalse, ): Promise; export default function search( this: ModuleThis, query: string, queryOptionsOverrides?: SearchOptions, - moduleOptions?: ModuleOptions + moduleOptions?: ModuleOptions, ): Promise { return this._moduleExec({ moduleName: "searchTypebox", diff --git a/src/modules/trendingSymbols.spec.ts b/src/modules/trendingSymbols.spec.ts index c6e97aa1..53917310 100644 --- a/src/modules/trendingSymbols.spec.ts +++ b/src/modules/trendingSymbols.spec.ts @@ -10,13 +10,13 @@ describe("trendingSymbols", () => { await yf.trendingSymbols(country, undefined, { devel: `trendingSymbols-${country}.json`, }); - } + }, ); if (process.env.FETCH_DEVEL !== "nocache") it("throws on weird result", () => { const devel = "weirdJsonResult.fake.json"; return expect(yf.trendingSymbols("GB", {}, { devel })).rejects.toThrow( - /^Unexpected result/ + /^Unexpected result/, ); }); }); diff --git a/src/modules/trendingSymbols.ts b/src/modules/trendingSymbols.ts index ca24a814..7ad3d8b7 100644 --- a/src/modules/trendingSymbols.ts +++ b/src/modules/trendingSymbols.ts @@ -13,7 +13,7 @@ const TrendingSymbol = Type.Object( }, { additionalProperties: Type.Any(), - } + }, ); const TrendingSymbolsResult = Type.Object( @@ -26,7 +26,7 @@ const TrendingSymbolsResult = Type.Object( { additionalProperties: Type.Any(), title: "TrendingSymbolsResult", - } + }, ); const TrendingSymbolsOptions = Type.Optional( @@ -38,8 +38,8 @@ const TrendingSymbolsOptions = Type.Optional( }, { title: "TrendingSymbolsOptions", - } - ) + }, + ), ); type TrendingSymbolsResult = Static; @@ -54,21 +54,21 @@ export default function trendingSymbols( this: ModuleThis, query: string, queryOptionsOverrides?: TrendingSymbolsOptions, - moduleOptions?: ModuleOptionsWithValidateTrue + moduleOptions?: ModuleOptionsWithValidateTrue, ): Promise; export default function trendingSymbols( this: ModuleThis, query: string, queryOptionsOverrides?: TrendingSymbolsOptions, - moduleOptions?: ModuleOptionsWithValidateFalse + moduleOptions?: ModuleOptionsWithValidateFalse, ): Promise; export default function trendingSymbols( this: ModuleThis, query: string, queryOptionsOverrides?: TrendingSymbolsOptions, - moduleOptions?: ModuleOptions + moduleOptions?: ModuleOptions, ): Promise { return this._moduleExec({ moduleName: "trendingSymbols", diff --git a/src/other/quoteCombine.ts b/src/other/quoteCombine.ts index 2096dd06..49dad291 100644 --- a/src/other/quoteCombine.ts +++ b/src/other/quoteCombine.ts @@ -17,28 +17,28 @@ export default function quoteCombine( this: ModuleThis, query: string, queryOptionsOverrides?: QuoteOptions, - moduleOptions?: ModuleOptionsWithValidateTrue + moduleOptions?: ModuleOptionsWithValidateTrue, ): Promise; export default function quoteCombine( this: ModuleThis, query: string, queryOptionsOverrides?: QuoteOptions, - moduleOptions?: ModuleOptionsWithValidateFalse + moduleOptions?: ModuleOptionsWithValidateFalse, ): Promise; export default function quoteCombine( this: ModuleThis, query: string, queryOptionsOverrides: QuoteOptions = {}, - moduleOptions?: ModuleOptions + moduleOptions?: ModuleOptions, ): Promise { const symbol = query; if (typeof symbol !== "string") throw new Error( "quoteCombine expects a string query parameter, received: " + - JSON.stringify(symbol, null, 2) + JSON.stringify(symbol, null, 2), ); validateAndCoerceTypebox({ diff --git a/tests/testSymbols.ts b/tests/testSymbols.ts index 0c83adac..4b9fc19f 100644 --- a/tests/testSymbols.ts +++ b/tests/testSymbols.ts @@ -46,7 +46,7 @@ export default function testSymbols(options?: testSymbolsOptions) { (options.skip.length && typeof options.skip[0] !== "string") ) throw new Error( - "createTestSymbols 'skip' option should be an array of strings" + "createTestSymbols 'skip' option should be an array of strings", ); symbols = symbols.filter((symbol) => !options.skip!.includes(symbol)); } @@ -57,7 +57,7 @@ export default function testSymbols(options?: testSymbolsOptions) { (options.add.length && typeof options.add[0] !== "string") ) throw new Error( - "createTestSymbols 'skip' option should be an array of strings" + "createTestSymbols 'skip' option should be an array of strings", ); symbols = symbols.concat(options.add); } diff --git a/yarn.lock b/yarn.lock index 0f039811..57f16dd1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2824,10 +2824,10 @@ escape-string-regexp@^4.0.0: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== -eslint-config-prettier@8.10.0: - version "8.10.0" - resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.10.0.tgz#3a06a662130807e2502fc3ff8b4143d8a0658e11" - integrity sha512-SM8AMJdeQqRYT9O9zguiruQZaN7+z+E4eAP9oiLNGKMtomwaB1E9dcgUD6ZAn/eQAb52USbvezbiljfZUhbJcg== +eslint-config-prettier@^9.1.0: + version "9.1.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz#31af3d94578645966c082fcb71a5846d3c94867f" + integrity sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw== eslint-scope@^5.1.1: version "5.1.1" @@ -5434,10 +5434,10 @@ prelude-ls@^1.2.1: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== -prettier@2.8.8: - version "2.8.8" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" - integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== +prettier@^3.3.3: + version "3.3.3" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.3.3.tgz#30c54fe0be0d8d12e6ae61dbb10109ea00d53105" + integrity sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew== pretty-format@^24.9.0: version "24.9.0"