Playdate SDK support for luacheck

I've started adding support for the Playdate SDK in luacheck. This can either be used from the command line or integrated in your editor, for example if you're using Nova it already has an extension for luacheck.

I made a fork of the project and included my current PR and also another one which adds support for compound operators. It works great here(tm) and I've ran it across most of the SDK sample code but I would love some help testing this further so if anyone has time that would be awesome.

You'll need something like this in a .luacheckrc file:

std = "lua54+playdate"
operators = {"+=", "-=", "*=", "/="}

A couple of caveats so far, if you use OO support provided by the SDK you'll need to a comment like this to quiet a warning for declarations:

-- luacheck: globals Scroller
class('Scroller').extends(Object)

and a comment like this if a member function doesn't use self (which, of course, means it probably doesn't need to be a member function :slight_smile: )

function Scroller:find_char_index(character) -- luacheck: ignore self

I've made the decision to no include member methods right now. They can't be checked by luacheck when they are being used with the : syntax (for example myNineSlice:getSize()) and I my thinking right now is that it could help spot incorrect uses like playdate.graphics.nineSlice.getSize().

Let me know what you guys think about this.

3 Likes