mirror of https://github.com/zulip/zulip.git
eslint: Fix new-cap errors.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
f84fd0839d
commit
2c5e9f65f8
|
@ -38,12 +38,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"import/unambiguous": "error",
|
"import/unambiguous": "error",
|
||||||
"new-cap": [
|
"new-cap": "error",
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"capIsNew": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"no-alert": "error",
|
"no-alert": "error",
|
||||||
"no-array-constructor": "error",
|
"no-array-constructor": "error",
|
||||||
"no-bitwise": "error",
|
"no-bitwise": "error",
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
const {strict: assert} = require("assert");
|
const {strict: assert} = require("assert");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
|
|
||||||
const JQuery = require("jquery");
|
const jQueryFactory = require("jquery");
|
||||||
const {JSDOM} = require("jsdom");
|
const {JSDOM} = require("jsdom");
|
||||||
|
|
||||||
const {set_global, zrequire} = require("../zjsunit/namespace");
|
const {set_global, zrequire} = require("../zjsunit/namespace");
|
||||||
|
@ -12,7 +12,7 @@ const {make_zjquery} = require("../zjsunit/zjquery");
|
||||||
|
|
||||||
const template = fs.readFileSync("templates/corporate/upgrade.html", "utf-8");
|
const template = fs.readFileSync("templates/corporate/upgrade.html", "utf-8");
|
||||||
const dom = new JSDOM(template, {pretendToBeVisual: true});
|
const dom = new JSDOM(template, {pretendToBeVisual: true});
|
||||||
const jquery = JQuery(dom.window);
|
const jquery = jQueryFactory(dom.window);
|
||||||
|
|
||||||
set_global("$", make_zjquery());
|
set_global("$", make_zjquery());
|
||||||
set_global("page_params", {});
|
set_global("page_params", {});
|
||||||
|
|
|
@ -37,7 +37,7 @@ const createPasteEvent = function () {
|
||||||
const clipboardData = new DataTransfer();
|
const clipboardData = new DataTransfer();
|
||||||
const pasteEvent = new window.Event("paste");
|
const pasteEvent = new window.Event("paste");
|
||||||
pasteEvent.clipboardData = clipboardData;
|
pasteEvent.clipboardData = clipboardData;
|
||||||
return $.Event(pasteEvent);
|
return new $.Event(pasteEvent);
|
||||||
};
|
};
|
||||||
|
|
||||||
run_test("paste_handler", () => {
|
run_test("paste_handler", () => {
|
||||||
|
|
|
@ -173,7 +173,7 @@ run_test("hash_interactions", () => {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
helper.clear_events();
|
helper.clear_events();
|
||||||
$(window).trigger($.Event("hashchange", {}));
|
$(window).trigger("hashchange");
|
||||||
helper.assert_events([
|
helper.assert_events([
|
||||||
"overlays.close_for_hash_change",
|
"overlays.close_for_hash_change",
|
||||||
"message_viewport.stop_auto_scrolling",
|
"message_viewport.stop_auto_scrolling",
|
||||||
|
@ -185,7 +185,7 @@ run_test("hash_interactions", () => {
|
||||||
window.location.hash = "#narrow/stream/Denmark";
|
window.location.hash = "#narrow/stream/Denmark";
|
||||||
|
|
||||||
helper.clear_events();
|
helper.clear_events();
|
||||||
$(window).trigger($.Event("hashchange", {}));
|
$(window).trigger("hashchange");
|
||||||
helper.assert_events([
|
helper.assert_events([
|
||||||
"overlays.close_for_hash_change",
|
"overlays.close_for_hash_change",
|
||||||
"message_viewport.stop_auto_scrolling",
|
"message_viewport.stop_auto_scrolling",
|
||||||
|
@ -199,7 +199,7 @@ run_test("hash_interactions", () => {
|
||||||
window.location.hash = "#narrow";
|
window.location.hash = "#narrow";
|
||||||
|
|
||||||
helper.clear_events();
|
helper.clear_events();
|
||||||
$(window).trigger($.Event("hashchange", {}));
|
$(window).trigger("hashchange");
|
||||||
helper.assert_events([
|
helper.assert_events([
|
||||||
"overlays.close_for_hash_change",
|
"overlays.close_for_hash_change",
|
||||||
"message_viewport.stop_auto_scrolling",
|
"message_viewport.stop_auto_scrolling",
|
||||||
|
@ -213,43 +213,43 @@ run_test("hash_interactions", () => {
|
||||||
window.location.hash = "#streams/whatever";
|
window.location.hash = "#streams/whatever";
|
||||||
|
|
||||||
helper.clear_events();
|
helper.clear_events();
|
||||||
$(window).trigger($.Event("hashchange", {}));
|
$(window).trigger("hashchange");
|
||||||
helper.assert_events(["overlays.close_for_hash_change", "subs.launch"]);
|
helper.assert_events(["overlays.close_for_hash_change", "subs.launch"]);
|
||||||
|
|
||||||
window.location.hash = "#keyboard-shortcuts/whatever";
|
window.location.hash = "#keyboard-shortcuts/whatever";
|
||||||
|
|
||||||
helper.clear_events();
|
helper.clear_events();
|
||||||
$(window).trigger($.Event("hashchange", {}));
|
$(window).trigger("hashchange");
|
||||||
helper.assert_events(["overlays.close_for_hash_change", "info: keyboard-shortcuts"]);
|
helper.assert_events(["overlays.close_for_hash_change", "info: keyboard-shortcuts"]);
|
||||||
|
|
||||||
window.location.hash = "#message-formatting/whatever";
|
window.location.hash = "#message-formatting/whatever";
|
||||||
|
|
||||||
helper.clear_events();
|
helper.clear_events();
|
||||||
$(window).trigger($.Event("hashchange", {}));
|
$(window).trigger("hashchange");
|
||||||
helper.assert_events(["overlays.close_for_hash_change", "info: message-formatting"]);
|
helper.assert_events(["overlays.close_for_hash_change", "info: message-formatting"]);
|
||||||
|
|
||||||
window.location.hash = "#search-operators/whatever";
|
window.location.hash = "#search-operators/whatever";
|
||||||
|
|
||||||
helper.clear_events();
|
helper.clear_events();
|
||||||
$(window).trigger($.Event("hashchange", {}));
|
$(window).trigger("hashchange");
|
||||||
helper.assert_events(["overlays.close_for_hash_change", "info: search-operators"]);
|
helper.assert_events(["overlays.close_for_hash_change", "info: search-operators"]);
|
||||||
|
|
||||||
window.location.hash = "#drafts";
|
window.location.hash = "#drafts";
|
||||||
|
|
||||||
helper.clear_events();
|
helper.clear_events();
|
||||||
$(window).trigger($.Event("hashchange", {}));
|
$(window).trigger("hashchange");
|
||||||
helper.assert_events(["overlays.close_for_hash_change", "drafts.launch"]);
|
helper.assert_events(["overlays.close_for_hash_change", "drafts.launch"]);
|
||||||
|
|
||||||
window.location.hash = "#settings/alert-words";
|
window.location.hash = "#settings/alert-words";
|
||||||
|
|
||||||
helper.clear_events();
|
helper.clear_events();
|
||||||
$(window).trigger($.Event("hashchange", {}));
|
$(window).trigger("hashchange");
|
||||||
helper.assert_events(["overlays.close_for_hash_change", "settings.launch"]);
|
helper.assert_events(["overlays.close_for_hash_change", "settings.launch"]);
|
||||||
|
|
||||||
window.location.hash = "#organization/user-list-admin";
|
window.location.hash = "#organization/user-list-admin";
|
||||||
|
|
||||||
helper.clear_events();
|
helper.clear_events();
|
||||||
$(window).trigger($.Event("hashchange", {}));
|
$(window).trigger("hashchange");
|
||||||
helper.assert_events(["overlays.close_for_hash_change", "admin.launch"]);
|
helper.assert_events(["overlays.close_for_hash_change", "admin.launch"]);
|
||||||
|
|
||||||
let called_back;
|
let called_back;
|
||||||
|
|
|
@ -208,7 +208,7 @@ run_test("initialize", () => {
|
||||||
};
|
};
|
||||||
search_query_box.val("test string");
|
search_query_box.val("test string");
|
||||||
narrow_state.search_string = () => "ver";
|
narrow_state.search_string = () => "ver";
|
||||||
search_query_box.trigger($.Event("blur", stub_event));
|
search_query_box.trigger(new $.Event("blur", stub_event));
|
||||||
assert.equal(search_query_box.val(), "test string");
|
assert.equal(search_query_box.val(), "test string");
|
||||||
|
|
||||||
searchbox.css({"box-shadow": "inset 0px 0px 0px 2px hsl(204, 20%, 74%)"});
|
searchbox.css({"box-shadow": "inset 0px 0px 0px 2px hsl(204, 20%, 74%)"});
|
||||||
|
|
|
@ -435,7 +435,7 @@ class CommonUtils {
|
||||||
$(field_selector)
|
$(field_selector)
|
||||||
.trigger("focus")
|
.trigger("focus")
|
||||||
.val(str)
|
.val(str)
|
||||||
.trigger($.Event("keyup", {which: 0}));
|
.trigger(new $.Event("keyup", {which: 0}));
|
||||||
|
|
||||||
// Trigger the typeahead.
|
// Trigger the typeahead.
|
||||||
// Reaching into the guts of Bootstrap Typeahead like this is not
|
// Reaching into the guts of Bootstrap Typeahead like this is not
|
||||||
|
|
|
@ -255,8 +255,8 @@ async function test_search_venice(page) {
|
||||||
.expectOne()
|
.expectOne()
|
||||||
.trigger("focus")
|
.trigger("focus")
|
||||||
.val("vEnI") // Must be case insensitive.
|
.val("vEnI") // Must be case insensitive.
|
||||||
.trigger($.Event("input"))
|
.trigger("input")
|
||||||
.trigger($.Event("click"));
|
.trigger("click");
|
||||||
});
|
});
|
||||||
|
|
||||||
await page.waitForSelector(await get_stream_li(page, "Denmark"), {hidden: true});
|
await page.waitForSelector(await get_stream_li(page, "Denmark"), {hidden: true});
|
||||||
|
@ -267,7 +267,7 @@ async function test_search_venice(page) {
|
||||||
|
|
||||||
// Clearing list gives back all the streams in the list
|
// Clearing list gives back all the streams in the list
|
||||||
await page.evaluate(() =>
|
await page.evaluate(() =>
|
||||||
$(".stream-list-filter").expectOne().trigger("focus").val("").trigger($.Event("input")),
|
$(".stream-list-filter").expectOne().trigger("focus").val("").trigger("input"),
|
||||||
);
|
);
|
||||||
await page.waitForSelector(await get_stream_li(page, "Denmark"), {visible: true});
|
await page.waitForSelector(await get_stream_li(page, "Denmark"), {visible: true});
|
||||||
await page.waitForSelector(await get_stream_li(page, "Venice"), {visible: true});
|
await page.waitForSelector(await get_stream_li(page, "Venice"), {visible: true});
|
||||||
|
@ -292,7 +292,7 @@ async function test_stream_search_filters_stream_list(page) {
|
||||||
|
|
||||||
// Enter the search box and test highlighted suggestion
|
// Enter the search box and test highlighted suggestion
|
||||||
await page.evaluate(() =>
|
await page.evaluate(() =>
|
||||||
$(".stream-list-filter").expectOne().trigger("focus").trigger($.Event("click")),
|
$(".stream-list-filter").expectOne().trigger("focus").trigger("click"),
|
||||||
);
|
);
|
||||||
|
|
||||||
await page.waitForSelector("#stream_filters .highlighted_stream", {visible: true});
|
await page.waitForSelector("#stream_filters .highlighted_stream", {visible: true});
|
||||||
|
@ -327,7 +327,7 @@ async function test_stream_search_filters_stream_list(page) {
|
||||||
|
|
||||||
// Search for brginning of "Verona".
|
// Search for brginning of "Verona".
|
||||||
await page.evaluate(() =>
|
await page.evaluate(() =>
|
||||||
$(".stream-list-filter").expectOne().trigger("focus").val("ver").trigger($.Event("input")),
|
$(".stream-list-filter").expectOne().trigger("focus").val("ver").trigger("input"),
|
||||||
);
|
);
|
||||||
await page.waitForSelector(await get_stream_li(page, "Denmark"), {hidden: true});
|
await page.waitForSelector(await get_stream_li(page, "Denmark"), {hidden: true});
|
||||||
await page.click(await get_stream_li(page, "Verona"));
|
await page.click(await get_stream_li(page, "Verona"));
|
||||||
|
@ -365,9 +365,7 @@ async function test_users_search(page) {
|
||||||
await assert_in_list(page, "aaron");
|
await assert_in_list(page, "aaron");
|
||||||
|
|
||||||
// Enter the search box and test selected suggestion navigation
|
// Enter the search box and test selected suggestion navigation
|
||||||
await page.evaluate(() =>
|
await page.evaluate(() => $("#user_filter_icon").expectOne().trigger("focus").trigger("click"));
|
||||||
$("#user_filter_icon").expectOne().trigger("focus").trigger($.Event("click")),
|
|
||||||
);
|
|
||||||
await page.waitForSelector("#user_presences .highlighted_user", {visible: true});
|
await page.waitForSelector("#user_presences .highlighted_user", {visible: true});
|
||||||
await assert_selected(page, "Desdemona");
|
await assert_selected(page, "Desdemona");
|
||||||
await assert_not_selected(page, "Cordelia Lear");
|
await assert_not_selected(page, "Cordelia Lear");
|
||||||
|
|
|
@ -239,7 +239,7 @@ async function get_suggestions(page, str) {
|
||||||
$(".create_default_stream")
|
$(".create_default_stream")
|
||||||
.trigger("focus")
|
.trigger("focus")
|
||||||
.val(str)
|
.val(str)
|
||||||
.trigger($.Event("keyup", {which: 0}));
|
.trigger(new $.Event("keyup", {which: 0}));
|
||||||
}, str);
|
}, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ async function copy_messages(page, start_message, end_message) {
|
||||||
$("#copytempdiv").remove();
|
$("#copytempdiv").remove();
|
||||||
|
|
||||||
// emulate copy event
|
// emulate copy event
|
||||||
$("body").trigger($.Event("keydown", {which: 67, ctrlKey: true}));
|
$("body").trigger(new $.Event("keydown", {which: 67, ctrlKey: true}));
|
||||||
|
|
||||||
// find temp div with copied text
|
// find temp div with copied text
|
||||||
const temp_div = $("#copytempdiv");
|
const temp_div = $("#copytempdiv");
|
||||||
|
|
|
@ -97,7 +97,7 @@ try {
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace.restore();
|
namespace.restore();
|
||||||
Handlebars.HandlebarsEnvironment();
|
Handlebars.HandlebarsEnvironment.call(Handlebars);
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.stack) {
|
if (error.stack) {
|
||||||
|
|
|
@ -425,7 +425,7 @@ exports.do_post_send_tasks = function () {
|
||||||
exports.clear_preview_area();
|
exports.clear_preview_area();
|
||||||
// TODO: Do we want to fire the event even if the send failed due
|
// TODO: Do we want to fire the event even if the send failed due
|
||||||
// to a server-side error?
|
// to a server-side error?
|
||||||
$(document).trigger($.Event("compose_finished.zulip"));
|
$(document).trigger("compose_finished.zulip");
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.update_email = function (user_id, new_email) {
|
exports.update_email = function (user_id, new_email) {
|
||||||
|
|
|
@ -119,7 +119,7 @@ exports.complete_starting_tasks = function (msg_type, opts) {
|
||||||
ui_util.change_tab_to("#message_feed_container");
|
ui_util.change_tab_to("#message_feed_container");
|
||||||
compose_fade.start_compose(msg_type);
|
compose_fade.start_compose(msg_type);
|
||||||
ui_util.decorate_stream_bar(opts.stream, $("#stream-message .message_header_stream"), true);
|
ui_util.decorate_stream_bar(opts.stream, $("#stream-message .message_header_stream"), true);
|
||||||
$(document).trigger($.Event("compose_started.zulip", opts));
|
$(document).trigger(new $.Event("compose_started.zulip", opts));
|
||||||
exports.update_placeholder_text();
|
exports.update_placeholder_text();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -270,7 +270,7 @@ exports.cancel = function () {
|
||||||
compose.abort_video_callbacks(undefined);
|
compose.abort_video_callbacks(undefined);
|
||||||
compose_state.set_message_type(false);
|
compose_state.set_message_type(false);
|
||||||
compose_pm_pill.clear();
|
compose_pm_pill.clear();
|
||||||
$(document).trigger($.Event("compose_canceled.zulip"));
|
$(document).trigger("compose_canceled.zulip");
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.respond_to_message = function (opts) {
|
exports.respond_to_message = function (opts) {
|
||||||
|
|
|
@ -109,7 +109,7 @@ const DropdownListWidget = function (opts) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const custom_event = jQuery.Event("keydown.dropdown.data-api", {
|
const custom_event = new jQuery.Event("keydown.dropdown.data-api", {
|
||||||
keyCode: e.keyCode,
|
keyCode: e.keyCode,
|
||||||
which: e.keyCode,
|
which: e.keyCode,
|
||||||
});
|
});
|
||||||
|
|
|
@ -197,7 +197,7 @@ class MessageList {
|
||||||
this.view.maybe_rerender();
|
this.view.maybe_rerender();
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).trigger($.Event("message_selected.zulip", opts));
|
$(document).trigger(new $.Event("message_selected.zulip", opts));
|
||||||
}
|
}
|
||||||
|
|
||||||
reselect_selected_id() {
|
reselect_selected_id() {
|
||||||
|
|
|
@ -299,7 +299,7 @@ exports.check_for_unsuspend = function () {
|
||||||
watchdog_time = new_time;
|
watchdog_time = new_time;
|
||||||
// Our app's JS wasn't running, which probably means the machine was
|
// Our app's JS wasn't running, which probably means the machine was
|
||||||
// asleep.
|
// asleep.
|
||||||
$(document).trigger($.Event("unsuspend"));
|
$(document).trigger("unsuspend");
|
||||||
}
|
}
|
||||||
watchdog_time = new_time;
|
watchdog_time = new_time;
|
||||||
};
|
};
|
||||||
|
|
|
@ -172,7 +172,7 @@ exports.upload_files = function (uppy, config, files) {
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.setup_upload = function (config) {
|
exports.setup_upload = function (config) {
|
||||||
const uppy = Uppy({
|
const uppy = new Uppy({
|
||||||
debug: false,
|
debug: false,
|
||||||
autoProceed: true,
|
autoProceed: true,
|
||||||
restrictions: {
|
restrictions: {
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
that the documented examples are all correct, runnable code.
|
that the documented examples are all correct, runnable code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const ExamplesHandler = function () {
|
const examples_handler = function () {
|
||||||
const config = {
|
const config = {
|
||||||
username: process.env.ZULIP_USERNAME,
|
username: process.env.ZULIP_USERNAME,
|
||||||
apiKey: process.env.ZULIP_API_KEY,
|
apiKey: process.env.ZULIP_API_KEY,
|
||||||
|
@ -47,8 +47,8 @@ const ExamplesHandler = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
const main = async () => {
|
const main = async () => {
|
||||||
const Zulip = require("zulip-js");
|
const zulipInit = require("zulip-js");
|
||||||
const client = await Zulip(config);
|
const client = await zulipInit(config);
|
||||||
|
|
||||||
await generate_validation_data(client, examples.send_message);
|
await generate_validation_data(client, examples.send_message);
|
||||||
await generate_validation_data(client, examples.create_user);
|
await generate_validation_data(client, examples.create_user);
|
||||||
|
@ -90,7 +90,7 @@ const ExamplesHandler = function () {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const {main, add_example} = ExamplesHandler();
|
const {main, add_example} = examples_handler();
|
||||||
|
|
||||||
const send_test_message = async (client) => {
|
const send_test_message = async (client) => {
|
||||||
const params = {
|
const params = {
|
||||||
|
|
|
@ -46,7 +46,7 @@ client = zulip.Client(config_file="~/zuliprc-admin")
|
||||||
"""
|
"""
|
||||||
|
|
||||||
JS_CLIENT_CONFIG = """
|
JS_CLIENT_CONFIG = """
|
||||||
const Zulip = require('zulip-js');
|
const zulipInit = require('zulip-js');
|
||||||
|
|
||||||
// Pass the path to your zuliprc file here.
|
// Pass the path to your zuliprc file here.
|
||||||
const config = { zuliprc: 'zuliprc' };
|
const config = { zuliprc: 'zuliprc' };
|
||||||
|
@ -54,7 +54,7 @@ const config = { zuliprc: 'zuliprc' };
|
||||||
"""
|
"""
|
||||||
|
|
||||||
JS_CLIENT_ADMIN_CONFIG = """
|
JS_CLIENT_ADMIN_CONFIG = """
|
||||||
const Zulip = require('zulip-js');
|
const zulipInit = require('zulip-js');
|
||||||
|
|
||||||
// The user for this zuliprc file must be an organization administrator.
|
// The user for this zuliprc file must be an organization administrator.
|
||||||
const config = { zuliprc: 'zuliprc-admin' };
|
const config = { zuliprc: 'zuliprc-admin' };
|
||||||
|
@ -156,7 +156,7 @@ def render_javascript_code_example(function: str, admin_config: bool=False,
|
||||||
code_example.append('```js')
|
code_example.append('```js')
|
||||||
code_example.extend(config)
|
code_example.extend(config)
|
||||||
for snippet in snippets:
|
for snippet in snippets:
|
||||||
code_example.append("Zulip(config).then(async (client) => {")
|
code_example.append("zulipInit(config).then(async (client) => {")
|
||||||
for line in snippet:
|
for line in snippet:
|
||||||
result = re.search('const result.*=(.*);', line)
|
result = re.search('const result.*=(.*);', line)
|
||||||
if result:
|
if result:
|
||||||
|
|
Loading…
Reference in New Issue