Integrated jsonlint
This commit is contained in:
parent
5fc5e302dc
commit
adb3c6bdd9
|
@ -11,6 +11,7 @@ var NAME_MINIMALIST = 'jsoneditor-minimalist';
|
||||||
var ENTRY = './src/index.js';
|
var ENTRY = './src/index.js';
|
||||||
var HEADER = './src/header.js';
|
var HEADER = './src/header.js';
|
||||||
var DIST = './dist';
|
var DIST = './dist';
|
||||||
|
var EMPTY = __dirname + '/src/utils/empty.js'
|
||||||
|
|
||||||
// generate banner with today's date and correct version
|
// generate banner with today's date and correct version
|
||||||
function createBanner() {
|
function createBanner() {
|
||||||
|
@ -69,9 +70,9 @@ var compilerMinimalist = webpack({
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
bannerPlugin,
|
bannerPlugin,
|
||||||
new webpack.IgnorePlugin(new RegExp('^brace$')),
|
new webpack.NormalModuleReplacementPlugin(new RegExp('^brace$'), EMPTY),
|
||||||
new webpack.IgnorePlugin(new RegExp('^ajv')),
|
new webpack.NormalModuleReplacementPlugin(new RegExp('^ajv'), EMPTY),
|
||||||
new webpack.IgnorePlugin(new RegExp('jsonlint$')),
|
new webpack.NormalModuleReplacementPlugin(new RegExp('jsonlint$'), EMPTY),
|
||||||
new webpack.optimize.UglifyJsPlugin() // TODO: don't minify when watching
|
new webpack.optimize.UglifyJsPlugin() // TODO: don't minify when watching
|
||||||
],
|
],
|
||||||
module: {
|
module: {
|
||||||
|
|
12
package.json
12
package.json
|
@ -23,18 +23,18 @@
|
||||||
"test": "ava test/*.test.js test/**/*.test.js --verbose"
|
"test": "ava test/*.test.js test/**/*.test.js --verbose"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ajv": "4.7.0",
|
"ajv": "4.7.5",
|
||||||
"brace": "0.8.0",
|
"brace": "0.8.0",
|
||||||
"javascript-natural-sort": "0.7.1",
|
"javascript-natural-sort": "0.7.1",
|
||||||
"lodash": "4.15.0",
|
"lodash": "4.16.2",
|
||||||
"preact": "6.0.2"
|
"preact": "6.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"ava": "0.16.0",
|
"ava": "0.16.0",
|
||||||
"babel-core": "6.14.0",
|
"babel-core": "6.16.0",
|
||||||
"babel-loader": "6.2.5",
|
"babel-loader": "6.2.5",
|
||||||
"babel-preset-stage-2": "6.13.0",
|
"babel-preset-stage-2": "6.16.0",
|
||||||
"babel-preset-stage-3": "6.11.0",
|
"babel-preset-stage-3": "6.16.0",
|
||||||
"css-loader": "0.25.0",
|
"css-loader": "0.25.0",
|
||||||
"gulp": "3.9.1",
|
"gulp": "3.9.1",
|
||||||
"gulp-shell": "0.5.2",
|
"gulp-shell": "0.5.2",
|
||||||
|
|
|
@ -1,15 +1,18 @@
|
||||||
/* Jison generated parser */
|
/*
|
||||||
var jsonlint = (function(){
|
* Jison generated parser
|
||||||
var parser = {trace: function trace() { },
|
* Refactored into an ES6 module
|
||||||
yy: {},
|
**/
|
||||||
symbols_: {"error":2,"JSONString":3,"STRING":4,"JSONNumber":5,"NUMBER":6,"JSONNullLiteral":7,"NULL":8,"JSONBooleanLiteral":9,"TRUE":10,"FALSE":11,"JSONText":12,"JSONValue":13,"EOF":14,"JSONObject":15,"JSONArray":16,"{":17,"}":18,"JSONMemberList":19,"JSONMember":20,":":21,",":22,"[":23,"]":24,"JSONElementList":25,"$accept":0,"$end":1},
|
export var parser = (function(){
|
||||||
terminals_: {2:"error",4:"STRING",6:"NUMBER",8:"NULL",10:"TRUE",11:"FALSE",14:"EOF",17:"{",18:"}",21:":",22:",",23:"[",24:"]"},
|
var parser = {trace: function trace() { },
|
||||||
productions_: [0,[3,1],[5,1],[7,1],[9,1],[9,1],[12,2],[13,1],[13,1],[13,1],[13,1],[13,1],[13,1],[15,2],[15,3],[20,3],[19,1],[19,3],[16,2],[16,3],[25,1],[25,3]],
|
yy: {},
|
||||||
performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) {
|
symbols_: {"error":2,"JSONString":3,"STRING":4,"JSONNumber":5,"NUMBER":6,"JSONNullLiteral":7,"NULL":8,"JSONBooleanLiteral":9,"TRUE":10,"FALSE":11,"JSONText":12,"JSONValue":13,"EOF":14,"JSONObject":15,"JSONArray":16,"{":17,"}":18,"JSONMemberList":19,"JSONMember":20,":":21,",":22,"[":23,"]":24,"JSONElementList":25,"$accept":0,"$end":1},
|
||||||
|
terminals_: {2:"error",4:"STRING",6:"NUMBER",8:"NULL",10:"TRUE",11:"FALSE",14:"EOF",17:"{",18:"}",21:":",22:",",23:"[",24:"]"},
|
||||||
|
productions_: [0,[3,1],[5,1],[7,1],[9,1],[9,1],[12,2],[13,1],[13,1],[13,1],[13,1],[13,1],[13,1],[15,2],[15,3],[20,3],[19,1],[19,3],[16,2],[16,3],[25,1],[25,3]],
|
||||||
|
performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) {
|
||||||
|
|
||||||
var $0 = $$.length - 1;
|
var $0 = $$.length - 1;
|
||||||
switch (yystate) {
|
switch (yystate) {
|
||||||
case 1: // replace escaped characters with actual character
|
case 1: // replace escaped characters with actual character
|
||||||
this.$ = yytext.replace(/\\(\\|")/g, "$"+"1")
|
this.$ = yytext.replace(/\\(\\|")/g, "$"+"1")
|
||||||
.replace(/\\n/g,'\n')
|
.replace(/\\n/g,'\n')
|
||||||
.replace(/\\r/g,'\r')
|
.replace(/\\r/g,'\r')
|
||||||
|
@ -18,43 +21,43 @@ case 1: // replace escaped characters with actual character
|
||||||
.replace(/\\f/g,'\f')
|
.replace(/\\f/g,'\f')
|
||||||
.replace(/\\b/g,'\b');
|
.replace(/\\b/g,'\b');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 2:this.$ = Number(yytext);
|
case 2:this.$ = Number(yytext);
|
||||||
break;
|
break;
|
||||||
case 3:this.$ = null;
|
case 3:this.$ = null;
|
||||||
break;
|
break;
|
||||||
case 4:this.$ = true;
|
case 4:this.$ = true;
|
||||||
break;
|
break;
|
||||||
case 5:this.$ = false;
|
case 5:this.$ = false;
|
||||||
break;
|
break;
|
||||||
case 6:return this.$ = $$[$0-1];
|
case 6:return this.$ = $$[$0-1];
|
||||||
break;
|
break;
|
||||||
case 13:this.$ = {};
|
case 13:this.$ = {};
|
||||||
break;
|
break;
|
||||||
case 14:this.$ = $$[$0-1];
|
case 14:this.$ = $$[$0-1];
|
||||||
break;
|
break;
|
||||||
case 15:this.$ = [$$[$0-2], $$[$0]];
|
case 15:this.$ = [$$[$0-2], $$[$0]];
|
||||||
break;
|
break;
|
||||||
case 16:this.$ = {}; this.$[$$[$0][0]] = $$[$0][1];
|
case 16:this.$ = {}; this.$[$$[$0][0]] = $$[$0][1];
|
||||||
break;
|
break;
|
||||||
case 17:this.$ = $$[$0-2]; $$[$0-2][$$[$0][0]] = $$[$0][1];
|
case 17:this.$ = $$[$0-2]; $$[$0-2][$$[$0][0]] = $$[$0][1];
|
||||||
break;
|
break;
|
||||||
case 18:this.$ = [];
|
case 18:this.$ = [];
|
||||||
break;
|
break;
|
||||||
case 19:this.$ = $$[$0-1];
|
case 19:this.$ = $$[$0-1];
|
||||||
break;
|
break;
|
||||||
case 20:this.$ = [$$[$0]];
|
case 20:this.$ = [$$[$0]];
|
||||||
break;
|
break;
|
||||||
case 21:this.$ = $$[$0-2]; $$[$0-2].push($$[$0]);
|
case 21:this.$ = $$[$0-2]; $$[$0-2].push($$[$0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
table: [{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],12:1,13:2,15:7,16:8,17:[1,14],23:[1,15]},{1:[3]},{14:[1,16]},{14:[2,7],18:[2,7],22:[2,7],24:[2,7]},{14:[2,8],18:[2,8],22:[2,8],24:[2,8]},{14:[2,9],18:[2,9],22:[2,9],24:[2,9]},{14:[2,10],18:[2,10],22:[2,10],24:[2,10]},{14:[2,11],18:[2,11],22:[2,11],24:[2,11]},{14:[2,12],18:[2,12],22:[2,12],24:[2,12]},{14:[2,3],18:[2,3],22:[2,3],24:[2,3]},{14:[2,4],18:[2,4],22:[2,4],24:[2,4]},{14:[2,5],18:[2,5],22:[2,5],24:[2,5]},{14:[2,1],18:[2,1],21:[2,1],22:[2,1],24:[2,1]},{14:[2,2],18:[2,2],22:[2,2],24:[2,2]},{3:20,4:[1,12],18:[1,17],19:18,20:19},{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],13:23,15:7,16:8,17:[1,14],23:[1,15],24:[1,21],25:22},{1:[2,6]},{14:[2,13],18:[2,13],22:[2,13],24:[2,13]},{18:[1,24],22:[1,25]},{18:[2,16],22:[2,16]},{21:[1,26]},{14:[2,18],18:[2,18],22:[2,18],24:[2,18]},{22:[1,28],24:[1,27]},{22:[2,20],24:[2,20]},{14:[2,14],18:[2,14],22:[2,14],24:[2,14]},{3:20,4:[1,12],20:29},{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],13:30,15:7,16:8,17:[1,14],23:[1,15]},{14:[2,19],18:[2,19],22:[2,19],24:[2,19]},{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],13:31,15:7,16:8,17:[1,14],23:[1,15]},{18:[2,17],22:[2,17]},{18:[2,15],22:[2,15]},{22:[2,21],24:[2,21]}],
|
table: [{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],12:1,13:2,15:7,16:8,17:[1,14],23:[1,15]},{1:[3]},{14:[1,16]},{14:[2,7],18:[2,7],22:[2,7],24:[2,7]},{14:[2,8],18:[2,8],22:[2,8],24:[2,8]},{14:[2,9],18:[2,9],22:[2,9],24:[2,9]},{14:[2,10],18:[2,10],22:[2,10],24:[2,10]},{14:[2,11],18:[2,11],22:[2,11],24:[2,11]},{14:[2,12],18:[2,12],22:[2,12],24:[2,12]},{14:[2,3],18:[2,3],22:[2,3],24:[2,3]},{14:[2,4],18:[2,4],22:[2,4],24:[2,4]},{14:[2,5],18:[2,5],22:[2,5],24:[2,5]},{14:[2,1],18:[2,1],21:[2,1],22:[2,1],24:[2,1]},{14:[2,2],18:[2,2],22:[2,2],24:[2,2]},{3:20,4:[1,12],18:[1,17],19:18,20:19},{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],13:23,15:7,16:8,17:[1,14],23:[1,15],24:[1,21],25:22},{1:[2,6]},{14:[2,13],18:[2,13],22:[2,13],24:[2,13]},{18:[1,24],22:[1,25]},{18:[2,16],22:[2,16]},{21:[1,26]},{14:[2,18],18:[2,18],22:[2,18],24:[2,18]},{22:[1,28],24:[1,27]},{22:[2,20],24:[2,20]},{14:[2,14],18:[2,14],22:[2,14],24:[2,14]},{3:20,4:[1,12],20:29},{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],13:30,15:7,16:8,17:[1,14],23:[1,15]},{14:[2,19],18:[2,19],22:[2,19],24:[2,19]},{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],13:31,15:7,16:8,17:[1,14],23:[1,15]},{18:[2,17],22:[2,17]},{18:[2,15],22:[2,15]},{22:[2,21],24:[2,21]}],
|
||||||
defaultActions: {16:[2,6]},
|
defaultActions: {16:[2,6]},
|
||||||
parseError: function parseError(str, hash) {
|
parseError: function parseError(str, hash) {
|
||||||
throw new Error(str);
|
throw new Error(str);
|
||||||
},
|
},
|
||||||
parse: function parse(input) {
|
parse: function parse(input) {
|
||||||
var self = this,
|
var self = this,
|
||||||
stack = [0],
|
stack = [0],
|
||||||
vstack = [null], // semantic value stack
|
vstack = [null], // semantic value stack
|
||||||
|
@ -237,18 +240,18 @@ parse: function parse(input) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}};
|
}};
|
||||||
/* Jison generated lexer */
|
/* Jison generated lexer */
|
||||||
var lexer = (function(){
|
var lexer = (function(){
|
||||||
var lexer = ({EOF:1,
|
var lexer = ({EOF:1,
|
||||||
parseError:function parseError(str, hash) {
|
parseError:function parseError(str, hash) {
|
||||||
if (this.yy.parseError) {
|
if (this.yy.parseError) {
|
||||||
this.yy.parseError(str, hash);
|
this.yy.parseError(str, hash);
|
||||||
} else {
|
} else {
|
||||||
throw new Error(str);
|
throw new Error(str);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setInput:function (input) {
|
setInput:function (input) {
|
||||||
this._input = input;
|
this._input = input;
|
||||||
this._more = this._less = this.done = false;
|
this._more = this._less = this.done = false;
|
||||||
this.yylineno = this.yyleng = 0;
|
this.yylineno = this.yyleng = 0;
|
||||||
|
@ -257,7 +260,7 @@ setInput:function (input) {
|
||||||
this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0};
|
this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0};
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
input:function () {
|
input:function () {
|
||||||
var ch = this._input[0];
|
var ch = this._input[0];
|
||||||
this.yytext+=ch;
|
this.yytext+=ch;
|
||||||
this.yyleng++;
|
this.yyleng++;
|
||||||
|
@ -268,34 +271,34 @@ input:function () {
|
||||||
this._input = this._input.slice(1);
|
this._input = this._input.slice(1);
|
||||||
return ch;
|
return ch;
|
||||||
},
|
},
|
||||||
unput:function (ch) {
|
unput:function (ch) {
|
||||||
this._input = ch + this._input;
|
this._input = ch + this._input;
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
more:function () {
|
more:function () {
|
||||||
this._more = true;
|
this._more = true;
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
less:function (n) {
|
less:function (n) {
|
||||||
this._input = this.match.slice(n) + this._input;
|
this._input = this.match.slice(n) + this._input;
|
||||||
},
|
},
|
||||||
pastInput:function () {
|
pastInput:function () {
|
||||||
var past = this.matched.substr(0, this.matched.length - this.match.length);
|
var past = this.matched.substr(0, this.matched.length - this.match.length);
|
||||||
return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
|
return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
|
||||||
},
|
},
|
||||||
upcomingInput:function () {
|
upcomingInput:function () {
|
||||||
var next = this.match;
|
var next = this.match;
|
||||||
if (next.length < 20) {
|
if (next.length < 20) {
|
||||||
next += this._input.substr(0, 20-next.length);
|
next += this._input.substr(0, 20-next.length);
|
||||||
}
|
}
|
||||||
return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, "");
|
return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, "");
|
||||||
},
|
},
|
||||||
showPosition:function () {
|
showPosition:function () {
|
||||||
var pre = this.pastInput();
|
var pre = this.pastInput();
|
||||||
var c = new Array(pre.length + 1).join("-");
|
var c = new Array(pre.length + 1).join("-");
|
||||||
return pre + this.upcomingInput() + "\n" + c+"^";
|
return pre + this.upcomingInput() + "\n" + c+"^";
|
||||||
},
|
},
|
||||||
next:function () {
|
next:function () {
|
||||||
if (this.done) {
|
if (this.done) {
|
||||||
return this.EOF;
|
return this.EOF;
|
||||||
}
|
}
|
||||||
|
@ -345,7 +348,7 @@ next:function () {
|
||||||
{text: "", token: null, line: this.yylineno});
|
{text: "", token: null, line: this.yylineno});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
lex:function lex() {
|
lex:function lex() {
|
||||||
var r = this.next();
|
var r = this.next();
|
||||||
if (typeof r !== 'undefined') {
|
if (typeof r !== 'undefined') {
|
||||||
return r;
|
return r;
|
||||||
|
@ -353,66 +356,65 @@ lex:function lex() {
|
||||||
return this.lex();
|
return this.lex();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
begin:function begin(condition) {
|
begin:function begin(condition) {
|
||||||
this.conditionStack.push(condition);
|
this.conditionStack.push(condition);
|
||||||
},
|
},
|
||||||
popState:function popState() {
|
popState:function popState() {
|
||||||
return this.conditionStack.pop();
|
return this.conditionStack.pop();
|
||||||
},
|
},
|
||||||
_currentRules:function _currentRules() {
|
_currentRules:function _currentRules() {
|
||||||
return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules;
|
return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules;
|
||||||
},
|
},
|
||||||
topState:function () {
|
topState:function () {
|
||||||
return this.conditionStack[this.conditionStack.length-2];
|
return this.conditionStack[this.conditionStack.length-2];
|
||||||
},
|
},
|
||||||
pushState:function begin(condition) {
|
pushState:function begin(condition) {
|
||||||
this.begin(condition);
|
this.begin(condition);
|
||||||
}});
|
}});
|
||||||
lexer.options = {};
|
lexer.options = {};
|
||||||
lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
|
lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
|
||||||
|
|
||||||
var YYSTATE=YY_START
|
var YYSTATE=YY_START
|
||||||
switch($avoiding_name_collisions) {
|
switch($avoiding_name_collisions) {
|
||||||
case 0:/* skip whitespace */
|
case 0:/* skip whitespace */
|
||||||
break;
|
break;
|
||||||
case 1:return 6
|
case 1:return 6
|
||||||
break;
|
break;
|
||||||
case 2:yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2); return 4
|
case 2:yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2); return 4
|
||||||
break;
|
break;
|
||||||
case 3:return 17
|
case 3:return 17
|
||||||
break;
|
break;
|
||||||
case 4:return 18
|
case 4:return 18
|
||||||
break;
|
break;
|
||||||
case 5:return 23
|
case 5:return 23
|
||||||
break;
|
break;
|
||||||
case 6:return 24
|
case 6:return 24
|
||||||
break;
|
break;
|
||||||
case 7:return 22
|
case 7:return 22
|
||||||
break;
|
break;
|
||||||
case 8:return 21
|
case 8:return 21
|
||||||
break;
|
break;
|
||||||
case 9:return 10
|
case 9:return 10
|
||||||
break;
|
break;
|
||||||
case 10:return 11
|
case 10:return 11
|
||||||
break;
|
break;
|
||||||
case 11:return 8
|
case 11:return 8
|
||||||
break;
|
break;
|
||||||
case 12:return 14
|
case 12:return 14
|
||||||
break;
|
break;
|
||||||
case 13:return 'INVALID'
|
case 13:return 'INVALID'
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
lexer.rules = [/^(?:\s+)/,/^(?:(-?([0-9]|[1-9][0-9]+))(\.[0-9]+)?([eE][-+]?[0-9]+)?\b)/,/^(?:"(?:\\[\\"bfnrt/]|\\u[a-fA-F0-9]{4}|[^\\\0-\x09\x0a-\x1f"])*")/,/^(?:\{)/,/^(?:\})/,/^(?:\[)/,/^(?:\])/,/^(?:,)/,/^(?::)/,/^(?:true\b)/,/^(?:false\b)/,/^(?:null\b)/,/^(?:$)/,/^(?:.)/];
|
lexer.rules = [/^(?:\s+)/,/^(?:(-?([0-9]|[1-9][0-9]+))(\.[0-9]+)?([eE][-+]?[0-9]+)?\b)/,/^(?:"(?:\\[\\"bfnrt/]|\\u[a-fA-F0-9]{4}|[^\\\0-\x09\x0a-\x1f"])*")/,/^(?:\{)/,/^(?:\})/,/^(?:\[)/,/^(?:\])/,/^(?:,)/,/^(?::)/,/^(?:true\b)/,/^(?:false\b)/,/^(?:null\b)/,/^(?:$)/,/^(?:.)/];
|
||||||
lexer.conditions = {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13],"inclusive":true}};
|
lexer.conditions = {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13],"inclusive":true}};
|
||||||
|
|
||||||
|
|
||||||
;
|
return lexer;
|
||||||
return lexer;})()
|
})()
|
||||||
parser.lexer = lexer;
|
|
||||||
return parser;
|
parser.lexer = lexer;
|
||||||
|
return parser;
|
||||||
})();
|
})();
|
||||||
if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
|
|
||||||
exports.parser = jsonlint;
|
export var parse = parser.parse.bind(parser);
|
||||||
exports.parse = jsonlint.parse.bind(jsonlint);
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
// This file is used to replace excluded dependencies with an empty placeholder
|
|
@ -1,7 +1,4 @@
|
||||||
// TODO: import jsonlint globally
|
let jsonlint = require('../assets/jsonlint/jsonlint')
|
||||||
//import '../assets/jsonlint/jsonlint'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse JSON using the parser built-in in the browser.
|
* Parse JSON using the parser built-in in the browser.
|
||||||
|
@ -31,10 +28,16 @@ export function parseJSON(jsonString) {
|
||||||
* @throws Error
|
* @throws Error
|
||||||
*/
|
*/
|
||||||
export function validate(jsonString) {
|
export function validate(jsonString) {
|
||||||
if (typeof(window.jsonlint) !== 'undefined') {
|
if (jsonlint && jsonlint.parse) {
|
||||||
|
// use embedded jsonlint
|
||||||
|
jsonlint.parse(jsonString)
|
||||||
|
}
|
||||||
|
else if (window.jsonlint && window.jsonlint.parse) {
|
||||||
|
// use global jsonlint
|
||||||
window.jsonlint.parse(jsonString)
|
window.jsonlint.parse(jsonString)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// don't use jsonlint
|
||||||
JSON.parse(jsonString)
|
JSON.parse(jsonString)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue