Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

unexpected apply or call

  • Loading branch information...
commit c33bb0a65760048e03f90fec68a9f7a2a39e1d75 1 parent ea6fdf0
@douglascrockford authored
Showing with 11 additions and 2 deletions.
  1. +11 −2 jslint.js
View
13 jslint.js
@@ -1,5 +1,5 @@
// jslint.js
-// 2012-08-23
+// 2012-09-17
// Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
@@ -3623,6 +3623,15 @@ klass: do {
left.id !== '?') {
warn('bad_invocation', left);
}
+ if (left.id === '.' && p.length > 0 &&
+ left.first && left.first.first &&
+ are_similar(p[0], left.first.first)) {
+ if (left.second.string === 'call' ||
+ (left.second.string === 'apply' && (p.length === 1 ||
+ (p[1].arity === 'prefix' && p[1].id === '[')))) {
+ warn('unexpected_a', left.second);
+ }
+ }
}
that.first = left;
that.second = p;
@@ -6439,7 +6448,7 @@ klass: do {
itself.jslint = itself;
- itself.edition = '2012-08-23';
+ itself.edition = '2012-09-17';
return itself;
}());

4 comments on commit c33bb0a

@noiv

Not sure whether related, but can I force JSLint to accept:

var ctx = document.getElementById("canvas").getContext("2d");
ctx.setTransform.apply(ctx, [1, 0, 0, 1, 0, 0]);

without unexpected 'apply' using the 2012-11-13 version?

@douglascrockford

ctx.setTransform(1, 0, 0, 1, 0, 0);

@noiv

That's fine for the identity matrix. In all other cases it got uglified:

ctx.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);

Here is another example:

Math.max.apply(Math, arrayWithNumbers)

Is there a rationale for 'unexpected apply'?

@douglascrockford

Yes, it shouldn't be used were it is absolutely not needed.

Your example is wrong. Fix your code, but be starter about how you do it this time.

Please sign in to comment.
Something went wrong with that request. Please try again.