@prantlf/jsonlint 10.1.1 → 10.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [10.2.0](https://github.com/prantlf/jsonlint/compare/v10.1.1...v10.2.0) (2019-12-28)
2
+
3
+ ### Features
4
+
5
+ * Allow trimming trailing commas in arrays and objects (JSON5) ([136ea99](https://github.com/prantlf/jsonlint/commit/136ea995bef7b0f77c2ac54b6ce7dd8572190bf8))
6
+ * Allow unifying quotes around object keys to double or single ones (JSON5) ([6b6da17](https://github.com/prantlf/jsonlint/commit/6b6da175cfea8f71841e145a525ef124c19c2607))
7
+
1
8
  # [10.1.1](https://github.com/prantlf/jsonlint/compare/v10.1.0...v10.1.1) (2019-12-27)
2
9
 
3
10
  ### Bug Fixes
package/README.md CHANGED
@@ -103,6 +103,11 @@ By default, `jsonlint` will either report a syntax error with details or pretty-
103
103
  --prune-comments omit comments from the prettified output
104
104
  --strip-object-keys strip quotes from object keys if possible
105
105
  (JSON5)
106
+ --enforce-double-quotes surrounds all strings with double quotes
107
+ --enforce-single-quotes surrounds all strings with single quotes
108
+ (JSON5)
109
+ --trim-trailing-commas omit trailing commas from objects and arrays
110
+ (JSON5)
106
111
  -v, --version output the version number
107
112
  -h, --help output usage information
108
113
 
@@ -202,6 +207,9 @@ The [`print`](#pretty-printing) method accepts an object `options` as the second
202
207
  | `indent` | count of spaces or the specific characters to be used as an indentation unit |
203
208
  | `pruneComments` | will omit all tokens with comments |
204
209
  | `stripObjectKeys` | will not print quotes around object keys which are JavaScript identifier names |
210
+ | `enforceDoubleQuotes` | will surround all strings with double quotes |
211
+ | `enforceSingleQuotes` | will surround all strings with single quotes |
212
+ | `trimTrailingCommas` | will omit all trailing commas after the last object entry or array item |
205
213
 
206
214
  ```js
207
215
  // Just concatenate the tokens to produce the same output as was the input.
@@ -220,6 +228,12 @@ print(tokens, { indent: 2 })
220
228
  print(tokens, { indent: ' ', pruneComments: true })
221
229
  // Print to multiple lines with indentation enabled and JSON5 object keys.
222
230
  print(tokens, { indent: '\t', stripObjectKeys: true })
231
+ // Print to multiple lines with indentation enabled, unify JSON5 formatting.
232
+ print(tokens, {
233
+ indent: ' ',
234
+ enforceDoubleQuotes: true,
235
+ trimTrailingCommas: true
236
+ })
223
237
  ```
224
238
 
225
239
  ### Tokenizing
package/lib/cli.js CHANGED
@@ -34,6 +34,9 @@ var options = require('commander')
34
34
  .option('-P, --pretty-print-invalid', 'force pretty-printing even for invalid input')
35
35
  .option('--prune-comments', 'omit comments from the prettified output')
36
36
  .option('--strip-object-keys', 'strip quotes from object keys if possible (JSON5)')
37
+ .option('--enforce-double-quotes', 'surrounds all strings with double quotes')
38
+ .option('--enforce-single-quotes', 'surrounds all strings with single quotes (JSON5)')
39
+ .option('--trim-trailing-commas', 'omit trailing commas from objects and arrays (JSON5)')
37
40
  .version(pkg.version, '-v, --version')
38
41
  .on('--help', () => {
39
42
  console.log()
@@ -86,7 +89,10 @@ function parse (source, file) {
86
89
  return printer.print(tokens, {
87
90
  indent: options.indent,
88
91
  pruneComments: options.pruneComments,
89
- stripObjectKeys: options.stripObjectKeys
92
+ stripObjectKeys: options.stripObjectKeys,
93
+ enforceDoubleQuotes: options.enforceDoubleQuotes,
94
+ enforceSingleQuotes: options.enforceSingleQuotes,
95
+ trimTrailingCommas: options.trimTrailingCommas
90
96
  })
91
97
  }
92
98
  if (options.sortKeys) {
package/lib/jsonlint.d.ts CHANGED
@@ -90,6 +90,9 @@ declare module '@prantlf/jsonlint/lib/printer' {
90
90
  indent?: number | string
91
91
  pruneComments?: boolean
92
92
  stripObjectKeys?: boolean
93
+ enforceDoubleQuotes?: boolean
94
+ enforceSingleQuotes?: boolean
95
+ trimTrailingCommas?: boolean
93
96
  }
94
97
 
95
98
  /**
package/lib/printer.js CHANGED
@@ -48,6 +48,9 @@
48
48
  var prettyPrint = indentString !== undefined
49
49
  var pruneComments = options.pruneComments
50
50
  var stripObjectKeys = options.stripObjectKeys
51
+ var enforceDoubleQuotes = options.enforceDoubleQuotes
52
+ var enforceSingleQuotes = options.enforceSingleQuotes
53
+ var trimTrailingCommas = options.trimTrailingCommas
51
54
 
52
55
  var outputString = ''
53
56
  var foundLineBreak, addedLineBreak, needsLineBreak
@@ -59,6 +62,16 @@
59
62
  var tokenCount = tokens.length
60
63
  var tokenIndex, token, tokenType, tokenContent
61
64
 
65
+ function peekAtNextToken () {
66
+ var nextTokenIndex = tokenIndex
67
+ var nextToken
68
+ do {
69
+ nextToken = tokens[++nextTokenIndex]
70
+ } while (nextToken && (nextToken.type === 'whitespace' ||
71
+ nextToken.type === 'comment'))
72
+ return nextToken
73
+ }
74
+
62
75
  var addIndent
63
76
  if (prettyPrint && indentString) {
64
77
  addIndent = function () {
@@ -184,6 +197,14 @@
184
197
  if (stripObjectKeys && scopeType === '{' && !isValue &&
185
198
  isIdentifierName(tokenValue)) {
186
199
  outputString += tokenValue
200
+ } else if (typeof tokenValue === 'string') {
201
+ if (enforceDoubleQuotes && tokenContent[0] !== '"') {
202
+ outputString += JSON.stringify(tokenValue)
203
+ } else if (enforceSingleQuotes && tokenContent[0] !== '\'') {
204
+ outputString += '\'' + tokenValue.replace(/'/g, '\\\'') + '\''
205
+ } else {
206
+ outputString += tokenContent
207
+ }
187
208
  } else {
188
209
  outputString += tokenContent
189
210
  }
@@ -212,6 +233,12 @@
212
233
  }
213
234
 
214
235
  function addComma () {
236
+ if (trimTrailingCommas) {
237
+ var nextToken = peekAtNextToken()
238
+ if (nextToken && nextToken.type === 'symbol') {
239
+ return tryAddingInlineComment()
240
+ }
241
+ }
215
242
  addDelayedSpaceOrLineBreak()
216
243
  outputString += ','
217
244
  tryAddingInlineComment()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prantlf/jsonlint",
3
- "version": "10.1.1",
3
+ "version": "10.2.0",
4
4
  "description": "JSON parser, syntax and schema validator and pretty-printer.",
5
5
  "author": "Ferdinand Prantl <prantlf@gmail.com> (http://prantl.tk)",
6
6
  "contributors": [
@@ -1,2 +1,2 @@
1
- (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports):typeof define==="function"&&define.amd?define("jsonlint-printer",["exports"],factory):(global=global||self,factory(global.jsonlintPrinter={}))})(this,function(exports){"use strict";function noop(){}function isIdentifierName(value){return/^[a-zA-Z$_][a-zA-Z0-9$_]*$/.test(value)}function concatenateTokens(tokens){var outputString="";var tokenCount=tokens.length;var tokenIndex;for(tokenIndex=0;tokenIndex<tokenCount;++tokenIndex){outputString+=tokens[tokenIndex].raw}return outputString}function print(tokens,options){if(!(tokens&&tokens.length)){throw new Error("JSON tokens missing.")}if(!(tokens[0]&&tokens[0].raw)){throw new Error("JSON tokens lack raw values.")}if(!options){return concatenateTokens(tokens)}var indentString=options.indent;if(typeof indentString==="number"){indentString=new Array(indentString+1).join(" ")}var prettyPrint=indentString!==undefined;var pruneComments=options.pruneComments;var stripObjectKeys=options.stripObjectKeys;var outputString="";var foundLineBreak,addedLineBreak,needsLineBreak;var addedSpace,needsSpace;var indentLevel=0;var scopes=[];var scopeType;var isValue;var tokenCount=tokens.length;var tokenIndex,token,tokenType,tokenContent;var addIndent;if(prettyPrint&&indentString){addIndent=function(){for(var i=0;i<indentLevel;++i){outputString+=indentString}}}else{addIndent=noop}var addLineBreak,addDelayedSpaceOrLineBreak;if(prettyPrint){addLineBreak=function(){outputString+="\n"};addDelayedSpaceOrLineBreak=function(){if(needsLineBreak){addLineBreak();addIndent()}else if(needsSpace){outputString+=" "}needsSpace=needsLineBreak=false}}else{addLineBreak=addDelayedSpaceOrLineBreak=noop}var addStandaloneComment,tryAddingInlineComment;if(pruneComments){addStandaloneComment=tryAddingInlineComment=noop}else{if(prettyPrint){addStandaloneComment=function(){if(!addedLineBreak&&tokenIndex>0){addLineBreak();addIndent()}outputString+=tokenContent;foundLineBreak=false;addedLineBreak=false;needsLineBreak=true};tryAddingInlineComment=function(){foundLineBreak=false;addedLineBreak=false;addedSpace=false;var tryTokenIndex=tokenIndex+1;function skipWhitespace(){var token=tokens[tryTokenIndex];if(token&&token.type==="whitespace"){foundLineBreak=token.raw.indexOf("\n")>=0;token=tokens[++tryTokenIndex]}return token}var token=skipWhitespace();if(!foundLineBreak&&token&&token.type==="comment"){if(needsLineBreak){if(!addedLineBreak){addLineBreak();addIndent()}}else{if(!addedSpace){outputString+=" "}}outputString+=token.raw;tokenIndex=tryTokenIndex++;skipWhitespace();if(foundLineBreak){needsSpace=false;needsLineBreak=true}else{needsSpace=true;needsLineBreak=false}}}}else{addStandaloneComment=function(){if(tokenContent[1]==="/"){outputString+="/*";outputString+=tokenContent.substr(2,tokenContent.length-2);outputString+=" */"}else{outputString+=tokenContent}};tryAddingInlineComment=noop}}function addLiteral(){addDelayedSpaceOrLineBreak();var tokenValue=token.value;if(stripObjectKeys&&scopeType==="{"&&!isValue&&isIdentifierName(tokenValue)){outputString+=tokenValue}else{outputString+=tokenContent}tryAddingInlineComment()}function openScope(){addDelayedSpaceOrLineBreak();scopes.push(scopeType);scopeType=tokenContent;isValue=scopeType==="[";outputString+=tokenContent;tryAddingInlineComment();++indentLevel;needsLineBreak=true}function closeScope(){scopeType=scopes.pop();addLineBreak();--indentLevel;addIndent();needsSpace=needsLineBreak=false;outputString+=tokenContent;tryAddingInlineComment()}function addComma(){addDelayedSpaceOrLineBreak();outputString+=",";tryAddingInlineComment();addLineBreak();addIndent();addedLineBreak=true;needsLineBreak=false;isValue=scopeType==="["}function addColon(){addDelayedSpaceOrLineBreak();outputString+=":";needsSpace=true;tryAddingInlineComment();isValue=true}for(tokenIndex=0;tokenIndex<tokenCount;++tokenIndex){token=tokens[tokenIndex];tokenType=token.type;tokenContent=token.raw;switch(tokenType){case"literal":addLiteral();break;case"comment":addStandaloneComment();break;case"symbol":switch(tokenContent){case"{":case"[":openScope();break;case"}":case"]":closeScope();break;case",":addComma();break;case":":addColon()}break;default:foundLineBreak=tokenContent.indexOf("\n")>=0}}return outputString}exports.print=print;Object.defineProperty(exports,"__esModule",{value:true})});
1
+ (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports):typeof define==="function"&&define.amd?define("jsonlint-printer",["exports"],factory):(global=global||self,factory(global.jsonlintPrinter={}))})(this,function(exports){"use strict";function noop(){}function isIdentifierName(value){return/^[a-zA-Z$_][a-zA-Z0-9$_]*$/.test(value)}function concatenateTokens(tokens){var outputString="";var tokenCount=tokens.length;var tokenIndex;for(tokenIndex=0;tokenIndex<tokenCount;++tokenIndex){outputString+=tokens[tokenIndex].raw}return outputString}function print(tokens,options){if(!(tokens&&tokens.length)){throw new Error("JSON tokens missing.")}if(!(tokens[0]&&tokens[0].raw)){throw new Error("JSON tokens lack raw values.")}if(!options){return concatenateTokens(tokens)}var indentString=options.indent;if(typeof indentString==="number"){indentString=new Array(indentString+1).join(" ")}var prettyPrint=indentString!==undefined;var pruneComments=options.pruneComments;var stripObjectKeys=options.stripObjectKeys;var enforceDoubleQuotes=options.enforceDoubleQuotes;var enforceSingleQuotes=options.enforceSingleQuotes;var trimTrailingCommas=options.trimTrailingCommas;var outputString="";var foundLineBreak,addedLineBreak,needsLineBreak;var addedSpace,needsSpace;var indentLevel=0;var scopes=[];var scopeType;var isValue;var tokenCount=tokens.length;var tokenIndex,token,tokenType,tokenContent;function peekAtNextToken(){var nextTokenIndex=tokenIndex;var nextToken;do{nextToken=tokens[++nextTokenIndex]}while(nextToken&&(nextToken.type==="whitespace"||nextToken.type==="comment"));return nextToken}var addIndent;if(prettyPrint&&indentString){addIndent=function(){for(var i=0;i<indentLevel;++i){outputString+=indentString}}}else{addIndent=noop}var addLineBreak,addDelayedSpaceOrLineBreak;if(prettyPrint){addLineBreak=function(){outputString+="\n"};addDelayedSpaceOrLineBreak=function(){if(needsLineBreak){addLineBreak();addIndent()}else if(needsSpace){outputString+=" "}needsSpace=needsLineBreak=false}}else{addLineBreak=addDelayedSpaceOrLineBreak=noop}var addStandaloneComment,tryAddingInlineComment;if(pruneComments){addStandaloneComment=tryAddingInlineComment=noop}else{if(prettyPrint){addStandaloneComment=function(){if(!addedLineBreak&&tokenIndex>0){addLineBreak();addIndent()}outputString+=tokenContent;foundLineBreak=false;addedLineBreak=false;needsLineBreak=true};tryAddingInlineComment=function(){foundLineBreak=false;addedLineBreak=false;addedSpace=false;var tryTokenIndex=tokenIndex+1;function skipWhitespace(){var token=tokens[tryTokenIndex];if(token&&token.type==="whitespace"){foundLineBreak=token.raw.indexOf("\n")>=0;token=tokens[++tryTokenIndex]}return token}var token=skipWhitespace();if(!foundLineBreak&&token&&token.type==="comment"){if(needsLineBreak){if(!addedLineBreak){addLineBreak();addIndent()}}else{if(!addedSpace){outputString+=" "}}outputString+=token.raw;tokenIndex=tryTokenIndex++;skipWhitespace();if(foundLineBreak){needsSpace=false;needsLineBreak=true}else{needsSpace=true;needsLineBreak=false}}}}else{addStandaloneComment=function(){if(tokenContent[1]==="/"){outputString+="/*";outputString+=tokenContent.substr(2,tokenContent.length-2);outputString+=" */"}else{outputString+=tokenContent}};tryAddingInlineComment=noop}}function addLiteral(){addDelayedSpaceOrLineBreak();var tokenValue=token.value;if(stripObjectKeys&&scopeType==="{"&&!isValue&&isIdentifierName(tokenValue)){outputString+=tokenValue}else if(typeof tokenValue==="string"){if(enforceDoubleQuotes&&tokenContent[0]!=='"'){outputString+=JSON.stringify(tokenValue)}else if(enforceSingleQuotes&&tokenContent[0]!=="'"){outputString+="'"+tokenValue.replace(/'/g,"\\'")+"'"}else{outputString+=tokenContent}}else{outputString+=tokenContent}tryAddingInlineComment()}function openScope(){addDelayedSpaceOrLineBreak();scopes.push(scopeType);scopeType=tokenContent;isValue=scopeType==="[";outputString+=tokenContent;tryAddingInlineComment();++indentLevel;needsLineBreak=true}function closeScope(){scopeType=scopes.pop();addLineBreak();--indentLevel;addIndent();needsSpace=needsLineBreak=false;outputString+=tokenContent;tryAddingInlineComment()}function addComma(){if(trimTrailingCommas){var nextToken=peekAtNextToken();if(nextToken&&nextToken.type==="symbol"){return tryAddingInlineComment()}}addDelayedSpaceOrLineBreak();outputString+=",";tryAddingInlineComment();addLineBreak();addIndent();addedLineBreak=true;needsLineBreak=false;isValue=scopeType==="["}function addColon(){addDelayedSpaceOrLineBreak();outputString+=":";needsSpace=true;tryAddingInlineComment();isValue=true}for(tokenIndex=0;tokenIndex<tokenCount;++tokenIndex){token=tokens[tokenIndex];tokenType=token.type;tokenContent=token.raw;switch(tokenType){case"literal":addLiteral();break;case"comment":addStandaloneComment();break;case"symbol":switch(tokenContent){case"{":case"[":openScope();break;case"}":case"]":closeScope();break;case",":addComma();break;case":":addColon()}break;default:foundLineBreak=tokenContent.indexOf("\n")>=0}}return outputString}exports.print=print;Object.defineProperty(exports,"__esModule",{value:true})});
2
2
  //# sourceMappingURL=printer.min.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["lib/printer.js"],"names":["global","factory","exports","module","define","amd","self","jsonlintPrinter","this","noop","isIdentifierName","value","test","concatenateTokens","tokens","outputString","tokenCount","length","tokenIndex","raw","print","options","Error","indentString","indent","Array","join","prettyPrint","undefined","pruneComments","stripObjectKeys","foundLineBreak","addedLineBreak","needsLineBreak","addedSpace","needsSpace","indentLevel","scopes","scopeType","isValue","token","tokenType","tokenContent","addIndent","i","addLineBreak","addDelayedSpaceOrLineBreak","addStandaloneComment","tryAddingInlineComment","tryTokenIndex","skipWhitespace","type","indexOf","substr","addLiteral","tokenValue","openScope","push","closeScope","pop","addComma","addColon","Object","defineProperty"],"mappings":"CAAC,SAAUA,OAAQC,gBAEVC,UAAY,iBAAmBC,SAAW,YAAcF,QAAQC,gBAE5DE,SAAW,YAAcA,OAAOC,IAAMD,OAAO,mBAAoB,CAAC,WAAYH,UAElFD,OAASA,QAAUM,KAAML,QAAQD,OAAOO,gBAAkB,MANnE,CAOEC,KAAM,SAAUN,SAChB,aAEA,SAASO,QAET,SAASC,iBAAkBC,OACzB,MAAO,6BAA6BC,KAAKD,OAG3C,SAASE,k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lB,cAAgB2B,aAChBM,yBAGF,SAASY,WACPd,6BACA/B,cAAgB,IAChBiC,yBACAH,eACAF,YACAX,eAAiB,KACjBC,eAAiB,MACjBM,QAAUD,YAAc,IAG1B,SAASuB,WACPf,6BACA/B,cAAgB,IAChBoB,WAAa,KACba,yBACAT,QAAU,KAGZ,IAAKrB,WAAa,EAAGA,WAAaF,aAAcE,WAAY,CAC1DsB,MAAQ1B,OAAOI,YACfuB,UAAYD,MAAMW,KAClBT,aAAeF,MAAMrB,IACrB,OAAQsB,WACN,IAAK,UACHa,aACA,MACF,IAAK,UACHP,uBACA,MACF,IAAK,SACH,OAAQL,cACN,IAAK,IACL,IAAK,IACHc,YACA,MACF,IAAK,IACL,IAAK,IACHE,aACA,MACF,IAAK,IACHE,WACA,MACF,IAAK,IACHC,WAEJ,MACF,QACE9B,eAAiBW,aAAaU,QAAQ,OAAS,GAIrD,OAAOrC,aAGTb,QAAQkB,MAAQA,MAEhB0C,OAAOC,eAAe7D,QAAS,aAAc,CAAES,MAAO","file":"printer.js","sourcesContent":["(function (global, factory) {\n // eslint-disable-next-line no-unused-expressions\n typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports)\n // eslint-disable-next-line no-undef\n : typeof define === 'function' && define.amd ? define('jsonlint-printer', ['exports'], factory)\n // eslint-disable-next-line no-undef\n : (global = global || self, factory(global.jsonlintPrinter = {}))\n}(this, function (exports) {\n 'use strict'\n\n function noop () {}\n\n function isIdentifierName (value) {\n return /^[a-zA-Z$_][a-zA-Z0-9$_]*$/.test(value)\n }\n\n function concatenateTokens (tokens) {\n var outputString = ''\n var tokenCount = tokens.length\n var tokenIndex\n for (tokenIndex = 0; tokenIndex < tokenCount; ++tokenIndex) {\n outputString += tokens[tokenIndex].raw\n }\n return outputString\n }\n\n function print (tokens, options) {\n if (!(tokens && tokens.length)) {\n throw new Error('JSON tokens missing.')\n }\n // Whitespace and comments are available only as raw token content.\n if (!(tokens[0] && tokens[0].raw)) {\n throw new Error('JSON tokens lack raw values.')\n }\n\n if (!options) {\n // If no options, not even an empty object is passed, just concatenate\n // the raw tokens with neither minification, nor pretty-printing.\n return concatenateTokens(tokens)\n }\n\n var indentString = options.indent\n if (typeof indentString === 'number') {\n indentString = new Array(indentString + 1).join(' ')\n }\n // Setting the indent to an empty string enables pretty-printing too.\n // It will just insert line breaks without any indentation.\n var prettyPrint = indentString !== undefined\n var pruneComments = options.pruneComments\n var stripObjectKeys = options.stripObjectKeys\n\n var outputString = ''\n var foundLineBreak, addedLineBreak, needsLineBreak\n var addedSpace, needsSpace\n var indentLevel = 0\n var scopes = []\n var scopeType\n var isValue\n var tokenCount = tokens.length\n var tokenIndex, token, tokenType, tokenContent\n\n var addIndent\n if (prettyPrint && indentString) {\n addIndent = function () {\n for (var i = 0; i < indentLevel; ++i) {\n outputString += indentString\n }\n }\n } else {\n addIndent = noop\n }\n\n var addLineBreak, addDelayedSpaceOrLineBreak\n if (prettyPrint) {\n addLineBreak = function () {\n outputString += '\\n'\n }\n\n addDelayedSpaceOrLineBreak = function () {\n // A line break is more important than a space.\n if (needsLineBreak) {\n addLineBreak()\n addIndent()\n } else if (needsSpace) {\n outputString += ' '\n }\n needsSpace = needsLineBreak = false\n }\n } else {\n addLineBreak = addDelayedSpaceOrLineBreak = noop\n }\n\n var addStandaloneComment, tryAddingInlineComment\n if (pruneComments) {\n addStandaloneComment = tryAddingInlineComment = noop\n } else {\n if (prettyPrint) {\n addStandaloneComment = function () {\n // If a comment is not appended to the end of a line, it will start\n // on a new line with the current indentation.\n if (!addedLineBreak && tokenIndex > 0) {\n addLineBreak()\n addIndent()\n }\n outputString += tokenContent\n foundLineBreak = false\n addedLineBreak = false\n // If a comment is not appended to the end of a line, it will take\n // the whole line and has to end by a line break.\n needsLineBreak = true\n }\n\n tryAddingInlineComment = function () {\n // This function is called after printing a non-line-break character.\n foundLineBreak = false\n addedLineBreak = false\n addedSpace = false\n\n // Start with the character after the just processed one.\n var tryTokenIndex = tokenIndex + 1\n\n function skipWhitespace () {\n var token = tokens[tryTokenIndex]\n if (token && token.type === 'whitespace') {\n foundLineBreak = token.raw.indexOf('\\n') >= 0\n token = tokens[++tryTokenIndex]\n }\n return token\n }\n\n var token = skipWhitespace()\n // If line break followed the previous token, leave the comment\n // to be handled by the next usual token processing.\n if (!foundLineBreak && token && token.type === 'comment') {\n if (needsLineBreak) {\n // If the previous non-whitespace token was ended by a line\n // break, retain it. Print the comment after the line break too.\n if (!addedLineBreak) {\n addLineBreak()\n addIndent()\n }\n } else {\n // If the previous non-whitespace token was not ended by a line\n // break, ensure that the comment is separated from it.\n if (!addedSpace) {\n outputString += ' '\n }\n }\n outputString += token.raw\n // Set the current token to the just processed comment.\n tokenIndex = tryTokenIndex++\n // Check the whitespace after the comment to give a hint\n // about the next whitespace to the further processing.\n skipWhitespace()\n if (foundLineBreak) {\n needsSpace = false\n needsLineBreak = true\n } else {\n needsSpace = true\n needsLineBreak = false\n }\n }\n }\n } else {\n // If all whitespace is omitted, convert single-line comments\n // to multi-line ones, which include a comment-closing token.\n addStandaloneComment = function () {\n if (tokenContent[1] === '/') {\n outputString += '/*'\n outputString += tokenContent.substr(2, tokenContent.length - 2)\n outputString += ' */'\n } else {\n outputString += tokenContent\n }\n }\n\n tryAddingInlineComment = noop\n }\n }\n\n function addLiteral () {\n addDelayedSpaceOrLineBreak()\n var tokenValue = token.value\n if (stripObjectKeys && scopeType === '{' && !isValue &&\n isIdentifierName(tokenValue)) {\n outputString += tokenValue\n } else {\n outputString += tokenContent\n }\n tryAddingInlineComment()\n }\n\n function openScope () {\n addDelayedSpaceOrLineBreak()\n scopes.push(scopeType)\n scopeType = tokenContent\n isValue = scopeType === '['\n outputString += tokenContent\n tryAddingInlineComment()\n ++indentLevel\n needsLineBreak = true\n }\n\n function closeScope () {\n scopeType = scopes.pop()\n addLineBreak()\n --indentLevel\n addIndent()\n needsSpace = needsLineBreak = false\n outputString += tokenContent\n tryAddingInlineComment()\n }\n\n function addComma () {\n addDelayedSpaceOrLineBreak()\n outputString += ','\n tryAddingInlineComment()\n addLineBreak()\n addIndent()\n addedLineBreak = true\n needsLineBreak = false\n isValue = scopeType === '['\n }\n\n function addColon () {\n addDelayedSpaceOrLineBreak()\n outputString += ':'\n needsSpace = true\n tryAddingInlineComment()\n isValue = true\n }\n\n for (tokenIndex = 0; tokenIndex < tokenCount; ++tokenIndex) {\n token = tokens[tokenIndex]\n tokenType = token.type\n tokenContent = token.raw\n switch (tokenType) {\n case 'literal':\n addLiteral()\n break\n case 'comment':\n addStandaloneComment()\n break\n case 'symbol':\n switch (tokenContent) {\n case '{':\n case '[':\n openScope()\n break\n case '}':\n case ']':\n closeScope()\n break\n case ',':\n addComma()\n break\n case ':':\n addColon()\n }\n break\n default: // whitespace\n foundLineBreak = tokenContent.indexOf('\\n') >= 0\n }\n }\n\n return outputString\n }\n\n exports.print = print\n\n Object.defineProperty(exports, '__esModule', { value: true })\n}))\n"]}
1
+ {"version":3,"sources":["lib/printer.js"],"names":["global","factory","exports","module","define","amd","self","jsonlintPrinter","this","noop","isIdentifierName","value","test","concatenateTokens","tokens","outputString","tokenCount","length","tokenIndex","raw","print","options","Error","indentString","indent","Array","join","prettyPrint","undefined","pruneComments","stripObjectKeys","enforceDoubleQuotes","enforceSingleQuotes","trimTrailingCommas","foundLineBreak","addedLineBreak","needsLineBreak","addedSpace","needsSpace","indentLevel","scopes","scopeType","isValue","token","tokenType","tokenContent","peekAtNextToken","nextTokenIndex","nextToken","type","addIndent","i","addLineBreak","addDelayedSpaceOrLineBreak","addStandaloneComment","tryAddingInlineComment","tryTokenIndex","skipWhitespace","indexOf","substr","addLiteral","tokenValue","JSON","stringify","replace","openScope","push","closeScope","pop","addComma","addColon","Object","defineProperty"],"mappings":"CAAC,SAAUA,OAAQC,gBAEVC,UAAY,iBAAmBC,SAAW,YAAcF,QAAQC,gBAE5DE,SAAW,YAAcA,OAAOC,IAAMD,OAAO,mBAAoB,CAAC,WAAYH,UAElFD,OAASA,QAAUM,KAAML,QAAQD,O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,aAAaa,QAAQ,OAAS,GAIrD,OAAO3C,aAGTb,QAAQkB,MAAQA,MAEhBmD,OAAOC,eAAetE,QAAS,aAAc,CAAES,MAAO","file":"printer.js","sourcesContent":["(function (global, factory) {\n // eslint-disable-next-line no-unused-expressions\n typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports)\n // eslint-disable-next-line no-undef\n : typeof define === 'function' && define.amd ? define('jsonlint-printer', ['exports'], factory)\n // eslint-disable-next-line no-undef\n : (global = global || self, factory(global.jsonlintPrinter = {}))\n}(this, function (exports) {\n 'use strict'\n\n function noop () {}\n\n function isIdentifierName (value) {\n return /^[a-zA-Z$_][a-zA-Z0-9$_]*$/.test(value)\n }\n\n function concatenateTokens (tokens) {\n var outputString = ''\n var tokenCount = tokens.length\n var tokenIndex\n for (tokenIndex = 0; tokenIndex < tokenCount; ++tokenIndex) {\n outputString += tokens[tokenIndex].raw\n }\n return outputString\n }\n\n function print (tokens, options) {\n if (!(tokens && tokens.length)) {\n throw new Error('JSON tokens missing.')\n }\n // Whitespace and comments are available only as raw token content.\n if (!(tokens[0] && tokens[0].raw)) {\n throw new Error('JSON tokens lack raw values.')\n }\n\n if (!options) {\n // If no options, not even an empty object is passed, just concatenate\n // the raw tokens with neither minification, nor pretty-printing.\n return concatenateTokens(tokens)\n }\n\n var indentString = options.indent\n if (typeof indentString === 'number') {\n indentString = new Array(indentString + 1).join(' ')\n }\n // Setting the indent to an empty string enables pretty-printing too.\n // It will just insert line breaks without any indentation.\n var prettyPrint = indentString !== undefined\n var pruneComments = options.pruneComments\n var stripObjectKeys = options.stripObjectKeys\n var enforceDoubleQuotes = options.enforceDoubleQuotes\n var enforceSingleQuotes = options.enforceSingleQuotes\n var trimTrailingCommas = options.trimTrailingCommas\n\n var outputString = ''\n var foundLineBreak, addedLineBreak, needsLineBreak\n var addedSpace, needsSpace\n var indentLevel = 0\n var scopes = []\n var scopeType\n var isValue\n var tokenCount = tokens.length\n var tokenIndex, token, tokenType, tokenContent\n\n function peekAtNextToken () {\n var nextTokenIndex = tokenIndex\n var nextToken\n do {\n nextToken = tokens[++nextTokenIndex]\n } while (nextToken && (nextToken.type === 'whitespace' ||\n nextToken.type === 'comment'))\n return nextToken\n }\n\n var addIndent\n if (prettyPrint && indentString) {\n addIndent = function () {\n for (var i = 0; i < indentLevel; ++i) {\n outputString += indentString\n }\n }\n } else {\n addIndent = noop\n }\n\n var addLineBreak, addDelayedSpaceOrLineBreak\n if (prettyPrint) {\n addLineBreak = function () {\n outputString += '\\n'\n }\n\n addDelayedSpaceOrLineBreak = function () {\n // A line break is more important than a space.\n if (needsLineBreak) {\n addLineBreak()\n addIndent()\n } else if (needsSpace) {\n outputString += ' '\n }\n needsSpace = needsLineBreak = false\n }\n } else {\n addLineBreak = addDelayedSpaceOrLineBreak = noop\n }\n\n var addStandaloneComment, tryAddingInlineComment\n if (pruneComments) {\n addStandaloneComment = tryAddingInlineComment = noop\n } else {\n if (prettyPrint) {\n addStandaloneComment = function () {\n // If a comment is not appended to the end of a line, it will start\n // on a new line with the current indentation.\n if (!addedLineBreak && tokenIndex > 0) {\n addLineBreak()\n addIndent()\n }\n outputString += tokenContent\n foundLineBreak = false\n addedLineBreak = false\n // If a comment is not appended to the end of a line, it will take\n // the whole line and has to end by a line break.\n needsLineBreak = true\n }\n\n tryAddingInlineComment = function () {\n // This function is called after printing a non-line-break character.\n foundLineBreak = false\n addedLineBreak = false\n addedSpace = false\n\n // Start with the character after the just processed one.\n var tryTokenIndex = tokenIndex + 1\n\n function skipWhitespace () {\n var token = tokens[tryTokenIndex]\n if (token && token.type === 'whitespace') {\n foundLineBreak = token.raw.indexOf('\\n') >= 0\n token = tokens[++tryTokenIndex]\n }\n return token\n }\n\n var token = skipWhitespace()\n // If line break followed the previous token, leave the comment\n // to be handled by the next usual token processing.\n if (!foundLineBreak && token && token.type === 'comment') {\n if (needsLineBreak) {\n // If the previous non-whitespace token was ended by a line\n // break, retain it. Print the comment after the line break too.\n if (!addedLineBreak) {\n addLineBreak()\n addIndent()\n }\n } else {\n // If the previous non-whitespace token was not ended by a line\n // break, ensure that the comment is separated from it.\n if (!addedSpace) {\n outputString += ' '\n }\n }\n outputString += token.raw\n // Set the current token to the just processed comment.\n tokenIndex = tryTokenIndex++\n // Check the whitespace after the comment to give a hint\n // about the next whitespace to the further processing.\n skipWhitespace()\n if (foundLineBreak) {\n needsSpace = false\n needsLineBreak = true\n } else {\n needsSpace = true\n needsLineBreak = false\n }\n }\n }\n } else {\n // If all whitespace is omitted, convert single-line comments\n // to multi-line ones, which include a comment-closing token.\n addStandaloneComment = function () {\n if (tokenContent[1] === '/') {\n outputString += '/*'\n outputString += tokenContent.substr(2, tokenContent.length - 2)\n outputString += ' */'\n } else {\n outputString += tokenContent\n }\n }\n\n tryAddingInlineComment = noop\n }\n }\n\n function addLiteral () {\n addDelayedSpaceOrLineBreak()\n var tokenValue = token.value\n if (stripObjectKeys && scopeType === '{' && !isValue &&\n isIdentifierName(tokenValue)) {\n outputString += tokenValue\n } else if (typeof tokenValue === 'string') {\n if (enforceDoubleQuotes && tokenContent[0] !== '\"') {\n outputString += JSON.stringify(tokenValue)\n } else if (enforceSingleQuotes && tokenContent[0] !== '\\'') {\n outputString += '\\'' + tokenValue.replace(/'/g, '\\\\\\'') + '\\''\n } else {\n outputString += tokenContent\n }\n } else {\n outputString += tokenContent\n }\n tryAddingInlineComment()\n }\n\n function openScope () {\n addDelayedSpaceOrLineBreak()\n scopes.push(scopeType)\n scopeType = tokenContent\n isValue = scopeType === '['\n outputString += tokenContent\n tryAddingInlineComment()\n ++indentLevel\n needsLineBreak = true\n }\n\n function closeScope () {\n scopeType = scopes.pop()\n addLineBreak()\n --indentLevel\n addIndent()\n needsSpace = needsLineBreak = false\n outputString += tokenContent\n tryAddingInlineComment()\n }\n\n function addComma () {\n if (trimTrailingCommas) {\n var nextToken = peekAtNextToken()\n if (nextToken && nextToken.type === 'symbol') {\n return tryAddingInlineComment()\n }\n }\n addDelayedSpaceOrLineBreak()\n outputString += ','\n tryAddingInlineComment()\n addLineBreak()\n addIndent()\n addedLineBreak = true\n needsLineBreak = false\n isValue = scopeType === '['\n }\n\n function addColon () {\n addDelayedSpaceOrLineBreak()\n outputString += ':'\n needsSpace = true\n tryAddingInlineComment()\n isValue = true\n }\n\n for (tokenIndex = 0; tokenIndex < tokenCount; ++tokenIndex) {\n token = tokens[tokenIndex]\n tokenType = token.type\n tokenContent = token.raw\n switch (tokenType) {\n case 'literal':\n addLiteral()\n break\n case 'comment':\n addStandaloneComment()\n break\n case 'symbol':\n switch (tokenContent) {\n case '{':\n case '[':\n openScope()\n break\n case '}':\n case ']':\n closeScope()\n break\n case ',':\n addComma()\n break\n case ':':\n addColon()\n }\n break\n default: // whitespace\n foundLineBreak = tokenContent.indexOf('\\n') >= 0\n }\n }\n\n return outputString\n }\n\n exports.print = print\n\n Object.defineProperty(exports, '__esModule', { value: true })\n}))\n"]}