📄 jslint.js
字号:
// jslint.js
// 2008-12-31
/*
Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/*
JSLINT is a global function. It takes two parameters.
var myResult = JSLINT(source, option);
The first parameter is either a string or an array of strings. If it is a
string, it will be split on '\n' or '\r'. If it is an array of strings, it
is assumed that each string represents one line. The source can be a
JavaScript text, or HTML text, or a Konfabulator text.
The second parameter is an optional object of options which control the
operation of JSLINT. Most of the options are booleans: They are all are
optional and have a default value of false.
If it checks out, JSLINT returns true. Otherwise, it returns false.
If false, you can inspect JSLINT.errors to find out the problems.
JSLINT.errors is an array of objects containing these members:
{
line : The line (relative to 0) at which the lint was found
character : The character (relative to 0) at which the lint was found
reason : The problem
evidence : The text line in which the problem occurred
raw : The raw message before the details were inserted
a : The first detail
b : The second detail
c : The third detail
d : The fourth detail
}
If a fatal error was found, a null will be the last element of the
JSLINT.errors array.
You can request a Function Report, which shows all of the functions
and the parameters and vars that they use. This can be used to find
implied global variables and other problems. The report is in HTML and
can be inserted in an HTML <body>.
var myReport = JSLINT.report(limited);
If limited is true, then the report will be limited to only errors.
*/
/*jslint evil: true, nomen: false, onevar: false, regexp: false */
/*global JSLINT*/
/*members "\b", "\t", "\n", "\f", "\r", "\"", "%", "(begin)",
"(breakage)", "(context)", "(error)", "(global)", "(identifier)",
"(line)", "(loopage)", "(name)", "(onevar)", "(params)", "(scope)",
"(verb)", ")", "++", "--", "\/", ADSAFE, Array, Boolean, COM, Canvas,
CustomAnimation, Date, Debug, E, Error, EvalError, FadeAnimation,
FormField, Frame, Function, HotKey, Image, JSON, LN10, LN2, LOG10E,
LOG2E, MAX_VALUE, MIN_VALUE, Math, MenuItem, MoveAnimation,
NEGATIVE_INFINITY, Number, Object, Option, PI, POSITIVE_INFINITY, Point,
RangeError, ReferenceError, RegExp, ResizeAnimation, RotateAnimation,
SQRT1_2, SQRT2, ScrollBar, String, SyntaxError, System, Text, TextArea,
Timer, TypeError, URIError, URL, Window, XMLDOM, XMLHttpRequest, "\\",
"]", a, abbr, acronym, active, address, adsafe, after, 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, before,
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, 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,
darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred,
darksalmon, darkseagreen, darkslateblue, darkslategray, darkturquoise,
darkviolet, dd, debug, decodeURI, decodeURIComponent, deeppink,
deepskyblue, defaultStatus, defineClass, del, deserialize, dfn, dimgray,
dir, direction, display, div, dl, document, dodgerblue, dt, else, em,
embed, empty, "empty-cells", encodeURI, encodeURIComponent, entityify,
eqeqeq, errors, escape, eval, event, evidence, evil, ex, exec, exps,
fieldset, filesystem, firebrick, first, "first-child", "first-letter",
"first-line", 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, function, g, gainsboro, gc,
getComputedStyle, ghostwhite, gold, goldenrod, gray, green, greenyellow,
h1, h2, h3, h4, h5, h6, hasOwnProperty, head, height, help, history,
honeydew, hotpink, hover, hr, html, i, iTunes, id, identifier, iframe,
img, import, in, include, indent, indexOf, indianred, indigo, init,
input, ins, isAlpha, isApplicationRunning, isDigit, isFinite, isNaN,
ivory, join, kbd, khaki, konfabulatorVersion, label, labelled, lang,
lavender, lavenderblush, lawngreen, laxbreak, lbp, led, left, legend,
lemonchiffon, length, "letter-spacing", li, lightblue, lightcoral,
lightcyan, lightgoldenrodyellow, lightgreen, lightpink, lightsalmon,
lightseagreen, lightskyblue, lightslategray, lightsteelblue,
lightyellow, lime, limegreen, line, "line-height", linen, link,
"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", media,
mediumaquamarine, mediumblue, mediumorchid, mediumpurple,
mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise,
mediumvioletred, 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, 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, p, padding,
"padding-bottom", "padding-left", "padding-right", "padding-top", page,
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, 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, self, 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, 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, toLowerCase, toString, toUpperCase, toint32, token, tomato, top,
tr, tt, turquoise, type, u, ul, undef, unescape, "unicode-bidi", union,
unwatch, updateNow, value, valueOf, var, version, "vertical-align",
violet, visibility, visited, watch, wheat, white, "white-space",
whitesmoke, widget, width, window, "word-spacing", yahooCheckLogin,
yahooLogin, yahooLogout, yellow, yellowgreen, "z-index"
*/
// We build the application inside a function so that we produce only a single
// global variable. The function will be invoked, its return value is the JSLINT
// application itself.
"use strict";
JSLINT = function () {
var adsafe_id, // The widget's ADsafe id.
adsafe_may, // The widget may load approved scripts.
adsafe_went, // ADSAFE.go has been called.
anonname, // The guessed name for anonymous functions.
approved, // ADsafe approved urls.
atrule = {
'import' : true,
media : true,
'font-face': true,
page : true
},
badbreak = {
')': true,
']': true,
'++': true,
'--': true
},
// These are members that should not be permitted in third party ads.
banned = { // the member names that ADsafe prohibits.
apply : true,
'arguments' : true,
call : true,
callee : true,
caller : true,
constructor : true,
'eval' : true,
prototype : true,
unwatch : true,
valueOf : true,
watch : true
},
// These are the JSLint boolean options.
boolOptions = {
adsafe : true, // if ADsafe should be enforced
bitwise : true, // if bitwise operators should not be allowed
browser : true, // if the standard browser globals should be predefined
cap : true, // if upper case HTML should be allowed
css : true, // if CSS workarounds should be tolerated
debug : true, // if debugger statements should be allowed
eqeqeq : true, // if === should be required
evil : true, // if eval should be allowed
forin : true, // if for in statements must filter
fragment : true, // if HTML fragments should be allowed
laxbreak : true, // if line breaks should not be checked
newcap : true, // if constructor names must be capitalized
nomen : true, // if names should be checked
on : true, // if HTML event handlers should be allowed
onevar : true, // if only one var statement per function should be allowed
passfail : true, // if the scan should stop on first error
plusplus : true, // if increment/decrement should not be allowed
regexp : true, // if the . should not be allowed in regexp literals
rhino : true, // if the Rhino environment globals should be predefined
undef : true, // if variables should be declared before used
safe : true, // if use of some browser features should be restricted
sidebar : true, // if the System object should be predefined
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
ec_eqnull : true // if (x == null or x != null) should be allowed. (Custom option added for Echo)
},
// browser contains a set of global names which are commonly provided by a
// web browser environment.
browser = {
alert : true,
blur : true,
clearInterval : true,
clearTimeout : true,
close : true,
closed : true,
confirm : true,
console : true,
Debug : true,
defaultStatus : true,
document : true,
event : true,
focus : true,
frames : true,
getComputedStyle: true,
history : true,
Image : true,
length : true,
location : true,
moveBy : true,
moveTo : true,
name : true,
navigator : true,
onblur : true,
onerror : true,
onfocus : true,
onload : true,
onresize : true,
onunload : true,
open : true,
opener : true,
opera : true,
Option : true,
parent : true,
print : true,
prompt : true,
resizeBy : true,
resizeTo : true,
screen : true,
scroll : true,
scrollBy : true,
scrollTo : true,
self : true,
setInterval : true,
setTimeout : true,
status : true,
top : true,
window : true,
XMLHttpRequest : true
},
cssAttributeData,
cssAny,
cssColorData = {
"aliceblue": true,
"antiquewhite": true,
"aqua": true,
"aquamarine": true,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -