nu-lint-0.0.7 has been yanked.
nu-lint
A static analysis tool for Nushell scripts based on the official style guide.
Can detect stylistic issues in Nushell scripts and suggest improvements. Functions complementary to the basic checks done by nu-check.
(Inspired by Rust's Clippy)
Installation
From crates.io:
Or build from source:
Nix
Add to your configuration.nix:
let
nu-lint = pkgs.callPackage (pkgs.fetchFromGitHub {
owner = "wvhulle";
repo = "nu-lint";
rev = "main"; # or specific 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 = "main";
sha256 = ""; # nix will tell you the correct hash
}) {};
in
pkgs.mkShell {
buildInputs = [
nu-lint
];
}
Usage
Configuration
Create .nu-lint.toml in your project root (or any parent directory):
[]
= "warning"
[]
= "warning"
= "info"
= "warning"
[]
= 100
= 4
[]
= ["*.test.nu", "vendor/**"]
The linter will automatically find and use this config file when you run it.
Rules
Categories:
- naming
- formatting
- idioms
- error handling
- code quality
- documentation
- type safety
Example Output
info[prefer_parse_over_each_split]
ℹ Manual splitting with 'each' and 'split row' - consider using 'parse'
╭─[example.nu:5:1]
5 │ $data | each { |line| $line | split row " " | get 0 }
· ───────────────────┬──────────────────────────
· ╰── AST-based detection of structured text processing pattern
╰────
help: Use 'parse "{field1} {field2}"' for structured text extraction instead of 'each' with 'split row'
This example demonstrates AST traversal detecting command patterns that the regex-based rules cannot catch.
Contributing
Contributions are welcome. Please run tests and formatting before submitting:
License
MIT