Linter
Installation
Section titled “Installation”npm install -D @puruslang/linterOr globally:
npm install -g @puruslang/linter# Lint specific filespurus-lint src/main.purus
# Lint all files in a directorypurus-lint --directory src
# Lint using config.purus settingspurus-lintWhen no files are specified, purus-lint reads config.purus and lints all files in the entry directory.
Options
Section titled “Options”| Option | Alias | Description |
|---|---|---|
--directory <dir> | -d | Lint all Purus files in the directory |
--config <file> | Path to config JSON file (.puruslint.json) | |
--help | -h | Show help |
| Rule | Default | Description |
|---|---|---|
no-var | warn | Avoid var; use const or let |
no-nil | warn | Use null instead of nil |
indent-size | warn (2) | Indentation must be a multiple of N spaces |
no-trailing-whitespace | warn | No trailing whitespace |
max-line-length | off (100) | Maximum line length |
consistent-naming | warn (kebab-case) | Naming convention |
Configuration
Section titled “Configuration”config.purus
Section titled “config.purus”Linter settings can be configured in config.purus alongside build settings:
-- Linter settingsconst lint.no-var be ///warn///const lint.indent-size be 2const lint.max-line-length be ///off///.puruslint.json
Section titled “.puruslint.json”Alternatively, create .puruslint.json in your project root:
{ "no-var": { "severity": "error" }, "max-line-length": { "severity": "warn", "max": 80 }}config.purus takes priority. If no config.purus is found, .puruslint.json is used as a fallback.
Programmatic API
Section titled “Programmatic API”const { lint } = require("@puruslang/linter");
const diagnostics = lint("var x be 42");// [{ rule: "no-var", severity: "warn", line: 1, col: 1, message: "..." }]