From 82026e22668a283e0590d9ceceda63b62ad6146b Mon Sep 17 00:00:00 2001 From: Carter McBride <18412686+carterworks@users.noreply.github.com> Date: Tue, 18 Jun 2024 21:36:13 -0600 Subject: [PATCH] Combine lint and format commands --- eslint.config.js | 2 +- package.json | 3 +- src/index.ts | 88 ++++++++++++++++++++++++------------------------ src/utilities.ts | 2 +- 4 files changed, 47 insertions(+), 48 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 871a05a..48120ba 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,5 +1,5 @@ -import globals from "globals"; import pluginJs from "@eslint/js"; +import globals from "globals"; import tseslint from "typescript-eslint"; export default [ diff --git a/package.json b/package.json index de10632..7e69f99 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,7 @@ "scripts": { "clean": "rm -rf dist", "build": "bun src/index.js", - "lint": "biome lint --write ./src", - "format": "biome format --write ./src ./eslint.config.js" + "check": "biome check --write ./src ./eslint.config.js" }, "author": { "name": "George Mandis", diff --git a/src/index.ts b/src/index.ts index 60e7338..4bf6f82 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,21 +10,21 @@ * Licensed under the MIT License (http://opensource.org/licenses/MIT) */ -import fetch from "node-fetch"; -import Parser from "rss-parser"; -import type { Feeds, FeedItem } from "./@types/bubo"; -import type { Response } from "node-fetch"; -import { render } from "./renderer.js"; -import { - getLink, - getTitle, - getTimestamp, - parseFeed, - getFeedList, - getBuboInfo, -} from "./utilities.js"; import { writeFile } from "node:fs/promises"; import chalk from "chalk"; +import fetch from "node-fetch"; +import type { Response } from "node-fetch"; +import Parser from "rss-parser"; +import type { FeedItem, Feeds } from "./@types/bubo"; +import { render } from "./renderer.js"; +import { + getBuboInfo, + getFeedList, + getLink, + getTimestamp, + getTitle, + parseFeed, +} from "./utilities.js"; const buboInfo = await getBuboInfo(); const parser = new Parser(); @@ -105,42 +105,42 @@ const processFeed = feed: string; startTime: number; }) => - async (response: Response): Promise => { - const body = await parseFeed(response); - //skip to the next one if this didn't work out - if (!body) return; + async (response: Response): Promise => { + const body = await parseFeed(response); + //skip to the next one if this didn't work out + if (!body) return; - try { - const contents: FeedItem = ( - typeof body === "string" ? await parser.parseString(body) : body - ) as FeedItem; + try { + const contents: FeedItem = ( + typeof body === "string" ? await parser.parseString(body) : body + ) as FeedItem; - contents.feed = feed; - contents.title = getTitle(contents); - contents.link = getLink(contents); + contents.feed = feed; + contents.title = getTitle(contents); + contents.link = getLink(contents); - // try to normalize date attribute naming - for (const item of contents.items) { - item.timestamp = getTimestamp(item); - item.title = getTitle(item); - item.link = getLink(item); - } - - contentFromAllFeeds[group].push(contents as object); - process.stdout.write( - `${success("Successfully fetched:")} ${feed} - ${benchmark(startTime)}\n`, - ); - } catch (err) { - process.stdout.write( - `${error("Error processing:")} ${feed} - ${benchmark( - startTime, - )}\n${err}\n`, - ); - errors.push(`Error processing: ${feed}\n\t${err}`); + // try to normalize date attribute naming + for (const item of contents.items) { + item.timestamp = getTimestamp(item); + item.title = getTitle(item); + item.link = getLink(item); } - finishBuild(); - }; + contentFromAllFeeds[group].push(contents as object); + process.stdout.write( + `${success("Successfully fetched:")} ${feed} - ${benchmark(startTime)}\n`, + ); + } catch (err) { + process.stdout.write( + `${error("Error processing:")} ${feed} - ${benchmark( + startTime, + )}\n${err}\n`, + ); + errors.push(`Error processing: ${feed}\n\t${err}`); + } + + finishBuild(); + }; // go through each group of feeds and process const processFeeds = () => { diff --git a/src/utilities.ts b/src/utilities.ts index 9a881cd..ee10b73 100644 --- a/src/utilities.ts +++ b/src/utilities.ts @@ -6,8 +6,8 @@ Note: these are tightly-coupled to the template and a personal preference. */ -import type { Response } from "node-fetch"; import { readFile } from "node:fs/promises"; +import type { Response } from "node-fetch"; import type { FeedItem, JSONValue } from "./@types/bubo"; export const getLink = (obj: FeedItem): string => {