Combine lint and format commands
This commit is contained in:
parent
7f0af2c0c1
commit
82026e2266
4 changed files with 47 additions and 48 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import globals from "globals";
|
|
||||||
import pluginJs from "@eslint/js";
|
import pluginJs from "@eslint/js";
|
||||||
|
import globals from "globals";
|
||||||
import tseslint from "typescript-eslint";
|
import tseslint from "typescript-eslint";
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,7 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"clean": "rm -rf dist",
|
"clean": "rm -rf dist",
|
||||||
"build": "bun src/index.js",
|
"build": "bun src/index.js",
|
||||||
"lint": "biome lint --write ./src",
|
"check": "biome check --write ./src ./eslint.config.js"
|
||||||
"format": "biome format --write ./src ./eslint.config.js"
|
|
||||||
},
|
},
|
||||||
"author": {
|
"author": {
|
||||||
"name": "George Mandis",
|
"name": "George Mandis",
|
||||||
|
|
|
||||||
88
src/index.ts
88
src/index.ts
|
|
@ -10,21 +10,21 @@
|
||||||
* Licensed under the MIT License (http://opensource.org/licenses/MIT)
|
* 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 { writeFile } from "node:fs/promises";
|
||||||
import chalk from "chalk";
|
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 buboInfo = await getBuboInfo();
|
||||||
const parser = new Parser();
|
const parser = new Parser();
|
||||||
|
|
@ -105,42 +105,42 @@ const processFeed =
|
||||||
feed: string;
|
feed: string;
|
||||||
startTime: number;
|
startTime: number;
|
||||||
}) =>
|
}) =>
|
||||||
async (response: Response): Promise<void> => {
|
async (response: Response): Promise<void> => {
|
||||||
const body = await parseFeed(response);
|
const body = await parseFeed(response);
|
||||||
//skip to the next one if this didn't work out
|
//skip to the next one if this didn't work out
|
||||||
if (!body) return;
|
if (!body) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const contents: FeedItem = (
|
const contents: FeedItem = (
|
||||||
typeof body === "string" ? await parser.parseString(body) : body
|
typeof body === "string" ? await parser.parseString(body) : body
|
||||||
) as FeedItem;
|
) as FeedItem;
|
||||||
|
|
||||||
contents.feed = feed;
|
contents.feed = feed;
|
||||||
contents.title = getTitle(contents);
|
contents.title = getTitle(contents);
|
||||||
contents.link = getLink(contents);
|
contents.link = getLink(contents);
|
||||||
|
|
||||||
// try to normalize date attribute naming
|
// try to normalize date attribute naming
|
||||||
for (const item of contents.items) {
|
for (const item of contents.items) {
|
||||||
item.timestamp = getTimestamp(item);
|
item.timestamp = getTimestamp(item);
|
||||||
item.title = getTitle(item);
|
item.title = getTitle(item);
|
||||||
item.link = getLink(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}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
// go through each group of feeds and process
|
||||||
const processFeeds = () => {
|
const processFeeds = () => {
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@
|
||||||
Note: these are tightly-coupled to the template and a personal preference.
|
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 { readFile } from "node:fs/promises";
|
||||||
|
import type { Response } from "node-fetch";
|
||||||
import type { FeedItem, JSONValue } from "./@types/bubo";
|
import type { FeedItem, JSONValue } from "./@types/bubo";
|
||||||
|
|
||||||
export const getLink = (obj: FeedItem): string => {
|
export const getLink = (obj: FeedItem): string => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue