diff --git a/src/Mutex.zig b/src/Mutex.zig index 0aaaee366d..7ca748a64a 100644 --- a/src/Mutex.zig +++ b/src/Mutex.zig @@ -59,11 +59,11 @@ else pub const ReleaseImpl = if (builtin.os.tag == .windows) - WindowsImpl -else if (builtin.os.tag.isDarwin()) - DarwinImpl -else - FutexImpl; + WindowsImpl + else if (builtin.os.tag.isDarwin()) + DarwinImpl + else + FutexImpl; pub const ExternImpl = ReleaseImpl.Type; diff --git a/src/cli/run_command.zig b/src/cli/run_command.zig index f0d81c831a..5104c63944 100644 --- a/src/cli/run_command.zig +++ b/src/cli/run_command.zig @@ -588,11 +588,11 @@ pub const RunCommand = struct { const is_probably_trying_to_run_a_pkg_script = original_script_for_bun_run != null and ((code == 1 and bun.strings.eqlComptime(original_script_for_bun_run.?, "test")) or - (code == 2 and bun.strings.eqlAnyComptime(original_script_for_bun_run.?, &.{ - "install", - "kill", - "link", - }) and ctx.positionals.len == 1)); + (code == 2 and bun.strings.eqlAnyComptime(original_script_for_bun_run.?, &.{ + "install", + "kill", + "link", + }) and ctx.positionals.len == 1)); if (is_probably_trying_to_run_a_pkg_script) { // if you run something like `bun run test`, you get a confusing message because diff --git a/src/cli/upgrade_command.zig b/src/cli/upgrade_command.zig index 8f38f9eb0f..a00a1eafeb 100644 --- a/src/cli/upgrade_command.zig +++ b/src/cli/upgrade_command.zig @@ -656,14 +656,14 @@ pub const UpgradeCommand = struct { const powershell_path = bun.which(&buf, bun.getenvZ("PATH") orelse "", "", "powershell") orelse hardcoded_system_powershell: { - const system_root = bun.getenvZ("SystemRoot") orelse "C:\\Windows"; - const hardcoded_system_powershell = bun.path.joinAbsStringBuf(system_root, &buf, &.{ system_root, "System32\\WindowsPowerShell\\v1.0\\powershell.exe" }, .windows); - if (bun.sys.exists(hardcoded_system_powershell)) { - break :hardcoded_system_powershell hardcoded_system_powershell; - } - Output.prettyErrorln("error: Failed to unzip {s} due to PowerShell not being installed.", .{tmpname}); - Global.exit(1); - }; + const system_root = bun.getenvZ("SystemRoot") orelse "C:\\Windows"; + const hardcoded_system_powershell = bun.path.joinAbsStringBuf(system_root, &buf, &.{ system_root, "System32\\WindowsPowerShell\\v1.0\\powershell.exe" }, .windows); + if (bun.sys.exists(hardcoded_system_powershell)) { + break :hardcoded_system_powershell hardcoded_system_powershell; + } + Output.prettyErrorln("error: Failed to unzip {s} due to PowerShell not being installed.", .{tmpname}); + Global.exit(1); + }; var unzip_argv = [_]string{ powershell_path, diff --git a/src/css/css_parser.zig b/src/css/css_parser.zig index 047c1237ec..639a6b3546 100644 --- a/src/css/css_parser.zig +++ b/src/css/css_parser.zig @@ -1697,15 +1697,15 @@ pub fn TopLevelRuleParser(comptime AtRuleParserT: type) type { const layer: ?struct { value: ?LayerName } = if (input.tryParse(Parser.expectIdentMatching, .{"layer"}) == .result) - .{ .value = null } - else if (input.tryParse(Parser.expectFunctionMatching, .{"layer"}) == .result) brk: { - break :brk .{ - .value = switch (input.parseNestedBlock(LayerName, {}, voidWrap(LayerName, LayerName.parse))) { - .result => |v| v, - .err => |e| return .{ .err = e }, - }, - }; - } else null; + .{ .value = null } + else if (input.tryParse(Parser.expectFunctionMatching, .{"layer"}) == .result) brk: { + break :brk .{ + .value = switch (input.parseNestedBlock(LayerName, {}, voidWrap(LayerName, LayerName.parse))) { + .result => |v| v, + .err => |e| return .{ .err = e }, + }, + }; + } else null; const supports = if (input.tryParse(Parser.expectFunctionMatching, .{"supports"}) == .result) brk: { const Func = struct { @@ -4710,11 +4710,12 @@ pub const nth = struct { if (bytes.len >= 3 and bun.strings.eqlCaseInsensitiveASCIIICheckLength(bytes[0..2], "n-") and brk: { - for (bytes[2..]) |b| { - if (b < '0' or b > '9') break :brk false; - } - break :brk true; - }) { + for (bytes[2..]) |b| { + if (b < '0' or b > '9') break :brk false; + } + break :brk true; + }) + { return parse_number_saturate(allocator, str[1..]); // Include the minus sign } else { return .{ .err = {} }; diff --git a/src/css/properties/custom.zig b/src/css/properties/custom.zig index 29ac1c3f87..18b67d2d40 100644 --- a/src/css/properties/custom.zig +++ b/src/css/properties/custom.zig @@ -177,9 +177,10 @@ pub const TokenList = struct { if (!dest.minify and i != this.v.items.len - 1 and !(this.v.items[i + 1] == .token and switch (this.v.items[i + 1].token) { - .comma, .close_paren => true, - else => false, - })) { + .comma, .close_paren => true, + else => false, + })) + { // Whitespace is removed during parsing, so add it back if we aren't minifying. try dest.writeChar(' '); return true; diff --git a/src/css/properties/font.zig b/src/css/properties/font.zig index 93935b9228..407bba9ff5 100644 --- a/src/css/properties/font.zig +++ b/src/css/properties/font.zig @@ -351,11 +351,12 @@ pub const FontFamily = union(enum) { if (val.len > 0 and !css.parse_utility.parseString( - dest.allocator, - GenericFontFamily, - val, - GenericFontFamily.parse, - ).isOk()) { + dest.allocator, + GenericFontFamily, + val, + GenericFontFamily.parse, + ).isOk()) + { var id = ArrayList(u8){}; defer id.deinit(dest.allocator); var first = true; diff --git a/src/css/rules/rules.zig b/src/css/rules/rules.zig index 67055e2254..a775832064 100644 --- a/src/css/rules/rules.zig +++ b/src/css/rules/rules.zig @@ -497,7 +497,7 @@ pub fn CssRuleList(comptime AtRule: type) type { } else { if (!dest.minify and !(last_without_block and - (rule.* == .import or rule.* == .namespace or rule.* == .layer_statement))) + (rule.* == .import or rule.* == .namespace or rule.* == .layer_statement))) { try dest.writeChar('\n'); } diff --git a/src/css/rules/style.zig b/src/css/rules/style.zig index 9e3893fd0b..618d808dbb 100644 --- a/src/css/rules/style.zig +++ b/src/css/rules/style.zig @@ -99,9 +99,9 @@ pub fn StyleRule(comptime R: type) type { // If supported, or there are no targets, preserve nesting. Otherwise, write nested rules after parent. const supports_nesting = this.rules.v.items.len == 0 or !css.Targets.shouldCompileSame( - &dest.targets, - .nesting, - ); + &dest.targets, + .nesting, + ); const len = this.declarations.declarations.items.len + this.declarations.important_declarations.items.len; const has_declarations = supports_nesting or len > 0 or this.rules.v.items.len == 0; @@ -246,16 +246,16 @@ pub fn StyleRule(comptime R: type) type { return this.declarations.len() == other.declarations.len() and this.selectors.eql(&other.selectors) and brk: { - var len = @min(this.declarations.declarations.items.len, other.declarations.declarations.items.len); - for (this.declarations.declarations.items[0..len], other.declarations.declarations.items[0..len]) |*a, *b| { - if (!a.propertyId().eql(&b.propertyId())) break :brk false; - } - len = @min(this.declarations.important_declarations.items.len, other.declarations.important_declarations.items.len); - for (this.declarations.important_declarations.items[0..len], other.declarations.important_declarations.items[0..len]) |*a, *b| { - if (!a.propertyId().eql(&b.propertyId())) break :brk false; - } - break :brk true; - }; + var len = @min(this.declarations.declarations.items.len, other.declarations.declarations.items.len); + for (this.declarations.declarations.items[0..len], other.declarations.declarations.items[0..len]) |*a, *b| { + if (!a.propertyId().eql(&b.propertyId())) break :brk false; + } + len = @min(this.declarations.important_declarations.items.len, other.declarations.important_declarations.items.len); + for (this.declarations.important_declarations.items[0..len], other.declarations.important_declarations.items[0..len]) |*a, *b| { + if (!a.propertyId().eql(&b.propertyId())) break :brk false; + } + break :brk true; + }; } }; } diff --git a/src/css/selectors/selector.zig b/src/css/selectors/selector.zig index ea453c6ce8..c7d2cee998 100644 --- a/src/css/selectors/selector.zig +++ b/src/css/selectors/selector.zig @@ -1176,7 +1176,7 @@ pub const serialize = struct { // so use :is() if that is not the case. if (ctx.selectors.v.len() == 1 and (first or (!hasTypeSelector(ctx.selectors.v.at(0)) and - isSimple(ctx.selectors.v.at(0))))) + isSimple(ctx.selectors.v.at(0))))) { try serializeSelector(ctx.selectors.v.at(0), W, dest, ctx.parent, false); } else { diff --git a/src/css/values/easing.zig b/src/css/values/easing.zig index 6de9a827b4..ee3a847e4c 100644 --- a/src/css/values/easing.zig +++ b/src/css/values/easing.zig @@ -231,11 +231,11 @@ pub const EasingFunction = union(enum) { pub fn isEase(this: *const EasingFunction) bool { return this.* == .ease or (this.* == .cubic_bezier and this.cubic_bezier.eql(&.{ - .x1 = 0.25, - .y1 = 0.1, - .x2 = 0.25, - .y2 = 1.0, - })); + .x1 = 0.25, + .y1 = 0.1, + .x2 = 0.25, + .y2 = 1.0, + })); } }; diff --git a/src/css/values/ident.zig b/src/css/values/ident.zig index 0bc12530d6..c86c6e3700 100644 --- a/src/css/values/ident.zig +++ b/src/css/values/ident.zig @@ -308,9 +308,9 @@ pub const CustomIdent = struct { ) PrintErr!void { const css_module_custom_idents_enabled = enabled_css_modules and if (dest.css_module) |*css_module| - css_module.config.custom_idents - else - false; + css_module.config.custom_idents + else + false; return dest.writeIdent(this.v, css_module_custom_idents_enabled); } diff --git a/src/css/values/image.zig b/src/css/values/image.zig index 5c3ae53121..e8a5cb8844 100644 --- a/src/css/values/image.zig +++ b/src/css/values/image.zig @@ -131,7 +131,7 @@ pub const Image = union(enum) { // Legacy -webkit-gradient() if (prefixes.contains(VendorPrefix.WEBKIT) and if (targets.browsers) |browsers| css.prefixes.Feature.isWebkitGradient(browsers) else false and - prefix_image.* == .gradient) + prefix_image.* == .gradient) { if (prefix_image.getLegacyWebkit(allocator)) |legacy| { res.append(allocator, legacy); @@ -262,10 +262,9 @@ pub const ImageSet = struct { pub fn isCompatible(this: *const @This(), browsers: css.targets.Browsers) bool { return css.Feature.isCompatible(.image_set, browsers) and - for (this.options.items) |opt| - { - if (!opt.image.isCompatible(browsers)) break false; - } else true; + for (this.options.items) |opt| { + if (!opt.image.isCompatible(browsers)) break false; + } else true; } /// Returns the `image-set()` value with the given vendor prefix. diff --git a/src/deps/diffz/DiffMatchPatch.zig b/src/deps/diffz/DiffMatchPatch.zig index e6dc26c17c..0cdcc4c585 100644 --- a/src/deps/diffz/DiffMatchPatch.zig +++ b/src/deps/diffz/DiffMatchPatch.zig @@ -522,7 +522,7 @@ fn diffBisect( var y2: isize = x2 - k2; while (x2 < before_length and y2 < after_length and before[@intCast(before_length - x2 - 1)] == - after[@intCast(after_length - y2 - 1)]) + after[@intCast(after_length - y2 - 1)]) { x2 += 1; y2 += 1; @@ -1231,9 +1231,9 @@ fn diffCleanupSemanticScore(one: []const u8, two: []const u8) usize { const blankLine2 = lineBreak2 and // BLANKLINESTART.IsMatch(two); (std.mem.startsWith(u8, two, "\n\n") or - std.mem.startsWith(u8, two, "\r\n\n") or - std.mem.startsWith(u8, two, "\n\r\n") or - std.mem.startsWith(u8, two, "\r\n\r\n")); + std.mem.startsWith(u8, two, "\r\n\n") or + std.mem.startsWith(u8, two, "\n\r\n") or + std.mem.startsWith(u8, two, "\r\n\r\n")); if (blankLine1 or blankLine2) { // Five points for blank lines. @@ -1314,8 +1314,8 @@ pub fn diffCleanupEfficiency( // ABXC if ((last_equality.Length != 0) and ((pre_ins and pre_del and post_ins and post_del) or - ((last_equality.Length < dmp.diff_edit_cost / 2) and - ((if (pre_ins) 1 else 0) + (if (pre_del) 1 else 0) + (if (post_ins) 1 else 0) + (if (post_del) 1 else 0)) == 3))) + ((last_equality.Length < dmp.diff_edit_cost / 2) and + ((if (pre_ins) 1 else 0) + (if (pre_del) 1 else 0) + (if (post_ins) 1 else 0) + (if (post_del) 1 else 0)) == 3))) { // Duplicate record. try diffs.insert( diff --git a/src/install/windows-shim/BinLinkingShim.zig b/src/install/windows-shim/BinLinkingShim.zig index e546579304..a76bad79ff 100644 --- a/src/install/windows-shim/BinLinkingShim.zig +++ b/src/install/windows-shim/BinLinkingShim.zig @@ -297,7 +297,7 @@ pub fn looseDecode(input: []const u8) ?Decoded { } break :bin_path_u8 input[0..bin_path_byte_len]; } else ( - // path slice is 0..flags-2 + // path slice is 0..flags-2 input[0 .. input.len - @sizeOf(Flags)]); if (bin_path_u8.len % 2 != 0) { diff --git a/src/js_lexer.zig b/src/js_lexer.zig index e047ae2c85..264d80dea8 100644 --- a/src/js_lexer.zig +++ b/src/js_lexer.zig @@ -1902,9 +1902,9 @@ fn NewLexer_( // Omit the trailing "*/" from the checks below const end_comment_text = if (is_multiline_comment) - text.len - 2 - else - text.len; + text.len - 2 + else + text.len; if (has_legal_annotation or lexer.preserve_all_comments_before) { if (is_multiline_comment) { diff --git a/src/macho.zig b/src/macho.zig index 1fbca63bd1..c5bbca81d2 100644 --- a/src/macho.zig +++ b/src/macho.zig @@ -149,14 +149,14 @@ pub const MachoFile = struct { const code_sign_cmd: ?*align(1) macho.linkedit_data_command = if (code_sign_cmd_idx) |idx| - @as(*align(1) macho.linkedit_data_command, @ptrCast(@constCast(@alignCast(&self.data.items[idx])))) - else - null; + @as(*align(1) macho.linkedit_data_command, @ptrCast(@constCast(@alignCast(&self.data.items[idx])))) + else + null; const linkedit_seg: *align(1) macho.segment_command_64 = if (linkedit_seg_idx) |idx| - @as(*align(1) macho.segment_command_64, @ptrCast(@constCast(@alignCast(&self.data.items[idx])))) - else - return error.MissingLinkeditSegment; + @as(*align(1) macho.segment_command_64, @ptrCast(@constCast(@alignCast(&self.data.items[idx])))) + else + return error.MissingLinkeditSegment; // Handle code signature specially var sig_data: ?[]u8 = null; diff --git a/src/resolver/data_url.zig b/src/resolver/data_url.zig index 4c536d3687..991967286c 100644 --- a/src/resolver/data_url.zig +++ b/src/resolver/data_url.zig @@ -212,8 +212,8 @@ pub const DataURL = struct { first_byte == '#' or i >= trailing_start or (first_byte == '%' and i + 2 < text.len and - PercentEncoding.isHex(text[i + 1]) and - PercentEncoding.isHex(text[i + 2])); + PercentEncoding.isHex(text[i + 1]) and + PercentEncoding.isHex(text[i + 2])); if (needs_escape) { if (run_start < i) { diff --git a/src/resolver/tsconfig_json.zig b/src/resolver/tsconfig_json.zig index 2da0564e73..869c20c6db 100644 --- a/src/resolver/tsconfig_json.zig +++ b/src/resolver/tsconfig_json.zig @@ -342,13 +342,14 @@ pub const TSConfigJSON = struct { allocator, ) and (has_base_url or - TSConfigJSON.isValidTSConfigPathNoBaseURLPattern( - str, - log, - &source, - allocator, - expr.loc, - ))) { + TSConfigJSON.isValidTSConfigPathNoBaseURLPattern( + str, + log, + &source, + allocator, + expr.loc, + ))) + { values[count] = str; count += 1; } diff --git a/src/semver/SemverRange.zig b/src/semver/SemverRange.zig index ccc0f4ec50..5a9c138710 100644 --- a/src/semver/SemverRange.zig +++ b/src/semver/SemverRange.zig @@ -226,14 +226,14 @@ pub fn satisfiesPre(range: Range, version: Version, range_buf: string, version_b // not, check the same with right if right exists and has prerelease. pre_matched.* = pre_matched.* or (range.left.version.tag.hasPre() and - version.patch == range.left.version.patch and - version.minor == range.left.version.minor and - version.major == range.left.version.major) or + version.patch == range.left.version.patch and + version.minor == range.left.version.minor and + version.major == range.left.version.major) or (has_right and - range.right.version.tag.hasPre() and - version.patch == range.right.version.patch and - version.minor == range.right.version.minor and - version.major == range.right.version.major); + range.right.version.tag.hasPre() and + version.patch == range.right.version.patch and + version.minor == range.right.version.minor and + version.major == range.right.version.major); if (!range.left.satisfies(version, range_buf, version_buf)) { return false; diff --git a/src/semver/SemverString.zig b/src/semver/SemverString.zig index 04d3f75dc8..c1e7e0aee1 100644 --- a/src/semver/SemverString.zig +++ b/src/semver/SemverString.zig @@ -12,7 +12,7 @@ pub const String = extern struct { comptime { if (inlinable_buffer.len > max_inline_len or inlinable_buffer.len == max_inline_len and - inlinable_buffer[max_inline_len - 1] >= 0x80) + inlinable_buffer[max_inline_len - 1] >= 0x80) { @compileError("string constant too long to be inlined"); } diff --git a/src/shell/shell.zig b/src/shell/shell.zig index 4c6e1cd088..83edd3691b 100644 --- a/src/shell/shell.zig +++ b/src/shell/shell.zig @@ -2381,9 +2381,9 @@ pub fn NewLexer(comptime encoding: StringEncoding) type { if (self.chars.state == .Single or self.chars.state == .Double) break :escaped; const whitespace_preceding = if (self.chars.prev) |prev| - Chars.isWhitespace(prev) - else - true; + Chars.isWhitespace(prev) + else + true; if (!whitespace_preceding) break :escaped; try self.break_word(true); self.eatComment(); @@ -2744,10 +2744,10 @@ pub fn NewLexer(comptime encoding: StringEncoding) type { ) { const tok: Token = switch (self.chars.state) { - .Normal => @unionInit(Token, "Text", .{ .start = start, .end = end }), - .Single => @unionInit(Token, "SingleQuotedText", .{ .start = start, .end = end }), - .Double => @unionInit(Token, "DoubleQuotedText", .{ .start = start, .end = end }), - }; + .Normal => @unionInit(Token, "Text", .{ .start = start, .end = end }), + .Single => @unionInit(Token, "SingleQuotedText", .{ .start = start, .end = end }), + .Double => @unionInit(Token, "DoubleQuotedText", .{ .start = start, .end = end }), + }; try self.tokens.append(tok); if (add_delimiter) { try self.tokens.append(.Delimit); @@ -2755,39 +2755,40 @@ pub fn NewLexer(comptime encoding: StringEncoding) type { } else if ((in_normal_space or in_operator) and self.tokens.items.len > 0 and // whether or not to add a delimiter token switch (self.tokens.items[self.tokens.items.len - 1]) { - .Var, - .VarArgv, - .Text, - .SingleQuotedText, - .DoubleQuotedText, - .BraceBegin, - .Comma, - .BraceEnd, - .CmdSubstEnd, - .Asterisk, - => true, + .Var, + .VarArgv, + .Text, + .SingleQuotedText, + .DoubleQuotedText, + .BraceBegin, + .Comma, + .BraceEnd, + .CmdSubstEnd, + .Asterisk, + => true, - .Pipe, - .DoublePipe, - .Ampersand, - .DoubleAmpersand, - .Redirect, - .Dollar, - .DoubleAsterisk, - .Eq, - .Semicolon, - .Newline, - .CmdSubstBegin, - .CmdSubstQuoted, - .OpenParen, - .CloseParen, - .JSObjRef, - .DoubleBracketOpen, - .DoubleBracketClose, - .Delimit, - .Eof, - => false, - }) { + .Pipe, + .DoublePipe, + .Ampersand, + .DoubleAmpersand, + .Redirect, + .Dollar, + .DoubleAsterisk, + .Eq, + .Semicolon, + .Newline, + .CmdSubstBegin, + .CmdSubstQuoted, + .OpenParen, + .CloseParen, + .JSObjRef, + .DoubleBracketOpen, + .DoubleBracketClose, + .Delimit, + .Eof, + => false, + }) + { try self.tokens.append(.Delimit); self.delimit_quote = false; } diff --git a/src/sql/postgres/postgres_protocol.zig b/src/sql/postgres/postgres_protocol.zig index c4347c9015..0416db70a0 100644 --- a/src/sql/postgres/postgres_protocol.zig +++ b/src/sql/postgres/postgres_protocol.zig @@ -809,9 +809,9 @@ pub const ErrorResponse = struct { const error_code: JSC.Error = // https://www.postgresql.org/docs/8.1/errcodes-appendix.html if (code.eqlComptime("42601")) - JSC.Error.ERR_POSTGRES_SYNTAX_ERROR - else - JSC.Error.ERR_POSTGRES_SERVER_ERROR; + JSC.Error.ERR_POSTGRES_SYNTAX_ERROR + else + JSC.Error.ERR_POSTGRES_SERVER_ERROR; const err = error_code.fmt(globalObject, "{s}", .{b.allocatedSlice()[0..b.len]}); inline for (possible_fields) |field| {