From 17036612738e6adad581aad991643566840cc4aa Mon Sep 17 00:00:00 2001 From: Luca Capezzuto Date: Sat, 11 Jun 2022 12:25:17 +0200 Subject: [PATCH] luacheck: add global objects, ignore W131 only Inspired by AwesomeWM's luacheckrc: https://github.com/awesomeWM/awesome/blob/master/.luacheckrc Signed-off-by: Luca Capezzuto --- .luacheckrc | 20 +++++++++++++++++--- helpers.lua | 20 ++++++++++---------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index 811a783..9944223 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,13 +1,27 @@ -codes = true +-- Only allow symbols available in all Lua versions +std = "min" + allow_defined = true max_line_length = false +cache = true + +-- Global objects defined by the C code +read_globals = { + "awesome", + "mousegrabber", + "table.unpack", + "unpack", + "utf8" +} globals = { - "client", "screen", "mouse" + "client", + "mouse", + "root", + "screen" } -- https://luacheck.readthedocs.io/en/stable/warnings.html ignore = { - "113", "131" } diff --git a/helpers.lua b/helpers.lua index 45f090f..ef9e08b 100644 --- a/helpers.lua +++ b/helpers.lua @@ -5,15 +5,15 @@ --]] -local spawn = require("awful.spawn") -local timer = require("gears.timer") -local debug = require("debug") -local io = { lines = io.lines, - open = io.open } -local pairs = pairs -local rawget = rawget -local table = { sort = table.sort, unpack = table.unpack } -local unpack = unpack or table.unpack -- lua 5.1 retro-compatibility +local spawn = require("awful.spawn") +local timer = require("gears.timer") +local debug = require("debug") +local io = { lines = io.lines, + open = io.open } +local pairs = pairs +local rawget = rawget +local tsort = table.sort +local unpack = unpack or table.unpack -- lua 5.1 retro-compatibility -- Lain helper functions for internal use -- lain.helpers @@ -164,7 +164,7 @@ function helpers.spairs(t) local keys = {} for k in pairs(t) do keys[#keys+1] = k end - table.sort(keys) + tsort(keys) -- return the iterator function local i = 0