Fix duplicate class and annotation placement lint errors

Classes contributed to by more than one file now carry the `partial`
attribute. trains.lua declared its command as `ExpCommand_Artillery`,
which was a copy paste.

`Color.0` and `MapPosition.0` became `.struct` in fmtk 2.1.6.

emmylua rejects `@type` on a function statement or a `do` block, so
those are moved onto the local or replaced by `@param` and `@return`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
bbassie
2026-08-07 15:31:18 +00:00
co-authored by Claude Opus 5
parent c6da1fd9ac
commit 90f32699c7
18 changed files with 29 additions and 30 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ The default permission authorities controlled by the flags: admin_only, system_o
local Storage = require("modules/exp_util/storage") local Storage = require("modules/exp_util/storage")
local Commands = require("modules/exp_commands") --- @class Commands local Commands = require("modules/exp_commands") --- @class (partial) Commands
local add, allow, deny = Commands.add_permission_authority, Commands.status.success, Commands.status.unauthorised local add, allow, deny = Commands.add_permission_authority, Commands.status.success, Commands.status.unauthorised
local authorities = {} local authorities = {}
+1 -1
View File
@@ -12,7 +12,7 @@ local ExpUtil = require("modules/exp_util")
local Async = require("modules/exp_util/async") local Async = require("modules/exp_util/async")
local Storage = require("modules/exp_util/storage") local Storage = require("modules/exp_util/storage")
local Commands = require("modules/exp_commands") --- @class Commands local Commands = require("modules/exp_commands") --- @class (partial) Commands
local rcon_env = {} --- @type table<string, any> local rcon_env = {} --- @type table<string, any>
local rcon_static = {} --- @type table<string, any> local rcon_static = {} --- @type table<string, any>
+1 -1
View File
@@ -25,7 +25,7 @@ local Commands = require("modules/exp_commands")
local add, parse = Commands.add_data_type, Commands.parse_input local add, parse = Commands.add_data_type, Commands.parse_input
local valid, invalid = Commands.status.success, Commands.status.invalid_input local valid, invalid = Commands.status.success, Commands.status.invalid_input
local types = {} --- @class Commands.types local types = {} --- @class (partial) Commands.types
--- A boolean value where true is one of: yes, y, true, 1 --- A boolean value where true is one of: yes, y, true, 1
types.boolean = types.boolean =
+2 -2
View File
@@ -61,7 +61,7 @@ local Search = require("modules/exp_commands/search")
--- @type LuaPlayer? --- @type LuaPlayer?
local _print_player local _print_player
--- @class Commands --- @class (partial) Commands
local Commands = { local Commands = {
color = ExpUtil.color, color = ExpUtil.color,
format_rich_text_color = ExpUtil.format_rich_text_color, format_rich_text_color = ExpUtil.format_rich_text_color,
@@ -84,7 +84,7 @@ local Commands = {
--- Contains the different status values a command can return --- Contains the different status values a command can return
Commands.status = {} Commands.status = {}
--- @class Commands.types: table<string, Commands.InputParser | Commands.InputParserFactory> --- @class (partial) Commands.types: table<string, Commands.InputParser | Commands.InputParserFactory>
--- Stores all input parsers and validators for different data types --- Stores all input parsers and validators for different data types
Commands.types = {} Commands.types = {}
+1 -1
View File
@@ -16,7 +16,7 @@ Storage.register(player_elements, function(tbl)
player_elements = tbl player_elements = tbl
end) end)
--- @class Gui --- @class (partial) Gui
local Gui = { local Gui = {
define = ExpElement.new, define = ExpElement.new,
from_argument = ExpElement.from_argument, from_argument = ExpElement.from_argument,
+1 -1
View File
@@ -1,4 +1,4 @@
--- @class Gui --- @class (partial) Gui
local Gui = require("modules/exp_gui") local Gui = require("modules/exp_gui")
--- @class Gui.elements --- @class Gui.elements
+1 -1
View File
@@ -1,4 +1,4 @@
--- @class Gui --- @class (partial) Gui
local Gui = require("modules/exp_gui") local Gui = require("modules/exp_gui")
--- @class Gui.styles --- @class Gui.styles
+1 -1
View File
@@ -1,5 +1,5 @@
--- @class Gui --- @class (partial) Gui
local Gui = require("modules/exp_gui") local Gui = require("modules/exp_gui")
local ExpElement = require("modules/exp_gui/prototype") local ExpElement = require("modules/exp_gui/prototype")
local mod_gui = require("mod-gui") local mod_gui = require("mod-gui")
+1 -1
View File
@@ -18,7 +18,7 @@ local valid, invalid = Commands.status.success, Commands.status.invalid_input
local Roles = require("modules.exp_legacy.expcore.roles") local Roles = require("modules.exp_legacy.expcore.roles")
local highest_role = Roles.get_player_highest_role local highest_role = Roles.get_player_highest_role
local types = {} --- @class Commands.types local types = {} --- @class (partial) Commands.types
--- A role defined by exp roles --- A role defined by exp roles
types.role = add("role", Commands.types.key_of(Roles.config.roles)) types.role = add("role", Commands.types.key_of(Roles.config.roles))
+4 -1
View File
@@ -11,7 +11,10 @@ local player_has_flag = Roles.player_has_flag
local Reports = require("modules.exp_legacy.modules.control.reports") --- @dep modules.control.reports local Reports = require("modules.exp_legacy.modules.control.reports") --- @dep modules.control.reports
--- @type Commands.InputParser --- @param input string
--- @param player LuaPlayer
--- @return Commands.Status
--- @return LuaPlayer | LocalisedString
local function reportable_player(input, player) local function reportable_player(input, player)
local success, status, result = parse_input(input, player, Commands.types.player) local success, status, result = parse_input(input, player, Commands.types.player)
if not success then return status, result end if not success then return status, result end
+6 -2
View File
@@ -10,7 +10,10 @@ local format_player_name = Commands.format_player_name_locale
local format_number = require("util").format_number local format_number = require("util").format_number
--- A player who is of a lower role than the executing player --- A player who is of a lower role than the executing player
--- @type Commands.InputParser --- @param input string
--- @param player LuaPlayer
--- @return Commands.Status
--- @return LuaItemPrototype | LocalisedString
local function parse_item(input, player) local function parse_item(input, player)
-- First Case - internal name is given -- First Case - internal name is given
-- Second Case - rich text is given -- Second Case - rich text is given
@@ -146,7 +149,8 @@ Commands.new("search-online", { "exp-commands_search.description-online" })
end) end)
--- Return the amount of an item a player has --- Return the amount of an item a player has
--- @type SortFunction --- @param data SearchResult
--- @return number
local function sort_by_count(data) local function sort_by_count(data)
return data.count return data.count
end end
+1 -1
View File
@@ -10,7 +10,7 @@ local format_number = require("util").format_number
local commands = {} local commands = {}
--- Set all trains to automatic --- Set all trains to automatic
--- @class ExpCommand_Artillery.commands.artillery: ExpCommand --- @class ExpCommand_Trains.commands.set_trains_to_automatic: ExpCommand
--- @overload fun(player: LuaPlayer, surface: LuaSurface?, force: LuaForce?) --- @overload fun(player: LuaPlayer, surface: LuaSurface?, force: LuaForce?)
commands.set_trains_to_automatic = Commands.new("set-trains-to-automatic", { "exp-commands_trains.description" }) commands.set_trains_to_automatic = Commands.new("set-trains-to-automatic", { "exp-commands_trains.description" })
:optional("surface", { "exp-commands_trains.arg-surface" }, Commands.types.surface) :optional("surface", { "exp-commands_trains.arg-surface" }, Commands.types.surface)
@@ -39,7 +39,7 @@ local function get_player_name(event)
end end
--- Convert a colour value into hex --- Convert a colour value into hex
--- @param color Color.0 --- @param color Color.struct
--- @return string --- @return string
local function to_hex(color) local function to_hex(color)
local hex_digits = "0123456789ABCDEF" local hex_digits = "0123456789ABCDEF"
@@ -53,7 +53,7 @@ local function to_hex(color)
end end
--- Emit the requires json to file for the given event arguments --- Emit the requires json to file for the given event arguments
--- @param opts { title: string?, color: (Color.0 | string)?, description: string?, tick: number?, fields: { name: string, value: string, inline: boolean? }[] } --- @param opts { title: string?, color: (Color.struct | string)?, description: string?, tick: number?, fields: { name: string, value: string, inline: boolean? }[] }
local function emit_event(opts) local function emit_event(opts)
local admins_online = 0 local admins_online = 0
local players_online = 0 local players_online = 0
+1 -1
View File
@@ -7,7 +7,7 @@ local config = require("modules.exp_legacy.config.spawn_area")
--- Apply an offset to a LuaPosition --- Apply an offset to a LuaPosition
--- @param position MapPosition --- @param position MapPosition
--- @param offset MapPosition --- @param offset MapPosition
--- @return MapPosition.0 --- @return MapPosition.struct
local function apply_offset(position, offset) local function apply_offset(position, offset)
return { return {
x = (position.x or position[1]) + (offset.x or offset[1]), x = (position.x or position[1]) + (offset.x or offset[1]),
+1 -2
View File
@@ -25,8 +25,7 @@ Elements.online_player_dropdown = Gui.define("player_dropdown")
} --[[ @as any ]] } --[[ @as any ]]
--- To help with caching and avoid context changes the player list from the previous update is remembered --- To help with caching and avoid context changes the player list from the previous update is remembered
--- @type (string?)[] do local _player_names = {} --- @type (string?)[]
do local _player_names = {}
--- Updates the player name list after a join or leave --- Updates the player name list after a join or leave
--- @return (string?)[] --- @return (string?)[]
function Elements.online_player_dropdown._update_player_names() function Elements.online_player_dropdown._update_player_names()
+1 -2
View File
@@ -47,8 +47,7 @@ Elements.bonus_used = Gui.define("player_bonus/bonus_used")
:element_data(0) --[[ @as any ]] :element_data(0) --[[ @as any ]]
--- Value is cached to save perf --- Value is cached to save perf
--- @type table<number, number> do local _points_limit = {} --- @type table<number, number>
do local _points_limit = {}
--- Clear the cache for points limit --- Clear the cache for points limit
--- @param player LuaPlayer --- @param player LuaPlayer
function Elements.bonus_used._clear_points_limit_cache(player) function Elements.bonus_used._clear_points_limit_cache(player)
@@ -326,8 +326,7 @@ function Elements.science_table.refresh_row(science_table, row_data)
Elements.production_label.refresh(row.used, row_data.used) Elements.production_label.refresh(row.used, row_data.used)
end end
--- @type table<string, { [string]: ExpGui_ScienceProduction.elements.science_table.row_data }> do local _row_data = {} --- @type table<string, { [string]: ExpGui_ScienceProduction.elements.science_table.row_data }>
do local _row_data = {}
--- Refresh the production tables for all online players --- Refresh the production tables for all online players
function Elements.science_table.refresh_online() function Elements.science_table.refresh_online()
-- Refresh the row data for online forces -- Refresh the row data for online forces
@@ -416,8 +415,7 @@ function Elements.eta_label.refresh(eta_label)
eta_label.tooltip = display_data.tooltip eta_label.tooltip = display_data.tooltip
end end
--- @type Elements.eta_label.display_data do local _display_data = {} --- @type Elements.eta_label.display_data
do local _display_data = {}
--- Refresh the eta label for all online players --- Refresh the eta label for all online players
function Elements.eta_label.refresh_online() function Elements.eta_label.refresh_online()
-- Refresh the row data for online forces -- Refresh the row data for online forces
@@ -477,8 +475,7 @@ local _fp_one_hour = defines.flow_precision_index.one_hour
--- @field ten_minutes ExpGui_ScienceProduction._item_data --- @field ten_minutes ExpGui_ScienceProduction._item_data
--- @field one_hour ExpGui_ScienceProduction._item_data --- @field one_hour ExpGui_ScienceProduction._item_data
--- @type table<string, { [string]: ExpGui_ScienceProduction.item_production_data }> do local _production_data = {} --- @type table<string, { [string]: ExpGui_ScienceProduction.item_production_data }>
do local _production_data = {}
--- Get the production stats for a force --- Get the production stats for a force
--- @param flow_stats any --- @param flow_stats any
-3
View File
@@ -261,7 +261,6 @@ local empty_table = setmetatable({}, {
--- Default status, will raise on_function_complete --- Default status, will raise on_function_complete
--- @param ... any The return value of the async call --- @param ... any The return value of the async call
--- @return Async.Status, any[] --- @return Async.Status, any[]
--- @type Async.Status
function Async.status.complete(...) function Async.status.complete(...)
if ... == nil then if ... == nil then
return Async.status.complete, empty_table return Async.status.complete, empty_table
@@ -272,7 +271,6 @@ end
--- Will queue the function to be called again on the next tick using the new arguments --- Will queue the function to be called again on the next tick using the new arguments
--- @param ... any The arguments to call the function with --- @param ... any The arguments to call the function with
--- @return Async.Status, any[] --- @return Async.Status, any[]
--- @type Async.Status
function Async.status.continue(...) function Async.status.continue(...)
if ... == nil then if ... == nil then
return Async.status.continue, empty_table return Async.status.continue, empty_table
@@ -284,7 +282,6 @@ end
--- @param ticks number The number of ticks to delay for --- @param ticks number The number of ticks to delay for
--- @param ... any The arguments to call the function with --- @param ... any The arguments to call the function with
--- @return Async.Status, number, any[] --- @return Async.Status, number, any[]
--- @type Async.Status
function Async.status.delay(ticks, ...) function Async.status.delay(ticks, ...)
ExpUtil.assert_argument_type(ticks, "number", 1, "ticks") ExpUtil.assert_argument_type(ticks, "number", 1, "ticks")
assert(ticks > 0, "Ticks must be a positive number") assert(ticks > 0, "Ticks must be a positive number")