visual-studio-codeluaworld-of-warcraft

VSCode clear errors


I am self teaching myself Lua by building a WoW addon; I have no background in coding at all.

After Notepad++ broke all extensions I changed to VSCode and I find it great and very flexible.

I have two questions about VSCode functionality.

  1. I currently have an extreme amount of errors showing in my Problems page and I wish to clear all the errors but I have not been able to find a way to this.

  2. A majority of errors are "accessing undefined variable" when it identifies api calls. Is there a way to I can ensure that api calls are not incorrectly identified as an error? enter image description here


Solution

  • Those errors/warnings are raised by luacheck, a Lua linter.

    The solution is an appropriate mix of writing proper code and configuring luacheck to not raise unwanted warnings.

    Read the luacheck manual to find out how to configure luacheck.

    Maybe the VS Code extension provides settings for luacheck.

    You can use a configuration file, inline configuration comments or command line options to change the behaviour of luacheck.

    You'll probably find a luacheck configuration for the WoW API online.

    To get rid of the unused loop variable warning you could simply use _ as variable name. This is commonly used for unused, but necessary values and hence ignored by luacheck.