Format JavaScript Standard Style as Stylish (i.e. snazzy) output
94
Build a command-line tool that processes code quality reports from stdin and outputs formatted results. The tool must correctly report success or failure to the calling process through its exit code, enabling integration with CI/CD pipelines and automated workflows.
The tool must read JSON data from stdin. The input contains an array of file reports, where each report includes:
Example input structure:
[
{
"file": "src/app.js",
"issues": [
{"line": 10, "column": 5, "severity": "error", "message": "Undefined variable"},
{"line": 15, "column": 2, "severity": "warning", "message": "Unused import"}
]
},
{
"file": "src/utils.js",
"issues": []
}
]The tool should output a human-readable summary to stdout showing:
The tool MUST set its exit code to communicate results to the calling process:
A Node.js package for formatting linter output. Use this as a reference for implementing proper exit code handling patterns.
Input (via stdin):
[
{"file": "src/clean.js", "issues": []},
{"file": "src/perfect.js", "issues": []}
]Expected stdout:
All files passed - no issues foundExpected exit code: 0
Test file: tests/cli.test.js
Input (via stdin):
[
{
"file": "src/buggy.js",
"issues": [
{"line": 5, "column": 10, "severity": "error", "message": "Syntax error"}
]
}
]Expected stdout (must include):
src/buggy.js
5:10 error Syntax error
1 issue foundExpected exit code: 1
Test file: tests/cli.test.js
Test code:
const QualityReporter = require('./reporter');
const { Readable } = require('stream');
const input = JSON.stringify([
{
file: "test.js",
issues: [{ line: 1, column: 1, severity: "error", message: "Failed" }]
}
]);
const reporter = new QualityReporter();
const inputStream = Readable.from([input]);
inputStream.pipe(reporter).pipe(process.stdout);
reporter.on('finish', () => {
console.log(`Exit code: ${reporter.exitCode}`);
// Should output: Exit code: 1
});Expected: The reporter instance should expose an exitCode property set to 1 after processing completes.
Test file: tests/programmatic.test.js
Install with Tessl CLI
npx tessl i tessl/npm-snazzydocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10