项目作者: standard

项目描述 :
:on:Format JavaScript Standard Style output to a JSON array.
高级语言: JavaScript
项目地址: git://github.com/standard/standard-json.git
创建时间: 2015-08-04T22:48:41Z
项目社区:https://github.com/standard/standard-json

开源协议:ISC License

下载


standard-json

npm
travis
downloads

Format JavaScript Standard Style output to a JSON array!

Install

  1. # use the CLI
  2. npm install --global standard-json
  3. # or use programatically
  4. npm install --save standard-json

CLI Usage

  1. standard | standard-json
  2. # exit code will be 1 if any errors are found
  3. standard --verbose | standard-json
  4. # the ruleId attribute will be filled in if --verbose is passed
  5. # works with anything based on standard-engine!
  6. semistandard | standard-json
  7. doublestandard | standard-json

Example output JSON (formatted)

Typical standard output:

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

After running through standard-json:

  1. [
  2. {
  3. "filePath": "/home/flet/code/something-great/bin.js",
  4. "messages": [
  5. {
  6. "line": "19",
  7. "column": "21",
  8. "message": "Missing space before function parentheses."
  9. }
  10. ]
  11. },
  12. {
  13. "filePath": "/home/flet/code/something-great/index.js",
  14. "messages": [
  15. {
  16. "line": "6",
  17. "column": "35",
  18. "message": "Strings must use singlequote."
  19. },
  20. {
  21. "line": "6",
  22. "column": "51",
  23. "message": "Extra semicolon."
  24. },
  25. {
  26. "line": "17",
  27. "column": "5",
  28. "message": "Keyword \"if\" must be followed by whitespace."
  29. },
  30. {
  31. "line": "22",
  32. "column": "28",
  33. "message": "Extra semicolon."
  34. }
  35. ]
  36. }
  37. ]

API Usage

  1. var txt = someStandardThing() // produces Standard Style output
  2. var standardJson = require('standard-json')
  3. var output = standardJson(txt)
  4. // output will be an array of errors or an empty array.
  5. var output = standardJson(txt, {noisey: true})
  6. // output will be an array of errors or an empty array.
  7. // The banner will be `console.error`'d (plus any other non-parsable lines)

Inspiration

This package was inspired by:

Contributing

Contributions welcome! Please read the contributing guidelines first.

License

ISC