Skip to content

Commit

Permalink
Fix biome config
Browse files Browse the repository at this point in the history
  • Loading branch information
prevostc committed Jun 21, 2024
1 parent c48ff02 commit 278db6f
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 75 deletions.
83 changes: 51 additions & 32 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,53 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.2/schema.json",
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 100,
"attributePosition": "auto",
"ignore": [
"./.husky",
"./build",
"./node_modules",
"src/queries/codegen/sdk.ts",
"src/queries/codegen/schema.graphql"
]
},
"organizeImports": { "enabled": true },
"linter": { "enabled": true, "rules": { "recommended": true } },
"javascript": {
"formatter": {
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingCommas": "es5",
"semicolons": "always",
"arrowParentheses": "asNeeded",
"bracketSpacing": true,
"bracketSameLine": false,
"quoteStyle": "single",
"attributePosition": "auto"
}
}
"$schema": "https://biomejs.dev/schemas/1.8.2/schema.json",
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 100,
"attributePosition": "auto",
"ignore": [
"./.husky/**",
"./build/**",
"./node_modules/**",
"src/queries/codegen/sdk.ts",
"src/queries/codegen/schema.graphql"
]
},
"organizeImports": {
"enabled": true,
"ignore": [
"./.husky/**",
"./build/**",
"./node_modules/**",
"src/queries/codegen/sdk.ts",
"src/queries/codegen/schema.graphql"
]
},
"linter": {
"enabled": true,
"ignore": [
"./.husky/**",
"./build/**",
"./node_modules/**",
"src/queries/codegen/sdk.ts",
"src/queries/codegen/schema.graphql"
],
"rules": { "recommended": true }
},
"javascript": {
"formatter": {
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingCommas": "es5",
"semicolons": "always",
"arrowParentheses": "asNeeded",
"bracketSpacing": true,
"bracketSameLine": false,
"quoteStyle": "single",
"attributePosition": "auto"
}
}
}
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test": "npm run test:ts && npm run test:unit && npm run test:lint",
"test:unit": "jest",
"test:ts": "tsc --noEmit",
"test:lint": "npm run prettier:check",
"test:lint": "biome ci",
"package:check": "ncu",
"package:fix": "ncu -u && npm install",
"postinstall": "npm --silent run codegen",
Expand Down
24 changes: 12 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import Fastify from 'fastify';
import FastifyCors from '@fastify/cors';
import FastifyEtag from '@fastify/etag';
import FastifyHelmet from '@fastify/helmet';
import FastifyRateLimit from '@fastify/rate-limit';
import FastifyUnderPressure from '@fastify/under-pressure';
import FastifyEtag from '@fastify/etag';
import FastifyCors from '@fastify/cors';
import { defaultLogger } from './utils/log';
import routes from './routes/index';
import { API_CORS_ORIGIN, API_ENV, API_PORT, API_RATE_LIMIT } from './config/env';
import { FriendlyError } from './utils/error';
import Decimal from 'decimal.js';
import Fastify from 'fastify';
import { API_CORS_ORIGIN, API_ENV, API_PORT, API_RATE_LIMIT } from './config/env';
import routes from './routes/index';
import { allowedToBypassRateLimit } from './utils/auth';
import { FriendlyError } from './utils/error';
import { defaultLogger } from './utils/log';

Decimal.set({
// make sure we have enough precision
Expand All @@ -35,7 +35,7 @@ server.register(async (instance, _opts, done) => {
continueExceeding: true,
skipOnError: false,
enableDraftSpec: true,
allowList: request => allowedToBypassRateLimit(request.headers['authorization']),
allowList: request => allowedToBypassRateLimit(request.headers.authorization),
errorResponseBuilder: (_request, context) => ({
statusCode: 429,
name: 'RateLimitExceededError',
Expand All @@ -48,11 +48,11 @@ server.register(async (instance, _opts, done) => {
methods: ['GET'],
origin: API_ENV === 'production' ? API_CORS_ORIGIN : true,
})
.setReplySerializer(function (payload) {
return JSON.stringify(payload, (_key, value) =>
.setReplySerializer(payload =>
JSON.stringify(payload, (_key, value) =>
typeof value === 'bigint' ? value.toString() : value
);
})
)
)
.addHook('onSend', async (_req, reply) => {
if (reply.raw.statusCode !== 200) {
reply.header('cache-control', 'no-cache, no-store, must-revalidate');
Expand Down
2 changes: 1 addition & 1 deletion src/routes/v1/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { FastifyInstance, FastifyPluginOptions } from 'fastify';
import status from './status';
import investor from './investor';
import status from './status';
import vault from './vault';
import vaults from './vaults';

Expand Down
6 changes: 3 additions & 3 deletions src/routes/v1/investor.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { FastifyInstance, FastifyPluginOptions, FastifySchema } from 'fastify';
import type { FastifyInstance, FastifyPluginOptions, FastifySchema } from 'fastify';
import S from 'fluent-json-schema';
import { addressSchema } from '../../schema/address';
import { getAsyncCache } from '../../utils/async-lock';

import type { Address } from '../../utils/scalar-types';
import { getClmTimeline } from '../../utils/timeline';
import { TimelineClmInteraction } from '../../utils/timeline-types';
import { Address } from '../../utils/scalar-types';
import type { TimelineClmInteraction } from '../../utils/timeline-types';

export default async function (
instance: FastifyInstance,
Expand Down
8 changes: 4 additions & 4 deletions src/routes/v1/status.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { FastifyInstance, FastifyPluginOptions, FastifySchema } from 'fastify';
import type { FastifyInstance, FastifyPluginOptions, FastifySchema } from 'fastify';
import S from 'fluent-json-schema';
import type { ChainId } from '../../config/chains';
import { getAsyncCache } from '../../utils/async-lock';
import { getAllSdks, SdkContext } from '../../utils/sdk';
import { ChainId } from '../../config/chains';
import { type SdkContext, getAllSdks } from '../../utils/sdk';

export default async function (
instance: FastifyInstance,
Expand All @@ -23,7 +23,7 @@ export default async function (
};

instance.get('/', { schema }, async (_, reply) => {
const res = await asyncCache.wrap(`status`, 60 * 1000, async () => {
const res = await asyncCache.wrap('status', 60 * 1000, async () => {
return await getStatus();
});
reply.send(res);
Expand Down
22 changes: 11 additions & 11 deletions src/routes/v1/vault.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { FastifyInstance, FastifyPluginOptions, FastifySchema } from 'fastify';
import type { FastifyInstance, FastifyPluginOptions, FastifySchema } from 'fastify';
import S from 'fluent-json-schema';
import { ChainId } from '../../config/chains';
import type { ChainId } from '../../config/chains';
import type { HarvestDataFragment, Token } from '../../queries/codegen/sdk';
import { addressSchema } from '../../schema/address';
import { getSdksForChain, paginateSdkCalls } from '../../utils/sdk';
import { getPeriodSeconds, Period, periodSchema } from '../../schema/period';
import { chainSchema } from '../../schema/chain';
import { bigintSchema } from '../../schema/bigint';
import { interpretAsDecimal } from '../../utils/decimal';
import { chainSchema } from '../../schema/chain';
import { type Period, getPeriodSeconds, periodSchema } from '../../schema/period';
import { getAsyncCache } from '../../utils/async-lock';
import { HarvestDataFragment, Token } from '../../queries/codegen/sdk';
import { Address } from '../../utils/scalar-types';
import { interpretAsDecimal } from '../../utils/decimal';
import type { Address } from '../../utils/scalar-types';
import { getSdksForChain, paginateSdkCalls } from '../../utils/sdk';

export default async function (
instance: FastifyInstance,
Expand Down Expand Up @@ -345,7 +345,7 @@ const getVaultHistoricPrices = async (
const token1 = vault.underlyingToken1;

return vault.snapshots.map(snapshot => ({
t: parseInt(snapshot.roundedTimestamp),
t: Number.parseInt(snapshot.roundedTimestamp),
min: interpretAsDecimal(snapshot.priceRangeMin1, token1.decimals),
v: interpretAsDecimal(snapshot.priceOfToken0InToken1, token1.decimals),
max: interpretAsDecimal(snapshot.priceRangeMax1, token1.decimals),
Expand All @@ -372,8 +372,8 @@ const getVaultHistoricPricesRange = async (
}

return {
min: parseInt(vault.minSnapshot?.[0]?.roundedTimestamp || '0'),
max: parseInt(vault.maxSnapshot?.[0]?.roundedTimestamp || '0'),
min: Number.parseInt(vault.minSnapshot?.[0]?.roundedTimestamp || '0'),
max: Number.parseInt(vault.maxSnapshot?.[0]?.roundedTimestamp || '0'),
};
};

Expand Down
20 changes: 10 additions & 10 deletions src/routes/v1/vaults.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { FastifyInstance, FastifyPluginOptions, FastifySchema } from 'fastify';
import type { FastifyInstance, FastifyPluginOptions, FastifySchema } from 'fastify';
import S from 'fluent-json-schema';
import { ChainId } from '../../config/chains';
import { getSdksForChain, paginateSdkCalls } from '../../utils/sdk';
import { max, sortedUniq } from 'lodash';
import type { ChainId } from '../../config/chains';
import type { VaultsQuery } from '../../queries/codegen/sdk';
import { addressSchema } from '../../schema/address';
import { chainSchema } from '../../schema/chain';
import { getPeriodSeconds, Period, periodSchema } from '../../schema/period';
import { type Period, getPeriodSeconds, periodSchema } from '../../schema/period';
import { calculateLastApr, prepareAprState } from '../../utils/apr';
import { interpretAsDecimal } from '../../utils/decimal';
import { PreparedVaultHarvest, prepareVaultHarvests } from './vault';
import { addressSchema } from '../../schema/address';
import { getAsyncCache } from '../../utils/async-lock';
import { VaultsQuery } from '../../queries/codegen/sdk';
import { max, sortedUniq } from 'lodash';
import { Address } from '../../utils/scalar-types';
import { fromUnixTime, getUnixTime } from '../../utils/date';
import { interpretAsDecimal } from '../../utils/decimal';
import type { Address } from '../../utils/scalar-types';
import { getSdksForChain, paginateSdkCalls } from '../../utils/sdk';
import { type PreparedVaultHarvest, prepareVaultHarvests } from './vault';

export default async function (
instance: FastifyInstance,
Expand Down

0 comments on commit 278db6f

Please sign in to comment.