[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/js/codemirror/ -> fakejshint.js (source)

   1  // JSHINT has some GPL Compatability issues, so we are faking it out and using esprima for validation
   2  // Based on https://github.com/jquery/esprima/blob/gh-pages/demo/validate.js which is MIT licensed
   3  
   4  var fakeJSHINT = new function() {
   5      var syntax, errors;
   6      var that = this;
   7      this.data = [];
   8      this.convertError = function( error ){
   9          return {
  10              line: error.lineNumber,
  11              character: error.column,
  12              reason: error.description,
  13              code: 'E'
  14          };
  15      };
  16      this.parse = function( code ){
  17          try {
  18              syntax = window.esprima.parse(code, { tolerant: true, loc: true });
  19              errors = syntax.errors;
  20              if ( errors.length > 0 ) {
  21                  for ( var i = 0; i < errors.length; i++) {
  22                      var error = errors[i];
  23                      that.data.push( that.convertError( error ) );
  24                  }
  25              } else {
  26                  that.data = [];
  27              }
  28          } catch (e) {
  29              that.data.push( that.convertError( e ) );
  30          }
  31      };
  32  };
  33  
  34  window.JSHINT = function( text ){
  35      fakeJSHINT.parse( text );
  36  };
  37  window.JSHINT.data = function(){
  38      return {
  39          errors: fakeJSHINT.data
  40      };
  41  };
  42  
  43  


Generated: Sun Dec 22 01:00:02 2024 Cross-referenced by PHPXref 0.7.1