handyjs
handyjs is a small, dependency-free checker that points out common JavaScript beginner mistakes and explains what to try instead. It is an educational aid, not a complete linter or proof that code is correct.
Install
npm install handyjs
Command line
npx handyjs src/app.js
npx handyjs src/app.js src/helpers.js
The command prints a file, line, column, rule name, and explanation for each possible issue. It exits with status 1 when it finds issues, 2 when a file cannot be read or no files were provided, and 0 when no issues are found. Run npx handyjs --help for usage.
JavaScript API
const { inspect } = require('handyjs');
const result = inspect('var count = 1;\nif (count == "1") console.log(count);', { filename: 'example.js' });
console.log(result.summary);
for (const finding of result.findings) console.log(`${finding.file}:${finding.line}:${finding.column} ${finding.ruleId}\n${finding.message}`);
Each finding contains ruleId, message, file, line, column, and excerpt. The result contains filename, findings, and summary.
Checks
no-var: recommends block-scopedconstorlet.no-loose-equality: flags==and!=, leaving===and!==alone.no-console-log: points out debugging output that may be left in shared code.no-debugger: flags debugger statements that can pause execution.parse-int-radix: recommends an explicit radix forparseInt.assignment-in-condition: catches a simple assignment in aniforwhilecondition.string-timeout: recommends a function callback forsetTimeoutandsetInterval.
Checks are intentionally small, line-based heuristics. They skip ordinary quoted strings and same-line comments, but template interpolation and complex or multi-line expressions can produce missed findings or false positives. Use a parser-based linter for comprehensive analysis.
License
MIT. See LICENSE.