diff --git a/.github/workflows/luau-lint.yml b/.github/workflows/luau-lint.yml new file mode 100644 index 000000000..f8ef3c894 --- /dev/null +++ b/.github/workflows/luau-lint.yml @@ -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/setup-aftman@v0.4.2 + + - name: Run Selene + run: selene rbx_dom_lua/src + + - name: Run StyLua + run: stylua rbx_dom_lua/src --check \ No newline at end of file diff --git a/aftman.toml b/aftman.toml index a16eeefb6..b1bd6be64 100644 --- a/aftman.toml +++ b/aftman.toml @@ -2,3 +2,4 @@ rojo = "rojo-rbx/rojo@7.3.0" run-in-roblox = "rojo-rbx/run-in-roblox@0.3.0" selene = "Kampfkarren/selene@0.25.0" +stylua = "JohnnyMorganz/StyLua@0.18.2" diff --git a/rbx_dom_lua/src/EncodedValue.lua b/rbx_dom_lua/src/EncodedValue.lua index c28ef88e8..b1a9ac13d 100644 --- a/rbx_dom_lua/src/EncodedValue.lua +++ b/rbx_dom_lua/src/EncodedValue.lua @@ -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 = {} @@ -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 @@ -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 @@ -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], @@ -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, @@ -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, }, @@ -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) @@ -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 @@ -290,7 +291,7 @@ types = { fromPod = unpackDecoder(NumberRange.new), toPod = function(roblox) - return {roblox.Min, roblox.Max} + return { roblox.Min, roblox.Max } end, }, @@ -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) @@ -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) @@ -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) @@ -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) @@ -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, }, @@ -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) @@ -492,7 +477,7 @@ types = { fromPod = unpackDecoder(Vector2int16.new), toPod = function(roblox) - return {roblox.X, roblox.Y} + return { roblox.X, roblox.Y } end, }, @@ -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, }, } diff --git a/rbx_dom_lua/src/Error.lua b/rbx_dom_lua/src/Error.lua index d4c8b1ca2..5b8f582c2 100644 --- a/rbx_dom_lua/src/Error.lua +++ b/rbx_dom_lua/src/Error.lua @@ -25,4 +25,4 @@ function Error:__tostring() return ("Error(%s: %s)"):format(self.kind, tostring(self.extra)) end -return Error \ No newline at end of file +return Error diff --git a/rbx_dom_lua/src/base64.lua b/rbx_dom_lua/src/base64.lua index 33011306c..0ea19d395 100644 --- a/rbx_dom_lua/src/base64.lua +++ b/rbx_dom_lua/src/base64.lua @@ -136,4 +136,4 @@ end return { decode = decodeBase64, encode = encodeBase64, -} \ No newline at end of file +} diff --git a/rbx_dom_lua/src/base64.spec.lua b/rbx_dom_lua/src/base64.spec.lua index 5f2a5f4a9..f1704bbcb 100644 --- a/rbx_dom_lua/src/base64.spec.lua +++ b/rbx_dom_lua/src/base64.spec.lua @@ -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 \ No newline at end of file +end diff --git a/rbx_dom_lua/src/customProperties.lua b/rbx_dom_lua/src/customProperties.lua index d4d6f7238..624523b6d 100644 --- a/rbx_dom_lua/src/customProperties.lua +++ b/rbx_dom_lua/src/customProperties.lua @@ -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, diff --git a/rbx_dom_lua/src/init.lua b/rbx_dom_lua/src/init.lua index 4230a0a1a..2d390a24c 100644 --- a/rbx_dom_lua/src/init.lua +++ b/rbx_dom_lua/src/init.lua @@ -24,7 +24,8 @@ local function findCanonicalPropertyDescriptor(className, propertyName) return PropertyDescriptor.fromRaw( currentClass.Properties[aliasData.AliasFor], currentClassName, - aliasData.AliasFor) + aliasData.AliasFor + ) end return nil diff --git a/rbx_dom_lua/src/init.spec.lua b/rbx_dom_lua/src/init.spec.lua index 4cafe5ae9..d95eb44ff 100644 --- a/rbx_dom_lua/src/init.spec.lua +++ b/rbx_dom_lua/src/init.spec.lua @@ -4,4 +4,4 @@ return function() it("should load", function() expect(RbxDom).to.be.ok() end) -end \ No newline at end of file +end diff --git a/selene.toml b/selene.toml index c4ddb460d..9048c0700 100644 --- a/selene.toml +++ b/selene.toml @@ -1 +1,3 @@ std = "roblox" + +exclude = ["*.spec.lua"]