Luacheck .luacheckrc for Factorio 0.15

Place to post guides, observations, things related to modding that are not mods themselves.
Post Reply
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Luacheck .luacheckrc for Factorio 0.15

Post 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
Last edited by Nexela on Fri Apr 28, 2017 3:02 am, edited 4 times in total.

User avatar
Afforess
Filter Inserter
Filter Inserter
Posts: 422
Joined: Tue May 05, 2015 6:07 pm
Contact:

Re: Luacheck .luacheckrc for Factorio 0.15

Post 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.

sparr
Smart Inserter
Smart Inserter
Posts: 1327
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: Luacheck .luacheckrc for Factorio 0.15

Post 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!

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Luacheck .luacheckrc for Factorio 0.15

Post 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

User avatar
Afforess
Filter Inserter
Filter Inserter
Posts: 422
Joined: Tue May 05, 2015 6:07 pm
Contact:

Re: Luacheck .luacheckrc for Factorio 0.15

Post 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.

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Luacheck .luacheckrc for Factorio 0.15

Post 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

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Luacheck .luacheckrc for Factorio 0.15

Post 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

ibeatbabybiters
Inserter
Inserter
Posts: 30
Joined: Sun Apr 30, 2017 7:14 pm
Contact:

Re: Luacheck .luacheckrc for Factorio 0.15

Post 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
Usually I don't beat babies, but when I do I beat baby biters.

Post Reply

Return to “Modding discussion”