Skip to content

Commit

Permalink
chore: update prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jul 5, 2023
1 parent b3aa049 commit 9a4b67e
Show file tree
Hide file tree
Showing 19 changed files with 106 additions and 104 deletions.
2 changes: 1 addition & 1 deletion examples/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<title>Consola</title>
Expand Down
2 changes: 1 addition & 1 deletion examples/index.legacy.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<title>Consola</title>
Expand Down
2 changes: 1 addition & 1 deletion examples/special.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ consola.error(undefined, null, false, true, Number.NaN);
consola.log("We can `monospace` keyword using grave accent charachter!");

consola.log(
"We can also _underline_ words but not_this or this should_not_be_underlined!"
"We can also _underline_ words but not_this or this should_not_be_underlined!",
);

// Nonstandard error
Expand Down
2 changes: 1 addition & 1 deletion examples/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ConsolaOptions, createConsola } from "../../src";
import { randomSentence } from "./sentence";

export function reporterDemo(
opts: Partial<ConsolaOptions & { fancy: boolean }>
opts: Partial<ConsolaOptions & { fancy: boolean }>,
) {
const consola = createConsola({
...opts,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"is-unicode-supported": "^1.3.0",
"jiti": "^1.18.2",
"lodash": "^4.17.21",
"prettier": "^2.8.8",
"prettier": "^3.0.0",
"sentencer": "^0.2.1",
"sisteransi": "^1.0.5",
"std-env": "^3.3.3",
Expand All @@ -98,4 +98,4 @@
"node": "^14.18.0 || >=16.10.0"
},
"packageManager": "pnpm@8.6.5"
}
}
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ConsolaInstance, createConsola as _createConsola } from "./consola";
export * from "./shared";

export function createConsola(
options: Partial<ConsolaOptions & { fancy: boolean }> = {}
options: Partial<ConsolaOptions & { fancy: boolean }> = {},
): ConsolaInstance {
// Log level
let level: LogLevel = LogLevels.info;
Expand Down
12 changes: 6 additions & 6 deletions src/consola.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class Consola {
colors: false,
compact: true,
},
}
},
);

// Create logger functions for current instance
Expand All @@ -60,7 +60,7 @@ export class Consola {
// @ts-expect-error
(this as unknown as ConsolaInstance)[type].raw = this._wrapLogFn(
defaults,
true
true,
);
}

Expand All @@ -81,7 +81,7 @@ export class Consola {
this.options.level = _normalizeLogLevel(
level,
this.options.types,
this.options.level
this.options.level,
);
}

Expand Down Expand Up @@ -347,7 +347,7 @@ export class Consola {
// Auto-resolve when throttle is timed out
this._lastLog.timeout = setTimeout(
resolveLog,
this.options.throttle
this.options.throttle,
);
return; // SPAM!
}
Expand All @@ -372,7 +372,7 @@ export class Consola {
function _normalizeLogLevel(
input: LogLevel | LogType | undefined,
types: any = {},
defaultLevel = 3
defaultLevel = 3,
) {
if (input === undefined) {
return defaultLevel;
Expand Down Expand Up @@ -409,7 +409,7 @@ Consola.prototype.pause = Consola.prototype.pauseLogs;
Consola.prototype.resume = Consola.prototype.resumeLogs;

export function createConsola(
options: Partial<ConsolaOptions> = {}
options: Partial<ConsolaOptions> = {},
): ConsolaInstance {
return new Consola(options) as ConsolaInstance;
}
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ConsolaInstance, createConsola as _createConsola } from "./consola";
export * from "./shared";

export function createConsola(
options: Partial<ConsolaOptions & { fancy: boolean }> = {}
options: Partial<ConsolaOptions & { fancy: boolean }> = {},
): ConsolaInstance {
// Log level
let level = _getDefaultLogLevel();
Expand Down
8 changes: 4 additions & 4 deletions src/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ type inferPromptReturnType<T extends PromptOptions> = T extends TextOptions
export async function prompt<
_ = any,
__ = any,
T extends PromptOptions = TextOptions
T extends PromptOptions = TextOptions,
>(
message: string,
opts: PromptOptions = {}
opts: PromptOptions = {},
): Promise<inferPromptReturnType<T>> {
if (!opts.type || opts.type === "text") {
return (await text({
Expand All @@ -75,7 +75,7 @@ export async function prompt<
return (await select({
message,
options: opts.options.map((o) =>
typeof o === "string" ? { value: o, label: o } : o
typeof o === "string" ? { value: o, label: o } : o,
),
})) as any;
}
Expand All @@ -84,7 +84,7 @@ export async function prompt<
return (await multiselect({
message,
options: opts.options.map((o) =>
typeof o === "string" ? { value: o, label: o } : o
typeof o === "string" ? { value: o, label: o } : o,
),
required: opts.required,
})) as any;
Expand Down
2 changes: 1 addition & 1 deletion src/reporters/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class BasicReporter implements ConsolaReporter {
line + "\n",
logObj.level < 2
? ctx.options.stderr || process.stderr
: ctx.options.stdout || process.stdout
: ctx.options.stdout || process.stdout,
);
}
}
2 changes: 1 addition & 1 deletion src/reporters/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class BrowserReporter {
style,
// Empty string as style resets to default console style
"",
...logObj.args.slice(1)
...logObj.args.slice(1),
);
} else {
consoleLogFn(badge, style, ...logObj.args);
Expand Down
12 changes: 6 additions & 6 deletions src/reporters/fancy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class FancyReporter extends BasicReporter {
" " +
line
.replace(/^at +/, (m) => colors.gray(m))
.replace(/\((.+)\)/, (_, m) => `(${colors.cyan(m)})`)
.replace(/\((.+)\)/, (_, m) => `(${colors.cyan(m)})`),
)
.join("\n")
);
Expand All @@ -69,7 +69,7 @@ export class FancyReporter extends BasicReporter {

if (isBadge) {
return getBgColor(typeColor)(
colors.black(` ${logObj.type.toUpperCase()} `)
colors.black(` ${logObj.type.toUpperCase()} `),
);
}

Expand All @@ -83,20 +83,20 @@ export class FancyReporter extends BasicReporter {

formatLogObj(logObj: LogObject, opts: FormatOptions) {
const [message, ...additional] = this.formatArgs(logObj.args, opts).split(
"\n"
"\n",
);

if (logObj.type === "box") {
return box(
characterFormat(
message + (additional.length > 0 ? "\n" + additional.join("\n") : "")
message + (additional.length > 0 ? "\n" + additional.join("\n") : ""),
),
{
title: logObj.title
? characterFormat(logObj.title as string)
: undefined,
style: logObj.style as BoxOpts["style"],
}
},
);
}

Expand All @@ -120,7 +120,7 @@ export class FancyReporter extends BasicReporter {
: (right ? `${colors.gray(`[${right}]`)} ` : "") + left;

line += characterFormat(
additional.length > 0 ? "\n" + additional.join("\n") : ""
additional.length > 0 ? "\n" + additional.join("\n") : "",
);

if (logObj.type === "trace") {
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ export interface ConsolaReporter {
logObj: LogObject,
ctx: {
options: ConsolaOptions;
}
},
) => void;
}
18 changes: 10 additions & 8 deletions src/utils/box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export function box(text: string, _opts: BoxOpts = {}) {
if (_color) {
for (const key in borderStyle) {
borderStyle[key as keyof typeof borderStyle] = _color(
borderStyle[key as keyof typeof borderStyle]
borderStyle[key as keyof typeof borderStyle],
);
}
}
Expand All @@ -260,22 +260,22 @@ export function box(text: string, _opts: BoxOpts = {}) {
// Include the title if it exists with borders
if (opts.title) {
const left = borderStyle.h.repeat(
Math.floor((width - stripAnsi(opts.title).length) / 2)
Math.floor((width - stripAnsi(opts.title).length) / 2),
);
const right = borderStyle.h.repeat(
width -
stripAnsi(opts.title).length -
stripAnsi(left).length +
paddingOffset
paddingOffset,
);
boxLines.push(
`${leftSpace}${borderStyle.tl}${left}${opts.title}${right}${borderStyle.tr}`
`${leftSpace}${borderStyle.tl}${left}${opts.title}${right}${borderStyle.tr}`,
);
} else {
boxLines.push(
`${leftSpace}${borderStyle.tl}${borderStyle.h.repeat(widthOffset)}${
borderStyle.tr
}`
}`,
);
}

Expand All @@ -291,15 +291,17 @@ export function box(text: string, _opts: BoxOpts = {}) {
if (i < valignOffset || i >= valignOffset + textLines.length) {
// Empty line
boxLines.push(
`${leftSpace}${borderStyle.v}${" ".repeat(widthOffset)}${borderStyle.v}`
`${leftSpace}${borderStyle.v}${" ".repeat(widthOffset)}${
borderStyle.v
}`,
);
} else {
// Text line
const line = textLines[i - valignOffset];
const left = " ".repeat(paddingOffset);
const right = " ".repeat(width - stripAnsi(line).length);
boxLines.push(
`${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`
`${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`,
);
}
}
Expand All @@ -308,7 +310,7 @@ export function box(text: string, _opts: BoxOpts = {}) {
boxLines.push(
`${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${
borderStyle.br
}`
}`,
);
if (opts.style.marginBottom > 0) {
boxLines.push("".repeat(opts.style.marginBottom));
Expand Down
10 changes: 5 additions & 5 deletions src/utils/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function replaceClose(
replace: string,
head = string.slice(0, Math.max(0, index)) + replace,
tail = string.slice(Math.max(0, index + close.length)),
next = tail.indexOf(close)
next = tail.indexOf(close),
): string {
return head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
}
Expand All @@ -42,7 +42,7 @@ function clearBleed(
string: string,
open: string,
close: string,
replace: string
replace: string,
) {
return index < 0
? open + string + close
Expand All @@ -53,7 +53,7 @@ function filterEmpty(
open: string,
close: string,
replace = open,
at = open.length + 1
at = open.length + 1,
) {
return (string: string) =>
string || !(string === "" || string === undefined)
Expand All @@ -62,7 +62,7 @@ function filterEmpty(
string,
open,
close,
replace
replace,
)
: "";
}
Expand Down Expand Up @@ -128,7 +128,7 @@ export const colors = createColors() as Record<ColorName, ColorFunction>;

export function getColor(
color: ColorName,
fallback: ColorName = "reset"
fallback: ColorName = "reset",
): ColorFunction {
return colors[color] || colors[fallback];
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function compileFormat(format: string) {
for (const arg of FORMAT_ARGS) {
_format = _format.replace(
new RegExp("([%-])" + arg[0], "g"),
"$1" + arg[1]
"$1" + arg[1],
);
}

Expand Down

0 comments on commit 9a4b67e

Please sign in to comment.