Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

import upstream: this will also revert local changes

  • Loading branch information...
commit d3f74849c0f09d399ae68c8241a5125f30058a7e 1 parent 88621b4
@smparkes authored
Showing with 174 additions and 143 deletions.
  1. +174 −143 lib/jslintrb/fulljslint.js
View
317 lib/jslintrb/fulljslint.js
@@ -1,5 +1,5 @@
// jslint.js
-// 2010-01-20
+// 2010-03-12
/*
Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
@@ -159,45 +159,46 @@ SOFTWARE.
URL, Web, Window, XMLDOM, XMLHttpRequest, "\\", a, abbr, acronym,
addEventListener, address, adsafe, alert, aliceblue, animator,
antiquewhite, appleScript, applet, apply, approved, aqua, aquamarine,
- area, arguments, arity, autocomplete, azure, b, background,
- "background-attachment", "background-color", "background-image",
- "background-position", "background-repeat", base, bdo, beep, beige, big,
- bisque, bitwise, black, blanchedalmond, block, blockquote, blue,
- blueviolet, blur, body, border, "border-bottom", "border-bottom-color",
- "border-bottom-style", "border-bottom-width", "border-collapse",
- "border-color", "border-left", "border-left-color", "border-left-style",
- "border-left-width", "border-right", "border-right-color",
- "border-right-style", "border-right-width", "border-spacing",
- "border-style", "border-top", "border-top-color", "border-top-style",
- "border-top-width", "border-width", bottom, br, brown, browser,
- burlywood, button, bytesToUIString, c, cadetblue, call, callee, caller,
- canvas, cap, caption, "caption-side", cases, center, charAt, charCodeAt,
- character, chartreuse, chocolate, chooseColor, chooseFile, chooseFolder,
- cite, clear, clearInterval, clearTimeout, clip, close, closeWidget,
- closed, closure, cm, code, col, colgroup, color, comment, condition,
- confirm, console, constructor, content, convertPathToHFS,
- convertPathToPlatform, coral, cornflowerblue, cornsilk,
- "counter-increment", "counter-reset", create, crimson, css, cursor,
- cyan, d, darkblue, darkcyan, darkgoldenrod, darkgray, darkgreen,
+ area, arguments, arity, article, aside, audio, autocomplete, azure, b,
+ background, "background-attachment", "background-color",
+ "background-image", "background-position", "background-repeat", base,
+ bdo, beep, beige, big, bisque, bitwise, black, blanchedalmond, block,
+ blockquote, blue, blueviolet, blur, body, border, "border-bottom",
+ "border-bottom-color", "border-bottom-style", "border-bottom-width",
+ "border-collapse", "border-color", "border-left", "border-left-color",
+ "border-left-style", "border-left-width", "border-right",
+ "border-right-color", "border-right-style", "border-right-width",
+ "border-spacing", "border-style", "border-top", "border-top-color",
+ "border-top-style", "border-top-width", "border-width", bottom, br,
+ brown, browser, burlywood, button, bytesToUIString, c, cadetblue, call,
+ callee, caller, canvas, cap, caption, "caption-side", cases, center,
+ charAt, charCodeAt, character, chartreuse, chocolate, chooseColor,
+ chooseFile, chooseFolder, cite, clear, clearInterval, clearTimeout,
+ clip, close, closeWidget, closed, closure, cm, code, col, colgroup,
+ color, command, comment, condition, confirm, console, constructor,
+ content, convertPathToHFS, convertPathToPlatform, coral, cornflowerblue,
+ cornsilk, "counter-increment", "counter-reset", create, crimson, css,
+ cursor, cyan, d, darkblue, darkcyan, darkgoldenrod, darkgray, darkgreen,
darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred,
darksalmon, darkseagreen, darkslateblue, darkslategray, darkturquoise,
- darkviolet, data, dd, debug, decodeURI, decodeURIComponent, deeppink,
- deepskyblue, defaultStatus, defineClass, del, deserialize, devel, dfn,
- dimension, dimgray, dir, direction, display, div, dl, document,
- dodgerblue, dt, edition, else, em, embed, empty, "empty-cells",
- encodeURI, encodeURIComponent, entityify, eqeqeq, errors, escape, eval,
- event, evidence, evil, ex, exception, exec, exps, fieldset, filesystem,
- firebrick, first, float, floor, floralwhite, focus, focusWidget, font,
- "font-face", "font-family", "font-size", "font-size-adjust",
- "font-stretch", "font-style", "font-variant", "font-weight",
- forestgreen, forin, form, fragment, frame, frames, frameset, from,
- fromCharCode, fuchsia, fud, funct, function, functions, g, gainsboro,
- gc, getComputedStyle, ghostwhite, global, globals, gold, goldenrod,
- gray, green, greenyellow, h1, h2, h3, h4, h5, h6, hasOwnProperty, head,
- height, help, history, honeydew, hotpink, hr, html, i, iTunes, id,
- identifier, iframe, img, immed, implieds, in, include, indent, indexOf,
- indianred, indigo, init, input, ins, isAlpha, isApplicationRunning,
- isDigit, isFinite, isNaN, ivory, join, jslint, json, kbd, khaki,
+ darkviolet, data, datalist, dd, debug, decodeURI, decodeURIComponent,
+ deeppink, deepskyblue, defaultStatus, defineClass, del, deserialize,
+ details, devel, dfn, dialog, dimension, dimgray, dir, direction,
+ display, div, dl, document, dodgerblue, dt, edition, else, em, embed,
+ empty, "empty-cells", encodeURI, encodeURIComponent, entityify, eqeqeq,
+ errors, escape, eval, event, evidence, evil, ex, exception, exec, exps,
+ fieldset, figure, filesystem, firebrick, first, float, floor,
+ floralwhite, focus, focusWidget, font, "font-face", "font-family",
+ "font-size", "font-size-adjust", "font-stretch", "font-style",
+ "font-variant", "font-weight", footer, forestgreen, forin, form,
+ fragment, frame, frames, frameset, from, fromCharCode, fuchsia, fud,
+ funct, function, functions, g, gainsboro, gc, getComputedStyle,
+ ghostwhite, global, globals, gold, goldenrod, gray, green, greenyellow,
+ h1, h2, h3, h4, h5, h6, hasOwnProperty, head, header, height, help,
+ hgroup, history, honeydew, hotpink, hr, html, i, iTunes, id, identifier,
+ iframe, img, immed, implieds, in, include, indent, indexOf, indianred,
+ indigo, init, input, ins, isAlpha, isApplicationRunning, isDigit,
+ isFinite, isNaN, ivory, join, jslint, json, kbd, keygen, khaki,
konfabulatorVersion, label, labelled, lang, last, lavender,
lavenderblush, lawngreen, laxbreak, lbp, led, left, legend,
lemonchiffon, length, "letter-spacing", li, lib, lightblue, lightcoral,
@@ -207,41 +208,42 @@ SOFTWARE.
"list-style", "list-style-image", "list-style-position",
"list-style-type", load, loadClass, location, log, m, magenta, map,
margin, "margin-bottom", "margin-left", "margin-right", "margin-top",
- "marker-offset", maroon, match, "max-height", "max-width", maxerr, maxlen,
- md5, media, mediumaquamarine, mediumblue, mediumorchid, mediumpurple,
- mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise,
- mediumvioletred, member, menu, message, meta, midnightblue,
- "min-height", "min-width", mintcream, mistyrose, mm, moccasin, moveBy,
- moveTo, name, navajowhite, navigator, navy, new, newcap, noframes,
- nomen, noscript, nud, object, ol, oldlace, olive, olivedrab, on,
- onbeforeunload, onblur, onerror, onevar, onfocus, onload, onresize,
- onunload, opacity, open, openURL, opener, opera, optgroup, option,
- orange, orangered, orchid, outer, outline, "outline-color",
- "outline-style", "outline-width", overflow, "overflow-x", "overflow-y",
- p, padding, "padding-bottom", "padding-left", "padding-right",
- "padding-top", page, "page-break-after", "page-break-before",
- palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip,
- param, parent, parseFloat, parseInt, passfail, pc, peachpuff, peru,
- pink, play, plum, plusplus, pop, popupMenu, position, powderblue, pre,
- predef, preferenceGroups, preferences, print, prompt, prototype, pt,
- purple, push, px, q, quit, quotes, random, range, raw, reach, readFile,
- readUrl, reason, red, regexp, reloadWidget, removeEventListener,
- replace, report, reserved, resizeBy, resizeTo, resolvePath,
- resumeUpdates, rhino, right, rosybrown, royalblue, runCommand,
- runCommandInBg, saddlebrown, safe, salmon, samp, sandybrown, saveAs,
- savePreferences, screen, script, scroll, scrollBy, scrollTo, seagreen,
- seal, search, seashell, select, serialize, setInterval, setTimeout,
- shift, showWidgetPreferences, sidebar, sienna, silver, skyblue,
- slateblue, slategray, sleep, slice, small, snow, sort, span, spawn,
- speak, split, springgreen, src, status, steelblue, strict, strong,
- style, styleproperty, sub, substr, sup, supplant, suppressUpdates, sync,
+ mark, "marker-offset", maroon, match, "max-height", "max-width", maxerr,
+ maxlen, md5, media, mediumaquamarine, mediumblue, mediumorchid,
+ mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen,
+ mediumturquoise, mediumvioletred, member, menu, message, meta, meter,
+ midnightblue, "min-height", "min-width", mintcream, mistyrose, mm,
+ moccasin, moveBy, moveTo, name, nav, navajowhite, navigator, navy, new,
+ newcap, noframes, nomen, noscript, nud, object, ol, oldlace, olive,
+ olivedrab, on, onbeforeunload, onblur, onerror, onevar, onfocus, onload,
+ onresize, onunload, opacity, open, openURL, opener, opera, optgroup,
+ option, orange, orangered, orchid, outer, outline, "outline-color",
+ "outline-style", "outline-width", output, overflow, "overflow-x",
+ "overflow-y", p, padding, "padding-bottom", "padding-left",
+ "padding-right", "padding-top", page, "page-break-after",
+ "page-break-before", palegoldenrod, palegreen, paleturquoise,
+ palevioletred, papayawhip, param, parent, parseFloat, parseInt,
+ passfail, pc, peachpuff, peru, pink, play, plum, plusplus, pop,
+ popupMenu, position, powderblue, pre, predef, preferenceGroups,
+ preferences, print, progress, prompt, prototype, pt, purple, push, px,
+ q, quit, quotes, random, range, raw, reach, readFile, readUrl, reason,
+ red, regexp, reloadWidget, removeEventListener, replace, report,
+ reserved, resizeBy, resizeTo, resolvePath, resumeUpdates, rhino, right,
+ rosybrown, royalblue, rp, rt, ruby, runCommand, runCommandInBg,
+ saddlebrown, safe, salmon, samp, sandybrown, saveAs, savePreferences,
+ screen, script, scroll, scrollBy, scrollTo, seagreen, seal, search,
+ seashell, section, select, serialize, setInterval, setTimeout, shift,
+ showWidgetPreferences, sidebar, sienna, silver, skyblue, slateblue,
+ slategray, sleep, slice, small, snow, sort, source, span, spawn, speak,
+ split, springgreen, src, stack, status, steelblue, strict, strong, style,
+ styleproperty, sub, substr, sup, supplant, suppressUpdates, sync,
system, table, "table-layout", tan, tbody, td, teal, tellWidget, test,
"text-align", "text-decoration", "text-indent", "text-shadow",
- "text-transform", textarea, tfoot, th, thead, thistle, title,
+ "text-transform", textarea, tfoot, th, thead, thistle, time, title,
toLowerCase, toString, toUpperCase, toint32, token, tomato, top, tr, tt,
turquoise, type, u, ul, undef, unescape, "unicode-bidi", unused,
unwatch, updateNow, urls, value, valueOf, var, version,
- "vertical-align", violet, visibility, watch, wheat, white,
+ "vertical-align", video, violet, visibility, watch, wheat, white,
"white-space", whitesmoke, widget, width, "word-spacing", "word-wrap",
yahooCheckLogin, yahooLogin, yahooLogout, yellow, yellowgreen,
"z-index"
@@ -294,6 +296,7 @@ var JSLINT = (function () {
constructor : true,
'eval' : true,
prototype : true,
+ stack : true,
unwatch : true,
valueOf : true,
watch : true
@@ -330,8 +333,7 @@ var JSLINT = (function () {
strict : true, // require the "use strict"; pragma
sub : true, // if all forms of subscript notation are tolerated
white : true, // if strict whitespace rules apply
- widget : true, // if the Yahoo Widgets globals should be predefined
- withstmt : true // if with statements should be allowd
+ widget : true // if the Yahoo Widgets globals should be predefined
},
// browser contains a set of global names which are commonly provided by a
@@ -583,6 +585,9 @@ var JSLINT = (function () {
address: {},
applet: {},
area: {empty: true, parent: ' map '},
+ article: {},
+ aside: {},
+ audio: {},
b: {},
base: {empty: true, parent: ' head '},
bdo: {},
@@ -598,8 +603,12 @@ var JSLINT = (function () {
code: {},
col: {empty: true, parent: ' table colgroup '},
colgroup: {parent: ' table '},
+ command: {parent: ' menu '},
+ datalist: {},
dd: {parent: ' dl '},
del: {},
+ details: {},
+ dialog: {},
dfn: {},
dir: {},
div: {},
@@ -608,7 +617,9 @@ var JSLINT = (function () {
em: {},
embed: {},
fieldset: {},
+ figure: {},
font: {},
+ footer: {},
form: {},
frame: {empty: true, parent: ' frameset '},
frameset: {parent: ' html frameset '},
@@ -619,6 +630,8 @@ var JSLINT = (function () {
h5: {},
h6: {},
head: {parent: ' html '},
+ header: {},
+ hgroup: {},
html: {parent: '*'},
hr: {empty: true},
i: {},
@@ -627,28 +640,39 @@ var JSLINT = (function () {
input: {empty: true},
ins: {},
kbd: {},
+ keygen: {},
label: {},
- legend: {parent: ' fieldset '},
+ legend: {parent: ' details fieldset figure '},
li: {parent: ' dir menu ol ul '},
link: {empty: true, parent: ' head '},
map: {},
+ mark: {},
menu: {},
meta: {empty: true, parent: ' head noframes noscript '},
+ meter: {},
+ nav: {},
noframes: {parent: ' html body '},
noscript: {parent: ' body head noframes '},
object: {},
ol: {},
optgroup: {parent: ' select '},
option: {parent: ' optgroup select '},
+ output: {},
p: {},
param: {empty: true, parent: ' applet object '},
pre: {},
+ progress: {},
q: {},
+ rp: {},
+ rt: {},
+ ruby: {},
samp: {},
script: {empty: true, parent: ' body div frame head iframe p pre span '},
+ section: {},
select: {},
small: {},
span: {},
+ source: {},
strong: {},
style: {parent: ' head ', empty: true},
sub: {},
@@ -660,12 +684,14 @@ var JSLINT = (function () {
tfoot: {parent: ' table '},
th: {parent: ' tr '},
thead: {parent: ' table '},
+ time: {},
title: {parent: ' head '},
tr: {parent: ' table tbody thead tfoot '},
tt: {},
u: {},
ul: {},
- 'var': {}
+ 'var': {},
+ video: {}
},
ids, // HTML ids
@@ -887,7 +913,7 @@ var JSLINT = (function () {
sx = /^\s*([{:#%.=,>+\[\]@()"';]|\*=?|\$=|\|=|\^=|~=|[a-zA-Z_][a-zA-Z0-9_\-]*|[0-9]+|<\/|\/\*)/,
ssx = /^\s*([@#!"'};:\-%.=,+\[\]()*_]|[a-zA-Z][a-zA-Z0-9._\-]*|\/\*?|\d+(?:\.\d+)?|<\/)/,
// attributes characters
- qx = /[^a-zA-Z0-9-_\/ ]/,
+ qx = /[^a-zA-Z0-9+\-_\/ ]/,
// query characters for ids
dx = /[\[\]\/\\"'*<>.&:(){}+=#]/,
@@ -1439,7 +1465,8 @@ var JSLINT = (function () {
errorAt("Unclosed comment.", line, character);
} else {
if (option.safe && ax.test(s)) {
- warningAt("ADsafe comment violation.", line, character);
+ warningAt("ADsafe comment violation.",
+ line, character);
}
}
}
@@ -1484,11 +1511,13 @@ var JSLINT = (function () {
l += 1;
switch (c) {
case '':
- errorAt("Unclosed regular expression.", line, from);
+ errorAt("Unclosed regular expression.",
+ line, from);
return;
case '/':
if (depth > 0) {
- warningAt("Unescaped '{a}'.", line, from + l, '/');
+ warningAt("Unescaped '{a}'.",
+ line, from + l, '/');
}
c = s.substr(0, l - 1);
q = {
@@ -1504,15 +1533,18 @@ var JSLINT = (function () {
s = s.substr(l);
q = s.charAt(0);
if (q === '/' || q === '*') {
- errorAt("Confusing regular expression.", line, from);
+ errorAt("Confusing regular expression.",
+ line, from);
}
return it('(regexp)', c);
case '\\':
c = s.charAt(l);
if (c < ' ') {
- warningAt("Unexpected control character in regular expression.", line, from + l);
+ warningAt(
+"Unexpected control character in regular expression.", line, from + l);
} else if (c === '<') {
- warningAt("Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
+ warningAt(
+"Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
}
l += 1;
break;
@@ -1528,7 +1560,8 @@ var JSLINT = (function () {
l += 1;
break;
default:
- warningAt("Expected '{a}' and instead saw '{b}'.", line, from + l, ':', s.charAt(l));
+ warningAt(
+"Expected '{a}' and instead saw '{b}'.", line, from + l, ':', s.charAt(l));
}
} else {
captures += 1;
@@ -1539,7 +1572,8 @@ var JSLINT = (function () {
break;
case ')':
if (depth === 0) {
- warningAt("Unescaped '{a}'.", line, from + l, ')');
+ warningAt("Unescaped '{a}'.",
+ line, from + l, ')');
} else {
depth -= 1;
}
@@ -1551,7 +1585,8 @@ var JSLINT = (function () {
q += 1;
}
if (q > 1) {
- warningAt("Spaces are hard to count. Use {{a}}.", line, from + l, q);
+ warningAt(
+"Spaces are hard to count. Use {{a}}.", line, from + l, q);
}
break;
case '[':
@@ -1559,55 +1594,64 @@ var JSLINT = (function () {
if (c === '^') {
l += 1;
if (option.regexp) {
- warningAt("Insecure '{a}'.", line, from + l, c);
+ warningAt("Insecure '{a}'.",
+ line, from + l, c);
}
}
q = false;
if (c === ']') {
- warningAt("Empty class.", line, from + l - 1);
+ warningAt("Empty class.", line,
+ from + l - 1);
q = true;
}
- klass: do {
+klass: do {
c = s.charAt(l);
l += 1;
switch (c) {
case '[':
case '^':
- warningAt("Unescaped '{a}'.", line, from + l, c);
+ warningAt("Unescaped '{a}'.",
+ line, from + l, c);
q = true;
break;
case '-':
if (q) {
q = false;
} else {
- warningAt("Unescaped '{a}'.", line, from + l, '-');
+ warningAt("Unescaped '{a}'.",
+ line, from + l, '-');
q = true;
}
break;
case ']':
if (!q) {
- warningAt("Unescaped '{a}'.", line, from + l - 1, '-');
+ warningAt("Unescaped '{a}'.",
+ line, from + l - 1, '-');
}
break klass;
case '\\':
c = s.charAt(l);
if (c < ' ') {
- warningAt("Unexpected control character in regular expression.", line, from + l);
+ warningAt(
+"Unexpected control character in regular expression.", line, from + l);
} else if (c === '<') {
- warningAt("Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
+ warningAt(
+"Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
}
l += 1;
q = true;
break;
case '/':
- warningAt("Unescaped '{a}'.", line, from + l - 1, '/');
+ warningAt("Unescaped '{a}'.",
+ line, from + l - 1, '/');
q = true;
break;
case '<':
if (xmode === 'script') {
c = s.charAt(l);
if (c === '!' || c === '/') {
- warningAt("HTML confusion in regular expression '<{a}'.", line, from + l, c);
+ warningAt(
+"HTML confusion in regular expression '<{a}'.", line, from + l, c);
}
}
q = true;
@@ -1619,7 +1663,8 @@ var JSLINT = (function () {
break;
case '.':
if (option.regexp) {
- warningAt("Insecure '{a}'.", line, from + l, c);
+ warningAt("Insecure '{a}'.", line,
+ from + l, c);
}
break;
case ']':
@@ -1628,13 +1673,15 @@ var JSLINT = (function () {
case '}':
case '+':
case '*':
- warningAt("Unescaped '{a}'.", line, from + l, c);
+ warningAt("Unescaped '{a}'.", line,
+ from + l, c);
break;
case '<':
if (xmode === 'script') {
c = s.charAt(l);
if (c === '!' || c === '/') {
- warningAt("HTML confusion in regular expression '<{a}'.", line, from + l, c);
+ warningAt(
+"HTML confusion in regular expression '<{a}'.", line, from + l, c);
}
}
}
@@ -1652,7 +1699,8 @@ var JSLINT = (function () {
l += 1;
c = s.charAt(l);
if (c < '0' || c > '9') {
- warningAt("Expected a number and instead saw '{a}'.", line, from + l, c);
+ warningAt(
+"Expected a number and instead saw '{a}'.", line, from + l, c);
}
l += 1;
low = +c;
@@ -1683,7 +1731,8 @@ var JSLINT = (function () {
}
}
if (s.charAt(l) !== '}') {
- warningAt("Expected '{a}' and instead saw '{b}'.", line, from + l, '}', c);
+ warningAt(
+"Expected '{a}' and instead saw '{b}'.", line, from + l, '}', c);
} else {
l += 1;
}
@@ -1691,7 +1740,8 @@ var JSLINT = (function () {
l += 1;
}
if (low > high) {
- warningAt("'{a}' should not be greater than '{b}'.", line, from + l, low, high);
+ warningAt(
+"'{a}' should not be greater than '{b}'.", line, from + l, low, high);
}
}
}
@@ -1785,7 +1835,8 @@ var JSLINT = (function () {
function addlabel(t, type) {
- if (option.safe && funct['(global)'] && typeof predefined[t] !== 'boolean') {
+ if (option.safe && funct['(global)'] &&
+ typeof predefined[t] !== 'boolean') {
warning('ADsafe global: ' + t + '.', token);
} else if (t === 'hasOwnProperty') {
warning("'hasOwnProperty' is a really bad name.");
@@ -1961,7 +2012,8 @@ loop: for (;;) {
if (nexttoken.id === '(end)') {
warning("Unmatched '{a}'.", t, t.id);
} else {
- warning("Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.",
+ warning(
+"Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.",
nexttoken, id, t.id, t.line, nexttoken.value);
}
} else if (nexttoken.type !== '(identifier)' ||
@@ -2101,7 +2153,8 @@ loop: for (;;) {
if (option.white && nexttoken.id !== '(end)') {
i = indent + (bias || 0);
if (nexttoken.from !== i) {
- warning("Expected '{a}' to have an indentation at {b} instead at {c}.",
+ warning(
+"Expected '{a}' to have an indentation at {b} instead at {c}.",
nexttoken, nexttoken.value, i, nexttoken.from);
}
}
@@ -2210,7 +2263,8 @@ loop: for (;;) {
function reservevar(s, v) {
return reserve(s, function () {
- if (this.id === 'this' || this.id === 'arguments') {
+ if (this.id === 'this' || this.id === 'arguments' ||
+ this.id === 'eval') {
if (strict_mode && funct['(global)']) {
warning("Strict violation.", this);
} else if (option.safe) {
@@ -2365,7 +2419,8 @@ loop: for (;;) {
x.led = function (left) {
if (option.plusplus) {
warning("Unexpected use of '{a}'.", this, this.id);
- } else if ((!left.identifier || left.reserved) && left.id !== '.' && left.id !== '[') {
+ } else if ((!left.identifier || left.reserved) &&
+ left.id !== '.' && left.id !== '[') {
warning("Bad operand.", this);
}
this.left = left;
@@ -2459,9 +2514,6 @@ loop: for (;;) {
if (!noindent) {
indentation();
}
- if (nexttoken.id === 'new') {
- warning("'new' should not be used as a statement.");
- }
r = parse(0, true);
// Look for the final semicolon.
@@ -2471,6 +2523,8 @@ loop: for (;;) {
warning(
"Expected an assignment or function call and instead saw an expression.",
token);
+ } else if (r.id === '(' && r.left.id === 'new') {
+ warning("Do not use 'new' for side effects.");
}
if (nexttoken.id !== ';') {
warningAt("Missing semicolon.", token.line,
@@ -3511,7 +3565,9 @@ loop: for (;;) {
if (ids[u] === true) {
warning("Duplicate id='{a}'.", nexttoken, v);
}
- if (option.adsafe) {
+ if (!/^[A-Za-z][A-Za-z0-9._:\-]*$/.test(v)) {
+ warning("Bad id: '{a}'.", nexttoken, v);
+ } else if (option.adsafe) {
if (adsafe_id) {
if (v.slice(0, adsafe_id.length) !== adsafe_id) {
warning("ADsafe violation: An id must have a '{a}' prefix",
@@ -4000,6 +4056,9 @@ loop: for (;;) {
return this;
});
+
+// ECMAScript parser
+
delim('(endline)');
delim('(begin)');
delim('(end)').reach = true;
@@ -4584,28 +4643,6 @@ loop: for (;;) {
return p;
}
}
- };
-
- function withparams() {
- var i, t = nexttoken, p = [];
- advance('(');
- nospace();
- if (nexttoken.id === ')') {
- advance(')');
- nospace(prevtoken, token);
- return;
- }
- for (;;) {
- i = parse(20);
- p.push(i);
- if (nexttoken.id === ',') {
- comma();
- } else {
- advance(')', t);
- nospace(prevtoken, token);
- return p;
- }
- }
}
function doFunction(i) {
@@ -4658,8 +4695,8 @@ loop: for (;;) {
nonadjacent(token, nexttoken);
}
doFunction(i);
- if (funct['(loopage)'] && nexttoken.id !== '(') {
- warning("Be careful when making functions within a loop. Consider putting the function in a closure.");
+ if (funct['(loopage)']) {
+ warning("Don't make functions within a loop.");
}
return this;
});
@@ -4690,15 +4727,6 @@ loop: for (;;) {
return this;
});
- blockstmt('with', function () {
- if (!option.withstmt) {
- warning("Don't use with statements");
- }
- withparams();
- block(true);
- return this;
- });
-
blockstmt('try', function () {
var b, e, s;
if (option.adsafe) {
@@ -5056,6 +5084,9 @@ loop: for (;;) {
reserve('public');
reserve('static');
+
+// Parse JSON
+
function jsonValue() {
function jsonObject() {
@@ -5181,7 +5212,6 @@ loop: for (;;) {
o.sub = false;
o.undef = true;
o.widget = false;
- o.withstmt= false;
predefined.Date = null;
predefined['eval'] = null;
predefined.Function = null;
@@ -5312,6 +5342,7 @@ loop: for (;;) {
return a;
}
+
// Data summary.
itself.data = function () {
@@ -5525,8 +5556,8 @@ loop: for (;;) {
};
itself.jslint = itself;
- itself.edition = '2010-01-20';
+ itself.edition = '2010-03-12';
return itself;
-}());
+}());
Please sign in to comment.
Something went wrong with that request. Please try again.