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 src
# Lint using config.purus settingspurus-lintWhen no files are specified, purus-lint reads config.purus and lints all files in the entry directory.
You can pass files and directories as positional arguments.
Options
Section titled “Options”| Option | Alias | Description |
|---|---|---|
--config <file> | Path to config file | |
--help | -h | Show help |
| Rule | Default | Description |
|---|---|---|
no-var | warn | Avoid var; use const or let |
no-nil | off | 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 |
no-unused-import | warn | Warn on unused imports |
consistent-naming | off (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.no-nil be ///off///const lint.indent-size be 2const lint.max-line-length be ///off///const lint.no-trailing-whitespace be ///warn///const lint.no-unused-import be ///warn///const lint.consistent-naming be ///off///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: "..." }]