Skip to content

Commit 7dd65be

Browse files
authored
Merge pull request #118 from appgurueu/luanti
Update Luanti (formerly Minetest) standard to 5.10.0
2 parents 9f67f8f + 398f29d commit 7dd65be

File tree

7 files changed

+42
-22
lines changed

7 files changed

+42
-22
lines changed

luacheck-dev-1.rockspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ build = {
4545
luacheck = "src/luacheck/init.lua",
4646
["luacheck.builtin_standards"] = "src/luacheck/builtin_standards/init.lua",
4747
["luacheck.builtin_standards.love"] = "src/luacheck/builtin_standards/love.lua",
48-
["luacheck.builtin_standards.minetest"] = "src/luacheck/builtin_standards/minetest.lua",
48+
["luacheck.builtin_standards.luanti"] = "src/luacheck/builtin_standards/luanti.lua",
4949
["luacheck.builtin_standards.playdate"] = "src/luacheck/builtin_standards/playdate.lua",
5050
["luacheck.builtin_standards.ngx"] = "src/luacheck/builtin_standards/ngx.lua",
5151
["luacheck.cache"] = "src/luacheck/cache.lua",

spec/cli_spec.lua

+13-10
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,7 @@ Checking spec/samples/globals.lua 2 warnings
12421242
Checking spec/samples/indirect_globals.lua 3 warnings
12431243
Checking spec/samples/inline_options.lua 7 warnings / 2 errors
12441244
Checking spec/samples/line_length.lua 8 warnings
1245-
Checking spec/samples/minetest.lua 2 warnings
1245+
Checking spec/samples/luanti.lua 2 warnings
12461246
Checking spec/samples/python_code.lua 1 error
12471247
Checking spec/samples/read_globals.lua 5 warnings
12481248
Checking spec/samples/read_globals_inline_options.lua 3 warnings
@@ -1269,7 +1269,7 @@ Checking globals.lua 2 warnings
12691269
Checking indirect_globals.lua 3 warnings
12701270
Checking inline_options.lua 7 warnings / 2 errors
12711271
Checking line_length.lua 8 warnings
1272-
Checking minetest.lua 2 warnings
1272+
Checking luanti.lua 2 warnings
12731273
Checking python_code.lua 1 error
12741274
Checking read_globals.lua 5 warnings
12751275
Checking read_globals_inline_options.lua 3 warnings
@@ -1295,7 +1295,7 @@ Checking globals.lua 2 warnings
12951295
Checking indirect_globals.lua 3 warnings
12961296
Checking inline_options.lua 7 warnings / 2 errors
12971297
Checking line_length.lua 8 warnings
1298-
Checking minetest.lua 2 warnings
1298+
Checking luanti.lua 2 warnings
12991299
Checking python_code.lua 1 error
13001300
Checking redefined.lua 7 warnings
13011301
Checking reversed_fornum.lua 1 warning
@@ -1355,13 +1355,16 @@ Total: 1 warning / 0 errors in 1 file
13551355
end)
13561356

13571357
describe("responds to builtin std preset", function()
1358-
it("minetest", function()
1359-
-- make sure minetest sample has something that normally throws a lint error
1360-
assert.equal(1, get_exitcode "spec/samples/minetest.lua --no-config")
1361-
-- turning on minetest std should pass all lints
1362-
assert.equal(0, get_exitcode "spec/samples/minetest.lua --no-config --std minetest")
1363-
-- confirm minetest std set isn't just blindly allowing anything
1364-
assert.equal(1, get_exitcode "spec/samples/sample.rockspec --no-config --std minetest")
1358+
it("luanti", function()
1359+
-- make sure luanti sample has something that normally throws a lint error
1360+
assert.equal(1, get_exitcode "spec/samples/luanti.lua --no-config")
1361+
-- test both the new "luanti" std name and the "minetest" compatibility alias
1362+
for _, std_name in ipairs {"luanti", "minetest"} do
1363+
-- turning on luanti std should pass all lints
1364+
assert.equal(0, get_exitcode("spec/samples/luanti.lua --no-config --std " .. std_name))
1365+
-- confirm luanti std set isn't just blindly allowing anything
1366+
assert.equal(1, get_exitcode("spec/samples/sample.rockspec --no-config --std " .. std_name))
1367+
end
13651368
end)
13661369
end)
13671370

spec/samples/luanti.lua

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
local _ = core
2+
local _ = core.get_current_modname()

spec/samples/minetest.lua

-2
This file was deleted.

src/luacheck/builtin_standards/init.lua

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
local love = require "luacheck.builtin_standards.love"
2-
local minetest = require "luacheck.builtin_standards.minetest"
2+
local luanti = require "luacheck.builtin_standards.luanti"
33
local playdate = require "luacheck.builtin_standards.playdate"
44
local ngx = require "luacheck.builtin_standards.ngx"
55
local standards = require "luacheck.standards"
@@ -297,7 +297,9 @@ builtin_standards.busted = {
297297

298298
builtin_standards.love = love
299299

300-
builtin_standards.minetest = minetest
300+
builtin_standards.luanti = luanti
301+
-- Minetest was renamed to Luanti. Keep an alias for compatibility.
302+
builtin_standards.minetest = luanti
301303

302304
builtin_standards.playdate = playdate
303305

src/luacheck/builtin_standards/minetest.lua src/luacheck/builtin_standards/luanti.lua

+21-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
-- minetest lua api standard
2-
-- lua-api reference: https://github.com/minetest/minetest/blob/master/doc/lua_api.md
1+
-- Luanti Lua API standard
2+
-- API reference: https://github.com/minetest/minetest/blob/master/doc/lua_api.md
3+
-- Changelog: https://dev.minetest.net/Changelog
4+
-- Current version of this standard: 5.10.0
35
local standards = require "luacheck.standards"
46

57
local empty = {}
68
local read_write = {read_only = false}
79
local open_table = {read_only = false, other_fields = true}
810

911
-- main namespace
10-
local minetest = {
12+
local core = {
1113
fields = {
1214
-- Utilities
1315
get_current_modname = empty,
@@ -16,6 +18,7 @@ local minetest = {
1618
get_game_info = empty,
1719
get_worldpath = empty,
1820
is_singleplayer = empty,
21+
is_valid_player_name = empty,
1922
features = open_table,
2023
has_feature = empty,
2124
get_player_information = empty,
@@ -30,8 +33,10 @@ local minetest = {
3033
sha1 = empty,
3134
colorspec_to_colorstring = empty,
3235
colorspec_to_bytes = empty,
36+
colorspec_to_table = empty,
3337
encode_png = empty,
3438
urlencode = empty,
39+
time_to_day_night_ratio = empty,
3540

3641
-- Logging
3742
debug = empty,
@@ -167,6 +172,7 @@ local minetest = {
167172
set_node = empty,
168173
add_node = empty,
169174
bulk_set_node = empty,
175+
bulk_swap_node = empty,
170176
swap_node = empty,
171177
remove_node = empty,
172178
get_node = empty,
@@ -395,6 +401,12 @@ local minetest = {
395401
get_translated_string = empty,
396402
translate = empty,
397403

404+
-- IPC
405+
ipc_set = empty,
406+
ipc_get = empty,
407+
ipc_cas = empty,
408+
ipc_poll = empty,
409+
398410
-- Global tables
399411
registered_items = open_table,
400412
registered_nodes = open_table,
@@ -430,7 +442,7 @@ local minetest = {
430442
}
431443

432444
-- Table additions
433-
local table = standards.def_fields("copy", "indexof", "insert_all", "key_value_swap", "shuffle")
445+
local table = standards.def_fields("copy", "indexof", "insert_all", "key_value_swap", "shuffle", "keyof")
434446

435447
-- String additions
436448
local string = standards.def_fields("split", "trim")
@@ -445,12 +457,15 @@ local bit = standards.def_fields("tobit","tohex","bnot","band","bor","bxor","lsh
445457
-- vector util
446458
local vector = standards.def_fields("new", "zero", "copy", "from_string", "to_string", "direction", "distance",
447459
"length", "normalize", "floor", "round", "apply", "combine", "equals", "sort", "angle", "dot", "cross", "offset",
448-
"check", "in_area", "add", "subtract", "multiply", "divide", "rotate", "rotate_around_axis", "dir_to_rotation")
460+
"check", "in_area", "add", "subtract", "multiply", "divide", "rotate", "rotate_around_axis", "dir_to_rotation",
461+
"ceil", "sign", "abs", "random_in_area", "random_direction")
449462

450463
return {
451464
read_globals = {
452465
-- main namespace
453-
minetest = minetest,
466+
core = core,
467+
-- compatibility alias
468+
minetest = core,
454469

455470
-- extensions
456471
table = table,

src/luacheck/main.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Links:
9292
" luajit - globals of LuaJIT 2.x;\n" ..
9393
" ngx_lua - globals of Openresty lua-nginx-module 0.10.10, including standard LuaJIT 2.x globals;\n" ..
9494
" love - globals added by LÖVE;\n" ..
95-
" minetest - globals added by minetest;\n" ..
95+
" luanti - globals added by Luanti (formerly Minetest);\n" ..
9696
" playdate - globals added by the Playdate SDK;\n" ..
9797
" busted - globals added by Busted 2.0, by default added for files ending with _spec.lua within spec, " ..
9898
"test, and tests subdirectories;\n" ..

0 commit comments

Comments
 (0)