2012-10-04 19:48:24 +02:00
|
|
|
"use strict";
|
|
|
|
|
2012-10-04 07:45:44 +02:00
|
|
|
// Global variables, categorized by place of definition.
|
|
|
|
var globals =
|
|
|
|
// Third-party libraries
|
2013-02-15 21:35:29 +01:00
|
|
|
' $ jQuery Spinner Handlebars XDate'
|
2012-10-04 07:45:44 +02:00
|
|
|
|
|
|
|
// index.html
|
2012-10-10 23:26:01 +02:00
|
|
|
+ ' initial_pointer email stream_list people_list have_initial_messages'
|
2013-01-16 00:52:57 +01:00
|
|
|
+ ' fullname desktop_notifications_enabled domain poll_timeout lurk_stream'
|
2012-10-04 07:45:44 +02:00
|
|
|
|
2012-10-18 20:29:16 +02:00
|
|
|
// common.js
|
|
|
|
+ ' status_classes'
|
|
|
|
|
2012-10-04 07:45:44 +02:00
|
|
|
// compose.js
|
2012-10-18 20:29:16 +02:00
|
|
|
+ ' compose'
|
2012-10-04 07:45:44 +02:00
|
|
|
|
2012-10-18 20:46:06 +02:00
|
|
|
// rows.js
|
2012-10-18 20:55:41 +02:00
|
|
|
+ ' rows'
|
2012-10-04 07:45:44 +02:00
|
|
|
|
|
|
|
// hotkey.js
|
2012-10-18 19:58:10 +02:00
|
|
|
+ ' hotkeys'
|
2012-10-04 07:45:44 +02:00
|
|
|
|
|
|
|
// narrow.js
|
2012-10-18 20:12:04 +02:00
|
|
|
+ ' narrow'
|
2012-10-04 07:45:44 +02:00
|
|
|
|
2012-10-29 21:02:46 +01:00
|
|
|
// reload.js
|
|
|
|
+ ' reload'
|
|
|
|
|
2013-01-30 21:49:56 +01:00
|
|
|
// notifications_bar.js
|
|
|
|
+ ' notifications_bar'
|
|
|
|
|
2012-10-26 16:59:38 +02:00
|
|
|
// search.js
|
2012-11-14 20:52:53 +01:00
|
|
|
+ ' search'
|
2012-10-26 16:59:38 +02:00
|
|
|
|
2012-10-04 07:45:44 +02:00
|
|
|
// setup.js
|
2013-01-16 19:37:50 +01:00
|
|
|
+ ' templates csrf_token'
|
2012-10-04 07:45:44 +02:00
|
|
|
|
2012-10-18 21:42:08 +02:00
|
|
|
// subs.js
|
2012-10-18 21:37:07 +02:00
|
|
|
+ ' subs'
|
2012-10-04 07:45:44 +02:00
|
|
|
|
2012-11-01 18:01:33 +01:00
|
|
|
// composebox_typeahead.js
|
|
|
|
+ ' composebox_typeahead'
|
|
|
|
|
2012-11-18 19:04:00 +01:00
|
|
|
// typeahead_helper.js
|
|
|
|
+ ' typeahead_helper'
|
|
|
|
|
2012-11-23 23:53:38 +01:00
|
|
|
// notifications.js
|
|
|
|
+ ' notifications'
|
|
|
|
|
2012-12-07 20:52:39 +01:00
|
|
|
// hashchange.js
|
|
|
|
+ ' hashchange'
|
|
|
|
|
2012-12-05 22:48:15 +01:00
|
|
|
// invite.js
|
|
|
|
+ ' invite'
|
|
|
|
|
2012-10-04 07:45:44 +02:00
|
|
|
// ui.js
|
2012-11-16 16:45:39 +01:00
|
|
|
+ ' ui'
|
2012-10-04 07:45:44 +02:00
|
|
|
|
2012-11-30 18:33:32 +01:00
|
|
|
// util.js
|
|
|
|
+ ' util'
|
|
|
|
|
2013-02-07 19:57:45 +01:00
|
|
|
// activity.js
|
|
|
|
+ ' activity'
|
|
|
|
|
2012-10-04 07:45:44 +02:00
|
|
|
// zephyr.js
|
2012-10-29 18:06:53 +01:00
|
|
|
+ ' message_array message_dict get_updates_params'
|
2012-11-27 22:30:47 +01:00
|
|
|
+ ' clear_table add_to_table add_messages'
|
2013-01-14 22:18:30 +01:00
|
|
|
+ ' subject_dict people_dict same_stream_and_subject'
|
2012-10-10 20:20:31 +02:00
|
|
|
+ ' keep_pointer_in_view move_pointer_at_page_top_and_bottom'
|
|
|
|
+ ' respond_to_message'
|
2012-10-09 23:51:45 +02:00
|
|
|
+ ' select_message select_message_by_id'
|
2012-12-03 19:49:12 +01:00
|
|
|
+ ' scroll_to_selected disable_pointer_movement get_private_message_recipient'
|
2012-11-19 17:43:46 +01:00
|
|
|
+ ' load_old_messages'
|
2013-02-08 19:24:39 +01:00
|
|
|
+ ' selected_message selected_message_id persistent_message_id'
|
2012-10-05 22:29:59 +02:00
|
|
|
+ ' at_top_of_viewport at_bottom_of_viewport'
|
2012-10-16 04:07:52 +02:00
|
|
|
+ ' viewport'
|
2012-11-27 23:17:30 +01:00
|
|
|
+ ' load_more_messages reset_load_more_status have_scrolled_away_from_top'
|
2013-02-15 04:53:03 +01:00
|
|
|
+ ' total_unread_messages'
|
2012-10-04 07:45:44 +02:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
var jslint_options = {
|
|
|
|
browser: true, // Assume browser environment
|
|
|
|
vars: true, // Allow multiple 'var' per function
|
|
|
|
sloppy: true, // Don't require "use strict"
|
|
|
|
white: true, // Lenient whitespace rules
|
|
|
|
plusplus: true, // Allow increment/decrement operators
|
|
|
|
regexp: true, // Allow . and [^...] in regular expressions
|
|
|
|
todo: true, // Allow "TODO" comments.
|
2013-02-12 21:41:59 +01:00
|
|
|
newcap: true, // Don't assume that capitalized functions are
|
|
|
|
// constructors (and the converse)
|
2012-10-04 07:45:44 +02:00
|
|
|
|
|
|
|
predef: globals.split(/\s+/)
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// For each error.raw message, we can return 'true' to ignore
|
|
|
|
// the error.
|
|
|
|
var exceptions = {
|
|
|
|
"Expected '{a}' and instead saw '{b}'." : function (error) {
|
|
|
|
// We allow single-statement 'if' with no brace.
|
|
|
|
// This exception might be overly broad but oh well.
|
|
|
|
return (error.a === '{');
|
|
|
|
},
|
|
|
|
|
|
|
|
"Unexpected 'else' after 'return'." : function () {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var fs = require('fs');
|
2012-10-04 19:15:37 +02:00
|
|
|
var path = require('path');
|
|
|
|
var JSLINT = require(path.join(__dirname, 'jslint')).JSLINT;
|
2012-10-04 07:45:44 +02:00
|
|
|
|
2012-10-04 19:40:29 +02:00
|
|
|
var cwd = process.cwd();
|
2012-10-04 19:15:37 +02:00
|
|
|
var js_dir = fs.realpathSync(path.join(__dirname, '../../zephyr/static/js'));
|
2012-10-04 07:45:44 +02:00
|
|
|
|
|
|
|
var exit_code = 0;
|
|
|
|
|
|
|
|
fs.readdirSync(js_dir).forEach(function (filename) {
|
|
|
|
if (filename.slice('-3') !== '.js')
|
|
|
|
return;
|
|
|
|
|
2012-10-04 19:40:29 +02:00
|
|
|
var filepath = path.join(js_dir, filename);
|
|
|
|
var contents = fs.readFileSync(filepath, 'utf8');
|
2012-10-04 07:45:44 +02:00
|
|
|
var messages = [];
|
|
|
|
|
|
|
|
if (!JSLINT(contents, jslint_options)) {
|
|
|
|
JSLINT.errors.forEach(function (error) {
|
|
|
|
if (error === null) {
|
|
|
|
// JSLint stopping error
|
|
|
|
messages.push(' (JSLint giving up)');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var exn = exceptions[error.raw];
|
|
|
|
if (exn && exn(error)) {
|
|
|
|
// Ignore this error.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NB: this will break on a 10,000 line file
|
|
|
|
var line = (' ' + error.line).slice(-4);
|
|
|
|
|
|
|
|
messages.push(' ' + line + ' ' + error.reason);
|
|
|
|
});
|
|
|
|
|
|
|
|
if (messages.length > 0) {
|
|
|
|
exit_code = 1;
|
|
|
|
|
2012-10-04 19:40:29 +02:00
|
|
|
console.log(path.relative(cwd, filepath));
|
2012-10-04 07:45:44 +02:00
|
|
|
|
|
|
|
// Something very wacky happens if we do
|
|
|
|
// .forEach(console.log) directly.
|
|
|
|
messages.forEach(function (msg) {
|
|
|
|
console.log(msg);
|
|
|
|
});
|
|
|
|
|
|
|
|
console.log('');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
process.exit(exit_code);
|