Skip to content

Conversation

comedinha
Copy link
Contributor

@comedinha comedinha commented Apr 23, 2024

I use the LuaLS for many years and all of these years I had disabled the undefined-global because my project use global envs, and in these envs I have some globals like "const_something" and "SOMETHING" in more than 1000 submodules. So I needed this feature to improve my project checking.

I also improved to avoid unecessary checks in checkIsUndefinedGlobal like create a table with all elements to check only one of them.

This is related to: #2627

Exemple of config:

"Lua.diagnostics.globalsRegex": [
  "^const.*",
  "^[A-Z][A-Z0-9_]+$",
],

Improve checkIsUndefinedGlobal to avoid unecessary checks and tables
emmericp added a commit to emmericp/DBM-Retail that referenced this pull request Apr 26, 2024
By default LuaLS allows us to implictly declare a global by writing to
it, whereas LuaCheck didn't allow this. Since we don't want to write to
many globals it's better to require them to be explicitly declared in
.luarc.json.

Unlike LuaCheck this unfortunately doesn't support regular expressions
to define the set of allowed globals, this will be fixed in
LuaLS/lua-language-server#2629 soon hopefully.
emmericp added a commit to emmericp/DBM-Retail that referenced this pull request Apr 26, 2024
By default LuaLS allows us to implictly declare a global by writing to
it, whereas LuaCheck didn't allow this. Since we don't want to write to
many globals it's better to require them to be explicitly declared in
.luarc.json.

Unlike LuaCheck this unfortunately doesn't support regular expressions
to define the set of allowed globals, this will be fixed in
LuaLS/lua-language-server#2629 soon hopefully.
emmericp added a commit to DeadlyBossMods/DeadlyBossMods that referenced this pull request Apr 26, 2024
By default LuaLS allows us to implictly declare a global by writing to
it, whereas LuaCheck didn't allow this. Since we don't want to write to
many globals it's better to require them to be explicitly declared in
.luarc.json.

Unlike LuaCheck this unfortunately doesn't support regular expressions
to define the set of allowed globals, this will be fixed in
LuaLS/lua-language-server#2629 soon hopefully.
@sumneko sumneko merged commit 3ead0aa into LuaLS:master May 9, 2024
@sumneko
Copy link
Collaborator

sumneko commented May 9, 2024

Nice work, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants