リンター
インストール
Section titled “インストール”npm install -D @puruslang/linterグローバル:
npm install -g @puruslang/linter# 特定のファイルをリントpurus-lint src/main.purus
# ディレクトリ内のすべてのファイルをリントpurus-lint src
# config.purusの設定を使用してリントpurus-lintファイルが指定されていない場合、purus-lint は config.purus を読み込み、entry ディレクトリ内のすべてのファイルをリントします。
ファイルやディレクトリは位置引数として渡せます。
| オプション | エイリアス | 説明 |
|---|---|---|
--config <file> | 設定ファイルのパス | |
--help | -h | ヘルプを表示 |
| ルール | デフォルト | 説明 |
|---|---|---|
no-var | warn | var を避け、const または let を使用 |
bare-assignment | warn | const/let/var なしの裸の代入を避ける |
no-nil | warn | nil の代わりに null を使用 |
no-function | warn | function は非推奨、fn を使用 |
no-protected | warn | protected は非推奨、private を使用 |
no-else-if | warn | else if の代わりに elif を使用 |
no-js-chars | error | JavaScript文字((){}""''$#@“)は使用不可 |
no-js-operators | error | JavaScript演算子(===, !==, &&, ||, +=, -= など)は使用不可 |
no-for-range | warn | for ... in range は非推奨; JS スタイルの for ループを使用 |
bracket-match | error | [ または ] の括弧不一致 |
const-reassign | error | const 変数の再代入不可 |
duplicate-use | warn | use インポートの重複 |
indent-size | warn (2) | インデントはNスペースの倍数であること |
no-trailing-whitespace | warn | 末尾空白なし |
max-line-length | off (100) | 最大行長 |
no-unused-import | warn | 未使用importへの警告 |
consistent-naming | warn (kebab-case) | 命名規則 |
config.purus
Section titled “config.purus”リンター設定はビルド設定と一緒に config.purus で構成できます:
-- リンター設定const lint.no-var be ///warn///const lint.bare-assignment be ///warn///const lint.no-nil be ///warn///const lint.no-function be ///warn///const lint.no-protected be ///warn///const lint.no-else-if be ///warn///const lint.no-js-chars be ///error///const lint.no-js-operators be ///error///const lint.bracket-match be ///error///const lint.const-reassign be ///error///const lint.duplicate-use be ///warn///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 ///warn///プログラマティックAPI
Section titled “プログラマティックAPI”const { lint } = require("@puruslang/linter");
const diagnostics = lint("var x be 42");// [{ rule: "no-var", severity: "warn", line: 1, col: 1, message: "..." }]