当我在我的项目上运行 luacheck 时,它给了我数百条关于无法识别的全局变量的警告。以下是此类警告的示例:
accessing undefined variable _G
mutating non-standard global variable _G
accessing undefined variable pairs
accessing undefined variable ipairs
accessing undefined variable math
accessing undefined variable assert
accessing undefined variable print
......等等无止境。粗略来说,luacheck 根本不明白 lua 是什么,我也不输入,这是 bug 还是特性!?我应该如何调整以防止这种情况发生?
原则上,我可以通过将整个排除列表添加到 .luacheckrc 来解决这个问题,但这显然是一个 hack。
知道了!问题是这样的:
.luacheckrc我的文件看起来像这样:luacheck 文档中给出了这样的示例设置,但并没有说这些设置会覆盖标准的 lua 变量!
这就是该文件的外观,以使一切正常工作: