Nu-Lint
Linter for the innovative Nu shell.
Learning to use a new shell is a radical change that can use some assistance. This project is aimed at helping new users of the Nu shell. Nu shell has a lot of interesting and useful features and this program will give you hints to use all the features of Nu.
For example, the rule prefer_pipeline_input in this program recommends to use pipelines instead of positional arguments:
def filter-positive [numbers] {
$numbers | where $it > 0
}
def filter-positive [] {
where $it > 0
}
All rules are optional and can be disabled with a configuration file. The rule definitions are designed to be compatible with:
- The standard Nu parser nu-check.
- The standard Nu formatter topiary-nushell.
Installation
Cross-platform
From crates.io:
Source
Build from source:
VS Code extension
Available at VS Code Marketplace.
Nix
To install in Nix or NixOS, add to configuration.nix:
let
nu-lint = pkgs.callPackage (pkgs.fetchFromGitHub {
owner = "wvhulle";
repo = "nu-lint";
rev = "COMMIT_HASH";
sha256 = ""; # nix will tell you the correct hash
}) {};
in
{
environment.systemPackages = [
nu-lint
];
}
Or in a shell.nix:
{ pkgs ? import <nixpkgs> {} }:
let
nu-lint = pkgs.callPackage (pkgs.fetchFromGitHub {
owner = "wvhulle";
repo = "nu-lint";
rev = "COMMIT_HASH";
sha256 = ""; # nix will tell you the correct hash
}) {};
in
pkgs.mkShell {
buildInputs = [
nu-lint
];
}
Usage
Basic:
Configuration
Show all rules:
Create .nu-lint.toml in your project root (or any parent directory):
[]
= "info"
[]
= "warning"
The linter will automatically find and use this config file when you run it. Otherwise:
Rules
The rules are categorised roughly in the following categories (but don't rely on the category being completely correct):
- naming
- formatting
- idioms
- error handling
- code quality
- documentation
- type safety
You can add, remove or change rules by forking this repo and opening a PR (see ./CONTRIBUTING.md).
License
MIT