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

Update prettier #8198

Merged
merged 2 commits into from
Jan 16, 2024
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
4 changes: 2 additions & 2 deletions bench/snippets/buffer-concat.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ for (let size of [32, 2048, 1024 * 16, 1024 * 1024 * 2, 1024 * 1024 * 16]) {
size > 1024 * 1024
? new Intl.NumberFormat(undefined, { unit: "megabyte", style: "unit" })
: size > 1024
? new Intl.NumberFormat(undefined, { unit: "kilobyte", style: "unit" })
: new Intl.NumberFormat(undefined, { unit: "byte", style: "unit" });
? new Intl.NumberFormat(undefined, { unit: "kilobyte", style: "unit" })
: new Intl.NumberFormat(undefined, { unit: "byte", style: "unit" });

bench(
`Buffer.concat(${fmt.format(
Expand Down
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"eslint-config-prettier": "^8.5.0",
"mitata": "^0.1.3",
"peechy": "0.4.34",
"prettier": "^2.4.1",
"prettier": "3.2.2",
"react": "next",
"react-dom": "next",
"source-map-js": "^1.0.2",
Expand Down
8 changes: 4 additions & 4 deletions packages/bun-types/bun.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3953,8 +3953,8 @@ declare module "bun" {
type ReadableToIO<X extends Readable> = X extends "pipe" | undefined
? ReadableStream<Uint8Array>
: X extends BunFile | ArrayBufferView | number
? number
: undefined;
? number
: undefined;

type ReadableToSyncIO<X extends Readable> = X extends "pipe" | undefined
? Buffer
Expand All @@ -3965,8 +3965,8 @@ declare module "bun" {
type WritableToIO<X extends Writable> = X extends "pipe"
? FileSink
: X extends BunFile | ArrayBufferView | Blob | Request | Response | number
? number
: undefined;
? number
: undefined;
}

interface ResourceUsage {
Expand Down
10 changes: 5 additions & 5 deletions packages/bun-types/ffi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,8 @@ declare module "bun:ffi" {
type ToFFIType<T extends FFITypeOrString> = T extends FFIType
? T
: T extends string
? FFITypeStringToType[T]
: never;
? FFITypeStringToType[T]
: never;

// eslint-disable-next-line @definitelytyped/no-single-element-tuple-type
type _Narrow<T, U> = [U] extends [T] ? U : Extract<T, U>;
Expand All @@ -576,9 +576,9 @@ declare module "bun:ffi" {
...args: Fns[K]["args"] extends infer A extends readonly FFITypeOrString[]
? { [L in keyof A]: FFITypeToArgsType[ToFFIType<A[L]>] }
: // eslint-disable-next-line @definitelytyped/no-single-element-tuple-type
[unknown] extends [Fns[K]["args"]]
? []
: never
[unknown] extends [Fns[K]["args"]]
? []
: never
) => // eslint-disable-next-line @definitelytyped/no-single-element-tuple-type
[unknown] extends [Fns[K]["returns"]]
? undefined
Expand Down
2 changes: 1 addition & 1 deletion packages/bun-types/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ declare namespace Bun {
*/
env?:
| Record<string, string>
| typeof import("node:worker_threads")["SHARE_ENV"]
| (typeof import("node:worker_threads"))["SHARE_ENV"]
| undefined;

/**
Expand Down
8 changes: 4 additions & 4 deletions packages/bun-types/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1933,8 +1933,8 @@ declare namespace JestMock {
export type Spied<T extends ClassLike | FunctionLike> = T extends ClassLike
? SpiedClass<T>
: T extends FunctionLike
? SpiedFunction<T>
: never;
? SpiedFunction<T>
: never;

export type SpiedClass<T extends ClassLike = UnknownClass> = MockInstance<
(...args: ConstructorParameters<T>) => InstanceType<T>
Expand Down Expand Up @@ -1975,8 +1975,8 @@ declare namespace JestMock {
): A extends "get"
? SpiedGetter<V>
: A extends "set"
? SpiedSetter<V>
: never;
? SpiedSetter<V>
: never;
<
T_1 extends object,
K_5 extends
Expand Down
8 changes: 4 additions & 4 deletions src/codegen/bundle-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ $$capture_start$$(${fn.async ? "async " : ""}${
overriddenName: fn.directives.getter
? `"get ${fn.name}"_s`
: fn.directives.overriddenName
? `"${fn.directives.overriddenName}"_s`
: "ASCIILiteral()",
? `"${fn.directives.overriddenName}"_s`
: "ASCIILiteral()",
});
}

Expand Down Expand Up @@ -358,8 +358,8 @@ for (const { basename, internal } of files) {
bundledCPP += `#define DECLARE_GLOBAL_STATIC(name) \\
Zig::GlobalObject::GlobalPropertyInfo( \\
clientData.builtinFunctions().${low(basename)}Builtins().name##PrivateName(), ${low(
basename,
)}().m_##name##Function.get() , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly),
basename,
)}().m_##name##Function.get() , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly),
WEBCORE_FOREACH_${basename.toUpperCase()}_BUILTIN_FUNCTION_NAME(DECLARE_GLOBAL_STATIC)
#undef DECLARE_GLOBAL_STATIC
`;
Expand Down
8 changes: 4 additions & 4 deletions src/codegen/bundle-modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,10 @@ JSValue InternalModuleRegistry::createInternalModuleById(JSGlobalObject* globalO
.map((id, n) => {
return `case Field::${idToEnumName(id)}: {
INTERNAL_MODULE_REGISTRY_GENERATE(globalObject, vm, "${idToPublicSpecifierOrEnumName(id)}"_s, ${JSON.stringify(
id.replace(/\.[mc]?[tj]s$/, ".js"),
)}_s, InternalModuleRegistryConstants::${idToEnumName(id)}Code, "builtin://${id
.replace(/\.[mc]?[tj]s$/, "")
.replace(/[^a-zA-Z0-9]+/g, "/")}"_s);
id.replace(/\.[mc]?[tj]s$/, ".js"),
)}_s, InternalModuleRegistryConstants::${idToEnumName(id)}Code, "builtin://${id
.replace(/\.[mc]?[tj]s$/, "")
.replace(/[^a-zA-Z0-9]+/g, "/")}"_s);
}`;
})
.join("\n ")}
Expand Down
54 changes: 27 additions & 27 deletions src/codegen/generate-classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,11 @@ function generatePrototype(typeName, obj) {

specialSymbols += `
this->putDirect(vm, WebCore::clientData(vm)->builtinNames().${privateSymbol}PrivateName(), JSFunction::create(vm, globalObject, ${
protoFields[name].length || 0
}, String("${fn}"_s), ${protoSymbolName(
typeName,
fn,
)}Callback, ImplementationVisibility::Private), PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | 0);`;
protoFields[name].length || 0
}, String("${fn}"_s), ${protoSymbolName(
typeName,
fn,
)}Callback, ImplementationVisibility::Private), PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | 0);`;
continue;
}

Expand Down Expand Up @@ -464,8 +464,8 @@ function generateConstructorHeader(typeName) {
public:
using Base = JSC::InternalFunction;
static ${name}* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, ${prototypeName(
typeName,
)}* prototype);
typeName,
)}* prototype);

static constexpr unsigned StructureFlags = Base::StructureFlags;
static constexpr bool needsDestruction = false;
Expand Down Expand Up @@ -726,8 +726,8 @@ function renderCallbacksZig(typeName, callbacks: Record<string, string>) {
.join("\n")}
}) void {
${symbolName(typeName, "_setAllCallbacks")}(this.instance, ${Object.keys(callbacks)
.map((name, i) => `values.${camelCase(name)}`)
.join(", ")},);
.map((name, i) => `values.${camelCase(name)}`)
.join(", ")},);
}
`;

Expand Down Expand Up @@ -915,8 +915,8 @@ JSC_DEFINE_CUSTOM_GETTER(${symbolName(

JSC::JSValue result = JSC::JSValue::decode(
${symbolName(typeName, proto[name].getter)}(thisObject->wrapped(),${
proto[name].this!! ? " encodedThisValue, " : ""
} globalObject)
proto[name].this!! ? " encodedThisValue, " : ""
} globalObject)
);
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->${cacheName}.set(vm, thisObject, result);
Expand All @@ -932,8 +932,8 @@ JSC_DEFINE_CUSTOM_GETTER(${symbolName(
auto& vm = globalObject->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
${className(typeName)}* thisObject = jsDynamicCast<${className(
typeName,
)}*>(JSValue::decode(encodedThisValue));
typeName,
)}*>(JSValue::decode(encodedThisValue));
if (UNLIKELY(!thisObject)) {
return JSValue::encode(jsUndefined());
}
Expand All @@ -945,8 +945,8 @@ JSC_DEFINE_CUSTOM_GETTER(${symbolName(

JSC::JSValue result = JSC::JSValue::decode(
${symbolName(typeName, proto[name].getter)}(thisObject->wrapped(),${
proto[name].this!! ? " thisValue, " : ""
} globalObject)
proto[name].this!! ? " thisValue, " : ""
} globalObject)
);
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->${cacheName}.set(vm, thisObject, result);
Expand All @@ -969,8 +969,8 @@ JSC_DEFINE_CUSTOM_GETTER(${symbolName(
${className(typeName)}* thisObject = jsCast<${className(typeName)}*>(JSValue::decode(encodedThisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
JSC::EncodedJSValue result = ${symbolName(typeName, proto[name].getter)}(thisObject->wrapped(),${
!!proto[name].this ? " encodedThisValue, " : ""
} globalObject);
!!proto[name].this ? " encodedThisValue, " : ""
} globalObject);
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
Expand All @@ -986,15 +986,15 @@ JSC_DEFINE_CUSTOM_GETTER(${symbolName(
Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
${className(typeName)}* thisObject = jsDynamicCast<${className(
typeName,
)}*>(JSValue::decode(encodedThisValue));
typeName,
)}*>(JSValue::decode(encodedThisValue));
if (UNLIKELY(!thisObject)) {
return JSValue::encode(jsUndefined());
}
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
JSC::EncodedJSValue result = ${symbolName(typeName, proto[name].getter)}(thisObject->wrapped(),${
!!proto[name].this ? " encodedThisValue, " : ""
} globalObject);
!!proto[name].this ? " encodedThisValue, " : ""
} globalObject);
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
Expand All @@ -1015,8 +1015,8 @@ JSC_DEFINE_CUSTOM_SETTER(${symbolName(
${className(typeName)}* thisObject = jsCast<${className(typeName)}*>(JSValue::decode(encodedThisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
auto result = ${symbolName(typeName, proto[name].setter || proto[name].accessor.setter)}(thisObject->wrapped(),${
!!proto[name].this ? " encodedThisValue, " : ""
} lexicalGlobalObject, encodedValue);
!!proto[name].this ? " encodedThisValue, " : ""
} lexicalGlobalObject, encodedValue);

RELEASE_AND_RETURN(throwScope, result);
}
Expand Down Expand Up @@ -1427,10 +1427,10 @@ ${
? `JSObject* ${name}::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
return WebCore::${constructorName(typeName)}::create(vm, globalObject, WebCore::${constructorName(
typeName,
)}::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::${prototypeName(
typeName,
)}*>(prototype));
typeName,
)}::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::${prototypeName(
typeName,
)}*>(prototype));
}`
: ""
}
Expand Down
8 changes: 4 additions & 4 deletions src/codegen/internal-module-registry-scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export function createInternalModuleRegistry(basedir: string) {
const prefix = moduleList[i].startsWith("node/")
? "node:"
: moduleList[i].startsWith("bun:")
? "bun:"
: moduleList[i].startsWith("internal/")
? "internal/"
: undefined;
? "bun:"
: moduleList[i].startsWith("internal/")
? "internal/"
: undefined;
if (prefix) {
const id = prefix + moduleList[i].slice(prefix.length).replaceAll(".", "/").slice(0, -3);
internalRegistry.set(id, i);
Expand Down
4 changes: 2 additions & 2 deletions src/js/builtins.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ type PromiseFieldType = typeof $promiseFieldFlags | typeof $promiseFieldReaction
type PromiseFieldToValue<X extends PromiseFieldType, V> = X extends typeof $promiseFieldFlags
? number
: X extends typeof $promiseFieldReactionsOrResult
? V | any
: any;
? V | any
: any;
type WellKnownSymbol = keyof { [K in keyof SymbolConstructor as SymbolConstructor[K] extends symbol ? K : never]: K };

// You can also `@` on any method on a classes to avoid prototype pollution and secret internals
Expand Down
3 changes: 2 additions & 1 deletion src/js/internal/util/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ const codes = {}; // exported from errors.js
if (!ArrayIsArray(expected)) expected = [expected];

let msg = "The ";
if (StringPrototypeEndsWith(name, " argument")) msg += `${name} `; // For cases like 'first argument'
if (StringPrototypeEndsWith(name, " argument"))
msg += `${name} `; // For cases like 'first argument'
else msg += `"${name}" ${StringPrototypeIncludes(name, ".") ? "property" : "argument"} `;
msg += "must be ";

Expand Down
8 changes: 4 additions & 4 deletions src/js/node/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ var require_errors = __commonJS({
len > 2
? "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(", "), ", or ") + expected[len - 1]
: len === 2
? "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1])
: "of ".concat(thing, " ").concat(expected[0])
? "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1])
: "of ".concat(thing, " ").concat(expected[0])
);
} else return "of ".concat(thing, " ").concat(String(expected));
}
Expand Down Expand Up @@ -1079,8 +1079,8 @@ var require_assert = __commonJS({
return expected.prototype !== void 0 && actual instanceof expected
? !0
: Error.isPrototypeOf(expected)
? !1
: expected.$call({}, actual) === !0;
? !1
: expected.$call({}, actual) === !0;
}
function getActual(fn) {
if (typeof fn != "function") throw new ERR_INVALID_ARG_TYPE("fn", "Function", fn);
Expand Down
Loading