Skip to content

Lint

Linters ensure source code follows best practices.

lintBash

Lints Bash code with ShellCheck.

Types:

  • lintBash:
    • enable (boolean): Optional. Defaults to false.
    • targets (listOf str): Optional. Files or directories (relative to the project) to lint. Defaults to the entire project.

Example:

{
  lintBash = {
    enable = true;
    targets = [
      "/" # Entire project
      "/file.sh" # A file
      "/directory" # A directory within the project
    ];
  };
}
m . /lintBash

lintClojure

Lints clojure code with clj-kondo.

Types:

  • lintClojure (attrsOf (listOf str)): Optional. Mapping of custom names to lists of paths (relative to the project) to lint.

    Defaults to { }.

Example:

{
  lintClojure = {
    example1 = [
      "/" # Entire project
      "/file.clj" # A file
    ];
    example2 = [
      "/directory" # A directory within the project
    ];
  };
}
m . /lintClojure/example1`

lintGitCommitMsg

It creates a commit diff between you current branch and the main branch of the repository. All commits included in the diff are linted using Commitlint.

Types:

  • lintGitCommitMsg:
    • enable (boolean): Optional. Defaults to false.
    • branch (str): Optional. Name of the main branch. Defaults to main.
    • config (str): Optional. Path to a configuration file for Commitlint. Defaults to config.js.
    • parser (str): Optional. Commitlint parser definitions. Defaults to parser.js.

Example:

1
2
3
4
5
6
7
8
9
{
  lintGitCommitMsg = {
    enable = true;
    branch = "my-branch-name";
    # If you want to use custom configs or parsers you can do it like this:
    # config = "/src/config/config.js";
    # parser = "/src/config/parser.js";
  };
}
m . /lintGitCommitMsg

lintGitMailMap

Lint the Git mailmap of the project with MailMap Linter.

Types:

  • lintGitMailmap:
    • enable (boolean): Optional. Defaults to false.
    • exclude (str): Optional. If the excludes aren't too many then use exclude instead of the exclude file (.mailmap-exclude). Defaults to ^$.

Example:

1
2
3
4
5
6
{
  lintGitMailMap = {
    enable = true;
    exclude = "^.* <.*noreply@github.com>$";
  };
}
m . /lintGitMailMap

lintNix

Lints Nix code with statix.

Types:

  • lintNix:
    • enable (boolean): Optional. Defaults to false.
    • targets (listOf str): Optional. Files or directories (relative to the project) to lint. Defaults to the entire project.

Example:

{
  lintNix = {
    enable = true;
    targets = [
      "/" # Entire project
      "/file.nix" # A file
      "/directory" # A directory within the project
    ];
  };
}
m . /lintNix

lintPython

Lints Python code with mypy, Prospector, and (if configured) import-linter.

Types:

  • lintPython:
    • dirOfModules (attrsOf dirOfModulesType): Optional. Definitions of directories of python packages/modules to lint. Defaults to { }.
    • imports (attrsOf importsType): Optional. Definitions of python packages whose imports will be linted. Defaults to { }.
    • modules (attrsOf moduleType): Optional. Definitions of python packages/modules to lint. Defaults to { }.
  • dirOfModulesType (submodule):
    • config (atrrs): Optional.
    • searchPaths (asIn makeSearchPaths): Optional. Arguments here will be passed as-is to makeSearchPaths. Defaults to makeSearchPaths's defaults.
    • src (str): Path to the directory that contains inside many packages/modules.
  • importsType (submodule):
    • config (str): Path to the import-linter configuration file.
    • searchPaths (asIn makeSearchPaths): Optional. Arguments here will be passed as-is to makeSearchPaths. Defaults to makeSearchPaths's defaults.
    • src (str): Path to the package/module.
  • moduleType (submodule):
    • config (atrrs): Optional.
    • searchPaths (asIn makeSearchPaths): Optional. Arguments here will be passed as-is to makeSearchPaths. Defaults to makeSearchPaths's defaults.
    • src (str): Path to the package/module.

Example:

{
  lintPython = {
    dirOfModules = {
      makes = {
        config = {};
        src = "/src/cli";
      };
    };
    imports = {
      cli = {
        config = "/src/cli/imports.cfg";
        src = "/src/cli";
      };
    };
    modules = {
      cliMain = {
        config = {};
        src = "/src/cli/main";
      };
    };
  };
}
m . /lintPython/dirOfModules/makes/main
m . /lintPython/module/cliMain

lintTerraform

Lint Terraform code with TFLint.

Types:

  • lintTerraform:
    • config (str): Optional. Path to a TFLint configuration file. Defaults to config.hcl.
    • modules (attrsOf moduleType): Optional. Path to Terraform modules to lint. Defaults to { }.
  • moduleType (submodule):
    • setup (listOf package): Optional. Makes Environment or Makes Secrets to source (as in Bash's source) before anything else. Defaults to [ ].
    • src (str): Path to the Terraform module.
    • version (enum [ "0.14" "0.15" "1.0" ]): Terraform version your module is built with.

Example:

{
  lintTerraform = {
    # You can use a custom configuration like this:
    # config = "/src/config/tflint.hcl";
    modules = {
      module1 = {
        src = "/my/module1";
        version = "0.14";
      };
      module2 = {
        src = "/my/module2";
        version = "0.15";
      };
    };
  };
}
m . /lintTerraform/module1

lintWithAjv

Warning

This function is only available on Linux at the moment.

Lints JSON and YAML data files with JSON Schemas. It uses ajv-cli.

Types:

  • lintWithAjv (attrsOf schemaType): Optional. Definitions of schema and associated data to lint. Defaults to { }.
  • schemaType (submodule):
    • schema (str): Required. Path to the JSON Schema.
    • targets (listOf str): Required. YAML or JSON data files to lint with schema.

Example:

{
  lintWithAjv = {
    users = {
      schema = "/users/schema.json";
      targets = [
        "/users/data1.json"
        "/users/data.yaml"
      ];
    };
    colors = {
      schema = "/colors/schema.json";
      targets = [
        "/colors/data1.json"
        "/colors/data2.yaml"
      ];
    };
  };
}
m . /lintWithAjv/users

lintWithLizard

Using Lizard to check Ciclomatic Complexity and functions length in all supported languages

Types:

  • lintWithLizard (attrsOf (listOf str)): Optional. Mapping of custom names to lists of paths (relative to the project) to lint.

    Defaults to { }.

Example:

{
  lintWithLizard = {
    example1 = [
      "/" # Entire project
      "/file.py" # A file
    ];
    example2 = [
      "/directory" # A directory within the project
    ];
  };
}
$ m . /lintWithLizard/example1