Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow_defined_top in default luacheckrc causes errors in .luacheckrc files #21

Open
idbrii opened this issue Jul 29, 2021 · 0 comments
Open

Comments

@idbrii
Copy link

idbrii commented Jul 29, 2021

Using allow_defined_top in the default luacheckrc causes unused global errors in .luacheckrc files.

%LOCALAPPDATA%/Luacheck/.luacheckrc:

allow_defined_top = true

Run:

luacheck  %LOCALAPPDATA%/Luacheck/.luacheckrc

Get:

.luacheckrc:2:1: unused global variable 'allow_defined_top'

I guess allow_defined_top makes luacheck recognize all top-level defines as new globals instead of ignoring the ones already foudn in globals.


To solve this specific problem, I tried changing lua53\share\lua\5.3\luacheck\builtin_standards\init.lua:

builtin_standards.luacheckrc = {
   globals = { ...
   },
   allow_defined_top = false, -- this doesn't work
}

But no luck.

Workaround

Add to your .luacheckrc files:

-- Above allow_defined_top breaks std.luacheck
local luacheck = {
    std = 'luacheckrc',
    allow_defined_top  = false,
}
files['**/.luacheckrc'] = luacheck
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant