1. standard-json
Format JavaScript Standard Style output to a JSON array.
standard-json
Package: standard-json
Created by: flet
Last modified: Thu, 13 Jul 2023 22:46:05 GMT
Version: 1.1.0
License: ISC
Downloads: 155,530
Repository: https://github.com/flet/standard-json

Install

npm install standard-json
yarn add standard-json

standard-json

npm
travis
downloads

Format JavaScript Standard Style output to a JSON array!

Install

# use the CLI
npm install --global standard-json

# or use programatically
npm install --save standard-json

CLI Usage

 standard | standard-json
# exit code will be 1 if any errors are found

standard --verbose | standard-json
# the ruleId attribute will be filled in if --verbose is passed

# works with anything based on standard-engine!
semistandard | standard-json
doublestandard | standard-json

Example output JSON (formatted)

Typical standard output:

 standard: Use JavaScript Standard Style (https://github.com/feross/standard)
  /home/icmpdev/code/standard-json/bin.js:19:21: Missing space before function parentheses.
  /home/icmpdev/code/standard-json/index.js:6:35: Strings must use singlequote.
  /home/icmpdev/code/standard-json/index.js:6:51: Extra semicolon.
  /home/icmpdev/code/standard-json/index.js:17:5: Keyword "if" must be followed by whitespace.
  /home/icmpdev/code/standard-json/index.js:22:28: Extra semicolon.

After running through standard-json:

 [
  {
    "filePath": "/home/flet/code/something-great/bin.js",
    "messages": [
      {
        "line": "19",
        "column": "21",
        "message": "Missing space before function parentheses."
      }
    ]
  },
  {
    "filePath": "/home/flet/code/something-great/index.js",
    "messages": [
      {
        "line": "6",
        "column": "35",
        "message": "Strings must use singlequote."
      },
      {
        "line": "6",
        "column": "51",
        "message": "Extra semicolon."
      },
      {
        "line": "17",
        "column": "5",
        "message": "Keyword \"if\" must be followed by whitespace."
      },
      {
        "line": "22",
        "column": "28",
        "message": "Extra semicolon."
      }
    ]
  }
]

API Usage

 
var txt = someStandardThing() // produces Standard Style output

var standardJson = require('standard-json')

var output = standardJson(txt)
// output will be an array of errors or an empty array.

var output = standardJson(txt, {noisey: true})
// output will be an array of errors or an empty array.
// The banner will be `console.error`'d (plus any other non-parsable lines)

Inspiration

This package was inspired by:

  • snazzy
  • https://github.com/standard/standard/issues/222

Contributing

Contributions welcome! Please read the contributing guidelines first.

License

ISC

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code