mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
fix(lint): resolve no-unused-expressions errors (#23127)
## Summary Fixes all oxlint `no-unused-expressions` violations across the codebase by: - Adding an oxlint override to disable the rule for `src/js/builtins/**`, where special syntax markers like `$getter`, `$constructor`, etc. are intentionally used as standalone expressions - Converting short-circuit expressions (`condition && fn()`) to proper if statements for improved code clarity - Wrapping intentional property access side effects (e.g., `this.stdio;`, `err.stack;`) with the `void` operator - Converting ternary expressions used for control flow to if/else statements ## Test plan - [x] `bun lint` passes with no errors 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Bot <claude-bot@bun.sh> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -589,7 +589,7 @@ Server.prototype[kRealListen] = function (tls, port, host, socketPath, reusePort
|
||||
}
|
||||
function onClose() {
|
||||
didFinish = true;
|
||||
resolveFunction && resolveFunction();
|
||||
if (resolveFunction) resolveFunction();
|
||||
}
|
||||
|
||||
setCloseCallback(http_res, onClose);
|
||||
@@ -732,7 +732,7 @@ Server.prototype.setTimeout = function (msecs, callback) {
|
||||
const server = this[serverSymbol];
|
||||
if (server) {
|
||||
setServerIdleTimeout(server, Math.ceil(msecs / 1000));
|
||||
typeof callback === "function" && this.once("timeout", callback);
|
||||
if (typeof callback === "function") this.once("timeout", callback);
|
||||
} else {
|
||||
(this[kDeferredTimeouts] ??= []).push({ msecs, callback });
|
||||
}
|
||||
@@ -905,7 +905,7 @@ const NodeHTTPServerSocket = class Socket extends Duplex {
|
||||
}
|
||||
#onCloseForDestroy(closeCallback) {
|
||||
this.#onClose();
|
||||
$isCallable(closeCallback) && closeCallback();
|
||||
if ($isCallable(closeCallback)) closeCallback();
|
||||
}
|
||||
|
||||
_onTimeout() {
|
||||
@@ -937,7 +937,7 @@ const NodeHTTPServerSocket = class Socket extends Duplex {
|
||||
_destroy(err, callback) {
|
||||
const handle = this[kHandle];
|
||||
if (!handle) {
|
||||
$isCallable(callback) && callback(err);
|
||||
if ($isCallable(callback)) callback(err);
|
||||
return;
|
||||
}
|
||||
handle.ondata = undefined;
|
||||
@@ -947,7 +947,7 @@ const NodeHTTPServerSocket = class Socket extends Duplex {
|
||||
if ($isCallable(onclose)) {
|
||||
onclose.$call(handle);
|
||||
}
|
||||
$isCallable(callback) && callback(err);
|
||||
if ($isCallable(callback)) callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1081,7 +1081,8 @@ const NodeHTTPServerSocket = class Socket extends Duplex {
|
||||
} catch (e) {
|
||||
err = e;
|
||||
}
|
||||
err ? _callback(err) : _callback();
|
||||
if (err) _callback(err);
|
||||
else _callback();
|
||||
}
|
||||
|
||||
pause() {
|
||||
@@ -1510,7 +1511,7 @@ ServerResponse.prototype._finish = function () {
|
||||
|
||||
ServerResponse.prototype.detachSocket = function (socket) {
|
||||
if (socket._httpMessage === this) {
|
||||
socket[kCloseCallback] && (socket[kCloseCallback] = undefined);
|
||||
if (socket[kCloseCallback]) socket[kCloseCallback] = undefined;
|
||||
socket.removeListener("close", onServerResponseClose);
|
||||
socket._httpMessage = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user