From 3d76332c38b5621f415aadd0d4cf2205c478335a Mon Sep 17 00:00:00 2001 From: Samuel Lison Date: Thu, 18 Jun 2026 18:05:33 +1000 Subject: [PATCH] Add StyLua/Selene/luau-lsp toolchain and make the scaffold lint-clean Pin stylua, selene, and luau-lsp in rokit.toml so local dev and CI use the same versions, and add their configs (stylua.toml, selene.toml, .luaurc). Two behavior-preserving source touches make the existing scaffold pass: guard the optional iteration in Components.readAttributes (clears a luau-lsp type error) and normalize Gatherable.luau to StyLua's canonical form. Ignore the CI-fetched globalTypes.d.luau. Co-Authored-By: Claude Opus 4.8 --- .gitignore | 1 + .luaurc | 5 +++++ rokit.toml | 4 ++++ selene.toml | 12 ++++++++++++ src/components/Gatherable.luau | 4 +--- src/components/init.luau | 8 +++++--- stylua.toml | 12 ++++++++++++ 7 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 .luaurc create mode 100644 selene.toml create mode 100644 stylua.toml diff --git a/.gitignore b/.gitignore index e3d1fd1..c534f1f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Rojo / Roblox sourcemap.json +globalTypes.d.luau *.rbxl *.rbxlx *.rbxl.lock diff --git a/.luaurc b/.luaurc new file mode 100644 index 0000000..fd4d760 --- /dev/null +++ b/.luaurc @@ -0,0 +1,5 @@ +{ + "languageMode": "nonstrict", + "lintErrors": false, + "globals": [] +} diff --git a/rokit.toml b/rokit.toml index f9e5eea..1a33a9f 100644 --- a/rokit.toml +++ b/rokit.toml @@ -1,4 +1,8 @@ # Toolchain pins (https://github.com/rojo-rbx/rokit). Run `rokit install`. +# CI installs this exact set; pin versions so local dev and CI stay identical. [tools] rojo = "rojo-rbx/rojo@7.6.1" wally = "UpliftGames/wally@0.3.2" +stylua = "JohnnyMorganz/stylua@2.5.2" +selene = "Kampfkarren/selene@0.31.0" +luau-lsp = "JohnnyMorganz/luau-lsp@1.68.1" diff --git a/selene.toml b/selene.toml new file mode 100644 index 0000000..ea74587 --- /dev/null +++ b/selene.toml @@ -0,0 +1,12 @@ +# Selene lint configuration — CI runs `selene .` on every push/PR. +# Uses the Roblox standard library (globals like `game`, `task`, `typeof`, `warn`). +std = "roblox" + +# Generated Wally/Rojo artifacts are not ours to lint. +exclude = ["Packages", "ServerPackages", "DevPackages"] + +[lints] +# Roblox code legitimately leaves some values unused (e.g. connection handles); +# keep the high-signal lints and let the formatter own style. +empty_if = "warn" +unused_variable = "warn" diff --git a/src/components/Gatherable.luau b/src/components/Gatherable.luau index a3dc688..f9935b1 100644 --- a/src/components/Gatherable.luau +++ b/src/components/Gatherable.luau @@ -24,9 +24,7 @@ return Components.define({ onSetup = function(instance, values) instance:SetAttribute("_HP", values.HP) - local host = if instance:IsA("BasePart") - then instance - else instance:FindFirstChildWhichIsA("BasePart") + local host = if instance:IsA("BasePart") then instance else instance:FindFirstChildWhichIsA("BasePart") if not host then warn(`[Gatherable] '{instance:GetFullName()}' has no BasePart to host a prompt`) return diff --git a/src/components/init.luau b/src/components/init.luau index 6205c22..e3f8e64 100644 --- a/src/components/init.luau +++ b/src/components/init.luau @@ -37,9 +37,11 @@ end local function readAttributes(instance: Instance, attributes: { [string]: any }?) local values = {} - for attrName, default in attributes or {} do - local v = instance:GetAttribute(attrName) - values[attrName] = if v == nil then default else v + if attributes then + for attrName, default in attributes do + local v = instance:GetAttribute(attrName) + values[attrName] = if v == nil then default else v + end end return values end diff --git a/stylua.toml b/stylua.toml new file mode 100644 index 0000000..86229bf --- /dev/null +++ b/stylua.toml @@ -0,0 +1,12 @@ +# StyLua formatting rules — CI runs `stylua --check` on every push/PR. +# Tabs match the existing source; format with `stylua src demo` before committing. +column_width = 120 +line_endings = "Unix" +indent_type = "Tabs" +indent_width = 4 +quote_style = "AutoPreferDouble" +call_parentheses = "Always" +collapse_simple_statement = "Never" + +[sort_requires] +enabled = false