File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
client/modules/IDE/components/Editor Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -230,6 +230,34 @@ function makeJsLinter(callback) {
230230 } ;
231231}
232232
233+ function makeJsonLinter ( callback ) {
234+ return ( view ) => {
235+ const documentContent = view . state . doc . toString ( ) ;
236+ const diagnostics = [ ] ;
237+
238+ try {
239+ JSON . parse ( documentContent ) ;
240+ } catch ( e ) {
241+ let pos = 0 ;
242+ const match = e . message . match ( / a t p o s i t i o n ( \d + ) / ) ;
243+ if ( match ) {
244+ pos = parseInt ( match [ 1 ] , 10 ) ;
245+ }
246+
247+ diagnostics . push ( {
248+ from : pos ,
249+ to : pos + 1 ,
250+ severity : 'error' ,
251+ message : e . message
252+ } ) ;
253+ }
254+
255+ if ( callback ) callback ( diagnostics ) ;
256+
257+ return diagnostics ;
258+ } ;
259+ }
260+
233261function getFileLinter ( fileName , callback ) {
234262 const fileMode = getFileMode ( fileName ) ;
235263
@@ -240,6 +268,8 @@ function getFileLinter(fileName, callback) {
240268 return linter ( makeHtmlLinter ( callback ) ) ;
241269 case 'css' :
242270 return linter ( makeCssLinter ( callback ) ) ;
271+ case 'application/json' :
272+ return linter ( makeJsonLinter ( callback ) ) ;
243273 default :
244274 return null ;
245275 }
You can’t perform that action at this time.
0 commit comments