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-10/

Linter Output Parser

Overview

Build a command-line tool that parses compact linter output from stdin and outputs the structured data as formatted JSON to stdout. The tool should handle variations in linter output formats robustly and provide helpful error messages.

Requirements

Input Processing

Your tool must:

  1. Read compact linter output from stdin
  2. Parse the input tolerantly, handling variations in format
  3. Normalize the parsed data into a consistent JSON structure
  4. Output the normalized JSON to stdout
  5. Exit with code 0 on success, or code 1 if parsing fails

Output Format

The output should be a JSON array of objects, where each object represents a file with linting issues:

[
  {
    "filePath": "path/to/file.js",
    "messages": [
      {
        "line": 10,
        "column": 5,
        "message": "Error description",
        "ruleId": "rule-name"
      }
    ]
  }
]

Error Handling

  • Handle malformed input gracefully
  • Provide informative error messages when parsing fails
  • Exit with appropriate exit codes

Test Cases { .tests }

Test Case 1: Basic Parsing { .test }

Input (via stdin):

/path/to/file.js:10:5: Missing semicolon. (semi)

Expected Output (to stdout):

[
  {
    "filePath": "/path/to/file.js",
    "messages": [
      {
        "line": 10,
        "column": 5,
        "message": "Missing semicolon.",
        "ruleId": "semi"
      }
    ]
  }
]

Exit Code: 0

Test File: test/parser.test.js

Test Case 2: Multiple Files { .test }

Input (via stdin):

src/app.js:15:3: Unexpected var, use let or const instead. (no-var)
src/utils.js:42:10: 'unused' is defined but never used. (no-unused-vars)

Expected Output (to stdout):

[
  {
    "filePath": "src/app.js",
    "messages": [
      {
        "line": 15,
        "column": 3,
        "message": "Unexpected var, use let or const instead.",
        "ruleId": "no-var"
      }
    ]
  },
  {
    "filePath": "src/utils.js",
    "messages": [
      {
        "line": 42,
        "column": 10,
        "message": "'unused' is defined but never used.",
        "ruleId": "no-unused-vars"
      }
    ]
  }
]

Exit Code: 0

Test File: test/parser.test.js

Implementation Notes

  • Focus on robust parsing that handles format variations
  • Use appropriate libraries for parsing compact linter output
  • Configure parsing options for maximum tolerance and error recovery
  • Ensure output is valid, well-formatted JSON

Dependencies { .dependencies }

standard-json { .dependency }

Provides parsing support for standard JavaScript linter output formats.

Install with Tessl CLI

npx tessl i tessl/npm-snazzy

tile.json