Skip to content

inconsistent formatting of parenthesized cast expression #466

@matthargett

Description

@matthargett

sample code below, some supporting screenshots:
image

stylua reformats, but still exceeds the line limit -- unless its somehow not counting the indentation tabs as 4 spaces?

function AssertionError.new(options: AssertionErrorOptions): AssertionError
	if message ~= nil then
		self = (setmetatable(Error.new(tostring(message)), AssertionError) :: any) :: AssertionError
	else
		if operator == "deepStrictEqual" or operator == "strictEqual" then
			-- StyLua does NOT break this up correctly
			self = (setmetatable(Error.new(createErrDiff(actual, expected, operator)), AssertionError) :: any) :: AssertionError
		elseif operator == "notDeepStrictEqual" or operator == "notStrictEqual" then
			if #res == 1 then
				-- StyLua DOES break this up correctly
				self = (
					setmetatable(
						Error.new(("%s%s%s"):format(base, if string.len(res[1]) > 5 then "\n\n" else " ", res[1])),
						AssertionError
					) :: any
				) :: AssertionError
			else
				-- StyLua DOES break this up correctly
				self = (
					setmetatable(Error.new(("%s\n\n%s\n"):format(base, Array.join(res, "\n"))), AssertionError) :: any
				) :: AssertionError
			end
		end
	end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions