Page 1 of 1

Luacheck .luacheckrc for Factorio 0.15

Posted: Wed Apr 26, 2017 11:35 pm
by Nexela
For anyone that uses luacheck for linting their code I have created a fairly strict .luacheckrc that can be found at
https://github.com/Nexela/Factorio-luacheckrc

[Updated for 15.3]
Moved to GitHub
Fixed Defines
Fixed some globals in wrong environment

I Will keep that updated as I make more and more changes and fixes.

Current "features"
Uses separate linting environments depending on the file.

Anything in data*.lua, settings*.lua prototypes/*.lua will show warnings if trying to access game script functions not available
Other lua files will show warnings when trying to use globals only available in the data stage.

All defines are listed. if you make a typo when accessing a defines you will be warned. defines.on_event.fake_event will show a warning.
The top level game global and associated methods are listed as well. game.not_available() will throw a warning.

luacheck now includes a windows binary for easy installation https://github.com/mpeterv/luacheck/releases
After installing luacheck save the .luacheckrc file to your source directory (or any directory before it).
Don't forgot to install a linter and linter luacheck package in your editor of choice.

Additional a working fork of the atom-autocomplete-factorio package can be found here https://github.com/Nexela/atom-autocomplete-factorio
It currently supports factorio .15.3
If you use ATOM drop that package into your home/.atom/packages/
It will enable autocompletes for the factorio API

[related]viewtopic.php?f=34&t=29919&p=206389&hil ... ck#p206389

Re: Luacheck .luacheckrc for Factorio 0.15

Posted: Thu Apr 27, 2017 11:32 pm
by Afforess
Could you possibly move this to it's own github repository? I have a Makefile build workflow for my mods, and as a git repo, I would be able to easily fetch the latest revision of your luacheck as part of the build process for my mods.

No pressure if you don't want to, but it would make things convenient.

Re: Luacheck .luacheckrc for Factorio 0.15

Posted: Thu Apr 27, 2017 11:45 pm
by sparr
gists are git repositories that you can fork and clone and use as submodules just like any other repo. Don't let this being a gist stop you from using it!

Re: Luacheck .luacheckrc for Factorio 0.15

Posted: Thu Apr 27, 2017 11:56 pm
by Nexela
I have no problem moving it to github.

I did make a booboo and put the game globals in the all globals spot. (I blame the really long defines table!). Just wish there was an easy way to require files that didn't rely on LUA_PATH

Re: Luacheck .luacheckrc for Factorio 0.15

Posted: Fri Apr 28, 2017 1:28 am
by Afforess
sparr wrote:gists are git repositories that you can fork and clone and use as submodules just like any other repo. Don't let this being a gist stop you from using it!
TIL. Cool.

Re: Luacheck .luacheckrc for Factorio 0.15

Posted: Fri Apr 28, 2017 2:27 am
by Nexela
I learned something new too!!!!!

But since working with gists is still a pain I went ahead and moved this to GitHub https://github.com/Nexela/Factorio_luacheckrc as well as fixing some minor issues for .15.3

Re: Luacheck .luacheckrc for Factorio 0.15

Posted: Fri Apr 28, 2017 3:02 am
by Nexela
Updated Original Post and added a link to

https://github.com/Nexela/atom-autocomplete-factorio
If you use ATOM drop that package into your home/.atom/packages/
It will enable autocompletes for the factorio API

Re: Luacheck .luacheckrc for Factorio 0.15

Posted: Sun Apr 30, 2017 8:57 pm
by ibeatbabybiters
I only now discovered this thread because the last two days I was busy developing my own autocomplete extension for VS Code LOL

Thanks a lot for the .luacheckrc file, I never wrote lua or factorio mods before so I'm sure it'll be helpful

And here is my VS Code extension in case of curiosity: viewtopic.php?f=34&t=45779