mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Fix #10692. JSLint is dead! Long live JSHint!
Still needs this sizzle PR: https://github.com/jquery/sizzle/pull/82
This commit is contained in:
parent
d6500cc8de
commit
98386cfd77
14
Makefile
14
Makefile
@ -46,7 +46,7 @@ DATE=$(shell git log -1 --pretty=format:%ad)
|
|||||||
|
|
||||||
all: update_submodules core
|
all: update_submodules core
|
||||||
|
|
||||||
core: jquery min lint size
|
core: jquery min hint size
|
||||||
@@echo "jQuery build complete."
|
@@echo "jQuery build complete."
|
||||||
|
|
||||||
${DIST_DIR}:
|
${DIST_DIR}:
|
||||||
@ -67,12 +67,14 @@ ${SRC_DIR}/selector.js: ${SIZZLE_DIR}/sizzle.js
|
|||||||
@@echo "Building selector code from Sizzle"
|
@@echo "Building selector code from Sizzle"
|
||||||
@@sed '/EXPOSE/r src/sizzle-jquery.js' ${SIZZLE_DIR}/sizzle.js | grep -v window.Sizzle > ${SRC_DIR}/selector.js
|
@@sed '/EXPOSE/r src/sizzle-jquery.js' ${SIZZLE_DIR}/sizzle.js | grep -v window.Sizzle > ${SRC_DIR}/selector.js
|
||||||
|
|
||||||
lint: jquery
|
lint: hint
|
||||||
|
|
||||||
|
hint: jquery
|
||||||
@@if test ! -z ${JS_ENGINE}; then \
|
@@if test ! -z ${JS_ENGINE}; then \
|
||||||
echo "Checking jQuery against JSLint..."; \
|
echo "Checking jQuery against JSHint..."; \
|
||||||
${JS_ENGINE} build/jslint-check.js; \
|
${JS_ENGINE} build/jshint-check.js; \
|
||||||
else \
|
else \
|
||||||
echo "You must have NodeJS installed in order to test jQuery against JSLint."; \
|
echo "You must have NodeJS installed in order to test jQuery against JSHint."; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
size: jquery min
|
size: jquery min
|
||||||
@ -134,4 +136,4 @@ pull_submodules:
|
|||||||
pull: pull_submodules
|
pull: pull_submodules
|
||||||
@@git pull ${REMOTE} ${BRANCH}
|
@@git pull ${REMOTE} ${BRANCH}
|
||||||
|
|
||||||
.PHONY: all jquery lint min clean distclean update_submodules pull_submodules pull core
|
.PHONY: all jquery lint hint min clean distclean update_submodules pull_submodules pull core
|
||||||
|
35
build/jshint-check.js
Normal file
35
build/jshint-check.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
var JSHINT = require("./lib/jshint").JSHINT,
|
||||||
|
print = require("sys").print,
|
||||||
|
src = require("fs").readFileSync("dist/jquery.js", "utf8");
|
||||||
|
|
||||||
|
JSHINT(src, {
|
||||||
|
evil: true,
|
||||||
|
undef: false,
|
||||||
|
browser: true,
|
||||||
|
wsh: true,
|
||||||
|
eqnull: true,
|
||||||
|
expr: true,
|
||||||
|
curly: true,
|
||||||
|
eqeq: true,
|
||||||
|
trailing: true,
|
||||||
|
predef: [
|
||||||
|
"define",
|
||||||
|
"DOMParser"
|
||||||
|
],
|
||||||
|
maxerr: 100
|
||||||
|
});
|
||||||
|
|
||||||
|
var e = JSHINT.errors, found = e.length, i = 0, w;
|
||||||
|
|
||||||
|
for ( ; i < e.length; i++ ) {
|
||||||
|
w = e[i];
|
||||||
|
|
||||||
|
print( "\n" + w.evidence + "\n" );
|
||||||
|
print( " Problem at line " + w.line + " character " + w.character + ": " + w.reason );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( found > 0 ) {
|
||||||
|
print( "\n" + found + " Error(s) found.\n" );
|
||||||
|
} else {
|
||||||
|
print( "JSHint check passed.\n" );
|
||||||
|
}
|
@ -1,36 +0,0 @@
|
|||||||
var JSLINT = require("./lib/jslint").JSLINT,
|
|
||||||
print = require("sys").print,
|
|
||||||
src = require("fs").readFileSync("dist/jquery.js", "utf8");
|
|
||||||
|
|
||||||
JSLINT(src, { evil: true, forin: true, maxerr: 100 });
|
|
||||||
|
|
||||||
// All of the following are known issues that we think are 'ok'
|
|
||||||
// (in contradiction with JSLint) more information here:
|
|
||||||
// http://docs.jquery.com/JQuery_Core_Style_Guidelines
|
|
||||||
var ok = {
|
|
||||||
"Expected an identifier and instead saw 'undefined' (a reserved word).": true,
|
|
||||||
"Use '===' to compare with 'null'.": true,
|
|
||||||
"Use '!==' to compare with 'null'.": true,
|
|
||||||
"Expected an assignment or function call and instead saw an expression.": true,
|
|
||||||
"Expected a 'break' statement before 'case'.": true,
|
|
||||||
"'e' is already defined.": true
|
|
||||||
};
|
|
||||||
|
|
||||||
var e = JSLINT.errors, found = 0, w;
|
|
||||||
|
|
||||||
for ( var i = 0; i < e.length; i++ ) {
|
|
||||||
w = e[i];
|
|
||||||
|
|
||||||
if ( !ok[ w.reason ] ) {
|
|
||||||
found++;
|
|
||||||
print( "\n" + w.evidence + "\n" );
|
|
||||||
print( " Problem at line " + w.line + " character " + w.character + ": " + w.reason );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( found > 0 ) {
|
|
||||||
print( "\n" + found + " Error(s) found.\n" );
|
|
||||||
|
|
||||||
} else {
|
|
||||||
print( "JSLint check passed.\n" );
|
|
||||||
}
|
|
4256
build/lib/jshint.js
Normal file
4256
build/lib/jshint.js
Normal file
File diff suppressed because it is too large
Load Diff
5504
build/lib/jslint.js
5504
build/lib/jslint.js
File diff suppressed because it is too large
Load Diff
24
src/ajax.js
24
src/ajax.js
@ -21,21 +21,21 @@ var r20 = /%20/g,
|
|||||||
_load = jQuery.fn.load,
|
_load = jQuery.fn.load,
|
||||||
|
|
||||||
/* Prefilters
|
/* Prefilters
|
||||||
* 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
|
* 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
|
||||||
* 2) These are called:
|
* 2) These are called:
|
||||||
* - BEFORE asking for a transport
|
* - BEFORE asking for a transport
|
||||||
* - AFTER param serialization (s.data is a string if s.processData is true)
|
* - AFTER param serialization (s.data is a string if s.processData is true)
|
||||||
* 3) key is the dataType
|
* 3) key is the dataType
|
||||||
* 4) the catchall symbol "*" can be used
|
* 4) the catchall symbol "*" can be used
|
||||||
* 5) execution will start with transport dataType and THEN continue down to "*" if needed
|
* 5) execution will start with transport dataType and THEN continue down to "*" if needed
|
||||||
*/
|
*/
|
||||||
prefilters = {},
|
prefilters = {},
|
||||||
|
|
||||||
/* Transports bindings
|
/* Transports bindings
|
||||||
* 1) key is the dataType
|
* 1) key is the dataType
|
||||||
* 2) the catchall symbol "*" can be used
|
* 2) the catchall symbol "*" can be used
|
||||||
* 3) selection will start with transport dataType and THEN go to "*" if needed
|
* 3) selection will start with transport dataType and THEN go to "*" if needed
|
||||||
*/
|
*/
|
||||||
transports = {},
|
transports = {},
|
||||||
|
|
||||||
// Document location
|
// Document location
|
||||||
|
@ -27,11 +27,11 @@ function createActiveXHR() {
|
|||||||
// (This is still attached to ajaxSettings for backward compatibility)
|
// (This is still attached to ajaxSettings for backward compatibility)
|
||||||
jQuery.ajaxSettings.xhr = window.ActiveXObject ?
|
jQuery.ajaxSettings.xhr = window.ActiveXObject ?
|
||||||
/* Microsoft failed to properly
|
/* Microsoft failed to properly
|
||||||
* implement the XMLHttpRequest in IE7 (can't request local files),
|
* implement the XMLHttpRequest in IE7 (can't request local files),
|
||||||
* so we use the ActiveXObject when it is available
|
* so we use the ActiveXObject when it is available
|
||||||
* Additionally XMLHttpRequest can be disabled in IE7/IE8 so
|
* Additionally XMLHttpRequest can be disabled in IE7/IE8 so
|
||||||
* we need a fallback.
|
* we need a fallback.
|
||||||
*/
|
*/
|
||||||
function() {
|
function() {
|
||||||
return !this.isLocal && createStandardXHR() || createActiveXHR();
|
return !this.isLocal && createStandardXHR() || createActiveXHR();
|
||||||
} :
|
} :
|
||||||
|
@ -185,9 +185,9 @@ jQuery.event = {
|
|||||||
handleObj = eventType[ j ];
|
handleObj = eventType[ j ];
|
||||||
|
|
||||||
if ( ( mappedTypes || origType === handleObj.origType ) &&
|
if ( ( mappedTypes || origType === handleObj.origType ) &&
|
||||||
( !handler || handler.guid === handleObj.guid ) &&
|
( !handler || handler.guid === handleObj.guid ) &&
|
||||||
( !namespaces || namespaces.test( handleObj.namespace ) ) &&
|
( !namespaces || namespaces.test( handleObj.namespace ) ) &&
|
||||||
( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
|
( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
|
||||||
eventType.splice( j--, 1 );
|
eventType.splice( j--, 1 );
|
||||||
|
|
||||||
if ( handleObj.selector ) {
|
if ( handleObj.selector ) {
|
||||||
|
@ -227,7 +227,7 @@ jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( me
|
|||||||
if ( win ) {
|
if ( win ) {
|
||||||
win.scrollTo(
|
win.scrollTo(
|
||||||
!top ? val : jQuery( win ).scrollLeft(),
|
!top ? val : jQuery( win ).scrollLeft(),
|
||||||
top ? val : jQuery( win ).scrollTop()
|
top ? val : jQuery( win ).scrollTop()
|
||||||
);
|
);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -73,11 +73,11 @@ jQuery.fn.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
is: function( selector ) {
|
is: function( selector ) {
|
||||||
return !!selector && (
|
return !!selector && (
|
||||||
typeof selector === "string" ?
|
typeof selector === "string" ?
|
||||||
// If this is a positional selector, check membership in the returned set
|
// If this is a positional selector, check membership in the returned set
|
||||||
// so $("p:first").is("p:last") won't return true for a doc with two "p".
|
// so $("p:first").is("p:last") won't return true for a doc with two "p".
|
||||||
POS.test( selector ) ?
|
POS.test( selector ) ?
|
||||||
jQuery( selector, this.context ).index( this[0] ) >= 0 :
|
jQuery( selector, this.context ).index( this[0] ) >= 0 :
|
||||||
jQuery.filter( selector, this ).length > 0 :
|
jQuery.filter( selector, this ).length > 0 :
|
||||||
this.filter( selector ).length > 0 );
|
this.filter( selector ).length > 0 );
|
||||||
@ -85,7 +85,7 @@ jQuery.fn.extend({
|
|||||||
|
|
||||||
closest: function( selectors, context ) {
|
closest: function( selectors, context ) {
|
||||||
var ret = [], i, l, cur = this[0];
|
var ret = [], i, l, cur = this[0];
|
||||||
|
|
||||||
// Array (deprecated as of jQuery 1.7)
|
// Array (deprecated as of jQuery 1.7)
|
||||||
if ( jQuery.isArray( selectors ) ) {
|
if ( jQuery.isArray( selectors ) ) {
|
||||||
var level = 1;
|
var level = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user