nu-lint
A static analysis tool for Nushell scripts.
Can detect stylistic issues in Nushell code and suggest improvements. Complementary to the basic checks by nu-check.
Installation
From crates.io:
Or build from source:
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
30+ rules covering style, best practices, performance, documentation, and type safety. All rules use either Nushell's AST parser or regex patterns for analysis.
View all rules: nu-lint list-rules
Get details about a rule: nu-lint explain <RULE_ID>
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