diff --git a/luacheck-dev-1.rockspec b/luacheck-dev-1.rockspec index 0389dd14..d95a5d4d 100644 --- a/luacheck-dev-1.rockspec +++ b/luacheck-dev-1.rockspec @@ -45,7 +45,7 @@ build = { luacheck = "src/luacheck/init.lua", ["luacheck.builtin_standards"] = "src/luacheck/builtin_standards/init.lua", ["luacheck.builtin_standards.love"] = "src/luacheck/builtin_standards/love.lua", - ["luacheck.builtin_standards.minetest"] = "src/luacheck/builtin_standards/minetest.lua", + ["luacheck.builtin_standards.luanti"] = "src/luacheck/builtin_standards/luanti.lua", ["luacheck.builtin_standards.playdate"] = "src/luacheck/builtin_standards/playdate.lua", ["luacheck.builtin_standards.ngx"] = "src/luacheck/builtin_standards/ngx.lua", ["luacheck.cache"] = "src/luacheck/cache.lua", diff --git a/spec/cli_spec.lua b/spec/cli_spec.lua index 4ebb90aa..a099ba61 100644 --- a/spec/cli_spec.lua +++ b/spec/cli_spec.lua @@ -1242,7 +1242,7 @@ Checking spec/samples/globals.lua 2 warnings Checking spec/samples/indirect_globals.lua 3 warnings Checking spec/samples/inline_options.lua 7 warnings / 2 errors Checking spec/samples/line_length.lua 8 warnings -Checking spec/samples/minetest.lua 2 warnings +Checking spec/samples/luanti.lua 2 warnings Checking spec/samples/python_code.lua 1 error Checking spec/samples/read_globals.lua 5 warnings Checking spec/samples/read_globals_inline_options.lua 3 warnings @@ -1269,7 +1269,7 @@ Checking globals.lua 2 warnings Checking indirect_globals.lua 3 warnings Checking inline_options.lua 7 warnings / 2 errors Checking line_length.lua 8 warnings -Checking minetest.lua 2 warnings +Checking luanti.lua 2 warnings Checking python_code.lua 1 error Checking read_globals.lua 5 warnings Checking read_globals_inline_options.lua 3 warnings @@ -1295,7 +1295,7 @@ Checking globals.lua 2 warnings Checking indirect_globals.lua 3 warnings Checking inline_options.lua 7 warnings / 2 errors Checking line_length.lua 8 warnings -Checking minetest.lua 2 warnings +Checking luanti.lua 2 warnings Checking python_code.lua 1 error Checking redefined.lua 7 warnings Checking reversed_fornum.lua 1 warning @@ -1355,13 +1355,16 @@ Total: 1 warning / 0 errors in 1 file end) describe("responds to builtin std preset", function() - it("minetest", function() - -- make sure minetest sample has something that normally throws a lint error - assert.equal(1, get_exitcode "spec/samples/minetest.lua --no-config") - -- turning on minetest std should pass all lints - assert.equal(0, get_exitcode "spec/samples/minetest.lua --no-config --std minetest") - -- confirm minetest std set isn't just blindly allowing anything - assert.equal(1, get_exitcode "spec/samples/sample.rockspec --no-config --std minetest") + it("luanti", function() + -- make sure luanti sample has something that normally throws a lint error + assert.equal(1, get_exitcode "spec/samples/luanti.lua --no-config") + -- test both the new "luanti" std name and the "minetest" compatibility alias + for _, std_name in ipairs {"luanti", "minetest"} do + -- turning on luanti std should pass all lints + assert.equal(0, get_exitcode("spec/samples/luanti.lua --no-config --std " .. std_name)) + -- confirm luanti std set isn't just blindly allowing anything + assert.equal(1, get_exitcode("spec/samples/sample.rockspec --no-config --std " .. std_name)) + end end) end) diff --git a/spec/samples/luanti.lua b/spec/samples/luanti.lua new file mode 100644 index 00000000..6f8b6e0e --- /dev/null +++ b/spec/samples/luanti.lua @@ -0,0 +1,2 @@ +local _ = core +local _ = core.get_current_modname() diff --git a/spec/samples/minetest.lua b/spec/samples/minetest.lua deleted file mode 100644 index b7206937..00000000 --- a/spec/samples/minetest.lua +++ /dev/null @@ -1,2 +0,0 @@ -local _ = minetest -local _ = minetest.get_current_modname() diff --git a/src/luacheck/builtin_standards/init.lua b/src/luacheck/builtin_standards/init.lua index 097fee2d..966d433f 100644 --- a/src/luacheck/builtin_standards/init.lua +++ b/src/luacheck/builtin_standards/init.lua @@ -1,5 +1,5 @@ local love = require "luacheck.builtin_standards.love" -local minetest = require "luacheck.builtin_standards.minetest" +local luanti = require "luacheck.builtin_standards.luanti" local playdate = require "luacheck.builtin_standards.playdate" local ngx = require "luacheck.builtin_standards.ngx" local standards = require "luacheck.standards" @@ -297,7 +297,9 @@ builtin_standards.busted = { builtin_standards.love = love -builtin_standards.minetest = minetest +builtin_standards.luanti = luanti +-- Minetest was renamed to Luanti. Keep an alias for compatibility. +builtin_standards.minetest = luanti builtin_standards.playdate = playdate diff --git a/src/luacheck/builtin_standards/minetest.lua b/src/luacheck/builtin_standards/luanti.lua similarity index 98% rename from src/luacheck/builtin_standards/minetest.lua rename to src/luacheck/builtin_standards/luanti.lua index ef06a42c..2b29e24f 100644 --- a/src/luacheck/builtin_standards/minetest.lua +++ b/src/luacheck/builtin_standards/luanti.lua @@ -1,5 +1,5 @@ --- minetest lua api standard --- lua-api reference: https://github.com/minetest/minetest/blob/master/doc/lua_api.md +-- Luanti Lua API standard +-- API reference: https://github.com/minetest/minetest/blob/master/doc/lua_api.md local standards = require "luacheck.standards" local empty = {} @@ -7,7 +7,7 @@ local read_write = {read_only = false} local open_table = {read_only = false, other_fields = true} -- main namespace -local minetest = { +local core = { fields = { -- Utilities get_current_modname = empty, @@ -450,7 +450,9 @@ local vector = standards.def_fields("new", "zero", "copy", "from_string", "to_st return { read_globals = { -- main namespace - minetest = minetest, + core = core, + -- compatibility alias + minetest = core, -- extensions table = table, diff --git a/src/luacheck/main.lua b/src/luacheck/main.lua index bb94eb67..cb8646af 100644 --- a/src/luacheck/main.lua +++ b/src/luacheck/main.lua @@ -92,7 +92,7 @@ Links: " luajit - globals of LuaJIT 2.x;\n" .. " ngx_lua - globals of Openresty lua-nginx-module 0.10.10, including standard LuaJIT 2.x globals;\n" .. " love - globals added by LÖVE;\n" .. - " minetest - globals added by minetest;\n" .. + " luanti - globals added by Luanti (formerly Minetest);\n" .. " playdate - globals added by the Playdate SDK;\n" .. " busted - globals added by Busted 2.0, by default added for files ending with _spec.lua within spec, " .. "test, and tests subdirectories;\n" ..