Node.JS bindings for luacheck.
You must have luacheck 0.10.0+ installed
and available in your PATH
variable.
npm install luacheck
var luacheck = require("luacheck");
try {
var errors = luacheck(sourceFilename, {sync: true});
// do something with `errors`
}
catch(err) {}
var luacheck = require("luacheck");
luacheck(sourceFilename, options, function(err, errors) {
// do something with `errors`
});
The options
argument is a dictionary that accepts the following keys:
Type: Boolean
Default: false
Whether to run the subprocess asynchronously (default) or wait for it to exit before returning (only supported in Node.Js 0.12+). A standard (err, result) continuation is expected as the last argument if running asynchronously. When running synchronously, errors are thrown and the results (i.e. luacheck errors) are returned.
Type: String
Default: undefined
By default luacheck
is executed from the source file's directory to work
around some weird .luacheckrc
behavior in older versions of luacheck. If this is not what you want,
you can override the working directory by passing a path to this parameter.
WARNING: source filenames are resolved relative to the current process'
working directory, not cwd
.
Type: String
Default: luacheck
(or luacheck.bat
on Windows)
The path to the luacheck binary. Useful if for whatever reason you can't have
it added to your PATH
.
Type: Boolean
Default: false
Filter out warnings related to global variables.
DEPRECATED: use global
in a .luacheckrc
file instead.
Type: Boolean
Default: false
Filter out warnings related to unused variables and values.
DEPRECATED: use unused
in a .luacheckrc
file instead.
Type: Boolean
Default: false
Filter out warnings related to redefined variables.
DEPRECATED: use redefined
in a .luacheckrc
file instead.
Type: Boolean
Default: false
Filter out warnings related to unused arguments and loop variables.
DEPRECATED: use unused_args
in a .luacheckrc
file instead.
Type: Boolean
Default: false
Filter out warnings related to unused variables set together with used ones. See Secondary values and variables.
DEPRECATED: use unused_secondaries
in a .luacheckrc
file instead.
Type: Boolean
Default: false
Filter out warnings related to set but unused global variables.
DEPRECATED: use unused_globals
in a .luacheckrc
file instead.
Type: String
Default: _G
Set standard globals to use. Must be one of:
_G
- globals of the Lua interpreter luacheck runs on (default);lua51
- globals of Lua 5.1;lua52
- globals of Lua 5.2;lua52c
- globals of Lua 5.2 compiled with LUA_COMPAT_ALL;lua53
- globals of Lua 5.3;lua53c
- globals of Lua 5.3 compiled with LUA_COMPAT_5_2;luajit
- globals of LuaJIT 2.0;min
- intersection of globals of Lua 5.1, Lua 5.2 and LuaJIT 2.0;max
- union of globals of Lua 5.1, Lua 5.2 and LuaJIT 2.0;none
- no standard globals.
DEPRECATED: use std
in a .luacheckrc
file instead.
Type: Array of Strings
Default: []
Add custom globals on top of standard ones.
DEPRECATED: use globals
in a .luacheckrc
file instead.
Type: Array of Strings
Default: []
Add custom read-only globals on top of standard ones.
DEPRECATED: use read_globals
in a .luacheckrc
file instead.
Type: Array of Strings
Default: []
Set custom globals. Removes custom globals added previously.
DEPRECATED: use new_globals
in a .luacheckrc
file instead.
Type: Array of Strings
Default: []
Set read-only globals. Removes read-only globals added previously.
DEPRECATED: use new_read_globals
in a .luacheckrc
file instead.
Type: Boolean
Default: false
Equivalent to {"std": "max"}
.
DEPRECATED: use std = "max"
or compat
in a .luacheckrc
file instead.
Type: Boolean
Default: false
Allow defining globals implicitly by setting them. See Implicitly defined globals
DEPRECATED: use allow_defined
in a .luacheckrc
file instead.
Type: Boolean
Default: false
Allow defining globals implicitly by setting them in the top level scope. See Implicitly defined globals
DEPRECATED: use allow_defined_top
in a .luacheckrc
file instead.
Type: Boolean
Default: false
Limit visibility of implicitly defined globals to their files. See Modules
DEPRECATED: use module
in a .luacheckrc
file instead.
Type: Array of Strings
Default: []
Filter out warnings matching patterns. See Patterns
DEPRECATED: use ignore
in a .luacheckrc
file instead.
Type: Array of Strings
Default: []
Do not filter out warnings matching patterns. See Patterns
DEPRECATED: use enable
in a .luacheckrc
file instead.
Type: Array of Strings
Default: []
Filter out warnings not matching patterns. See Patterns
DEPRECATED: use only
in a .luacheckrc
file instead.
Type: Boolean
Default: false
Disable inline options.
DEPRECATED: use inline
in a .luacheckrc
file instead.
Type: String
Default: undefined
Path to custom config file
(default: .luacheckrc
).
Type: Boolean
Default: false
Flag indicating whether config loading should be disabled or not. Pass in
true
to disable config loading.
DEPRECATED: You should always use a .luacheckrc
file instead of passing
options via the CLI.
Type: String
Default: undefined
Path to cache file. (default: .luacheckcache
).
See Caching
Type: Boolean
Default: true
Do not use cache. Defaults to true
in order to work without LuaFileSystem
.
See Caching
Type: Integer (Strictly Positive)
Default: 1
Check jobs
files in parallel. Requires LuaLanes
. Defaults to 1
in order
to work without it.
Q: Help, I'm getting a The input line is too long
error message on Windows.
A: This is a known issue on all versions of Windows. Switch to using config files and it's highly unlikely that you'll hit the limit again.
Since this is a thin wrapper on top of luacheck
, we don't consider bugs
unless running luacheck with identical options produces different results.
Everything else should be reported directly to luacheck
node-luacheck is licensed under the MIT license.