mirror of
https://github.com/frappe/books.git
synced 2026-08-24 10:04:45 -05:00
chore: fix all fixable eslint errors in remaining non vue files
- update files to ignore - delete babel.config.js
This commit is contained in:
+1
-1
@@ -13,7 +13,7 @@ export function generateCSV(matrix: unknown[][]): string {
|
||||
return formattedRows.join('\r\n');
|
||||
}
|
||||
|
||||
function splitCsvBlock(text: string, splitter: string = '\r\n'): string[] {
|
||||
function splitCsvBlock(text: string, splitter = '\r\n'): string[] {
|
||||
if (!text.endsWith(splitter)) {
|
||||
text += splitter;
|
||||
}
|
||||
|
||||
@@ -93,3 +93,15 @@ export abstract class DatabaseDemuxBase {
|
||||
|
||||
abstract callBespoke(method: string, ...args: unknown[]): Promise<unknown>;
|
||||
}
|
||||
|
||||
// Return types of Bespoke Queries
|
||||
export type TopExpenses = { account: string; total: number }[];
|
||||
export type TotalOutstanding = { total: number; outstanding: number };
|
||||
export type Cashflow = { inflow: number; outflow: number; yearmonth: string }[];
|
||||
export type Balance = { balance: number; yearmonth: string }[];
|
||||
export type IncomeExpense = { income: Balance; expense: Balance };
|
||||
export type TotalCreditAndDebit = {
|
||||
account: string;
|
||||
totalCredit: number;
|
||||
totalDebit: number;
|
||||
};
|
||||
+6
-4
@@ -115,6 +115,7 @@ export function invertMap(map: Record<string, string>): Record<string, string> {
|
||||
}
|
||||
|
||||
export function time<K, T>(func: (...args: K[]) => T, ...args: K[]): T {
|
||||
/* eslint-disable no-console */
|
||||
const name = func.name;
|
||||
console.time(name);
|
||||
const stuff = func(...args);
|
||||
@@ -126,6 +127,7 @@ export async function timeAsync<K, T>(
|
||||
func: (...args: K[]) => Promise<T>,
|
||||
...args: K[]
|
||||
): Promise<T> {
|
||||
/* eslint-disable no-console */
|
||||
const name = func.name;
|
||||
console.time(name);
|
||||
const stuff = await func(...args);
|
||||
@@ -255,20 +257,20 @@ export function removeAtIndex<T>(array: T[], index: number): T[] {
|
||||
|
||||
export function objectForEach<T extends object | unknown>(
|
||||
obj: T,
|
||||
func: Function
|
||||
func: (arg: unknown) => unknown
|
||||
) {
|
||||
if (typeof obj !== 'object' || obj === null) {
|
||||
return func(obj);
|
||||
}
|
||||
|
||||
const newObj: Record<string, unknown> = {};
|
||||
for (const key in obj) {
|
||||
obj[key] = objectForEach(obj[key], func);
|
||||
newObj[key] = objectForEach(obj[key], func);
|
||||
}
|
||||
|
||||
return func(obj);
|
||||
return func(newObj);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Asserts that `value` is of type T. Use with care.
|
||||
*/
|
||||
|
||||
@@ -10,7 +10,7 @@ export const schemaTranslateables = [
|
||||
'tab',
|
||||
];
|
||||
|
||||
export function getIndexFormat(inp: string | string[]) {
|
||||
export function getIndexFormat(inp: string | string[] | unknown) {
|
||||
/**
|
||||
* converts:
|
||||
* ['This is an ', ,' interpolated ',' string.'] and
|
||||
@@ -26,7 +26,7 @@ export function getIndexFormat(inp: string | string[]) {
|
||||
} else if (inp instanceof Array) {
|
||||
snippets = inp;
|
||||
} else {
|
||||
throw new Error(`invalid input ${inp} of type ${typeof inp}`);
|
||||
throw new Error(`invalid input ${String(inp)} of type ${typeof inp}`);
|
||||
}
|
||||
|
||||
if (snippets === undefined) {
|
||||
@@ -43,7 +43,7 @@ export function getIndexFormat(inp: string | string[]) {
|
||||
str += s;
|
||||
return;
|
||||
}
|
||||
str += s + '${' + i + '}';
|
||||
str += s + '${' + String(i) + '}';
|
||||
});
|
||||
|
||||
return str;
|
||||
@@ -70,5 +70,5 @@ export function getWhitespaceSanitized(str: string) {
|
||||
}
|
||||
|
||||
export function getIndexList(str: string) {
|
||||
return [...str.matchAll(/\${([^}]+)}/g)].map(([_, i]) => parseInt(i));
|
||||
return [...str.matchAll(/\${([^}]+)}/g)].map(([, i]) => parseInt(i));
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ export interface SelectFileReturn {
|
||||
canceled: boolean;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export type PropertyEnum<T extends Record<string, any>> = {
|
||||
[key in keyof Required<T>]: key;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user