Skip to content

Commit b2555e2

Browse files
committed
Upgrade dependencies, fix linting issues
1 parent 6c2da0c commit b2555e2

File tree

10 files changed

+499
-373
lines changed

10 files changed

+499
-373
lines changed

package-lock.json

Lines changed: 237 additions & 107 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jsoneditor",
3-
"version": "9.8.0",
3+
"version": "9.9.0",
44
"main": "./dist/jsoneditor.min.js",
55
"description": "A web-based tool to view, edit, format, and validate JSON",
66
"tags": [
@@ -26,23 +26,23 @@
2626
"prepublishOnly": "npm test && npm run build"
2727
},
2828
"dependencies": {
29-
"ace-builds": "^1.5.3",
29+
"ace-builds": "^1.6.0",
3030
"ajv": "^6.12.6",
3131
"javascript-natural-sort": "^0.7.1",
3232
"jmespath": "^0.16.0",
33-
"jsonrepair": "^2.2.1",
3433
"json-source-map": "^0.6.1",
34+
"jsonrepair": "^2.2.1",
3535
"mobius1-selectr": "^2.4.13",
3636
"picomodal": "^3.0.0",
3737
"vanilla-picker": "^2.12.1"
3838
},
3939
"devDependencies": {
40-
"@babel/core": "7.18.2",
40+
"@babel/core": "7.18.5",
4141
"@babel/preset-env": "7.18.2",
4242
"@babel/register": "7.17.7",
4343
"babel-loader": "8.2.5",
4444
"btoa": "1.2.1",
45-
"date-format": "4.0.10",
45+
"date-format": "4.0.11",
4646
"fancy-log": "2.0.0",
4747
"gulp": "4.0.2",
4848
"gulp-clean-css": "4.3.0",
@@ -52,11 +52,11 @@
5252
"json-loader": "0.5.7",
5353
"mkdirp": "1.0.4",
5454
"mocha": "10.0.0",
55-
"sass": "1.52.1",
56-
"source-map-loader": "3.0.1",
55+
"sass": "1.52.3",
56+
"source-map-loader": "4.0.0",
5757
"standard": "17.0.0",
58-
"uglify-js": "3.15.5",
59-
"webpack": "5.72.1"
58+
"uglify-js": "3.16.0",
59+
"webpack": "5.73.0"
6060
},
6161
"files": [
6262
"dist",

src/js/JSONEditor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ JSONEditor.prototype.setSchema = function (schema, schemaRefs) {
400400
}
401401

402402
if (typeof this._onSchemaChange === 'function') {
403-
this._onSchemaChange.call(this, schema, schemaRefs);
403+
this._onSchemaChange(schema, schemaRefs)
404404
}
405405
}
406406

src/js/SchemaTextCompleter.js

Lines changed: 80 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
isArray,
66
isObject,
77
uniqueMergeArrays,
8-
asyncExec,
8+
asyncExec
99
} from './util'
1010

1111
/**
@@ -15,50 +15,50 @@ import {
1515
*/
1616
export class SchemaTextCompleter {
1717
constructor (schema, schemaRefs) {
18-
this.schema = schema;
19-
this.schemaRefs = schemaRefs || {};
20-
this.suggestions = {};
21-
this.suggestionsRefs = {};
22-
this._buildSuggestions();
18+
this.schema = schema
19+
this.schemaRefs = schemaRefs || {}
20+
this.suggestions = {}
21+
this.suggestionsRefs = {}
22+
this._buildSuggestions()
2323
}
2424

2525
_buildSuggestions () {
26-
this._handleSchemaEntry("" , this.schema, this.suggestions);
27-
for (let refName in this.schemaRefs) {
28-
this.suggestionsRefs[refName] = {};
29-
this._handleSchemaEntry("" , this.schemaRefs[refName], this.suggestionsRefs[refName]);
26+
this._handleSchemaEntry('', this.schema, this.suggestions)
27+
for (const refName in this.schemaRefs) {
28+
this.suggestionsRefs[refName] = {}
29+
this._handleSchemaEntry('', this.schemaRefs[refName], this.suggestionsRefs[refName])
3030
}
3131
}
3232

33-
_handleRef(currectPath, refName, suggestionsObj) {
33+
_handleRef (currectPath, refName, suggestionsObj) {
3434
suggestionsObj[currectPath] = suggestionsObj[currectPath] || {}
3535
suggestionsObj[currectPath].refs = suggestionsObj[currectPath].refs || []
36-
suggestionsObj[currectPath].refs = uniqueMergeArrays(suggestionsObj[currectPath].refs, [refName]);
36+
suggestionsObj[currectPath].refs = uniqueMergeArrays(suggestionsObj[currectPath].refs, [refName])
3737
}
3838

39-
_handleSchemaEntry(currectPath, schemaNode, suggestionsObj) {
40-
if(!schemaNode) {
41-
console.error('SchemaTextCompleter: schema node is missing for path', currectPath);
42-
return;
39+
_handleSchemaEntry (currectPath, schemaNode, suggestionsObj) {
40+
if (!schemaNode) {
41+
console.error('SchemaTextCompleter: schema node is missing for path', currectPath)
42+
return
4343
}
4444
if (schemaNode.$ref) {
45-
this._handleRef(currectPath, schemaNode.$ref, suggestionsObj);
46-
return;
45+
this._handleRef(currectPath, schemaNode.$ref, suggestionsObj)
46+
return
4747
}
48-
const ofConditionEntry = this._checkOfConditon(schemaNode);
48+
const ofConditionEntry = this._checkOfConditon(schemaNode)
4949
if (ofConditionEntry) {
50-
this._handleOfCondition(currectPath, schemaNode[ofConditionEntry], suggestionsObj);
51-
return;
50+
this._handleOfCondition(currectPath, schemaNode[ofConditionEntry], suggestionsObj)
51+
return
5252
}
53-
switch(schemaNode.type) {
53+
switch (schemaNode.type) {
5454
case 'object':
5555
this._handleObject(currectPath, schemaNode, suggestionsObj)
56-
break;
56+
break
5757
case 'string':
5858
case 'number':
5959
case 'integer':
6060
this._handlePrimitive(currectPath, schemaNode, suggestionsObj)
61-
break;
61+
break
6262
case 'boolean':
6363
this._handleBoolean(currectPath, schemaNode, suggestionsObj)
6464
break
@@ -67,81 +67,80 @@ export class SchemaTextCompleter {
6767
}
6868
}
6969

70-
_handleObject(currectPath, schemaNode, suggestionsObj) {
70+
_handleObject (currectPath, schemaNode, suggestionsObj) {
7171
if (isObject(schemaNode.properties)) {
72-
const props = Object.keys(schemaNode.properties);
73-
suggestionsObj[currectPath] = suggestionsObj[currectPath] || {};
74-
suggestionsObj[currectPath].props = suggestionsObj[currectPath].props || [];
75-
suggestionsObj[currectPath].props = uniqueMergeArrays(suggestionsObj[currectPath].props, props);
72+
const props = Object.keys(schemaNode.properties)
73+
suggestionsObj[currectPath] = suggestionsObj[currectPath] || {}
74+
suggestionsObj[currectPath].props = suggestionsObj[currectPath].props || []
75+
suggestionsObj[currectPath].props = uniqueMergeArrays(suggestionsObj[currectPath].props, props)
7676
props.forEach((prop) => {
7777
asyncExec(() => {
78-
this._handleSchemaEntry(`${currectPath}/${prop}`,schemaNode.properties[prop], suggestionsObj);
78+
this._handleSchemaEntry(`${currectPath}/${prop}`, schemaNode.properties[prop], suggestionsObj)
7979
})
8080
})
8181
}
8282
}
8383

84-
_handlePrimitive(currectPath, schemaNode, suggestionsObj) {
85-
suggestionsObj[currectPath] = suggestionsObj[currectPath] || {};
84+
_handlePrimitive (currectPath, schemaNode, suggestionsObj) {
85+
suggestionsObj[currectPath] = suggestionsObj[currectPath] || {}
8686
if (isArray(schemaNode.examples)) {
87-
suggestionsObj[currectPath].examples = suggestionsObj[currectPath].examples || [];
88-
suggestionsObj[currectPath].examples = uniqueMergeArrays(suggestionsObj[currectPath].examples, schemaNode.examples);
87+
suggestionsObj[currectPath].examples = suggestionsObj[currectPath].examples || []
88+
suggestionsObj[currectPath].examples = uniqueMergeArrays(suggestionsObj[currectPath].examples, schemaNode.examples)
8989
}
9090
if (isArray(schemaNode.enum)) {
91-
suggestionsObj[currectPath].enum = suggestionsObj[currectPath].enum || [];
92-
suggestionsObj[currectPath].enum = uniqueMergeArrays(suggestionsObj[currectPath].enum, schemaNode.enum);
91+
suggestionsObj[currectPath].enum = suggestionsObj[currectPath].enum || []
92+
suggestionsObj[currectPath].enum = uniqueMergeArrays(suggestionsObj[currectPath].enum, schemaNode.enum)
9393
}
9494
}
9595

96-
_handleBoolean(currectPath, schemaNode, suggestionsObj) {
96+
_handleBoolean (currectPath, schemaNode, suggestionsObj) {
9797
if (!suggestionsObj[currectPath]) {
9898
suggestionsObj[currectPath] = {
99-
bool: [true,false]
99+
bool: [true, false]
100100
}
101101
}
102102
}
103103

104-
_handleArray(currectPath, schemaNode, suggestionsObj) {
104+
_handleArray (currectPath, schemaNode, suggestionsObj) {
105105
if (schemaNode.items) {
106106
asyncExec(() => {
107-
this._handleSchemaEntry(`${currectPath}/\\d+`, schemaNode.items, suggestionsObj);
107+
this._handleSchemaEntry(`${currectPath}/\\d+`, schemaNode.items, suggestionsObj)
108108
})
109109
}
110110
}
111111

112-
_handleOfCondition(currectPath, schemaNode, suggestionsObj) {
112+
_handleOfCondition (currectPath, schemaNode, suggestionsObj) {
113113
if (schemaNode && schemaNode.length) {
114114
schemaNode.forEach(schemaEntry => {
115115
asyncExec(() => {
116-
this._handleSchemaEntry(currectPath, schemaEntry, suggestionsObj);
116+
this._handleSchemaEntry(currectPath, schemaEntry, suggestionsObj)
117117
})
118118
})
119119
}
120120
}
121121

122-
_checkOfConditon(entry) {
122+
_checkOfConditon (entry) {
123123
if (!entry) {
124-
return;
124+
return
125125
}
126126
if (entry.oneOf) {
127-
return 'oneOf';
127+
return 'oneOf'
128128
}
129129
if (entry.anyOf) {
130-
return 'anyOf';
130+
return 'anyOf'
131131
}
132132
if (entry.allOf) {
133-
return 'allOf';
133+
return 'allOf'
134134
}
135135
}
136-
137136

138137
getCompletions (editor, session, pos, prefix, callback) {
139138
try {
140139
const map = jsonMap.parse(session.getValue())
141-
const pointers = map.pointers || {};
140+
const pointers = map.pointers || {}
142141
const processCompletionsCallback = (suggestions) => {
143-
let completions = [];
144-
let score = 0;
142+
let completions = []
143+
let score = 0
145144
const appendSuggesions = (type) => {
146145
const typeTitle = {
147146
props: 'property',
@@ -155,7 +154,7 @@ export class SchemaTextCompleter {
155154
caption: term + '',
156155
meta: `schema [${typeTitle[type]}]`,
157156
score: score++,
158-
value: term + '',
157+
value: term + ''
159158
}
160159
}))
161160
}
@@ -164,73 +163,70 @@ export class SchemaTextCompleter {
164163
appendSuggesions('enum')
165164
appendSuggesions('bool')
166165
appendSuggesions('examples')
167-
166+
168167
if (completions.length) {
169-
callback(null, completions);
168+
callback(null, completions)
170169
}
171-
172170
}
173171
Object.keys(pointers).forEach((ptr) => {
174172
asyncExec(() => {
175173
const matchPointersToPath = (pointer, currentSuggestions, path) => {
176174
const option = Object.keys(currentSuggestions).reduce((last, key) => {
177-
if(new RegExp(`\^${path}${key}`).test(pointer)) {
175+
if (new RegExp(`^${path}${key}`).test(pointer)) {
178176
if (!last || last.length < key.length) {
179-
return key;
177+
return key
180178
}
181179
}
182-
return last;
183-
});
180+
return last
181+
})
184182
if (typeof option === 'string') {
185183
if (currentSuggestions[option]?.refs?.length) {
186-
const mergedSuggestions = {};
187-
for (let idx in currentSuggestions[option].refs) {
188-
const refName = currentSuggestions[option].refs[idx]
184+
const mergedSuggestions = {}
185+
for (const idx in currentSuggestions[option].refs) {
186+
const refName = currentSuggestions[option].refs[idx]
189187
if (this.suggestionsRefs[refName]) {
190-
const refSuggestion = matchPointersToPath(pointer, this.suggestionsRefs[refName], `${path}${option}`);
191-
if(refSuggestion?.enum) {
192-
mergedSuggestions.enum = uniqueMergeArrays(mergedSuggestions.enum, refSuggestion.enum);
188+
const refSuggestion = matchPointersToPath(pointer, this.suggestionsRefs[refName], `${path}${option}`)
189+
if (refSuggestion?.enum) {
190+
mergedSuggestions.enum = uniqueMergeArrays(mergedSuggestions.enum, refSuggestion.enum)
193191
}
194-
if(refSuggestion?.examples) {
195-
mergedSuggestions.examples = uniqueMergeArrays(mergedSuggestions.examples, refSuggestion.examples);
192+
if (refSuggestion?.examples) {
193+
mergedSuggestions.examples = uniqueMergeArrays(mergedSuggestions.examples, refSuggestion.examples)
196194
}
197-
if(refSuggestion?.bool) {
198-
mergedSuggestions.bool = uniqueMergeArrays(mergedSuggestions.bool, refSuggestion.bool);
195+
if (refSuggestion?.bool) {
196+
mergedSuggestions.bool = uniqueMergeArrays(mergedSuggestions.bool, refSuggestion.bool)
199197
}
200-
if(refSuggestion?.props) {
201-
mergedSuggestions.props = uniqueMergeArrays(mergedSuggestions.props, refSuggestion.props);
198+
if (refSuggestion?.props) {
199+
mergedSuggestions.props = uniqueMergeArrays(mergedSuggestions.props, refSuggestion.props)
202200
}
203201
}
204202
}
205-
return mergedSuggestions;
206-
} else if (new RegExp(`\^${path}${option}$`).test(pointer)) {
207-
console.log('SchemaTextCompleter: Text suggestion match', {path: pointer, schemaPath: `${path}${option}`, suggestions: currentSuggestions[option]});
208-
return currentSuggestions[option];
203+
return mergedSuggestions
204+
} else if (new RegExp(`^${path}${option}$`).test(pointer)) {
205+
console.log('SchemaTextCompleter: Text suggestion match', { path: pointer, schemaPath: `${path}${option}`, suggestions: currentSuggestions[option] })
206+
return currentSuggestions[option]
209207
}
210208
}
211209
}
212-
let selectedPtr;
210+
let selectedPtr
213211
if (pointers[ptr].key?.line === pos.row) {
214212
if (pos.column >= pointers[ptr].key.column && pos.column <= pointers[ptr].keyEnd.column) {
215-
selectedPtr = ptr.slice(0, ptr.lastIndexOf('/'));
213+
selectedPtr = ptr.slice(0, ptr.lastIndexOf('/'))
216214
}
217-
}
218-
if (pointers[ptr].value?.line === pos.row &&
215+
}
216+
if (pointers[ptr].value?.line === pos.row &&
219217
pointers[ptr].value?.line === pointers[ptr].valueEnd?.line) { // multiline values are objects
220218
if (pos.column >= pointers[ptr].value.column && pos.column <= pointers[ptr].valueEnd.column) {
221-
selectedPtr = ptr;
219+
selectedPtr = ptr
222220
}
223221
}
224222
if (selectedPtr) {
225-
const chosenCompletions = matchPointersToPath(selectedPtr, this.suggestions, '');
226-
processCompletionsCallback(chosenCompletions);
223+
const chosenCompletions = matchPointersToPath(selectedPtr, this.suggestions, '')
224+
processCompletionsCallback(chosenCompletions)
227225
}
228-
229226
})
230227
})
231228
} catch (e) {
232229
// probably not valid json, ignore.
233230
}
234231
}
235-
236232
}

src/js/textmode.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,10 +405,10 @@ textmode.create = function (container, options = {}) {
405405
this.setSchema(this.options.schema, this.options.schemaRefs)
406406
}
407407

408-
textmode._onSchemaChange = function(schema, schemaRefs) {
408+
textmode._onSchemaChange = function (schema, schemaRefs) {
409409
if (this.options.allowSchemaSuggestions && schema) {
410410
this.aceEditor.setOption('enableBasicAutocompletion', [new SchemaTextCompleter(schema, schemaRefs)])
411-
this.aceEditor.setOption('enableLiveAutocompletion', true)
411+
this.aceEditor.setOption('enableLiveAutocompletion', true)
412412
} else {
413413
this.aceEditor.setOption('enableBasicAutocompletion', undefined)
414414
this.aceEditor.setOption('enableLiveAutocompletion', false)

0 commit comments

Comments
 (0)