mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-02 16:59:35 +01:00
9efeb545c0
JSHint inherits a license from JSLint that includes the clause "The Software shall be used for Good, not Evil." WordPress's license specifically allows grants the freedom to run the program, for any purpose. Please note, this is not an encouragement of evil. Rather than doing something evil, how about learning to love those around you. Instead of tweeting lies and saying people are "Not Good!", help your neighbor. In the words of Lin Manual Miranda, "Love is love is love is love is love is love is love is love, cannot be killed or swept aside." This replaces JSHint with esprima, a part of the larger jQuery project, and a custom wrapper for some basic error checking within codemirror. The existing JSHint configuration is kept in place in case someone wants to use that, but they can only do so for Good. Fixes #42850 Props netweb for a spelling fix on a comment. Built from https://develop.svn.wordpress.org/trunk@42547 git-svn-id: http://core.svn.wordpress.org/trunk@42376 1a063a9b-81f0-0310-95a4-ce76da25c4cd
44 lines
1002 B
JavaScript
44 lines
1002 B
JavaScript
// JSHINT has some GPL Compatability issues, so we are faking it out and using esprima for validation
|
|
// Based on https://github.com/jquery/esprima/blob/gh-pages/demo/validate.js which is MIT licensed
|
|
|
|
var fakeJSHINT = new function() {
|
|
var syntax, errors;
|
|
var that = this;
|
|
this.data = [];
|
|
this.convertError = function( error ){
|
|
return {
|
|
line: error.lineNumber,
|
|
character: error.column,
|
|
reason: error.description,
|
|
code: 'E'
|
|
};
|
|
};
|
|
this.parse = function( code ){
|
|
try {
|
|
syntax = window.esprima.parse(code, { tolerant: true, loc: true });
|
|
errors = syntax.errors;
|
|
if ( errors.length > 0 ) {
|
|
for ( var i = 0; i < errors.length; i++) {
|
|
var error = errors[i];
|
|
that.data.push( that.convertError( error ) );
|
|
}
|
|
} else {
|
|
that.data = [];
|
|
}
|
|
} catch (e) {
|
|
that.data.push( that.convertError( e ) );
|
|
}
|
|
};
|
|
};
|
|
|
|
window.JSHINT = function( text ){
|
|
fakeJSHINT.parse( text );
|
|
};
|
|
window.JSHINT.data = function(){
|
|
return {
|
|
errors: fakeJSHINT.data
|
|
};
|
|
};
|
|
|
|
|