selene -> luacheck

Greatly simplifies the Makefile.
This commit is contained in:
Sage Vaillancourt 2025-02-16 15:12:58 -05:00
parent bbaaca4a2d
commit db1409d94d
14 changed files with 31 additions and 87 deletions

View File

@ -1,5 +1,3 @@
SOURCE_FILES := $(shell grep "import '" src/main.lua | grep -v CoreLibs | sed "s/.*'\(.*\)'.*/src\/\1/") src/main.lua
all: all:
pdc --skip-unknown src BatterUp.pdx pdc --skip-unknown src BatterUp.pdx
@ -8,7 +6,7 @@ assets:
check: assets check: assets
stylua -c --indent-type Spaces src/ stylua -c --indent-type Spaces src/
cat __stub.ext.lua <(sed 's/^function/-- selene: allow(unused_variable)\nfunction/' ${PLAYDATE_SDK_PATH}/CoreLibs/__types.lua) ${SOURCE_FILES} | grep -v '^import' | sed 's/<const>//g' | selene - luacheck -d --codes src/ --exclude-files src/test/
test: check test: check
(cd src; find ./test -name '*lua' | xargs -L1 lua) (cd src; find ./test -name '*lua' | xargs -L1 lua)

View File

@ -1,4 +1,3 @@
-- selene: allow(unscoped_variables)
actionQueue = { actionQueue = {
---@type table<any, { coroutine: thread, expireTimeMs: number }> ---@type table<any, { coroutine: thread, expireTimeMs: number }>
queue = {}, queue = {},
@ -6,7 +5,6 @@ actionQueue = {
---@alias Action fun(deltaSeconds: number) ---@alias Action fun(deltaSeconds: number)
--selene: allow(incorrect_standard_library_use)
local close = coroutine.close local close = coroutine.close
--- Added actions will be called on every runWaiting() update. --- Added actions will be called on every runWaiting() update.

View File

@ -1,4 +1,3 @@
-- selene: allow(shadowing)
local gfx = playdate.graphics local gfx = playdate.graphics
local AnnouncementFont <const> = playdate.graphics.font.new("fonts/Roobert-20-Medium.pft") local AnnouncementFont <const> = playdate.graphics.font.new("fonts/Roobert-20-Medium.pft")
@ -10,7 +9,6 @@ local AnnouncerAnimatorInY <const> =
local AnnouncerAnimatorOutY <const> = local AnnouncerAnimatorOutY <const> =
playdate.graphics.animator.new(AnnouncementTransitionMs, 0, -70, playdate.easingFunctions.outQuint) playdate.graphics.animator.new(AnnouncementTransitionMs, 0, -70, playdate.easingFunctions.outQuint)
-- selene: allow(unscoped_variables)
---@class Announcer ---@class Announcer
---@field textQueue string[] ---@field textQueue string[]
---@field animatorY pd_animator ---@field animatorY pd_animator

View File

@ -1,90 +1,61 @@
-- GENERATED FILE - DO NOT EDIT -- GENERATED FILE - DO NOT EDIT
-- Instead, edit the source file directly: assets.lua2p. -- Instead, edit the source file directly: assets.lua2p.
--selene: allow(unused_variable) -- luacheck: ignore
--selene: allow(unscoped_variables)
DarkPlayerBack = playdate.graphics.image.new("images/game/DarkPlayerBack.png") DarkPlayerBack = playdate.graphics.image.new("images/game/DarkPlayerBack.png")
--selene: allow(unused_variable) -- luacheck: ignore
--selene: allow(unscoped_variables)
Glove = playdate.graphics.image.new("images/game/Glove.png") Glove = playdate.graphics.image.new("images/game/Glove.png")
--selene: allow(unused_variable) -- luacheck: ignore
--selene: allow(unscoped_variables)
PlayerFrown = playdate.graphics.image.new("images/game/PlayerFrown.png") PlayerFrown = playdate.graphics.image.new("images/game/PlayerFrown.png")
--selene: allow(unused_variable) -- luacheck: ignore
--selene: allow(unscoped_variables)
GloveHoldingBall = playdate.graphics.image.new("images/game/GloveHoldingBall.png") GloveHoldingBall = playdate.graphics.image.new("images/game/GloveHoldingBall.png")
--selene: allow(unused_variable) -- luacheck: ignore
--selene: allow(unscoped_variables)
GameLogo = playdate.graphics.image.new("images/game/GameLogo.png") GameLogo = playdate.graphics.image.new("images/game/GameLogo.png")
--selene: allow(unused_variable) -- luacheck: ignore
--selene: allow(unscoped_variables)
Hat = playdate.graphics.image.new("images/game/Hat.png") Hat = playdate.graphics.image.new("images/game/Hat.png")
--selene: allow(unused_variable) -- luacheck: ignore
--selene: allow(unscoped_variables)
DarkPlayerBase = playdate.graphics.image.new("images/game/DarkPlayerBase.png") DarkPlayerBase = playdate.graphics.image.new("images/game/DarkPlayerBase.png")
--selene: allow(unused_variable) -- luacheck: ignore
--selene: allow(unscoped_variables)
MenuImage = playdate.graphics.image.new("images/game/MenuImage.png") MenuImage = playdate.graphics.image.new("images/game/MenuImage.png")
--selene: allow(unused_variable) -- luacheck: ignore
--selene: allow(unscoped_variables)
PlayerSmile = playdate.graphics.image.new("images/game/PlayerSmile.png") PlayerSmile = playdate.graphics.image.new("images/game/PlayerSmile.png")
--selene: allow(unused_variable) -- luacheck: ignore
--selene: allow(unscoped_variables)
Minimap = playdate.graphics.image.new("images/game/Minimap.png") Minimap = playdate.graphics.image.new("images/game/Minimap.png")
--selene: allow(unused_variable) -- luacheck: ignore
--selene: allow(unscoped_variables)
GrassBackground = playdate.graphics.image.new("images/game/GrassBackground.png") GrassBackground = playdate.graphics.image.new("images/game/GrassBackground.png")
--selene: allow(unused_variable) -- luacheck: ignore
--selene: allow(unscoped_variables)
LightPlayerBase = playdate.graphics.image.new("images/game/LightPlayerBase.png") LightPlayerBase = playdate.graphics.image.new("images/game/LightPlayerBase.png")
--selene: allow(unused_variable) -- luacheck: ignore
--selene: allow(unscoped_variables)
LightPlayerBack = playdate.graphics.image.new("images/game/LightPlayerBack.png") LightPlayerBack = playdate.graphics.image.new("images/game/LightPlayerBack.png")
--selene: allow(unused_variable) -- luacheck: ignore
--selene: allow(unscoped_variables)
BatCrackReverb = playdate.sound.sampleplayer.new("sounds/BatCrackReverb.wav") BatCrackReverb = playdate.sound.sampleplayer.new("sounds/BatCrackReverb.wav")
--selene: allow(unused_variable) -- luacheck: ignore
--selene: allow(unscoped_variables)
BootTune = playdate.sound.sampleplayer.new("music/BootTune.wav") BootTune = playdate.sound.sampleplayer.new("music/BootTune.wav")
--selene: allow(unused_variable) -- luacheck: ignore
--selene: allow(unscoped_variables)
BootTuneOrgany = playdate.sound.sampleplayer.new("music/BootTuneOrgany.wav") BootTuneOrgany = playdate.sound.sampleplayer.new("music/BootTuneOrgany.wav")
--selene: allow(unused_variable) -- luacheck: ignore
--selene: allow(unscoped_variables)
TinnyBackground = playdate.sound.sampleplayer.new("music/TinnyBackground.wav") TinnyBackground = playdate.sound.sampleplayer.new("music/TinnyBackground.wav")
--selene: allow(unused_variable)
--selene: allow(unscoped_variables)
Logos = { Logos = {
--selene: allow(unused_variable)
--selene: allow(unscoped_variables)
{ name = "Base", image = playdate.graphics.image.new("images/game/logos/Base.png") }, { name = "Base", image = playdate.graphics.image.new("images/game/logos/Base.png") },
--selene: allow(unused_variable) -- luacheck: ignore
--selene: allow(unscoped_variables)
{ name = "Cats", image = playdate.graphics.image.new("images/game/logos/Cats.png") }, { name = "Cats", image = playdate.graphics.image.new("images/game/logos/Cats.png") },
--selene: allow(unused_variable) -- luacheck: ignore
--selene: allow(unscoped_variables)
{ name = "Hearts", image = playdate.graphics.image.new("images/game/logos/Hearts.png") }, { name = "Hearts", image = playdate.graphics.image.new("images/game/logos/Hearts.png") },
--selene: allow(unused_variable) -- luacheck: ignore
--selene: allow(unscoped_variables)
{ name = "Checkmarks", image = playdate.graphics.image.new("images/game/logos/Checkmarks.png") }, { name = "Checkmarks", image = playdate.graphics.image.new("images/game/logos/Checkmarks.png") },
--selene: allow(unused_variable) -- luacheck: ignore
--selene: allow(unscoped_variables)
{ name = "Smiles", image = playdate.graphics.image.new("images/game/logos/Smiles.png") }, { name = "Smiles", image = playdate.graphics.image.new("images/game/logos/Smiles.png") },
--selene: allow(unused_variable) -- luacheck: ignore
--selene: allow(unscoped_variables)
{ name = "FingerGuns", image = playdate.graphics.image.new("images/game/logos/FingerGuns.png") }, { name = "FingerGuns", image = playdate.graphics.image.new("images/game/logos/FingerGuns.png") },
--selene: allow(unused_variable) -- luacheck: ignore
--selene: allow(unscoped_variables)
{ name = "Frown", image = playdate.graphics.image.new("images/game/logos/Frown.png") }, { name = "Frown", image = playdate.graphics.image.new("images/game/logos/Frown.png") },
--selene: allow(unused_variable) -- luacheck: ignore
--selene: allow(unscoped_variables)
{ name = "Arrows", image = playdate.graphics.image.new("images/game/logos/Arrows.png") }, { name = "Arrows", image = playdate.graphics.image.new("images/game/logos/Arrows.png") },
--selene: allow(unused_variable) -- luacheck: ignore
--selene: allow(unscoped_variables)
{ name = "Turds", image = playdate.graphics.image.new("images/game/logos/Turds.png") }, { name = "Turds", image = playdate.graphics.image.new("images/game/logos/Turds.png") },
} }

View File

@ -4,7 +4,7 @@
return varName .. ' = ' .. value return varName .. ' = ' .. value
end end
--Open directory look for files, save data in p. By giving '-type f' as parameter, it returns all files. --Open directory look for files, save data in p. By giving '-type f' as parameter, it returns all files.
local p = io.popen('find src/' .. dir .. ' -type f -maxdepth 1') local p = io.popen('find src/' .. dir .. ' -maxdepth 1 -type f')
local assetCode = "" local assetCode = ""
--Loop through all files --Loop through all files
@ -12,8 +12,7 @@
if file:find(extension) then if file:find(extension) then
local varName = file:gsub(".*/(.*)." .. extension, "%1") local varName = file:gsub(".*/(.*)." .. extension, "%1")
file = file:gsub("src/", "") file = file:gsub("src/", "")
assetCode = assetCode .. '--selene: allow(unused_variable)\n' assetCode = assetCode .. '-- luacheck: ignore\n'
assetCode = assetCode .. '--selene: allow(unscoped_variables)\n'
assetCode = assetCode .. handle(varName, newFunc .. '("' .. file .. '")') .. sep assetCode = assetCode .. handle(varName, newFunc .. '("' .. file .. '")') .. sep
end end
end end
@ -27,11 +26,7 @@ end)!!(generatedFileWarning())
!!(dirLookup('images/game', 'png', 'playdate.graphics.image.new')) !!(dirLookup('images/game', 'png', 'playdate.graphics.image.new'))
!!(dirLookup('sounds', 'wav', 'playdate.sound.sampleplayer.new')) !!(dirLookup('sounds', 'wav', 'playdate.sound.sampleplayer.new'))
!!(dirLookup('music', 'wav', 'playdate.sound.sampleplayer.new')) !!(dirLookup('music', 'wav', 'playdate.sound.sampleplayer.new'))
--selene: allow(unused_variable)
--selene: allow(unscoped_variables)
Logos = { Logos = {
--selene: allow(unused_variable)
--selene: allow(unscoped_variables)
{ name = "Base", image = playdate.graphics.image.new("images/game/logos/Base.png") }, { name = "Base", image = playdate.graphics.image.new("images/game/logos/Base.png") },
!!(dirLookup('images/game/logos -not -name "Base.png"', 'png', 'playdate.graphics.image.new', ",\n", function(varName, value) !!(dirLookup('images/game/logos -not -name "Base.png"', 'png', 'playdate.graphics.image.new', ",\n", function(varName, value)

View File

@ -1,4 +1,3 @@
-- selene: allow(unscoped_variables)
---@class Ball ---@class Ball
---@field x number ---@field x number
---@field y number ---@field y number

View File

@ -6,7 +6,6 @@
--- forcedTo: Base | nil, --- forcedTo: Base | nil,
--- } --- }
-- selene: allow(unscoped_variables)
---@class Baserunning ---@class Baserunning
---@field runners Runner[] ---@field runners Runner[]
---@field outRunners Runner[] ---@field outRunners Runner[]
@ -255,6 +254,7 @@ function Baserunning:updateNonBatterRunners(appliedSpeed, forcedOnly, deltaSecon
return someRunnerMoved, runnersScored return someRunnerMoved, runnersScored
end end
-- luacheck: ignore
if not playdate or playdate.TEST_MODE then if not playdate or playdate.TEST_MODE then
return Baserunning return Baserunning
end end

View File

@ -1,4 +1,3 @@
-- selene: allow(unscoped_variables)
C = {} C = {}
C.Screen = { C.Screen = {

View File

@ -1,7 +1,5 @@
-- selene: allow(unscoped_variables)
dbg = {} dbg = {}
-- selene: allow(unused_variable)
function dbg.label(value, name) function dbg.label(value, name)
if type(value) == "table" then if type(value) == "table" then
print(name .. ":") print(name .. ":")
@ -19,7 +17,6 @@ function dbg.label(value, name)
end end
-- Only works if called with the bases empty (i.e. the only runner should be the batter. -- Only works if called with the bases empty (i.e. the only runner should be the batter.
-- selene: allow(unused_variable)
function dbg.loadTheBases(br) function dbg.loadTheBases(br)
br:pushNewBatter() br:pushNewBatter()
br:pushNewBatter() br:pushNewBatter()
@ -38,7 +35,6 @@ function dbg.loadTheBases(br)
br.runners[4].nextBase = C.Bases[C.Home] br.runners[4].nextBase = C.Bases[C.Home]
end end
-- selene: allow(unused_variable)
---@param points XyPair[] ---@param points XyPair[]
function dbg.drawLine(points) function dbg.drawLine(points)
for i = 2, #points do for i = 2, #points do

View File

@ -7,13 +7,11 @@
-- TODO: Run down baserunners in a pickle. -- TODO: Run down baserunners in a pickle.
-- selene: allow(unscoped_variables)
---@class Fielding ---@class Fielding
---@field fielders table<string, Fielder> ---@field fielders table<string, Fielder>
---@field fielderHoldingBall Fielder | nil ---@field fielderHoldingBall Fielder | nil
Fielding = {} Fielding = {}
-- selene: allow(unscoped_variables)
FielderDanceAnimator = playdate.graphics.animator.new(1, 10, 0, utils.easingHill) FielderDanceAnimator = playdate.graphics.animator.new(1, 10, 0, utils.easingHill)
FielderDanceAnimator.repeatCount = C.DanceBounceCount - 1 FielderDanceAnimator.repeatCount = C.DanceBounceCount - 1
@ -188,6 +186,7 @@ function Fielding:celebrate()
FielderDanceAnimator:reset(C.DanceBounceMs) FielderDanceAnimator:reset(C.DanceBounceMs)
end end
-- luacheck: ignore
if not playdate or playdate.TEST_MODE then if not playdate or playdate.TEST_MODE then
return { Fielding, newFielder } return { Fielding, newFielder }
end end

View File

@ -22,7 +22,6 @@ end
---@class Blipper ---@class Blipper
---@field draw fun(self: self, disableBlipping: boolean, x: number, y: number) ---@field draw fun(self: self, disableBlipping: boolean, x: number, y: number)
-- selene: allow(unscoped_variables)
blipper = {} blipper = {}
--- Build an object that simply "blips" between the given images at the given interval. --- Build an object that simply "blips" between the given images at the given interval.

View File

@ -1,13 +1,10 @@
-- selene: allow(unscoped_variables)
---@class MainMenu ---@class MainMenu
MainMenu = { MainMenu = {
---@type { new: fun(settings: Settings): { update: fun(self) } } ---@type { new: fun(settings: Settings): { update: fun(self) } }
next = nil, next = nil,
} }
-- selene: allow(shadowing)
local gfx = playdate.graphics local gfx = playdate.graphics
-- selene: allow(shadowing)
local StartFont <const> = gfx.font.new("fonts/Roobert-20-Medium.pft") local StartFont <const> = gfx.font.new("fonts/Roobert-20-Medium.pft")
--- Take control of playdate.update --- Take control of playdate.update

View File

@ -42,7 +42,6 @@ import 'npc.lua'
-- TODO: Customizable field structure. E.g. stands and ads etc. -- TODO: Customizable field structure. E.g. stands and ads etc.
-- selene: allow(shadowing)
local gfx <const>, C <const> = playdate.graphics, C local gfx <const>, C <const> = playdate.graphics, C
---@alias Team { score: number, benchPosition: XyPair } ---@alias Team { score: number, benchPosition: XyPair }
@ -95,7 +94,6 @@ local teams <const> = {
---@field private homeTeamBlipper Blipper ---@field private homeTeamBlipper Blipper
---@field private awayTeamBlipper Blipper ---@field private awayTeamBlipper Blipper
---@field private state MutableState ---@field private state MutableState
-- selene: allow(unscoped_variables)
Game = {} Game = {}
---@param settings Settings ---@param settings Settings

View File

@ -1,4 +1,4 @@
-- selene: allow(unscoped_variables) -- luacheck no new globals
utils = {} utils = {}
--- @alias XyPair { --- @alias XyPair {
@ -232,13 +232,11 @@ function utils.getNearestOf(array, x, y, extraCondition)
return nearest, nearestDistance return nearest, nearestDistance
end end
-- selene: allow(unscoped_variables)
PitchOutcomes = { PitchOutcomes = {
StrikeOut = {}, StrikeOut = {},
Walk = {}, Walk = {},
} }
-- selene: allow(unscoped_variables)
pitchTracker = { pitchTracker = {
--- Position of the pitch, or nil, if one has not been recorded. --- Position of the pitch, or nil, if one has not been recorded.
---@type number | nil ---@type number | nil
@ -277,7 +275,6 @@ pitchTracker = {
-- Throw Meter -- -- Throw Meter --
----------------- -----------------
-- selene: allow(unscoped_variables)
throwMeter = { throwMeter = {
value = 0, value = 0,
} }