selene is meant to be easily configurable. You can specify configurations for the entire project as well as for individual lints.

Configuration files are placed in the directory you are running selene in and are named selene.toml. As the name suggests, the configurations use the Tom's Obvious, Minimal Language (TOML) format. It is recommended you quickly brush up on the syntax, though it is very easy.

Changing the severity of lints

You can change the severity of lints by entering the following into selene.toml:

lint_1 = "severity"
lint_2 = "severity"

Where "severity" is one of the following:

  • "allow" - Don't check for this lint
  • "warn" - Warn for this lint
  • "deny" - Error for this lint

Note that "deny" and "warn" are effectively the same, only warn will give orange text while error gives red text, and they both have different counters.

Configuring specific lints

You can configure specific lints by entering the following into selene.toml:

lint1 = ...
lint2 = ...

Where the value is whatever the special configuration of that lint is. You can learn these on the lints specific page in the list of lints. For example, if we wanted to allow empty if branches if the contents contain comments, then we would write:

empty_if = { comments_count = true }

Setting the standard library

Many lints use standard libraries for either verifying their correct usage or for knowing that variables exist where they otherwise wouldn't.

By default, selene uses Lua 5.1, though if we wanted to use the Lua 5.2 standard library, we would write:

std = "lua52" the top of selene.toml. You can learn more about the standard library format on the standard library guide. The standard library given can either be one of the builtin ones (currently only lua51 and lua52) or the filename of a standard library file in this format. For example, if we had a file named special.toml, we would write:

std = "special"

Chaining the standard library

We can chain together multiple standard libraries by simply using a plus sign (+) in between the names.

For example, if we had game.toml and engine.toml standard libraries, we could chain them together like so:

std = "game+engine"

Excluding files from being linted

It is possible to exclude files from being linted using the exclude option:

exclude = ["external/*", "*.spec.lua"]