diff --git a/Makefile b/Makefile index 4f2c077..fe792ce 100644 --- a/Makefile +++ b/Makefile @@ -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///g' | selene - + luacheck -d --codes src/ --exclude-files src/test/ test: check (cd src; find ./test -name '*lua' | xargs -L1 lua) diff --git a/src/action-queue.lua b/src/action-queue.lua index 3df7fcf..2571249 100644 --- a/src/action-queue.lua +++ b/src/action-queue.lua @@ -1,4 +1,3 @@ --- selene: allow(unscoped_variables) actionQueue = { ---@type table 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. diff --git a/src/announcer.lua b/src/announcer.lua index d72458b..df7018d 100644 --- a/src/announcer.lua +++ b/src/announcer.lua @@ -1,4 +1,3 @@ --- selene: allow(shadowing) local gfx = playdate.graphics local AnnouncementFont = playdate.graphics.font.new("fonts/Roobert-20-Medium.pft") @@ -10,7 +9,6 @@ local AnnouncerAnimatorInY = local AnnouncerAnimatorOutY = playdate.graphics.animator.new(AnnouncementTransitionMs, 0, -70, playdate.easingFunctions.outQuint) --- selene: allow(unscoped_variables) ---@class Announcer ---@field textQueue string[] ---@field animatorY pd_animator diff --git a/src/assets.lua b/src/assets.lua index bbfc725..2452ba1 100644 --- a/src/assets.lua +++ b/src/assets.lua @@ -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") }, } diff --git a/src/assets.lua2p b/src/assets.lua2p index 5658d39..a589b91 100644 --- a/src/assets.lua2p +++ b/src/assets.lua2p @@ -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) diff --git a/src/ball.lua b/src/ball.lua index 2632e7f..9e3d040 100644 --- a/src/ball.lua +++ b/src/ball.lua @@ -1,4 +1,3 @@ --- selene: allow(unscoped_variables) ---@class Ball ---@field x number ---@field y number diff --git a/src/baserunning.lua b/src/baserunning.lua index 6f5b3cb..619e779 100644 --- a/src/baserunning.lua +++ b/src/baserunning.lua @@ -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 diff --git a/src/constants.lua b/src/constants.lua index 0cad138..177fbcd 100644 --- a/src/constants.lua +++ b/src/constants.lua @@ -1,4 +1,3 @@ --- selene: allow(unscoped_variables) C = {} C.Screen = { diff --git a/src/dbg.lua b/src/dbg.lua index 98c13b9..758c0b8 100644 --- a/src/dbg.lua +++ b/src/dbg.lua @@ -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 diff --git a/src/fielding.lua b/src/fielding.lua index 6d2ae6f..e755987 100644 --- a/src/fielding.lua +++ b/src/fielding.lua @@ -7,13 +7,11 @@ -- TODO: Run down baserunners in a pickle. --- selene: allow(unscoped_variables) ---@class Fielding ---@field fielders table ---@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 diff --git a/src/graphics.lua b/src/graphics.lua index 9a34b25..a5bfb95 100644 --- a/src/graphics.lua +++ b/src/graphics.lua @@ -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. diff --git a/src/main-menu.lua b/src/main-menu.lua index 9ec9ddf..f0afb97 100644 --- a/src/main-menu.lua +++ b/src/main-menu.lua @@ -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 = gfx.font.new("fonts/Roobert-20-Medium.pft") --- Take control of playdate.update diff --git a/src/main.lua b/src/main.lua index be9d0f5..268012c 100644 --- a/src/main.lua +++ b/src/main.lua @@ -42,7 +42,6 @@ import 'npc.lua' -- TODO: Customizable field structure. E.g. stands and ads etc. --- selene: allow(shadowing) local gfx , C = playdate.graphics, C ---@alias Team { score: number, benchPosition: XyPair } @@ -95,7 +94,6 @@ local teams = { ---@field private homeTeamBlipper Blipper ---@field private awayTeamBlipper Blipper ---@field private state MutableState --- selene: allow(unscoped_variables) Game = {} ---@param settings Settings diff --git a/src/utils.lua b/src/utils.lua index 391fe75..589fbaf 100644 --- a/src/utils.lua +++ b/src/utils.lua @@ -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, }