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

Add linting step for rbx_dom_lua #366

Merged
merged 6 commits into from
Oct 1, 2023
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
19 changes: 19 additions & 0 deletions .github/workflows/luau-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Luau Linting
on:
push:
branches: "master"
pull_request:
branches: "master"
paths: ["*.lua", "*.luau"]
jobs:
Lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ok-nick/[email protected]

- name: Run Selene
run: selene rbx_dom_lua/src

- name: Run StyLua
run: stylua rbx_dom_lua/src --check
1 change: 1 addition & 0 deletions aftman.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
rojo = "rojo-rbx/[email protected]"
run-in-roblox = "rojo-rbx/[email protected]"
selene = "Kampfkarren/[email protected]"
stylua = "JohnnyMorganz/[email protected]"
89 changes: 37 additions & 52 deletions rbx_dom_lua/src/EncodedValue.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ local function serializeFloat(value)
return value
end

local ALL_AXES = {"X", "Y", "Z"}
local ALL_FACES = {"Right", "Top", "Back", "Left", "Bottom", "Front"}
local ALL_AXES = { "X", "Y", "Z" }
local ALL_FACES = { "Right", "Top", "Back", "Left", "Bottom", "Front" }

local EncodedValue = {}

Expand All @@ -37,7 +37,10 @@ types = {
if ok then
output[key] = result
else
local warning = ("Could not decode attribute value of type %q: %s"):format(typeof(value), tostring(result))
local warning = ("Could not decode attribute value of type %q: %s"):format(
typeof(value),
tostring(result)
)
warn(warning)
end
end
Expand All @@ -53,7 +56,10 @@ types = {
if ok then
output[key] = result
else
local warning = ("Could not encode attribute value of type %q: %s"):format(typeof(value), tostring(result))
local warning = ("Could not encode attribute value of type %q: %s"):format(
typeof(value),
tostring(result)
)
warn(warning)
end
end
Expand Down Expand Up @@ -111,6 +117,7 @@ types = {
local pos = pod.position
local orient = pod.orientation

--stylua: ignore
return CFrame.new(
pos[1], pos[2], pos[3],
orient[1][1], orient[1][2], orient[1][3],
Expand All @@ -120,17 +127,14 @@ types = {
end,

toPod = function(roblox)
local x, y, z,
r00, r01, r02,
r10, r11, r12,
r20, r21, r22 = roblox:GetComponents()
local x, y, z, r00, r01, r02, r10, r11, r12, r20, r21, r22 = roblox:GetComponents()

return {
position = {x, y, z},
position = { x, y, z },
orientation = {
{r00, r01, r02},
{r10, r11, r12},
{r20, r21, r22},
{ r00, r01, r02 },
{ r10, r11, r12 },
{ r20, r21, r22 },
},
}
end,
Expand All @@ -140,7 +144,7 @@ types = {
fromPod = unpackDecoder(Color3.new),

toPod = function(roblox)
return {roblox.r, roblox.g, roblox.b}
return { roblox.r, roblox.g, roblox.b }
end,
},

Expand All @@ -161,10 +165,7 @@ types = {
local keypoints = {}

for index, keypoint in ipairs(pod.keypoints) do
keypoints[index] = ColorSequenceKeypoint.new(
keypoint.time,
types.Color3.fromPod(keypoint.color)
)
keypoints[index] = ColorSequenceKeypoint.new(keypoint.time, types.Color3.fromPod(keypoint.color))
end

return ColorSequence.new(keypoints)
Expand Down Expand Up @@ -279,7 +280,7 @@ types = {
pod[material.Name] = {
math.round(math.clamp(color.R, 0, 1) * 255),
math.round(math.clamp(color.G, 0, 1) * 255),
math.round(math.clamp(color.B, 0, 1) * 255)
math.round(math.clamp(color.B, 0, 1) * 255),
}
end
return pod
Expand All @@ -290,7 +291,7 @@ types = {
fromPod = unpackDecoder(NumberRange.new),

toPod = function(roblox)
return {roblox.Min, roblox.Max}
return { roblox.Min, roblox.Max }
end,
},

Expand All @@ -299,11 +300,7 @@ types = {
local keypoints = {}

for index, keypoint in ipairs(pod.keypoints) do
keypoints[index] = NumberSequenceKeypoint.new(
keypoint.time,
keypoint.value,
keypoint.envelope
)
keypoints[index] = NumberSequenceKeypoint.new(keypoint.time, keypoint.value, keypoint.envelope)
end

return NumberSequence.new(keypoints)
Expand Down Expand Up @@ -358,10 +355,7 @@ types = {

Ray = {
fromPod = function(pod)
return Ray.new(
types.Vector3.fromPod(pod.origin),
types.Vector3.fromPod(pod.direction)
)
return Ray.new(types.Vector3.fromPod(pod.origin), types.Vector3.fromPod(pod.direction))
end,

toPod = function(roblox)
Expand All @@ -374,10 +368,7 @@ types = {

Rect = {
fromPod = function(pod)
return Rect.new(
types.Vector2.fromPod(pod[1]),
types.Vector2.fromPod(pod[2])
)
return Rect.new(types.Vector2.fromPod(pod[1]), types.Vector2.fromPod(pod[2]))
end,

toPod = function(roblox)
Expand All @@ -389,31 +380,28 @@ types = {
},

Ref = {
fromPod = function(_pod)
fromPod = function(_)
error("Ref cannot be decoded on its own")
end,

toPod = function(_roblox)
toPod = function(_)
error("Ref can not be encoded on its own")
end,
},

Region3 = {
fromPod = function(pod)
fromPod = function(_)
error("Region3 is not implemented")
end,

toPod = function(roblox)
toPod = function(_)
error("Region3 is not implemented")
end,
},

Region3int16 = {
fromPod = function(pod)
return Region3int16.new(
types.Vector3int16.fromPod(pod[1]),
types.Vector3int16.fromPod(pod[2])
)
return Region3int16.new(types.Vector3int16.fromPod(pod[1]), types.Vector3int16.fromPod(pod[2]))
end,

toPod = function(roblox)
Expand All @@ -425,20 +413,20 @@ types = {
},

SecurityCapabilities = {
fromPod = function(pod)
fromPod = function(_pod)
error("SecurityCapabilities is not implemented")
end,
toPod = function(roblox)
toPod = function(_roblox)
error("SecurityCapabilities is not implemented")
end
end,
},

SharedString = {
fromPod = function(pod)
fromPod = function(_pod)
error("SharedString is not supported")
end,

toPod = function(roblox)
toPod = function(_roblox)
error("SharedString is not supported")
end,
},
Expand All @@ -452,16 +440,13 @@ types = {
fromPod = unpackDecoder(UDim.new),

toPod = function(roblox)
return {roblox.Scale, roblox.Offset}
return { roblox.Scale, roblox.Offset }
end,
},

UDim2 = {
fromPod = function(pod)
return UDim2.new(
types.UDim.fromPod(pod[1]),
types.UDim.fromPod(pod[2])
)
return UDim2.new(types.UDim.fromPod(pod[1]), types.UDim.fromPod(pod[2]))
end,

toPod = function(roblox)
Expand Down Expand Up @@ -492,7 +477,7 @@ types = {
fromPod = unpackDecoder(Vector2int16.new),

toPod = function(roblox)
return {roblox.X, roblox.Y}
return { roblox.X, roblox.Y }
end,
},

Expand All @@ -512,7 +497,7 @@ types = {
fromPod = unpackDecoder(Vector3int16.new),

toPod = function(roblox)
return {roblox.X, roblox.Y, roblox.Z}
return { roblox.X, roblox.Y, roblox.Z }
end,
},
}
Expand Down
2 changes: 1 addition & 1 deletion rbx_dom_lua/src/Error.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ function Error:__tostring()
return ("Error(%s: %s)"):format(self.kind, tostring(self.extra))
end

return Error
return Error
2 changes: 1 addition & 1 deletion rbx_dom_lua/src/base64.lua
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@ end
return {
decode = decodeBase64,
encode = encodeBase64,
}
}
24 changes: 12 additions & 12 deletions rbx_dom_lua/src/base64.spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ return function()
try("M", "TQ==")
try("ManM", "TWFuTQ==")
try(
[[Man is distinguished, not only by his reason, but by this ]]..
[[singular passion from other animals, which is a lust of the ]]..
[[mind, that by a perseverance of delight in the continued and ]]..
[[indefatigable generation of knowledge, exceeds the short ]]..
[[vehemence of any carnal pleasure.]],
[[TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sI]]..
[[GJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYW]]..
[[xzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJ]]..
[[zZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRl]]..
[[ZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZ]]..
[[SBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=]]
[[Man is distinguished, not only by his reason, but by this ]]
.. [[singular passion from other animals, which is a lust of the ]]
.. [[mind, that by a perseverance of delight in the continued and ]]
.. [[indefatigable generation of knowledge, exceeds the short ]]
.. [[vehemence of any carnal pleasure.]],
[[TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sI]]
.. [[GJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYW]]
.. [[xzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJ]]
.. [[zZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRl]]
.. [[ZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZ]]
.. [[SBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=]]
)
end)
end
end
4 changes: 2 additions & 2 deletions rbx_dom_lua/src/customProperties.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ return {
},
LocalizationTable = {
Contents = {
read = function(instance, key)
read = function(instance, _)
return true, instance:GetContents()
end,
write = function(instance, key, value)
write = function(instance, _, value)
instance:SetContents(value)
return true
end,
Expand Down
3 changes: 2 additions & 1 deletion rbx_dom_lua/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ local function findCanonicalPropertyDescriptor(className, propertyName)
return PropertyDescriptor.fromRaw(
currentClass.Properties[aliasData.AliasFor],
currentClassName,
aliasData.AliasFor)
aliasData.AliasFor
)
end

return nil
Expand Down
2 changes: 1 addition & 1 deletion rbx_dom_lua/src/init.spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ return function()
it("should load", function()
expect(RbxDom).to.be.ok()
end)
end
end
2 changes: 2 additions & 0 deletions selene.toml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
std = "roblox"

exclude = ["*.spec.lua"]