diff --git a/src/extensions/default/JSLint/htmlContent/results-table.html b/src/extensions/default/JSLint/htmlContent/results-table.html
new file mode 100644
index 00000000000..ce1a7612988
--- /dev/null
+++ b/src/extensions/default/JSLint/htmlContent/results-table.html
@@ -0,0 +1,11 @@
+
+
+ {{#reportList}}
+
+
{{line}}
+
{{reason}}
+
{{evidence}}
+
+ {{/reportList}}
+
+
diff --git a/src/extensions/default/JSLint/jslint.css b/src/extensions/default/JSLint/jslint.css
new file mode 100644
index 00000000000..1fd3688c824
--- /dev/null
+++ b/src/extensions/default/JSLint/jslint.css
@@ -0,0 +1,14 @@
+.jslint-disabled {
+ font-size: 1em;
+ color: #808080;
+}
+
+.jslint-errors {
+ font-size: 1em;
+ color: #dc322f;
+}
+
+.jslint-valid {
+ font-size: 1em;
+ color: #FFC81C;
+}
diff --git a/src/extensions/default/JSLint/keyboard.json b/src/extensions/default/JSLint/keyboard.json
new file mode 100644
index 00000000000..9796e9edc77
--- /dev/null
+++ b/src/extensions/default/JSLint/keyboard.json
@@ -0,0 +1,11 @@
+{
+ "gotoFirstError": [
+ {
+ "key": "F8"
+ },
+ {
+ "key": "Cmd-'",
+ "platform": "mac"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/src/extensions/default/JSLint/main.js b/src/extensions/default/JSLint/main.js
new file mode 100644
index 00000000000..9d1c92d238a
--- /dev/null
+++ b/src/extensions/default/JSLint/main.js
@@ -0,0 +1,279 @@
+/*
+ * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved.
+ *
+ * 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 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 vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
+/*global define, $, JSLINT, Mustache, brackets */
+
+/**
+ * Allows JSLint to run on the current document and report results in a UI panel.
+ */
+define(function (require, exports, module) {
+ "use strict";
+
+ // Load dependent non-module scripts
+ require("thirdparty/jslint/jslint");
+
+ // Load dependent modules
+ var Commands = brackets.getModule("command/Commands"),
+ CommandManager = brackets.getModule("command/CommandManager"),
+ Menus = brackets.getModule("command/Menus"),
+ DocumentManager = brackets.getModule("document/DocumentManager"),
+ EditorManager = brackets.getModule("editor/EditorManager"),
+ LanguageManager = brackets.getModule("language/LanguageManager"),
+ PreferencesManager = brackets.getModule("preferences/PreferencesManager"),
+ PerfUtils = brackets.getModule("utils/PerfUtils"),
+ Strings = brackets.getModule("strings"),
+ StringUtils = brackets.getModule("utils/StringUtils"),
+ AppInit = brackets.getModule("utils/AppInit"),
+ Resizer = brackets.getModule("utils/Resizer"),
+ ExtensionUtils = brackets.getModule("utils/ExtensionUtils"),
+ StatusBar = brackets.getModule("widgets/StatusBar"),
+ JSLintTemplate = require("text!htmlContent/bottom-panel.html"),
+ ResultsTemplate = require("text!htmlContent/results-table.html");
+
+ var KeyboardPrefs = JSON.parse(require("text!keyboard.json"));
+
+ var INDICATOR_ID = "JSLintStatus",
+ defaultPrefs = { enabled: true };
+
+
+ /** @const {string} JSLint commands ID */
+ var TOGGLE_ENABLED = "jslint.toggleEnabled";
+ var GOTO_FIRST_ERROR = "jslint.gotoFirstError";
+
+ /**
+ * @private
+ * @type {PreferenceStorage}
+ */
+ var _prefs = null;
+
+ /**
+ * @private
+ * @type {boolean}
+ */
+ var _enabled = true;
+
+ /**
+ * @private
+ * @type {$.Element}
+ */
+ var $lintResults;
+
+ /**
+ * @private
+ * @type {boolean}
+ */
+ var _gotoEnabled = false;
+
+ /**
+ * Enable or disable the "Go to First JSLint Error" command
+ * @param {boolean} gotoEnabled Whether it is enabled.
+ */
+ function setGotoEnabled(gotoEnabled) {
+ CommandManager.get(GOTO_FIRST_ERROR).setEnabled(gotoEnabled);
+ _gotoEnabled = gotoEnabled;
+ }
+
+ /**
+ * Run JSLint on the current document. Reports results to the main UI. Displays
+ * a gold star when no errors are found.
+ */
+ function run() {
+ var currentDoc = DocumentManager.getCurrentDocument();
+
+ var perfTimerDOM,
+ perfTimerLint;
+
+ var language = currentDoc ? LanguageManager.getLanguageForPath(currentDoc.file.fullPath) : "";
+
+ if (_enabled && language && language.getId() === "javascript") {
+ perfTimerLint = PerfUtils.markStart("JSLint linting:\t" + (!currentDoc || currentDoc.file.fullPath));
+ var text = currentDoc.getText();
+
+ // If a line contains only whitespace, remove the whitespace
+ // This should be doable with a regexp: text.replace(/\r[\x20|\t]+\r/g, "\r\r");,
+ // but that doesn't work.
+ var i, arr = text.split("\n");
+ for (i = 0; i < arr.length; i++) {
+ if (!arr[i].match(/\S/)) {
+ arr[i] = "";
+ }
+ }
+ text = arr.join("\n");
+
+ var result = JSLINT(text, null);
+
+ PerfUtils.addMeasurement(perfTimerLint);
+ perfTimerDOM = PerfUtils.markStart("JSLint DOM:\t" + (!currentDoc || currentDoc.file.fullPath));
+
+ if (!result) {
+ // Remove the null errors for the template
+ var errors = JSLINT.errors.filter(function (err) { return err !== null; });
+ var html = Mustache.render(ResultsTemplate, {reportList: errors});
+ var $selectedRow;
+
+ $lintResults.find(".table-container")
+ .empty()
+ .append(html)
+ .scrollTop(0) // otherwise scroll pos from previous contents is remembered
+ .on("click", function (e) {
+ if ($selectedRow) {
+ $selectedRow.removeClass("selected");
+ }
+
+ $selectedRow = $(e.target).closest("tr");
+ $selectedRow.addClass("selected");
+ var lineTd = $selectedRow.find("td.line");
+ var line = lineTd.text();
+ var character = lineTd.data("character");
+
+ var editor = EditorManager.getCurrentFullEditor();
+ editor.setCursorPos(line - 1, character - 1, true);
+ EditorManager.focusEditor();
+ });
+
+ $lintResults.show();
+ if (JSLINT.errors.length === 1) {
+ StatusBar.updateIndicator(INDICATOR_ID, true, "jslint-errors", Strings.JSLINT_ERROR_INFORMATION);
+ } else {
+ // Return the number of non-null errors
+ var numberOfErrors = errors.length;
+ // If there was a null value it means there was a stop notice and an indeterminate
+ // upper bound on the number of JSLint errors, which we'll represent by appending a '+'
+ if (numberOfErrors !== JSLINT.errors.length) {
+ // First discard the stop notice
+ numberOfErrors -= 1;
+ numberOfErrors += "+";
+ }
+ StatusBar.updateIndicator(INDICATOR_ID, true, "jslint-errors",
+ StringUtils.format(Strings.JSLINT_ERRORS_INFORMATION, numberOfErrors));
+ }
+ setGotoEnabled(true);
+
+ } else {
+ $lintResults.hide();
+ StatusBar.updateIndicator(INDICATOR_ID, true, "jslint-valid", Strings.JSLINT_NO_ERRORS);
+ setGotoEnabled(false);
+ }
+
+ PerfUtils.addMeasurement(perfTimerDOM);
+
+ } else {
+ // JSLint is disabled or does not apply to the current file, hide the results
+ $lintResults.hide();
+ StatusBar.updateIndicator(INDICATOR_ID, true, "jslint-disabled", Strings.JSLINT_DISABLED);
+ setGotoEnabled(false);
+ }
+
+ EditorManager.resizeEditor();
+ }
+
+ /**
+ * Update DocumentManager listeners.
+ */
+ function updateListeners() {
+ if (_enabled) {
+ // register our event listeners
+ $(DocumentManager)
+ .on("currentDocumentChange.jslint", function () {
+ run();
+ })
+ .on("documentSaved.jslint documentRefreshed.jslint", function (event, document) {
+ if (document === DocumentManager.getCurrentDocument()) {
+ run();
+ }
+ });
+ } else {
+ $(DocumentManager).off(".jslint");
+ }
+ }
+
+ /**
+ * Enable or disable JSLint.
+ * @param {boolean} enabled Enabled state.
+ */
+ function setEnabled(enabled) {
+ _enabled = enabled;
+
+ CommandManager.get(TOGGLE_ENABLED).setChecked(_enabled);
+ updateListeners();
+ _prefs.setValue("enabled", _enabled);
+
+ // run immediately
+ run();
+ }
+
+
+ /** Command to toggle enablement */
+ function handleToggleEnabled() {
+ setEnabled(!_enabled);
+ }
+
+ /** Command to go to the first JSLint Error */
+ function handleGotoFirstError() {
+ run();
+ if (_gotoEnabled) {
+ $lintResults.find("tr:first-child").trigger("click");
+ }
+ }
+
+
+ // Register command handlers
+ CommandManager.register(Strings.CMD_JSLINT, TOGGLE_ENABLED, handleToggleEnabled);
+ CommandManager.register(Strings.CMD_JSLINT_FIRST_ERROR, GOTO_FIRST_ERROR, handleGotoFirstError);
+
+ // Add the menu items
+ var menu = Menus.getMenu(Menus.AppMenuBar.VIEW_MENU);
+ menu.addMenuItem(TOGGLE_ENABLED, "", Menus.AFTER, Commands.TOGGLE_WORD_WRAP);
+ menu.addMenuDivider(Menus.AFTER, Commands.TOGGLE_WORD_WRAP);
+
+ menu = Menus.getMenu(Menus.AppMenuBar.NAVIGATE_MENU);
+ menu.addMenuItem(GOTO_FIRST_ERROR, KeyboardPrefs.gotoFirstError, Menus.AFTER, Commands.NAVIGATE_GOTO_DEFINITION);
+
+
+ // Init PreferenceStorage
+ _prefs = PreferencesManager.getPreferenceStorage(module, defaultPrefs);
+
+ // Initialize items dependent on HTML DOM
+ AppInit.htmlReady(function () {
+ ExtensionUtils.loadStyleSheet(module, "jslint.css");
+
+ var jsLintHtml = Mustache.render(JSLintTemplate, Strings);
+ $(jsLintHtml).insertBefore("#status-bar");
+
+ var goldStarHtml = Mustache.render("
★
", Strings);
+ $(goldStarHtml).insertBefore("#status-file");
+
+ $lintResults = $("#jslint-results");
+
+ StatusBar.addIndicator(INDICATOR_ID, $("#gold-star"));
+
+ // Called on HTML ready to trigger the initial UI state
+ setEnabled(_prefs.getValue("enabled"));
+
+ // AppInit.htmlReady() has already executed before extensions are loaded
+ // so, for now, we need to call this ourself
+ Resizer.makeResizable($lintResults.get(0), "vert", "top", 100);
+ });
+});
diff --git a/src/extensions/default/JSLint/thirdparty/jslint/README b/src/extensions/default/JSLint/thirdparty/jslint/README
new file mode 100644
index 00000000000..1023deb93a6
--- /dev/null
+++ b/src/extensions/default/JSLint/thirdparty/jslint/README
@@ -0,0 +1,41 @@
+JSLint, The JavaScript Code Quality Tool
+
+Douglas Crockford
+douglas@crockford.com
+
+2011-12-21
+
+jslint.js contains the fully commented JSLINT function.
+
+jslint.html runs the JSLINT function in a web page. The page also depends
+on adsafe.js [www.ADsafe.org] and json2.js [www.JSON.org] (which are not
+included in this project) and intercept.js and init_ui.js (which are). The
+js files should all be minified, and all except init_ui.js are concatenated
+together to form web_jslint.js.
+
+intercept.js augments ADsafe, giving widgets access to the clock, cookies,
+and the JSLINT function.
+
+init_ui.js hooks the HTML ui components to ADsafe.
+
+lint.html describes JSLint's usage. Please read it.
+
+Direct questions and comments to http://tech.groups.yahoo.com/group/jslint_com/.
+
+JSLint can be run anywhere that JavaScript (or Java) can run. See for example
+http://tech.groups.yahoo.com/group/jslint_com/database?method=reportRows&tbl=1
+
+The place to express yourself in programming is in the quality of your ideas,
+and the efficiency of execution. The role of style is the same as in
+literature. A great writer doesn't express himself by putting the spaces
+before his commas instead of after, or by putting extra spaces inside his
+parentheses. A great writer will slavishly conform to some rules of style,
+and that in no way constrains his power to express himself creatively.
+See for example William Strunk's The Elements of Style
+[http://www.crockford.com/wrrrld/style.html].
+
+This applies to programming as well. Conforming to a consistent style
+improves readability, and frees you to express yourself in ways that matter.
+JSLint here plays the part of a stern but benevolent editor, helping you to
+get the style right so that you can focus your creative energy where it is
+most needed.
diff --git a/src/extensions/default/JSLint/thirdparty/jslint/init_ui.js b/src/extensions/default/JSLint/thirdparty/jslint/init_ui.js
new file mode 100644
index 00000000000..36a638a955a
--- /dev/null
+++ b/src/extensions/default/JSLint/thirdparty/jslint/init_ui.js
@@ -0,0 +1,185 @@
+// init_ui.js
+// 2011-12-08
+
+// This is the web browser companion to fulljslint.js. It is an ADsafe
+// lib file that implements a web ui by adding behavior to the widget's
+// html tags.
+
+// It stores a function in lib.init_ui. Calling that function will
+// start up the JSLint widget ui.
+
+// option = {adsafe: true, fragment: false}
+
+/*properties check, cookie, each, edition, get, getCheck, getTitle, getValue,
+ has, indent, isArray, join, jslint, length, lib, maxerr, maxlen, on,
+ predef, push, q, select, set, split, stringify, style, target, tree, value
+*/
+
+
+ADSAFE.lib("init_ui", function (lib) {
+ 'use strict';
+
+ return function (dom) {
+ var table = dom.q('#JSLINT_TABLE'),
+ boxes = table.q('span'),
+ indent = dom.q('#JSLINT_INDENT'),
+ input = dom.q('#JSLINT_INPUT'),
+ jslintstring = dom.q('#JSLINT_JSLINTSTRING'),
+ maxerr = dom.q('#JSLINT_MAXERR'),
+ maxlen = dom.q('#JSLINT_MAXLEN'),
+ option = lib.cookie.get(),
+ output = dom.q('#JSLINT_OUTPUT'),
+ tree = dom.q('#JSLINT_TREE'),
+ predefined = dom.q('#JSLINT_PREDEF');
+
+ function show_jslint_control() {
+
+// Build and display a /*jslint*/ control comment.
+// The comment can be copied into a .js file.
+
+ var a = [];
+
+ boxes.each(function (bunch) {
+ var name = bunch.getTitle(),
+ value = ADSAFE.get(option, name);
+ if (typeof value === 'boolean') {
+ if (name !== 'adsafe' && name !== 'safe') {
+ a.push(name + ': ' + value);
+ }
+ bunch.style('backgroundColor', value ? 'black' : 'white');
+ } else {
+ bunch.style('backgroundColor', 'gainsboro');
+ }
+ });
+ if (typeof option.maxerr === 'number' && option.maxerr >= 0) {
+ a.push('maxerr: ' + String(option.maxerr));
+ }
+ if (typeof option.maxlen === 'number' && option.maxlen >= 0) {
+ a.push('maxlen: ' + String(option.maxlen));
+ }
+ if (typeof option.indent === 'number' && option.indent >= 0) {
+ a.push('indent: ' + String(option.indent));
+ }
+ jslintstring.value('/*jslint ' + a.join(', ') + ' */');
+
+// Make a JSON cookie of the option object.
+
+ lib.cookie.set(option);
+ }
+
+ function show_options() {
+ indent.value(String(option.indent));
+ maxlen.value(String(option.maxlen || ''));
+ maxerr.value(String(option.maxerr));
+ predefined.value(ADSAFE.isArray(option.predef)
+ ? option.predef.join(',')
+ : '');
+ show_jslint_control();
+ }
+
+ function update_box(event) {
+
+// Boxes are tristate, cycling true, false, undefined.
+
+ var title = event.target.getTitle();
+ if (title) {
+ ADSAFE.set(option, title,
+ ADSAFE.get(option, title) === true
+ ? false
+ : ADSAFE.get(option, title) === false
+ ? undefined
+ : true);
+ }
+ show_jslint_control();
+ }
+
+ function update_number(event) {
+ var value = event.target.getValue();
+ if (value.length === 0 || +value < 0 || !isFinite(value)) {
+ value = '';
+ ADSAFE.set(option, event.target.getTitle(), undefined);
+ } else {
+ ADSAFE.set(option, event.target.getTitle(), +value);
+ }
+ event.target.value(String(value));
+ show_jslint_control();
+ }
+
+ function update_list(event) {
+ var value = event.target.getValue().split(/\s*,\s*/);
+ ADSAFE.set(option, event.target.getTitle(), value);
+ event.target.value(value.join(', '));
+ show_jslint_control();
+ }
+
+
+// Restore the options from a JSON cookie.
+
+ if (!option || typeof option !== 'object') {
+ option = {
+ indent: 4,
+ maxerr: 50
+ };
+ } else {
+ option.indent = typeof option.indent === 'number' && option.indent >= 0
+ ? option.indent
+ : 4;
+ option.maxerr = typeof option.maxerr === 'number' && option.maxerr >= 0
+ ? option.maxerr
+ : 50;
+ }
+ show_options();
+
+
+// Display the edition.
+
+ dom.q('#JSLINT_EDITION').value('Edition ' + lib.edition());
+
+// Add click event handlers to the [JSLint] and [clear] buttons.
+
+ dom.q('input&jslint').on('click', function () {
+ tree.value('');
+
+// Call JSLint and display the report.
+
+ tree.value(String(lib.jslint(input.getValue(), option, output) / 1000) + ' seconds.');
+ input.select();
+ return false;
+ });
+
+ dom.q('input&tree').on('click', function () {
+ output.value('Tree:');
+ tree.value(JSON.stringify(lib.tree(), [
+ 'label', 'id', 'string', 'number', 'arity', 'name', 'first',
+ 'second', 'third', 'block', 'else', 'quote', 'flag', 'type'
+ ], 4));
+ input.select();
+ });
+
+ dom.q('input&clear').on('click', function () {
+ output.value('');
+ tree.value('');
+ input.value('').select();
+ });
+
+
+ dom.q('#JSLINT_CLEARALL').on('click', function () {
+ option = {
+ indent: 4,
+ maxerr: 50
+ };
+ show_options();
+ });
+
+ table.on('click', update_box);
+ indent.on('change', update_number);
+ maxerr.on('change', update_number);
+ maxlen.on('change', update_number);
+ predefined.on('change', update_list);
+ input
+ .on('change', function () {
+ output.value('');
+ })
+ .select();
+ };
+});
diff --git a/src/extensions/default/JSLint/thirdparty/jslint/intercept.js b/src/extensions/default/JSLint/thirdparty/jslint/intercept.js
new file mode 100644
index 00000000000..cd3d456aa07
--- /dev/null
+++ b/src/extensions/default/JSLint/thirdparty/jslint/intercept.js
@@ -0,0 +1,98 @@
+// intercept.js
+// 2011-06-13
+
+// This file makes it possible for JSLint to run as an ADsafe widget by
+// adding lib features.
+
+// It provides a JSON cookie facility. Each widget is allowed to create a
+// single JSON cookie.
+
+// It also provides a way for the widget to call JSLint. The widget cannot
+// call JSLint directly because it is loaded as a global variable. I don't
+// want to change that because other versions of JSLint depend on that.
+
+// And it provides access to the syntax tree that JSLint constructed.
+
+/*jslint nomen: true, unparam: true */
+
+/*global ADSAFE, document, JSLINT */
+
+/*properties ___nodes___, _intercept, cookie, edition, get, getTime,
+ indexOf, innerHTML, jslint, length, now, parse, replace, report, set,
+ setTime, slice, stringify, toGMTString, tree
+*/
+
+ADSAFE._intercept(function (id, dom, lib, bunch) {
+ "use strict";
+
+// Give every widget access to a JSON cookie. The name of the cookie will be
+// the same as the id of the widget.
+
+ lib.cookie = {
+ get: function () {
+
+// Get the raw cookie. Extract this widget's cookie, and parse it.
+
+ var c = ' ' + document.cookie + ';',
+ s = c.indexOf((' ' + id + '=')),
+ v;
+ try {
+ if (s >= 0) {
+ s += id.length + 2;
+ v = JSON.parse(c.slice(s, c.indexOf(';', s)));
+ }
+ } catch (ignore) {}
+ return v;
+ },
+ set: function (value) {
+
+// Set a cookie. It must be under 2000 in length. Escapify equal sign
+// and semicolon if necessary.
+
+ var d,
+ j = JSON.stringify(value)
+ .replace(/[=]/g, '\\u003d')
+ .replace(/[;]/g, '\\u003b');
+
+ if (j.length < 2000) {
+ d = new Date();
+ d.setTime(d.getTime() + 1e9);
+ document.cookie = id + "=" + j + ';expires=' + d.toGMTString();
+ }
+ }
+ };
+});
+
+ADSAFE._intercept(function (id, dom, lib, bunch) {
+ "use strict";
+
+// Give only the JSLINT_ widget access to the JSLINT function.
+// We add a jslint function to its lib that calls JSLINT and
+// then calls JSLINT.report, and stuffs the html result into
+// a node provided by the widget. A widget does not get direct
+// access to nodes.
+
+// We also add an edition function to the lib that gives the
+// widget access to the current edition string.
+
+ var now = Date.now || function () {
+ return new Date().getTime();
+ };
+ if (id === 'JSLINT_') {
+ lib.jslint = function (source, options, output) {
+ output.___nodes___[0].innerHTML = "Working.";
+ var after, report, before = now();
+ JSLINT(source, options);
+ report = JSLINT.report();
+ after = now();
+ output.___nodes___[0].innerHTML = report;
+ return after - before;
+ };
+ lib.edition = function () {
+ return JSLINT.edition;
+ };
+ lib.tree = function () {
+ return JSLINT.tree;
+ };
+ }
+});
diff --git a/src/extensions/default/JSLint/thirdparty/jslint/jslint.html b/src/extensions/default/JSLint/thirdparty/jslint/jslint.html
new file mode 100644
index 00000000000..5bf5f1c017a
--- /dev/null
+++ b/src/extensions/default/JSLint/thirdparty/jslint/jslint.html
@@ -0,0 +1,295 @@
+
+JSLint, The JavaScript Code Quality Tool
+
+
+
+
JSLint
+ is a JavaScript program that looks for problems in JavaScript programs.
+ It is a code quality tool.
+
+
When C
+ was a young
+ programming language, there were several common programming errors that
+ were not caught by the primitive compilers, so an accessory program called
+ lint
+ was developed that would scan a source file, looking for problems.
+
+
As the language matured, the definition of the language was
+strengthened to eliminate some insecurities, and compilers got better
+at issuing warnings. lint is no longer needed.
+
+
JavaScript is a young-for-its-age
+ language. It was originally intended to do small tasks in webpages, tasks
+ for which Java was too heavy and clumsy. But JavaScript is a very capable
+ language, and it is now being used in larger projects. Many of the features
+ that were intended to make the language easy to use are troublesome when projects become complicated. A lint for JavaScript is needed: JSLint,
+ a JavaScript syntax checker and validator.
+
+
JSLint takes a JavaScript source and scans it. If it finds
+ a problem, it returns a message describing the problem and an approximate
+ location within the source. The problem is not necessarily a syntax error,
+ although it often is. JSLint looks at some style conventions
+ as well as structural problems. It does not prove that your program is
+ correct. It just provides another set of eyes to help spot problems.
JavaScript is a sloppy language, but inside it there is an elegant, better
+ language. JSLint helps you to program in that better language
+ and to avoid most of the slop. JSLint will reject programs that browsers will accept because JSLint is concerned with the quality of your code and browsers are not. You should accept all of JSLint's advice.
+
JSLint can operate on JavaScript source, HTML source, CSS source, or JSON
+ text.
+
Global Variables
+
JavaScript's biggest
+ problem is its dependence on global variables, particularly implied
+ global variables. If a variable is not explicitly declared (usually with
+ the var statement), then JavaScript assumes that the variable
+ was global. This can mask misspelled names and other problems.
+
JSLint expects that all variables and functions are declared
+ before they are used or invoked. This allows it to detect implied global
+ variables. It is also good practice because it makes programs easier to
+ read.
+
Sometimes a file is dependent on global variables and functions that
+ are defined elsewhere. You can identify these to JSLint with a var statement that lists the global functions and objects
+ that your program depends on.
+
A global declaration can look like this:
+
var getElementByAttribute, breakCycles, hanoi;
+
The declaration should appear near the top of the file. It must appear before the use of the variables
+ it declares.
+
It is necessary to use a var statement to declare a variable before that variable is assigned to.
+
JSLint also recognizes a /*global */ directive that can indicate to JSLint that variables used in this file were defined in other files. The comment can contain a comma separated list of names. Each name can optionally be followed by a colon and either true or false, true indicating that the variable may be assigned to by this file, and false indicating that assignment is not allowed (which is the default). The directive respects function scope.
+
Some globals can be predefined for you. Select the Assume
+ a browser (browser) option to
+ predefine the standard global properties that are supplied by web browsers,
+ such as document and addEventListener. It has the same
+ effect as this comment:
Select the
+ Assume console, alert, ...
+(devel) option to predefine globals that are useful in development but that should be avoided in production, such as console and alert. It has the same
+effect as this comment:
Select the Assume Rhino (rhino) option
+ to predefine the global properties provided by the Rhino environment.
+ It has the same effect as this statement:
Select the Assume a Yahoo Widget (widget)
+ option to predefine the global properties provided
+ by the Yahoo! Widgets environment. It has the same effect as this statement:
Select the Assume Windows (windows)
+ option to predefine the global properties provided by Microsoft Windows. It has the same effect as this statement:
JavaScript uses a C-like syntax which requires the use of semicolons to delimit certain
+ statements. JavaScript attempts to make those semicolons optional with a semicolon
+ insertion mechanism. This is dangerous because it can mask errors.
+
Like C, JavaScript has ++ and -- and ( operators
+ which can be prefixes or suffixes. The disambiguation is done by the semicolon.
+
In JavaScript, a linefeed can be whitespace or it can act as a semicolon.
+ This replaces one ambiguity with another.
+
JSLint expects that every statement be followed by ; except
+ for for, function, if, switch, try, and
+ while. JSLint does not expect to see unnecessary semicolons or the
+ empty statement.
+
Comma
+
The comma operator can lead to excessively tricky expressions. It can also
+ mask some programming errors.
+
JSLint expects to see the comma used as a separator, but not as an
+ operator (except in the initialization and incrementation parts of the for
+ statement). It does not expect to see elided elements in array literals. Extra
+ commas should not be used. A comma should not appear after the last element
+ of an array literal or object literal because it can be misinterpreted by some
+ browsers.
+
Scope
+
+
In many languages, a block introduces a scope. Variables introduced in
+ a block are not visible outside of the block.
+
+
In JavaScript, blocks do not introduce a scope. There is only function-scope.
+ A variable introduced anywhere in a function is visible everywhere in
+ the function. JavaScript's blocks confuse experienced programmers and
+ lead to errors because the familiar syntax makes a false promise.
+
+
JSLint expects blocks with function, if,
+ switch, while, for, do,
+ and try statements and nowhere else.
+
In languages with block scope, it is usually recommended that variables
+ be declared at the site of first use. But because JavaScript does not
+ have block scope, it is wiser to declare all of a function's variables
+ at the top of the function. It is recommended that a single var
+ statement be used per function. This can be declined with the vars
+ option.
+
+
Required Blocks
+
+
JSLint expects that if, while,
+ do and for statements will be made with blocks
+ {that is, with statements enclosed in braces}.
+
+
JavaScript allows an if to be written like this:
+
+
if (condition)
+ statement;
+
+
That form is known to contribute to mistakes in projects where many programmers
+ are working on the same code. That is why JSLint expects the use of
+ a block:
+
+
if (condition) {
+ statements;
+}
+
+
Experience shows that this form is more resilient.
+
+
Expression Statements
+
An expression statement is expected to be an assignment or a function/method
+ call or delete. All other expression statements are considered
+ to be errors.
+
Type Confusion
+
JSLint can do type inference. It can report cases were variables and properties are
+used to house multiple types. The warning is Type confusion: {a} and {b}. where the {a} and {b} will be
+replaced with the names of types.
+
It is usually easy to see what caused the
+ warning. In some cases, it can be very puzzling. In the puzzling cases, try
+ initializing your vars with typed values. For example, if you expect that n will
+ contain numbers, then write
+
var n = 0;
+
That should produce clearer warnings.
+
Type confusion is not necessarily an error, particularly in a language that
+ provides as much type freedom as this one does. But some inconsistencies are
+ errors, so type discipline might be something to consider adding to your
+ programming style. Also, the fastest JavaScript engines will slow down in the
+ presence of type confusion.
+
+ To turn off these warnings, turn on the Tolerate type confusionoption.
The body of every forin statement should be
+ wrapped in an if statement that does filtering. It can select
+ for a particular type or range of values, or it can exclude functions,
+ or it can exclude properties from the prototype. For example,
+
for (name in object) {
+ if (object.hasOwnProperty(name)) {
+ ....
+ }
+
+}
+
+
switch
+
A common
+ error in switch statements is to forget to place a break
+ statement after each case, resulting in unintended fall-through. JSLint
+ expects that the statement before the next case or default
+ is one of these: break, return, or throw.
+
+
var
+
+
JavaScript allows var definitions to occur anywhere
+ within a function. JSLint is more strict.
+
+
JSLint expects that a var will be declared
+ only once, and that it will be declared before it is used.
+
JSLint expects that a function
+ will be declared before it is used.
+
JSLint expects that parameters will not also be declared
+ as vars.
+
+
JSLint does not expect the arguments array to be declared
+ as a var.
+
JSLint does not expect that a var will be defined in a block.
+ This is because JavaScript blocks do not have block scope. This can have
+ unexpected consequences. Define all variables at the top of the function.
+
+
with
+
+
The with statement was intended to provide a shorthand in accessing
+ properties in deeply nested objects. Unfortunately, it behaves very
+ badly when setting new properties. Never use the with statement. Use
+ a var instead.
+
+
JSLint does not expect to see a with statement.
+
+
=
+
JSLint does not expect to see an assignment statement in
+ the condition part of an if or for or while
+ or do statement. This is because it is more
+ likely that
+
if (a = b) {
+ ...
+}
+
was intended to be
+
if (a == b) {
+ ...
+}
+
It is difficult to write correct programs while using idioms that are
+ hard to distinguish from obvious errors.
+
== and !=
+
The == and != operators do type coercion before
+ comparing. This is bad because it causes ' \t\r\n' == 0 to
+ be true. This can mask type errors. JSLint cannot reliably determine if == is being used correctly, so it is best to not use == and != and to always use the more reliable === and !== operators instead.
+
If you only care that a value is truthy or falsy,
+ then use the short form. Instead of
+
(foo != 0)
+
just say
+
(foo)
+
and instead of
+
(foo == 0)
+
say
+
(!foo)
+
There is an eqeqoption that allows the use of == and !=.
+
Labels
+
JavaScript allows any statement to have a label, and labels have a
+ separate name space. JSLint is more strict.
+
+
JSLint expects labels only on statements that interact
+ with break: switch, while,
+ do, and for. JSLint expects that labels
+ will be distinct from vars and parameters.
+
+
Unreachable Code
+
JSLint expects that
+ a return, break, continue,
+ or throw statement will be followed by
+ a } or case or default.
+
+
Confusing Pluses and Minuses
+
+
JSLint expects that + will not be followed by
++ or ++, and that - will not be followed
+by - or --. A misplaced space can turn + + into ++, an error that is difficult to see. Use parens to avoid confusion..
+
++ and --
+
The ++ (increment) and -- (decrement)
+ operators have been known to contribute to bad code by encouraging excessive
+ trickiness. They are second only to faulty architecture in enabling to
+ viruses and other security menaces. Also, preincrement/postincrement confusion can produce off-by-one errors that are extremely difficult to diagnose. There is a plusplusoption
+ that allows the use of these operators.
+
Bitwise Operators
+
JavaScript does not have an integer type, but it does have bitwise operators.
+ The bitwise operators convert their operands from floating point to integers
+ and back, so they are not as efficient as in C or other languages. They
+ are rarely useful in browser applications. The similarity to the logical
+ operators can mask some programming errors. The bitwiseoption
+ allows the use of these operators: << >> >>>
+ ~ & |.
+
eval is evil
+
The eval function (and its relatives, Function,
+ setTimeout, and setInterval) provide access
+ to the JavaScript compiler. This is sometimes necessary, but in most cases
+ it indicates the presence of extremely bad coding. The eval
+ function is the most misused feature of JavaScript.
+
+
void
+
In most C-like languages, void is a type. In
+ JavaScript, void is a prefix operator that always
+ returns undefined. JSLint does not expect to
+ see void because it is confusing and not very useful.
+
+
Regular Expressions
+
Regular expressions are written in a terse and cryptic notation. JSLint
+ looks for problems that may cause portability problems. It also attempts
+ to resolve visual ambiguities by recommending explicit escapement.
+
JavaScript's syntax for regular expression literals overloads the /
+ character. To avoid ambiguity, JSLint expects that the character
+ preceding a regular expression literal is a ( or =
+ or : or , character.
+
Constructors and new
+
Constructors are functions that are designed to be used with the new
+ prefix. The new prefix creates a new object based on the
+ function's prototype, and binds that object to the function's
+ implied this parameter. If you neglect to use the new
+ prefix, no new object will be made and this will be bound
+ to the global object. This is a serious
+ mistake.
+
JSLint enforces the convention that constructor functions
+ be given names with initial uppercase. JSLint does not expect
+ to see a function invocation with an initial uppercase name unless it
+ has the new prefix. JSLint does not expect to
+ see the new prefix used with functions whose names do not
+ start with initial uppercase. This can be disabled with the newcap
+ option.
+
JSLint does not expect to see the wrapper forms new Number,
+ new String, new Boolean.
+
JSLint does not expect to see new Object (use {}
+ instead).
+
JSLint does not expect to see new Array (use []
+ instead).
+
Type Inference
+
Type inference is being added to JSLint. The goal is to ultimately make JSLint more helpful in spotting type inconsistencies and confusions. If you do not want this service, then select the confusionoption.
+
+
Properties
+
Since JavaScript is a loosely-typed, dynamic-object language, it is not
+ possible to determine at compile time if property names are spelled correctly.
+ JSLint provides some assistance with this.
+
At the bottom of its report, JSLint displays a /*properties*/
+ comment. It contains all of the names and string literals that were used
+ with dot notation, subscript notation, and object literals to name the
+ properties of objects. You can look through the list for misspellings. Property
+ names that were only used once are shown in italics. This is to make misspellings
+ easier to spot.
+
You can copy the /*properties*/ comment into your script file.
+ JSLint will check the spelling of all property names against
+ the list. That way, you can have JSLint look for misspellings
+ for you. The directive respects function scope.
+
JSLint allows the property names to be annotated with types: array, boolean, function, number, object, regexp, string, or * (a wildcard allowing any type). A function type can be followed by another type, indicating a function's return type.
+
For example,
+
/*properties
+ charAt: function string, slice: function *
+*/
+
+
Unsafe Characters
+
There are characters that are handled inconsistently in browsers, and
+ so must be escaped when placed in strings.
JSLint does not do flow analysis to determine that variables are assigned
+ values before used. This is because variables are given a value (undefined)
+ that is a reasonable default for many applications.
JSLint is able to handle HTML text. It can inspect the JavaScript content
+ contained within <script>...</script> tags. It
+ also inspects the HTML content, looking for problems that are known to interfere
+ with JavaScript:
+
+
All tag names must be in lower case.
+
All tags that can take a close tag (such as </p>)
+ must have a close tag.
+
All tags are correctly nested.
+
The entity < must be used for literal '<'.
+
+
JSLint is less anal than the sycophantic conformity demanded
+ by XHTML, but more strict than the popular browsers.
+
JSLint also checks for the occurrence of '</' in
+ string literals. You should always write '<\/' instead.
+ The extra backslash is ignored by the JavaScript compiler but not by the
+ HTML parser. Tricks like this should not be necessary, and yet they are.
+
There is a capoption that allows
+ use of uppercase tag names. There is also an onoption
+ that allows the use of inline HTML event handlers.
+
There is a fragmentoption that can
+ inspect a well formed HTML fragment. If the adsafeoption
+ is also used, then the fragment must be a <div> that
+ conforms to the ADsafe widget rules.
+
CSS
+
JSLint can inspect CSS files. It expects the first line
+ of a CSS file to be
+
@charset "UTF-8";
+
This feature is experimental. Please report any problems or limitations.
+ There is a cssoption that will tolerate
+ some of the non-standard-but-customary workarounds.
+
+
Options
+
JSLint provides several options that control its operation and
+ its sensitivity. In the web edition, the
+options are selected with several checkboxes and two fields.
+
It also provides assistance in constructing /*jslint*/
+ comments.
+
+
When JSLINT is called as a function, it accepts an option object
+ parameter that allows you to determine the subset of JavaScript that is
+ acceptable to you. The web page version of JSLint at http://www.JSLint.com/
+ does this for you.
+
Options can also be specified within a script with a /*jslint */
+ directive:
An option specification starts with /*jslint. Notice that
+ there is no space before the j. The specification contains
+ a sequence of name value pairs, where the names are JSLint
+ options, and the values are true or false. The
+ indentoption can take a number. A /*jslint */
+ comment takes precedence over the option object. The directive respects function scope.
+
+
+
+
Description
+
option
+
Meaning
+
+
+
ADsafe
+
adsafe
+
true if ADsafe
+ rules should be enforced. See http://www.ADsafe.org/. adsafe is used with the option object, but not
+ with the /*jslint */ comment.
+
+
+
Tolerate bitwise operators
+
bitwise
+
true if bitwise operators should be allowed. (more)
+
+
+
Assume a browser
+
browser
+
true if the standard browser globals should be predefined.
+ (more)
+
+
+
Tolerate HTML case
+
cap
+
true if uppercase HTML should be allowed.
+
+
+
Tolerate type confusion
+
+
confusion
+
true if variables and properties are allowed to contain more than one type of value.
+
+
+
Tolerate continue
+
continue
+
true if the continue statement should be allowed.
+
+
+
Tolerate CSS workarounds
+
css
+
true if CSS workarounds should be tolerated. (more)
+
+
+
Tolerate debugger statements
+
debug
+
true if debugger statements should be
+ allowed. Set this option to false before going into production.
+
+
+
Assume console, alert, ...
+
devel
+
true if browser globals that are useful in development should be
+ predefined. (more)
+
+
+
Tolerate == and !=
+
eqeq
+
true if the == and != operators should be tolerated. (more)
+
+
+
Tolerate ES5 syntax
+
es5
+
true if ES5 syntax should be allowed.
+ It is likely that programs using this option will produce syntax errors on ES3 systems.
An array of strings, the names of predefined global variables, or an object whose keys are global variable names, and whose values are booleans that determine if each variable is assignable (also see global). predef is used with the option object, but not
+ with the /*jslint */ comment. You can also use the var
+ statement to declare global variables in a script file.
+
+
+
Tolerate . and [^...]. in /RegExp/
+
regexp
+
true if . and [^...] should be allowed in RegExp
+ literals. They match more material than might be expected, allowing attackers to confuse applications. These forms should not be used when validating in secure applications.
+
+
+
Assume Rhino
+
rhino
+
true if the Rhino
+ environment globals should be predefined. (more)
+
+
+
Safe Subset
+
safe
+
true if the safe subset rules are enforced. These rules
+ are used by ADsafe. It enforces
+ the safe subset rules but not the widget structure rules. safe is used with the option object, but not
+ with the /*jslint */ comment.
+
+
+
Tolerate missing 'use strict' pragma
+
sloppy
+
true if the ES5 'use strict'; pragma
+ is not required. Do not use this pragma unless you know what you are doing.
+
+
+
Tolerate inefficient subscripting
+
+
sub
+
true if subscript notation may be used for expressions
+ better expressed in dot notation.
+
+
+
Tolerate misordered definitions
+
undef
+
true if variables and functions need not be declared before used. (more)
+
+
+
Tolerate unused parameters
+
unparam
+
true if warnings should not be given for unused parameters.
+
+
+
Tolerate many var statements per function
+
vars
+
true if multiple var statement per function
+ should be allowed. (more)
+
+
+
Tolerate messy white space
+
white
+
true if strict whitespace rules should be ignored.
Please let me know if JSLint is useful for you. Is it too
+ strict? Is there a check or a report that could help you to improve the
+ quality of your programs?
+ douglas@crockford.com.
+ But please don't ask me to dumb JSLint down or to make it more
+ forgiving of bad practices. You would only be disappointed.
Try it. Paste your script
+ into the window and click the
+
+ button. The analysis is done by a script running on your machine.
+ Your script is not sent over the network. You can set the options used.
diff --git a/src/language/JSLintUtils.js b/src/language/JSLintUtils.js
deleted file mode 100644
index 1cf9b80c017..00000000000
--- a/src/language/JSLintUtils.js
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved.
- *
- * 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 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 vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
-/*global define, $, JSLINT, PathUtils, brackets */
-
-/**
- * Allows JSLint to run on the current document and report results in a UI panel.
- *
- */
-define(function (require, exports, module) {
- "use strict";
-
- // Load dependent non-module scripts
- require("thirdparty/path-utils/path-utils.min");
- require("thirdparty/jslint/jslint");
-
- // Load dependent modules
- var Global = require("utils/Global"),
- Commands = require("command/Commands"),
- CommandManager = require("command/CommandManager"),
- DocumentManager = require("document/DocumentManager"),
- EditorManager = require("editor/EditorManager"),
- PreferencesManager = require("preferences/PreferencesManager"),
- PerfUtils = require("utils/PerfUtils"),
- Strings = require("strings"),
- StringUtils = require("utils/StringUtils"),
- AppInit = require("utils/AppInit"),
- StatusBar = require("widgets/StatusBar");
-
- var defaultPrefs = { enabled: !!brackets.config.enable_jslint };
-
- /**
- * @private
- * @type {PreferenceStorage}
- */
- var _prefs = null;
-
- /**
- * @private
- * @type {boolean}
- */
- var _enabled = true;
-
- /**
- * @return {boolean} Enabled state of JSLint.
- */
- function getEnabled() {
- return _enabled;
- }
-
- /**
- * @private
- * @type {function()}
- * Holds a pointer to the function that selects the first error in the
- * list. Stored when running JSLint and used by the "Go to First JSLint
- * Error" command
- */
- var _gotoFirstErrorFunction = null;
-
- /**
- * @private
- * Enable or disable the "Go to First JSLint Error" command
- * @param {boolean} gotoEnabled Whether it is enabled.
- */
- function _setGotoEnabled(gotoEnabled) {
- CommandManager.get(Commands.NAVIGATE_GOTO_JSLINT_ERROR).setEnabled(gotoEnabled);
- if (!gotoEnabled) {
- _gotoFirstErrorFunction = null;
- }
- }
-
- /**
- * Run JSLint on the current document. Reports results to the main UI. Displays
- * a gold star when no errors are found.
- */
- function run() {
- var currentDoc = DocumentManager.getCurrentDocument();
-
- var perfTimerDOM,
- perfTimerLint;
-
- var ext = currentDoc ? PathUtils.filenameExtension(currentDoc.file.fullPath) : "";
- var $lintResults = $("#jslint-results");
- var $goldStar = $("#gold-star");
-
- if (getEnabled() && /^\.js$/i.test(ext)) {
- perfTimerLint = PerfUtils.markStart("JSLint linting:\t" + (!currentDoc || currentDoc.file.fullPath));
- var text = currentDoc.getText();
-
- // If a line contains only whitespace, remove the whitespace
- // This should be doable with a regexp: text.replace(/\r[\x20|\t]+\r/g, "\r\r");,
- // but that doesn't work.
- var i, arr = text.split("\n");
- for (i = 0; i < arr.length; i++) {
- if (!arr[i].match(/\S/)) {
- arr[i] = "";
- }
- }
- text = arr.join("\n");
-
- var result = JSLINT(text, null);
-
- PerfUtils.addMeasurement(perfTimerLint);
- perfTimerDOM = PerfUtils.markStart("JSLint DOM:\t" + (!currentDoc || currentDoc.file.fullPath));
-
- if (!result) {
- var $errorTable = $("
")
- .append("");
- var $selectedRow;
-
- JSLINT.errors.forEach(function (item, i) {
- if (item) {
- var makeCell = function (content) {
- return $("
").text(content);
- };
-
- // Add row to error table
- var $row = $("
")
- .append(makeCell(item.line))
- .append(makeCell(item.reason))
- .append(makeCell(item.evidence || ""))
- .appendTo($errorTable);
-
- var clickCallback = function () {
- if ($selectedRow) {
- $selectedRow.removeClass("selected");
- }
- $row.addClass("selected");
- $selectedRow = $row;
-
- var editor = EditorManager.getCurrentFullEditor();
- editor.setCursorPos(item.line - 1, item.character - 1, true);
- EditorManager.focusEditor();
- };
- $row.click(clickCallback);
- if (i === 0) { // first result, so store callback for goto command
- _gotoFirstErrorFunction = clickCallback;
- }
- }
- });
-
- $("#jslint-results .table-container")
- .empty()
- .append($errorTable)
- .scrollTop(0); // otherwise scroll pos from previous contents is remembered
-
- $lintResults.show();
- $goldStar.hide();
- if (JSLINT.errors.length === 1) {
- StatusBar.updateIndicator(module.id, true, "jslint-errors", Strings.JSLINT_ERROR_INFORMATION);
- } else {
- //return the number of non-null errors
- var numberOfErrors = JSLINT.errors.filter(function (err) { return err !== null; }).length;
- //if there was a null value it means there was a stop notice and an indertiminate
- //upper bound on the number of JSLint errors, which we'll represent by appending a '+'
- if (numberOfErrors !== JSLINT.errors.length) {
- //first discard the stop notice
- numberOfErrors -= 1;
- numberOfErrors += "+";
- }
- StatusBar.updateIndicator(module.id, true, "jslint-errors", StringUtils.format(Strings.JSLINT_ERRORS_INFORMATION, numberOfErrors));
- }
- _setGotoEnabled(true);
- } else {
- $lintResults.hide();
- $goldStar.show();
- StatusBar.updateIndicator(module.id, true, "jslint-valid", Strings.JSLINT_NO_ERRORS);
- _setGotoEnabled(false);
- }
-
- PerfUtils.addMeasurement(perfTimerDOM);
-
- } else {
- // JSLint is disabled or does not apply to the current file, hide
- // both the results and the gold star
- $lintResults.hide();
- $goldStar.hide();
- StatusBar.updateIndicator(module.id, true, "jslint-disabled", Strings.JSLINT_DISABLED);
- _setGotoEnabled(false);
- }
-
- EditorManager.resizeEditor();
- }
-
- /**
- * @private
- * Update DocumentManager listeners.
- */
- function _updateListeners() {
- if (_enabled) {
- // register our event listeners
- $(DocumentManager)
- .on("currentDocumentChange.jslint", function () {
- run();
- })
- .on("documentSaved.jslint documentRefreshed.jslint", function (event, document) {
- if (document === DocumentManager.getCurrentDocument()) {
- run();
- }
- });
- } else {
- $(DocumentManager).off(".jslint");
- }
- }
-
- function _setEnabled(enabled) {
- _enabled = enabled;
-
- CommandManager.get(Commands.TOGGLE_JSLINT).setChecked(_enabled);
- _updateListeners();
- _prefs.setValue("enabled", _enabled);
-
- // run immediately
- run();
- }
-
- /**
- * Enable or disable JSLint.
- * @param {boolean} enabled Enabled state.
- */
- function setEnabled(enabled) {
- if (_enabled !== enabled) {
- _setEnabled(enabled);
- }
- }
-
- /** Command to toggle enablement */
- function _handleToggleJSLint() {
- setEnabled(!getEnabled());
- }
-
- /** Command to go to the first JSLint Error */
- function _handleGotoJSLintError() {
- run();
- if (_gotoFirstErrorFunction) {
- _gotoFirstErrorFunction();
- }
- }
-
- // Register command handlers
- CommandManager.register(Strings.CMD_JSLINT, Commands.TOGGLE_JSLINT, _handleToggleJSLint);
- CommandManager.register(Strings.CMD_JSLINT_FIRST_ERROR, Commands.NAVIGATE_GOTO_JSLINT_ERROR, _handleGotoJSLintError);
-
- // Init PreferenceStorage
- _prefs = PreferencesManager.getPreferenceStorage(module, defaultPrefs);
- //TODO: Remove preferences migration code
- PreferencesManager.handleClientIdChange(_prefs, module.id);
-
- // Initialize items dependent on HTML DOM
- AppInit.htmlReady(function () {
- var $jslintResults = $("#jslint-results"),
- $jslintContent = $("#jslint-results .table-container");
-
- StatusBar.addIndicator(module.id, $("#gold-star"));
-
- // Called on HTML ready to trigger the initial UI state
- _setEnabled(_prefs.getValue("enabled"));
- });
-
- // Define public API
- exports.run = run;
- exports.getEnabled = getEnabled;
- exports.setEnabled = setEnabled;
-});
diff --git a/src/search/QuickOpen.js b/src/search/QuickOpen.js
index 358bded1342..c284ad22f9f 100644
--- a/src/search/QuickOpen.js
+++ b/src/search/QuickOpen.js
@@ -423,9 +423,6 @@ define(function (require, exports, module) {
plugin.done();
}
- // Ty TODO: disabled for now while file switching is disabled in _handleItemFocus
- //JSLintUtils.setEnabled(true);
-
// Make sure Smart Autocomplete knows its popup is getting closed (in cases where there's no
// editor to give focus to below, it won't notice otherwise).
this.$searchField.trigger("lostFocus");
@@ -732,11 +729,6 @@ define(function (require, exports, module) {
// Global listener to hide search bar & popup
$(window.document).on("mousedown", this._handleDocumentMouseDown);
-
- // Ty TODO: disabled for now while file switching is disabled in _handleItemFocus
- // To improve performance during list selection disable JSLint until a document is chosen or dialog is closed
- //JSLintUtils.setEnabled(false);
-
// Record current document & cursor pos so we can restore it if search is canceled
// We record scroll pos *before* modal bar is opened since we're going to restore it *after* it's closed
var curDoc = DocumentManager.getCurrentDocument();
diff --git a/src/styles/brackets.less b/src/styles/brackets.less
index 23e8d381039..857cba2c43f 100644
--- a/src/styles/brackets.less
+++ b/src/styles/brackets.less
@@ -301,21 +301,6 @@ a, img {
display:none;
}
-.jslint-disabled {
- font-size: 1em;
- color: @bc-grey;
-}
-
-.jslint-errors {
- font-size: 1em;
- color: @bc-red;
-}
-
-.jslint-valid {
- font-size: 1em;
- color: lighten(@bc-yellow, @bc-color-step-size*2);
-}
-
#toolbar-go-live {
padding-right: 8px;
diff --git a/src/thirdparty/jslint b/src/thirdparty/jslint
deleted file mode 160000
index 2347ec449b1..00000000000
--- a/src/thirdparty/jslint
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 2347ec449b14eb3a4935daeaaa3ef036d42dd96d
diff --git a/src/widgets/StatusBar.html b/src/widgets/StatusBar.html
index 2714a4cd6eb..6f82dcc9ebc 100644
--- a/src/widgets/StatusBar.html
+++ b/src/widgets/StatusBar.html
@@ -3,7 +3,6 @@
-
★
diff --git a/src/widgets/StatusBar.js b/src/widgets/StatusBar.js
index 3184a04e87b..d195611c24b 100644
--- a/src/widgets/StatusBar.js
+++ b/src/widgets/StatusBar.js
@@ -4,7 +4,7 @@
/**
* A status bar with support for file information and busy and status indicators. This is a semi-generic
* container; for the code that decides what content appears in the status bar, see client modules like
- * EditorStatusBar and JSLintUtils. (Although in practice StatusBar's HTML structure and initialization
+ * EditorStatusBar. (Although in practice StatusBar's HTML structure and initialization
* assume it's only used for this one purpose, and all the APIs are on a singleton).
*/
define(function (require, exports, module) {
diff --git a/test/perf/Performance-test.js b/test/perf/Performance-test.js
index db9e9a8629c..76371afb7d9 100644
--- a/test/perf/Performance-test.js
+++ b/test/perf/Performance-test.js
@@ -34,12 +34,11 @@ define(function (require, exports, module) {
Commands, // loaded from brackets.test
DocumentCommandHandlers, // loaded from brackets.test
PerfUtils, // loaded from brackets.test
- JSLintUtils, // loaded from brackets.test
DocumentManager, // loaded from brackets.test
SpecRunnerUtils = require("spec/SpecRunnerUtils"),
UnitTestReporter = require("test/UnitTestReporter");
- var jsLintPrevSetting;
+ var jsLintCommand, jsLintPrevSetting;
describe("Performance Tests", function () {
@@ -77,10 +76,14 @@ define(function (require, exports, module) {
DocumentCommandHandlers = testWindow.brackets.test.DocumentCommandHandlers;
DocumentManager = testWindow.brackets.test.DocumentManager;
PerfUtils = testWindow.brackets.test.PerfUtils;
- JSLintUtils = testWindow.brackets.test.JSLintUtils;
- jsLintPrevSetting = JSLintUtils.getEnabled();
- JSLintUtils.setEnabled(false);
+ jsLintCommand = CommandManager.get("jslint.toggleEnabled");
+ if (jsLintCommand) {
+ jsLintPrevSetting = jsLintCommand.getChecked();
+ if (jsLintPrevSetting) {
+ jsLintCommand.execute();
+ }
+ }
});
});