Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migrate to biomejs from prettier #4184

Merged
merged 20 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions .deepsource.toml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ jobs:
- name: Lint 🪩
run: pnpm lint:affected

- name: Prettier
run: pnpm prettier:affected
- name: Biome
run: pnpm biome:affected

- name: Build 🎁
run: pnpm build
Expand Down
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
. "$(dirname "$0")/_/husky.sh"

pnpm lint:affected
pnpm biome:affected
pnpm typecheck:affected
2 changes: 0 additions & 2 deletions .prettierignore

This file was deleted.

2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"recommendations": [
"esbenp.prettier-vscode",
"biomejs.biome",
"formulahendry.auto-close-tag",
"mikestead.dotenv",
"dbaeumer.vscode-eslint",
Expand Down
9 changes: 8 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
{
"editor.tabSize": 2
"editor.tabSize": 2,
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"quickfix.biome": "always"
}
}
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
<a href="https://vercel.com/heyxyz?utm_source=Hey&utm_campaign=oss">
<img src="https://therealsujitk-vercel-badge.vercel.app/?app=heyxyz" alt="Vercel">
</a>
<a href="https://deepsource.io/gh/heyxyz/hey">
<img src="https://deepsource.io/gh/heyxyz/hey.svg/?label=active+issues&show_trend=true" alt="GitHub actions">
</a>
<a href="https://www.gitpoap.io/gh/lensterxyz">
<img src="https://public-api.gitpoap.io/v1/repo/lensterxyz/hey/badge" alt="Gitpoap">
</a>
Expand Down
2 changes: 0 additions & 2 deletions apps/api/.prettierignore

This file was deleted.

4 changes: 2 additions & 2 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"postinstall": "pnpm codegen",
"lint": "eslint . --ext .js,.ts,.tsx",
"lint:fix": "eslint . --fix --ext .js,.ts,.tsx",
"prettier": "prettier --check \"**/*.{js,ts,tsx,md}\" --cache",
"prettier:fix": "prettier --write \"**/*.{js,ts,tsx,md}\" --cache",
"biome": "biome check *",
"biome:fix": "biome check * --apply",
"prisma:format": "prisma format --schema ./src/db/schema.prisma",
"prisma:migrate": "prisma migrate dev --schema ./src/db/schema.prisma",
"prisma:studio": "prisma studio --schema ./src/db/schema.prisma",
Expand Down
6 changes: 4 additions & 2 deletions apps/api/src/routes/feed/getPublicationIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ export const get: Handler = async (req, res) => {
try {
let ids: string[] = [];
switch (provider) {
case AlgorithmProvider.K3L:
case AlgorithmProvider.K3L: {
ids = await k3lFeed(strategy, profile, limit, offset);
break;
case AlgorithmProvider.HEY:
}
case AlgorithmProvider.HEY: {
ids = await heyFeed(strategy, limit, offset);
break;
}
default:
return res
.status(200)
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/group/featured.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import catchedError from '@utils/catchedError';
import { SWR_CACHE_AGE_10_MINS_30_DAYS } from '@utils/constants';
import prisma from '@utils/prisma';

export const get: Handler = async (_req, res) => {
export const get: Handler = async (_, res) => {
try {
const data = await prisma.group.findMany({
orderBy: { createdAt: 'desc' },
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/health.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Handler } from 'express';
import createClickhouseClient from '@utils/createClickhouseClient';
import prisma from '@utils/prisma';

export const get: Handler = async (req, res) => {
export const get: Handler = async (_, res) => {
try {
// Postgres
const db = await prisma.feature.count();
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/routes/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Handler } from 'express';

export const get: Handler = async (_req, res) => {
res.json({ message: 'Hey API ✨' });
export const get: Handler = (_, res) => {
return res.json({ message: 'Hey API ✨' });
};
2 changes: 1 addition & 1 deletion apps/api/src/routes/misc/getVerified.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import catchedError from '@utils/catchedError';
import { SWR_CACHE_AGE_10_MINS_30_DAYS } from '@utils/constants';
import prisma from '@utils/prisma';

export const get: Handler = async (_req, res) => {
export const get: Handler = async (_, res) => {
try {
const data = await prisma.verified.findMany({
select: { id: true }
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/staff-pick/getStaffPicks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import catchedError from '@utils/catchedError';
import { SWR_CACHE_AGE_10_MINS_30_DAYS } from '@utils/constants';
import prisma from '@utils/prisma';

export const get: Handler = async (req, res) => {
export const get: Handler = async (_, res) => {
try {
const data = await prisma.staffPick.findMany({
orderBy: { score: 'desc' },
Expand Down
25 changes: 13 additions & 12 deletions apps/api/src/routes/stats/profileDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,19 @@ export const get: Handler = async (req, res) => {
`
});

const result = await rows.json<
Array<{
actor: string;
most_common_browser: string;
most_common_browser_version: string;
most_common_city: string;
most_common_country: string;
most_common_os: string;
most_common_region: string;
number_of_events: string;
}>
>();
const result =
await rows.json<
Array<{
actor: string;
most_common_browser: string;
most_common_browser_version: string;
most_common_city: string;
most_common_country: string;
most_common_os: string;
most_common_region: string;
number_of_events: string;
}>
>();
logger.info(`Profile details fetched for ${id}`);

return res
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/sts/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const params = {
}`
};

export const get: Handler = async (req, res) => {
export const get: Handler = async (_, res) => {
try {
const accessKeyId = process.env.EVER_ACCESS_KEY as string;
const secretAccessKey = process.env.EVER_ACCESS_SECRET as string;
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/token/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import catchedError from '@utils/catchedError';
import { SWR_CACHE_AGE_1_MIN_30_DAYS } from '@utils/constants';
import prisma from '@utils/prisma';

export const get: Handler = async (req, res) => {
export const get: Handler = async (_, res) => {
try {
const data = await prisma.allowedToken.findMany({
orderBy: { createdAt: 'desc' }
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/utils/feeds/providers/k3l/k3lFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const k3lFeed = async (
return await k3lPersonalFeed(strategy, profile, limit, offset);
}

logger.info(`[K3L] Global feed`);
logger.info('[K3L] Global feed');
return await k3lGlobalFeed(strategy, limit, offset);
};

Expand Down
15 changes: 10 additions & 5 deletions apps/api/src/utils/oembed/meta/generateIframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,21 @@ const generateIframe = (

switch (hostname) {
case 'youtube.com':
case 'youtu.be':
case 'youtu.be': {
if (youtubeRegex.test(url)) {
return `<iframe src="${pickedUrl}" ${universalSize} allow="accelerometer; encrypted-media" allowfullscreen></iframe>`;
}

return null;
case 'tape.xyz':
}
case 'tape.xyz': {
if (tapeRegex.test(url)) {
return `<iframe src="${pickedUrl}" ${universalSize} allow="accelerometer; encrypted-media" allowfullscreen></iframe>`;
}

return null;
case 'open.spotify.com':
}
case 'open.spotify.com': {
const spotifySize = `style="max-width: 560px;" width="100%"`;
if (spotifyTrackUrlRegex.test(url)) {
const spotifyUrl = pickedUrl.replace('/track', '/embed/track');
Expand All @@ -62,18 +64,21 @@ const generateIframe = (
}

return null;
case 'soundcloud.com':
}
case 'soundcloud.com': {
if (soundCloudRegex.test(url)) {
return `<iframe src="${pickedUrl}" ${universalSize}></iframe>`;
}

return null;
case 'oohlala.xyz':
}
case 'oohlala.xyz': {
if (oohlalaUrlRegex.test(url)) {
return `<iframe src="${pickedUrl}" ${universalSize}></iframe>`;
}

return null;
}
default:
return `<iframe src="${pickedUrl}" width="560"></iframe>`;
}
Expand Down
8 changes: 6 additions & 2 deletions apps/api/src/utils/oembed/meta/getDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ const getDescription = (document: Document): null | string => {

if (lens) {
return lens.getAttribute('content');
} else if (og) {
}

if (og) {
return og.getAttribute('content');
} else if (twitter) {
}

if (twitter) {
return twitter.getAttribute('content');
}

Expand Down
8 changes: 6 additions & 2 deletions apps/api/src/utils/oembed/meta/getEmbedUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ const getEmbedUrl = (document: Document): null | string => {

if (lens) {
return lens.getAttribute('content');
} else if (og) {
}

if (og) {
return og.getAttribute('content');
} else if (twitter) {
}

if (twitter) {
return twitter.getAttribute('content');
}

Expand Down
8 changes: 6 additions & 2 deletions apps/api/src/utils/oembed/meta/getImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ const getImage = (document: Document): null | string => {

if (lens) {
return lens.getAttribute('content');
} else if (og) {
}

if (og) {
return og.getAttribute('content');
} else if (twitter) {
}

if (twitter) {
return twitter.getAttribute('content');
}

Expand Down
4 changes: 3 additions & 1 deletion apps/api/src/utils/oembed/meta/getIsLarge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ const getIsLarge = (document: Document): boolean | null => {
if (lens) {
const card = lens.getAttribute('content') || '';
return largeTypes.includes(card);
} else if (twitter) {
}

if (twitter) {
const card = twitter.getAttribute('content') || '';
return largeTypes.includes(card);
}
Expand Down
8 changes: 6 additions & 2 deletions apps/api/src/utils/oembed/meta/getSite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ const getSite = (document: Document): null | string => {

if (lens) {
return lens.getAttribute('content');
} else if (og) {
}

if (og) {
return og.getAttribute('content');
} else if (twitter) {
}

if (twitter) {
return twitter.getAttribute('content');
}

Expand Down
8 changes: 6 additions & 2 deletions apps/api/src/utils/oembed/meta/getTitle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ const getTitle = (document: Document): null | string => {

if (lens) {
return lens.getAttribute('content');
} else if (og) {
}

if (og) {
return og.getAttribute('content');
} else if (twitter) {
}

if (twitter) {
return twitter.getAttribute('content');
}

Expand Down
6 changes: 3 additions & 3 deletions apps/api/src/utils/stats/generateDateRangeDict.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const generateDateRangeDict = (): { [key: string]: number } => {
let date = new Date();
const date = new Date();
date.setFullYear(date.getFullYear() - 1);

let dates: { [key: string]: number } = {};
const dates: { [key: string]: number } = {};
while (date < new Date()) {
let dateString = date.toISOString().split('T')[0];
const dateString = date.toISOString().split('T')[0];
dates[dateString] = 0;
date.setDate(date.getDate() + 1);
}
Expand Down
4 changes: 0 additions & 4 deletions apps/web/.prettierignore

This file was deleted.

4 changes: 2 additions & 2 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"dev": "next dev --port 4783",
"lint": "eslint . --ext .ts,.tsx",
"lint:fix": "eslint . --fix --ext .ts,.tsx",
"prettier": "prettier --check \"**/*.{js,ts,tsx,md}\" --cache",
"prettier:fix": "prettier --write \"**/*.{js,ts,tsx,md}\" --cache",
"biome": "biome check *",
"biome:fix": "biome check * --apply",
"start": "next start --port 4783",
"typecheck": "tsc --pretty"
},
Expand Down
Loading
Loading