Remove JSHint due to license compatibility

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.



git-svn-id: https://develop.svn.wordpress.org/trunk@42547 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Aaron Jorbin 2018-01-23 01:28:26 +00:00
parent 4fb6c02b99
commit 5bb7fc10c5
5 changed files with 6747 additions and 24547 deletions

View File

@ -779,6 +779,8 @@ $_old_files = array(
'wp-includes/js/mediaelement/renderers/soundcloud.min.js',
'wp-includes/js/mediaelement/renderers/twitch.js',
'wp-includes/js/mediaelement/renderers/twitch.min.js',
// 5.0
'wp-includes/js/codemirror/jshint.js',
);
/**

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,43 @@
// 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
};
};

File diff suppressed because one or more lines are too long

View File

@ -494,7 +494,8 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'wp-codemirror', '/wp-includes/js/codemirror/codemirror.min.js', array(), '5.29.1-alpha-ee20357' );
$scripts->add( 'csslint', '/wp-includes/js/codemirror/csslint.js', array(), '1.0.5' );
$scripts->add( 'jshint', '/wp-includes/js/codemirror/jshint.js', array(), '2.9.5' );
$scripts->add( 'jshint', '/wp-includes/js/codemirror/fakejshint.js', array( 'esprima' ), '2.9.5' );
$scripts->add( 'esprima', '/wp-includes/js/codemirror/esprima.js', array(), '4.0.0' );
$scripts->add( 'jsonlint', '/wp-includes/js/codemirror/jsonlint.js', array(), '1.6.2' );
$scripts->add( 'htmlhint', '/wp-includes/js/codemirror/htmlhint.js', array(), '0.9.14-xwp' );
$scripts->add( 'htmlhint-kses', '/wp-includes/js/codemirror/htmlhint-kses.js', array( 'htmlhint' ) );