chore(root): migrate to biome
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
export * from './src/crypto';
|
||||
export * from './src/profileId';
|
||||
export * from './src/date';
|
||||
export * from './src/object';
|
||||
export * from './src/names';
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
"version": "0.0.1",
|
||||
"main": "index.ts",
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"format": "prettier --check \"**/*.{mjs,ts,md,json}\"",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -18,22 +16,11 @@
|
||||
"unique-names-generator": "^4.7.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@openpanel/eslint-config": "workspace:*",
|
||||
"@openpanel/prettier-config": "workspace:*",
|
||||
"@openpanel/tsconfig": "workspace:*",
|
||||
"@openpanel/validation": "workspace:*",
|
||||
"@types/node": "^18.16.0",
|
||||
"@types/ramda": "^0.29.6",
|
||||
"eslint": "^8.48.0",
|
||||
"prettier": "^3.0.3",
|
||||
"prisma": "^5.1.1",
|
||||
"typescript": "^5.2.2"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true,
|
||||
"extends": [
|
||||
"@openpanel/eslint-config/base"
|
||||
]
|
||||
},
|
||||
"prettier": "@openpanel/prettier-config"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
randomBytes,
|
||||
scrypt,
|
||||
timingSafeEqual,
|
||||
} from 'crypto';
|
||||
} from 'node:crypto';
|
||||
|
||||
export function generateSalt() {
|
||||
return randomBytes(16).toString('hex');
|
||||
@@ -16,7 +16,7 @@ export function generateSalt() {
|
||||
*/
|
||||
export async function hashPassword(
|
||||
password: string,
|
||||
keyLength = 32
|
||||
keyLength = 32,
|
||||
): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
// generate random 16 bytes long salt - recommended by NodeJS Docs
|
||||
@@ -38,7 +38,7 @@ export async function hashPassword(
|
||||
export async function verifyPassword(
|
||||
password: string,
|
||||
hash: string,
|
||||
keyLength = 32
|
||||
keyLength = 32,
|
||||
): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const [salt, hashKey] = hash.split('.');
|
||||
2
packages/common/server/index.ts
Normal file
2
packages/common/server/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './crypto';
|
||||
export * from './profileId';
|
||||
@@ -84,7 +84,7 @@ export function completeSerie(
|
||||
data: ISerieDataItem[],
|
||||
_startDate: string,
|
||||
_endDate: string,
|
||||
interval: IInterval
|
||||
interval: IInterval,
|
||||
) {
|
||||
const startDate = parseISO(_startDate);
|
||||
const endDate = parseISO(_endDate);
|
||||
|
||||
@@ -6,7 +6,7 @@ import { round } from './math';
|
||||
|
||||
export function getPreviousMetric(
|
||||
current: number,
|
||||
previous: number | null | undefined
|
||||
previous: number | null | undefined,
|
||||
): PreviousValue {
|
||||
if (isNil(previous)) {
|
||||
return undefined;
|
||||
@@ -20,7 +20,7 @@ export function getPreviousMetric(
|
||||
: 0) -
|
||||
1) *
|
||||
100,
|
||||
1
|
||||
1,
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { isNumber } from 'mathjs';
|
||||
|
||||
export const round = (num: number, decimals = 2) => {
|
||||
const factor = Math.pow(10, decimals);
|
||||
const factor = 10 ** decimals;
|
||||
return Math.round((num + Number.EPSILON) * factor) / factor;
|
||||
};
|
||||
|
||||
export const average = (arr: (number | null)[]) => {
|
||||
const filtered = arr.filter(
|
||||
(n): n is number =>
|
||||
isNumber(n) && !Number.isNaN(n) && Number.isFinite(n) && n !== 0
|
||||
isNumber(n) && !Number.isNaN(n) && Number.isFinite(n) && n !== 0,
|
||||
);
|
||||
const avg = filtered.reduce((p, c) => p + c, 0) / filtered.length;
|
||||
return Number.isNaN(avg) ? 0 : avg;
|
||||
|
||||
@@ -3,7 +3,7 @@ import superjson from 'superjson';
|
||||
|
||||
export function toDots(
|
||||
obj: Record<string, unknown>,
|
||||
path = ''
|
||||
path = '',
|
||||
): Record<string, string> {
|
||||
return Object.entries(obj).reduce((acc, [key, value]) => {
|
||||
if (typeof value === 'object' && value !== null) {
|
||||
@@ -26,7 +26,7 @@ export function toDots(
|
||||
}
|
||||
|
||||
export function toObject(
|
||||
obj: Record<string, string | undefined>
|
||||
obj: Record<string, string | undefined>,
|
||||
): Record<string, unknown> {
|
||||
let result: Record<string, unknown> = {};
|
||||
Object.entries(obj).forEach(([key, value]) => {
|
||||
|
||||
@@ -9,7 +9,7 @@ const slugify = (str: string) => {
|
||||
.replace('Å', 'A')
|
||||
.replace('Ä', 'A')
|
||||
.replace('Ö', 'O'),
|
||||
{ lower: true, strict: true, trim: true }
|
||||
{ lower: true, strict: true, trim: true },
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export function parseSearchParams(
|
||||
params: URLSearchParams
|
||||
params: URLSearchParams,
|
||||
): Record<string, string> | undefined {
|
||||
const result: Record<string, string> = {};
|
||||
for (const [key, value] of params.entries()) {
|
||||
@@ -39,7 +39,7 @@ export function parsePath(path?: string): {
|
||||
|
||||
export function isSameDomain(
|
||||
url1: string | undefined,
|
||||
url2: string | undefined
|
||||
url2: string | undefined,
|
||||
) {
|
||||
if (!url1 || !url2) {
|
||||
return false;
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
"@/*": ["./src/*"],
|
||||
"@/server/*": ["./src/server/*"]
|
||||
},
|
||||
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user