CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-snazzy

Format JavaScript Standard Style as Stylish (i.e. snazzy) output

94

1.18x
Overview
Eval results
Files

task.mdevals/scenario-5/

Linter Output Formatter CLI

Create a command-line tool that transforms JSON linter output into a stylish, human-readable format with colorized output. The tool should read linter results from stdin and output formatted results to stdout.

Requirements

Your CLI tool must:

  1. Accept input via stdin - Automatically detect piped input and support explicit stdin flags (--stdin or -)
  2. Parse JSON linter output - Process JSON arrays containing file paths and error messages
  3. Format output stylishly - Display file paths as headers, errors in aligned columns with line:column numbers, and include a summary with total problem count
  4. Set proper exit codes - Exit with code 1 when errors are present, code 0 when no errors
  5. Show usage on invalid invocation - Display helpful message when run without piped input

Input Format

The tool will receive JSON input in this format:

[
  {
    "filePath": "src/example.js",
    "messages": [
      {
        "line": 15,
        "column": 7,
        "message": "Missing semicolon.",
        "ruleId": "semi"
      },
      {
        "line": 23,
        "column": 12,
        "message": "Unexpected var, use let or const instead.",
        "ruleId": "no-var"
      }
    ]
  },
  {
    "filePath": "src/utils.js",
    "messages": [
      {
        "line": 8,
        "column": 3,
        "message": "Expected indentation of 2 spaces.",
        "ruleId": "indent"
      }
    ]
  }
]

Expected Output Format

The formatted output should look like:

src/example.js
  15:7   error  Missing semicolon  semi
  23:12  error  Unexpected var, use let or const instead  no-var

src/utils.js
  8:3  error  Expected indentation of 2 spaces  indent

✖ 3 problems

Output Styling

The formatted output should include:

  • File paths styled distinctively (e.g., underlined)
  • Error information in aligned, tabular columns
  • Color-coded text: errors in red, metadata in gray
  • Proper singular/plural forms ("1 problem" vs "2 problems")
  • Unicode symbols in the summary line (✖)

Dependencies { .dependencies }

snazzy { .dependency }

Provides stream-based transformation of compact linter output to stylish format.

Test Cases

  • When piped valid JSON linter output with errors, it outputs formatted results and exits with code 1 @test
  • When piped JSON with no errors (empty messages arrays), it outputs clean results and exits with code 0 @test
  • When run without piped input (interactive terminal), it displays usage instructions @test

@generates

Install with Tessl CLI

npx tessl i tessl/npm-snazzy

tile.json