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:
pdc --skip-unknown src BatterUp.pdx
@ -8,7 +6,7 @@ assets:
check: assets
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
(cd src; find ./test -name '*lua' | xargs -L1 lua)

View File

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

View File

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

View File

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

View File

@ -4,7 +4,7 @@
return varName .. ' = ' .. value
end
--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 = ""
--Loop through all files
@ -12,8 +12,7 @@
if file:find(extension) then
local varName = file:gsub(".*/(.*)." .. extension, "%1")
file = file:gsub("src/", "")
assetCode = assetCode .. '--selene: allow(unused_variable)\n'
assetCode = assetCode .. '--selene: allow(unscoped_variables)\n'
assetCode = assetCode .. '-- luacheck: ignore\n'
assetCode = assetCode .. handle(varName, newFunc .. '("' .. file .. '")') .. sep
end
end
@ -27,11 +26,7 @@ end)!!(generatedFileWarning())
!!(dirLookup('images/game', 'png', 'playdate.graphics.image.new'))
!!(dirLookup('sounds', 'wav', 'playdate.sound.sampleplayer.new'))
!!(dirLookup('music', 'wav', 'playdate.sound.sampleplayer.new'))
--selene: allow(unused_variable)
--selene: allow(unscoped_variables)
Logos = {
--selene: allow(unused_variable)
--selene: allow(unscoped_variables)
{ 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)

View File

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

View File

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

View File

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

View File

@ -1,7 +1,5 @@
-- selene: allow(unscoped_variables)
dbg = {}
-- selene: allow(unused_variable)
function dbg.label(value, name)
if type(value) == "table" then
print(name .. ":")
@ -19,7 +17,6 @@ function dbg.label(value, name)
end
-- 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)
br:pushNewBatter()
br:pushNewBatter()
@ -38,7 +35,6 @@ function dbg.loadTheBases(br)
br.runners[4].nextBase = C.Bases[C.Home]
end
-- selene: allow(unused_variable)
---@param points XyPair[]
function dbg.drawLine(points)
for i = 2, #points do

View File

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

View File

@ -22,7 +22,6 @@ end
---@class Blipper
---@field draw fun(self: self, disableBlipping: boolean, x: number, y: number)
-- selene: allow(unscoped_variables)
blipper = {}
--- 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
MainMenu = {
---@type { new: fun(settings: Settings): { update: fun(self) } }
next = nil,
}
-- selene: allow(shadowing)
local gfx = playdate.graphics
-- selene: allow(shadowing)
local StartFont <const> = gfx.font.new("fonts/Roobert-20-Medium.pft")
--- Take control of playdate.update

View File

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

View File

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