mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 03:25:23 +09:00
Fix lint errors on new luals version (#384)
This commit is contained in:
4
.github/workflows/fmtk.yml
vendored
4
.github/workflows/fmtk.yml
vendored
@@ -20,12 +20,12 @@ jobs:
|
||||
jq -s '.[0] * .[1].settings' temp.luarc.json ${{ github.workspace }}/factorio/config.json > check.luarc.json
|
||||
- name: Install LuaLS
|
||||
run: |
|
||||
wget https://github.com/LuaLS/lua-language-server/releases/download/3.13.2/lua-language-server-3.13.2-linux-x64.tar.gz -q -O lusls.tar.gz
|
||||
wget https://github.com/LuaLS/lua-language-server/releases/download/3.13.9/lua-language-server-3.13.9-linux-x64.tar.gz -q -O lusls.tar.gz
|
||||
mkdir luals && tar -xf lusls.tar.gz -C luals && rm lusls.tar.gz
|
||||
- name: Run Lint Report
|
||||
shell: bash
|
||||
run: |
|
||||
./luals/bin/lua-language-server --check=. --logpath=. --configpath=check.luarc.json --checklevel=Information
|
||||
./luals/bin/lua-language-server --check=. --logpath=. --configpath=check.luarc.json --checklevel=Information --check_out_path=check.json
|
||||
|
||||
# Credit to https://github.com/Krealle/luals-check-action/blob/main/action.yml
|
||||
# Although some minor fixes were needed
|
||||
|
||||
@@ -216,9 +216,10 @@ end
|
||||
--- @param actions_names string[] An array of action names
|
||||
--- @return defines.input_action[]
|
||||
local function names_to_actions(actions_names)
|
||||
--- @type defines.input_action[], number[], number
|
||||
local actions, invalid, invalid_i = {}, {}, 1
|
||||
for i, action_name in ipairs(actions_names) do
|
||||
local action = defines.input_action[action_name]
|
||||
local action = defines.input_action[action_name] --[[ @as defines.input_action? ]]
|
||||
if action then
|
||||
actions[i] = action
|
||||
else
|
||||
|
||||
@@ -87,7 +87,7 @@ function GuiData._metatable.__index(self, key)
|
||||
|
||||
-- Check a given child table based on the object type
|
||||
assert(type(key) == "userdata", "Index type '" .. ExpUtil.get_class_name(key) .. "' given to GuiData. Must be of type userdata.")
|
||||
local object_name = key.object_name
|
||||
local object_name = key.object_name --- @diagnostic disable-line assign-type-mismatch
|
||||
if object_name == "LuaGuiElement" then
|
||||
local data = self._raw.element_data
|
||||
local player_elements = data and data[key.player_index]
|
||||
@@ -110,7 +110,7 @@ end
|
||||
--- @param value unknown
|
||||
function GuiData._metatable.__newindex(self, key, value)
|
||||
assert(type(key) == "userdata", "Index type '" .. ExpUtil.get_class_name(key) .. "' given to GuiData. Must be of type userdata.")
|
||||
local object_name = key.object_name
|
||||
local object_name = key.object_name --- @diagnostic disable-line assign-type-mismatch
|
||||
if object_name == "LuaGuiElement" then
|
||||
local data = self.element_data
|
||||
local player_elements = data[key.player_index]
|
||||
|
||||
@@ -37,6 +37,7 @@ local function nop() return nil, nil end
|
||||
local function next_valid_element(elements, prev_index)
|
||||
local element_index, element = next(elements, prev_index)
|
||||
while element and not element.valid do
|
||||
--- @cast element_index -nil
|
||||
elements[element_index] = nil
|
||||
element_index, element = next(elements, element_index)
|
||||
end
|
||||
@@ -61,6 +62,7 @@ local function next_valid_player(scope_elements, players, prev_index, online)
|
||||
if index == nil then
|
||||
return nil, nil, nil
|
||||
end
|
||||
--- @cast player -nil
|
||||
|
||||
if online == nil or player.connected == online then
|
||||
local player_elements = scope_elements[player.index]
|
||||
|
||||
@@ -142,7 +142,7 @@ group:set_action('toggle_map_editor', false)
|
||||
|
||||
]]
|
||||
function PermissionsGroups._prototype:set_action(action, state)
|
||||
local input_action = defines.input_action[action]
|
||||
local input_action = defines.input_action[action] --[[ @as defines.input_action? ]]
|
||||
if input_action == nil then input_action = action end
|
||||
assert(type(input_action) == "number", tostring(action) .. " is not a valid input action")
|
||||
self.actions[input_action] = state
|
||||
|
||||
@@ -34,7 +34,7 @@ local function get_server_id(server)
|
||||
if server_count > 1 then
|
||||
return false, { "exp-commands_connect.too-many-matching", concat(server_names, ", ") }
|
||||
elseif server_count == 1 then
|
||||
local server_id, server_details = next(servers)
|
||||
local server_id, server_details = next(servers) --- @cast server_details -nil
|
||||
local status = External.get_server_status(server_id)
|
||||
if server_id == current_server.id then
|
||||
return false, { "exp-commands_connect.same-server", server_details.name }
|
||||
|
||||
@@ -42,7 +42,7 @@ local function check_type(value, type_name)
|
||||
if type_name == "userdata" then
|
||||
return false, value_type
|
||||
end
|
||||
value_type = value.object_name
|
||||
value_type = value.object_name --- @diagnostic disable-line assign-type-mismatch
|
||||
elseif value_type == "table" then
|
||||
if type_name == "table" then
|
||||
return false, value_type
|
||||
|
||||
Reference in New Issue
Block a user