diff --git a/.eslintrc.json b/.eslintrc.json index 7c5e923bc4..17f1a633f0 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -19,7 +19,16 @@ "empty-returns/main": "error", "eqeqeq": "error", "guard-for-in": "error", + "import/first": "error", + "import/newline-after-import": "error", "import/no-unresolved": ["error", {"ignore": ["!"]}], + "import/order": [ + "error", + { + "alphabetize": {"order": "asc"}, + "newlines-between": "always" + } + ], "new-cap": [ "error", { @@ -78,7 +87,6 @@ } ], "radix": "error", - "sort-imports": "error", "spaced-comment": "off", "strict": "off", "valid-typeof": ["error", {"requireStringLiterals": true}], diff --git a/frontend_tests/casper_tests/01-login.js b/frontend_tests/casper_tests/01-login.js index c2fdfd43fd..b10249c05c 100644 --- a/frontend_tests/casper_tests/01-login.js +++ b/frontend_tests/casper_tests/01-login.js @@ -1,4 +1,5 @@ var common = require("../casper_lib/common.js"); + var realm_url = "http://zulip.zulipdev.com:9981/"; // Start of test script. diff --git a/frontend_tests/casper_tests/06-settings.js b/frontend_tests/casper_tests/06-settings.js index 73d17138b3..aca1fc473f 100644 --- a/frontend_tests/casper_tests/06-settings.js +++ b/frontend_tests/casper_tests/06-settings.js @@ -1,5 +1,6 @@ -var common = require("../casper_lib/common.js"); var test_credentials = require("../../var/casper/test_credentials.js").test_credentials; +var common = require("../casper_lib/common.js"); + var OUTGOING_WEBHOOK_BOT_TYPE = "3"; var GENERIC_BOT_TYPE = "1"; diff --git a/frontend_tests/node_tests/billing.js b/frontend_tests/node_tests/billing.js index a2971bbb91..49a5d58405 100644 --- a/frontend_tests/node_tests/billing.js +++ b/frontend_tests/node_tests/billing.js @@ -1,7 +1,8 @@ const noop = () => {}; -const {JSDOM} = require("jsdom"); const fs = require("fs"); +const {JSDOM} = require("jsdom"); + const template = fs.readFileSync("templates/corporate/billing.html", "utf-8"); const dom = new JSDOM(template, {pretendToBeVisual: true}); const document = dom.window.document; diff --git a/frontend_tests/node_tests/billing_helpers.js b/frontend_tests/node_tests/billing_helpers.js index 71f71f6407..592dea39a3 100644 --- a/frontend_tests/node_tests/billing_helpers.js +++ b/frontend_tests/node_tests/billing_helpers.js @@ -1,8 +1,11 @@ -const {JSDOM} = require("jsdom"); const fs = require("fs"); + +const JQuery = require("jquery"); +const {JSDOM} = require("jsdom"); + const template = fs.readFileSync("templates/corporate/upgrade.html", "utf-8"); const dom = new JSDOM(template, {pretendToBeVisual: true}); -const jquery = require("jquery")(dom.window); +const jquery = JQuery(dom.window); set_global("$", global.make_zjquery()); set_global("page_params", {}); diff --git a/frontend_tests/node_tests/compose.js b/frontend_tests/node_tests/compose.js index c68266a1a1..9b1598896a 100644 --- a/frontend_tests/node_tests/compose.js +++ b/frontend_tests/node_tests/compose.js @@ -1,5 +1,5 @@ -const rewiremock = require("rewiremock/node"); const {JSDOM} = require("jsdom"); +const rewiremock = require("rewiremock/node"); set_global("bridge", false); diff --git a/frontend_tests/node_tests/copy_and_paste.js b/frontend_tests/node_tests/copy_and_paste.js index f40b8c04b1..cb9789c6fd 100644 --- a/frontend_tests/node_tests/copy_and_paste.js +++ b/frontend_tests/node_tests/copy_and_paste.js @@ -6,9 +6,11 @@ set_global("page_params", { set_global("compose_ui", {}); const {JSDOM} = require("jsdom"); + const {window} = new JSDOM("

Hello world

"); const {DOMParser, document} = window; set_global("$", require("jquery")(window)); + set_global("DOMParser", DOMParser); set_global("document", document); diff --git a/frontend_tests/node_tests/dispatch_subs.js b/frontend_tests/node_tests/dispatch_subs.js index e986781ef7..669b196cf7 100644 --- a/frontend_tests/node_tests/dispatch_subs.js +++ b/frontend_tests/node_tests/dispatch_subs.js @@ -1,4 +1,5 @@ const events = require("./lib/events.js"); + const event_fixtures = events.fixtures; const test_user = events.test_user; diff --git a/frontend_tests/node_tests/support.js b/frontend_tests/node_tests/support.js index 636f9299fb..298a2cd35a 100644 --- a/frontend_tests/node_tests/support.js +++ b/frontend_tests/node_tests/support.js @@ -1,5 +1,7 @@ const fs = require("fs"); + const {JSDOM} = require("jsdom"); + const template = fs.readFileSync("templates/analytics/realm_details.html", "utf-8"); const dom = new JSDOM(template, {pretendToBeVisual: true}); const document = dom.window.document; diff --git a/frontend_tests/node_tests/timerender.js b/frontend_tests/node_tests/timerender.js index 2c94452acf..b05b4ec6cf 100644 --- a/frontend_tests/node_tests/timerender.js +++ b/frontend_tests/node_tests/timerender.js @@ -3,6 +3,7 @@ set_global("page_params", { twenty_four_hour_time: true, }); set_global("moment", require("moment-timezone")); + set_global("XDate", zrequire("XDate", "xdate")); zrequire("timerender"); diff --git a/frontend_tests/node_tests/upgrade.js b/frontend_tests/node_tests/upgrade.js index 5d42336ed3..bd76dbcf4d 100644 --- a/frontend_tests/node_tests/upgrade.js +++ b/frontend_tests/node_tests/upgrade.js @@ -1,7 +1,8 @@ const noop = () => {}; -const {JSDOM} = require("jsdom"); const fs = require("fs"); +const {JSDOM} = require("jsdom"); + const template = fs.readFileSync("templates/corporate/upgrade.html", "utf-8"); const dom = new JSDOM(template, {pretendToBeVisual: true}); const document = dom.window.document; diff --git a/frontend_tests/puppeteer_lib/common.js b/frontend_tests/puppeteer_lib/common.js index 8de6827737..099fcc1410 100644 --- a/frontend_tests/puppeteer_lib/common.js +++ b/frontend_tests/puppeteer_lib/common.js @@ -1,6 +1,8 @@ -const path = require("path"); -const puppeteer = require("puppeteer"); const assert = require("assert").strict; +const path = require("path"); + +const puppeteer = require("puppeteer"); + const test_credentials = require("../../var/casper/test_credentials.js").test_credentials; class CommonUtils { diff --git a/frontend_tests/puppeteer_tests/00-realm-creation.js b/frontend_tests/puppeteer_tests/00-realm-creation.js index 18f1a65575..187d98ceb3 100644 --- a/frontend_tests/puppeteer_tests/00-realm-creation.js +++ b/frontend_tests/puppeteer_tests/00-realm-creation.js @@ -1,6 +1,7 @@ -const common = require("../puppeteer_lib/common"); const assert = require("assert").strict; +const common = require("../puppeteer_lib/common"); + const email = "alice@test.example.com"; const subdomain = "testsubdomain"; const organization_name = "Awesome Organization"; diff --git a/frontend_tests/puppeteer_tests/01-login.js b/frontend_tests/puppeteer_tests/01-login.js index 3476575617..c584018bfb 100644 --- a/frontend_tests/puppeteer_tests/01-login.js +++ b/frontend_tests/puppeteer_tests/01-login.js @@ -1,5 +1,5 @@ -const common = require("../puppeteer_lib/common"); const test_credentials = require("../../var/casper/test_credentials.js").test_credentials; +const common = require("../puppeteer_lib/common"); async function login_tests(page) { await common.log_in(page, test_credentials.default_user); diff --git a/frontend_tests/zjsunit/finder.js b/frontend_tests/zjsunit/finder.js index bfda0b605f..3aced6e9e5 100644 --- a/frontend_tests/zjsunit/finder.js +++ b/frontend_tests/zjsunit/finder.js @@ -1,7 +1,8 @@ -const _ = require("underscore/underscore.js"); const fs = require("fs"); const path = require("path"); +const _ = require("underscore/underscore.js"); + exports.find_files_to_run = function () { let oneFileFilter = []; let testsDifference = []; diff --git a/frontend_tests/zjsunit/handlebars.js b/frontend_tests/zjsunit/handlebars.js index 0be7748973..a1a5d8d490 100644 --- a/frontend_tests/zjsunit/handlebars.js +++ b/frontend_tests/zjsunit/handlebars.js @@ -1,6 +1,7 @@ const fs = require("fs"); -const Handlebars = require("handlebars/dist/cjs/handlebars.js"); const path = require("path"); + +const Handlebars = require("handlebars/dist/cjs/handlebars.js"); const {SourceMapConsumer, SourceNode} = require("source-map"); const templates_path = path.resolve(__dirname, "../../static/templates"); diff --git a/frontend_tests/zjsunit/index.js b/frontend_tests/zjsunit/index.js index a83d063aac..ce579c49c9 100644 --- a/frontend_tests/zjsunit/index.js +++ b/frontend_tests/zjsunit/index.js @@ -1,7 +1,17 @@ -const path = require("path"); const fs = require("fs"); +const Module = require("module"); +const path = require("path"); + const escapeRegExp = require("lodash/escapeRegExp"); +const finder = require("./finder.js"); +const handlebars = require("./handlebars.js"); +const stub_i18n = require("./i18n.js"); +const namespace = require("./namespace.js"); +const stub = require("./stub.js"); +const make_blueslip = require("./zblueslip.js").make_zblueslip; +const zjquery = require("./zjquery.js"); + require("@babel/register")({ extensions: [".es6", ".es", ".jsx", ".js", ".mjs", ".ts"], only: [ @@ -15,6 +25,7 @@ require("@babel/register")({ global.assert = require("assert").strict; global._ = require("underscore/underscore.js"); + const _ = global._; // Create a helper function to avoid sneaky delays in tests. @@ -23,14 +34,12 @@ function immediate(f) { } // Find the files we need to run. -const finder = require("./finder.js"); const files = finder.find_files_to_run(); // may write to console if (files.length === 0) { throw "No tests found"; } // Set up our namespace helpers. -const namespace = require("./namespace.js"); global.set_global = namespace.set_global; global.patch_builtin = namespace.set_global; global.zrequire = namespace.zrequire; @@ -43,28 +52,19 @@ global.window = new Proxy(global, { global.to_$ = () => window; // Set up stub helpers. -const stub = require("./stub.js"); global.make_stub = stub.make_stub; global.with_stub = stub.with_stub; // Set up fake jQuery -global.make_zjquery = require("./zjquery.js").make_zjquery; - -// Set up fake blueslip -const make_blueslip = require("./zblueslip.js").make_zblueslip; - -// Set up fake translation -const stub_i18n = require("./i18n.js"); +global.make_zjquery = zjquery.make_zjquery; // Set up Handlebars -const handlebars = require("./handlebars.js"); global.make_handlebars = handlebars.make_handlebars; global.stub_templates = handlebars.stub_templates; const noop = function () {}; // Set up fake module.hot -const Module = require("module"); Module.prototype.hot = { accept: noop, }; diff --git a/frontend_tests/zjsunit/stub.js b/frontend_tests/zjsunit/stub.js index 727a7ee5fa..81a7e19d00 100644 --- a/frontend_tests/zjsunit/stub.js +++ b/frontend_tests/zjsunit/stub.js @@ -1,3 +1,5 @@ +const assert = require("assert").strict; + // Stubs don't do any magical modifications to your namespace. They // just provide you a function that records what arguments get passed // to it. To use stubs as something more like "spies," use something diff --git a/static/js/admin.js b/static/js/admin.js index 1266ce4a11..e5772411e2 100644 --- a/static/js/admin.js +++ b/static/js/admin.js @@ -1,8 +1,9 @@ -const settings_config = require("./settings_config"); -const settings_data = require("./settings_data"); const render_admin_tab = require("../templates/admin_tab.hbs"); const render_settings_organization_settings_tip = require("../templates/settings/organization_settings_tip.hbs"); +const settings_config = require("./settings_config"); +const settings_data = require("./settings_data"); + const admin_settings_label = { // Organization settings realm_allow_community_topic_editing: i18n.t("Users can edit the topic of any message"), diff --git a/static/js/blueslip_stacktrace.ts b/static/js/blueslip_stacktrace.ts index 7b4aa7f970..e97d353af8 100644 --- a/static/js/blueslip_stacktrace.ts +++ b/static/js/blueslip_stacktrace.ts @@ -1,7 +1,8 @@ -import $ from "jquery"; import ErrorStackParser from "error-stack-parser"; +import $ from "jquery"; import StackFrame from "stackframe"; import StackTraceGPS from "stacktrace-gps"; + import render_blueslip_stacktrace from "../templates/blueslip_stacktrace.hbs"; type FunctionName = { diff --git a/static/js/click_handlers.js b/static/js/click_handlers.js index 84bcadc2aa..c9db3b2d60 100644 --- a/static/js/click_handlers.js +++ b/static/js/click_handlers.js @@ -1,10 +1,11 @@ -const util = require("./util"); -const settings_panel_menu = require("./settings_panel_menu"); // You won't find every click handler here, but it's a good place to start! const render_buddy_list_tooltip = require("../templates/buddy_list_tooltip.hbs"); const render_buddy_list_tooltip_content = require("../templates/buddy_list_tooltip_content.hbs"); +const settings_panel_menu = require("./settings_panel_menu"); +const util = require("./util"); + function convert_enter_to_click(e) { const key = e.which; if (key === 13) { diff --git a/static/js/compose.js b/static/js/compose.js index c8fa06c691..e94552df54 100644 --- a/static/js/compose.js +++ b/static/js/compose.js @@ -1,11 +1,12 @@ -const rendered_markdown = require("./rendered_markdown"); -const util = require("./util"); const render_compose_all_everyone = require("../templates/compose_all_everyone.hbs"); const render_compose_announce = require("../templates/compose_announce.hbs"); const render_compose_invite_users = require("../templates/compose_invite_users.hbs"); const render_compose_not_subscribed = require("../templates/compose_not_subscribed.hbs"); const render_compose_private_stream_alert = require("../templates/compose_private_stream_alert.hbs"); +const rendered_markdown = require("./rendered_markdown"); +const util = require("./util"); + // Docs: https://zulip.readthedocs.io/en/latest/subsystems/sending-messages.html /* Track the state of the @all warning. The user must acknowledge that they are spamming the entire diff --git a/static/js/compose_fade.js b/static/js/compose_fade.js index 65e65c707c..8e9e1a916d 100644 --- a/static/js/compose_fade.js +++ b/static/js/compose_fade.js @@ -1,4 +1,5 @@ const util = require("./util"); + let focused_recipient; let normal_display = false; diff --git a/static/js/compose_pm_pill.js b/static/js/compose_pm_pill.js index 2a0b78a51f..b9d7a2a598 100644 --- a/static/js/compose_pm_pill.js +++ b/static/js/compose_pm_pill.js @@ -1,4 +1,5 @@ const util = require("./util"); + exports.initialize_pill = function () { const container = $("#private_message_recipient").parent(); diff --git a/static/js/composebox_typeahead.js b/static/js/composebox_typeahead.js index 312e89d11f..911e6922ad 100644 --- a/static/js/composebox_typeahead.js +++ b/static/js/composebox_typeahead.js @@ -1,8 +1,10 @@ +const autosize = require("autosize"); +const confirmDatePlugin = require("flatpickr/dist/plugins/confirmDate/confirmDate.js"); + const pygments_data = require("../generated/pygments_data.json"); const typeahead = require("../shared/js/typeahead"); -const autosize = require("autosize"); + const settings_data = require("./settings_data"); -const confirmDatePlugin = require("flatpickr/dist/plugins/confirmDate/confirmDate.js"); //************************************ // AN IMPORTANT NOTE ABOUT TYPEAHEADS diff --git a/static/js/drafts.js b/static/js/drafts.js index 8ecbaa9400..61c5ceeb52 100644 --- a/static/js/drafts.js +++ b/static/js/drafts.js @@ -1,6 +1,7 @@ -const util = require("./util"); const render_draft_table_body = require("../templates/draft_table_body.hbs"); +const util = require("./util"); + function set_count(count) { const draft_count = count.toString(); const text = i18n.t("Drafts (__draft_count__)", {draft_count}); diff --git a/static/js/emoji.js b/static/js/emoji.js index 14f8e32482..7bf2cbcbfe 100644 --- a/static/js/emoji.js +++ b/static/js/emoji.js @@ -1,6 +1,7 @@ -const util = require("./util"); const emoji_codes = require("../generated/emoji/emoji_codes.json"); +const util = require("./util"); + // `emojis_by_name` is the central data source that is supposed to be // used by every widget in the webapp for gathering data for displaying // emojis. Emoji picker uses this data to derive data for its own use. diff --git a/static/js/emoji_picker.js b/static/js/emoji_picker.js index 4a6a942213..0b3f30129c 100644 --- a/static/js/emoji_picker.js +++ b/static/js/emoji_picker.js @@ -1,6 +1,5 @@ const emoji_codes = require("../generated/emoji/emoji_codes.json"); const typeahead = require("../shared/js/typeahead"); - const render_emoji_popover = require("../templates/emoji_popover.hbs"); const render_emoji_popover_content = require("../templates/emoji_popover_content.hbs"); const render_emoji_popover_search_results = require("../templates/emoji_popover_search_results.hbs"); diff --git a/static/js/emojisets.js b/static/js/emojisets.js index e2f976fd6a..e13c90c960 100644 --- a/static/js/emojisets.js +++ b/static/js/emojisets.js @@ -1,10 +1,11 @@ -import google_blob_css from "!style-loader?injectType=lazyStyleTag!css-loader!../generated/emoji-styles/google-blob-sprite.css"; import google_blob_sheet from "emoji-datasource-google-blob/img/google/sheets-256/64.png"; -import google_css from "!style-loader?injectType=lazyStyleTag!css-loader!../generated/emoji-styles/google-sprite.css"; import google_sheet from "emoji-datasource-google/img/google/sheets-256/64.png"; -import twitter_css from "!style-loader?injectType=lazyStyleTag!css-loader!../generated/emoji-styles/twitter-sprite.css"; import twitter_sheet from "emoji-datasource-twitter/img/twitter/sheets-256/64.png"; +import google_blob_css from "!style-loader?injectType=lazyStyleTag!css-loader!../generated/emoji-styles/google-blob-sprite.css"; +import google_css from "!style-loader?injectType=lazyStyleTag!css-loader!../generated/emoji-styles/google-sprite.css"; +import twitter_css from "!style-loader?injectType=lazyStyleTag!css-loader!../generated/emoji-styles/twitter-sprite.css"; + const emojisets = new Map([ ["google", {css: google_css, sheet: google_sheet}], ["google-blob", {css: google_blob_css, sheet: google_blob_sheet}], diff --git a/static/js/filter.js b/static/js/filter.js index b7525a2aaa..f3e588fbe4 100644 --- a/static/js/filter.js +++ b/static/js/filter.js @@ -1,4 +1,5 @@ const util = require("./util"); + function zephyr_stream_name_match(message, operand) { // Zephyr users expect narrowing to "social" to also show messages to /^(un)*social(.d)*$/ // (unsocial, ununsocial, social.d, etc) diff --git a/static/js/invite.js b/static/js/invite.js index 9102b75696..1db31bdab9 100644 --- a/static/js/invite.js +++ b/static/js/invite.js @@ -1,9 +1,9 @@ +const autosize = require("autosize"); + const render_invitation_failed_error = require("../templates/invitation_failed_error.hbs"); const render_invite_subscription = require("../templates/invite_subscription.hbs"); const render_settings_dev_env_email_access = require("../templates/settings/dev_env_email_access.hbs"); -const autosize = require("autosize"); - function reset_error_messages() { $("#invite_status").hide().text("").removeClass(common.status_classes); $("#multiuse_invite_status").hide().text("").removeClass(common.status_classes); diff --git a/static/js/message_events.js b/static/js/message_events.js index df346ce1d5..0d2bfe4639 100644 --- a/static/js/message_events.js +++ b/static/js/message_events.js @@ -1,5 +1,5 @@ -const util = require("./util"); const huddle_data = require("./huddle_data"); +const util = require("./util"); function maybe_add_narrowed_messages(messages, msg_list) { const ids = []; diff --git a/static/js/message_list_data.js b/static/js/message_list_data.js index 7d12705cee..45439fa36b 100644 --- a/static/js/message_list_data.js +++ b/static/js/message_list_data.js @@ -1,4 +1,5 @@ const util = require("./util"); + function MessageListData(opts) { this.muting_enabled = opts.muting_enabled; if (this.muting_enabled) { diff --git a/static/js/message_list_view.js b/static/js/message_list_view.js index d0fa045f93..af83e9c586 100644 --- a/static/js/message_list_view.js +++ b/static/js/message_list_view.js @@ -1,10 +1,11 @@ -const util = require("./util"); -const rendered_markdown = require("./rendered_markdown"); const render_bookend = require("../templates/bookend.hbs"); const render_message_group = require("../templates/message_group.hbs"); const render_recipient_row = require("../templates/recipient_row.hbs"); const render_single_message = require("../templates/single_message.hbs"); +const rendered_markdown = require("./rendered_markdown"); +const util = require("./util"); + function MessageListView(list, table_name, collapse_messages) { this.list = list; this.collapse_messages = collapse_messages; diff --git a/static/js/message_store.js b/static/js/message_store.js index a83c07138e..c688783ada 100644 --- a/static/js/message_store.js +++ b/static/js/message_store.js @@ -1,4 +1,5 @@ const util = require("./util"); + const stored_messages = new Map(); /* diff --git a/static/js/message_viewport.js b/static/js/message_viewport.js index 87aaad93c9..1d052efc2e 100644 --- a/static/js/message_viewport.js +++ b/static/js/message_viewport.js @@ -1,4 +1,5 @@ const util = require("./util"); + let jwindow; const dimensions = {}; let in_stoppable_autoscroll = false; diff --git a/static/js/narrow.js b/static/js/narrow.js index 7a86e3debb..d414d33187 100644 --- a/static/js/narrow.js +++ b/static/js/narrow.js @@ -1,4 +1,5 @@ const util = require("./util"); + let unnarrow_times; const LARGER_THAN_MAX_MESSAGE_ID = 10000000000000000; diff --git a/static/js/notifications.js b/static/js/notifications.js index 2e822812e8..8b0568e258 100644 --- a/static/js/notifications.js +++ b/static/js/notifications.js @@ -1,5 +1,6 @@ const render_compose_notification = require("../templates/compose_notification.hbs"); const render_notification = require("../templates/notification.hbs"); + const settings_config = require("./settings_config"); const notice_memory = new Map(); diff --git a/static/js/panels.js b/static/js/panels.js index 56d540c71e..f04c83b138 100644 --- a/static/js/panels.js +++ b/static/js/panels.js @@ -1,4 +1,5 @@ const util = require("./util"); + const resize_app = function () { const panels_height = $("#panels").height(); $("body > .app").height("calc(100% - " + panels_height + "px)"); diff --git a/static/js/people.js b/static/js/people.js index 68796be2a8..f69bf72c0a 100644 --- a/static/js/people.js +++ b/static/js/people.js @@ -1,8 +1,9 @@ -const util = require("./util"); require("unorm"); // String.prototype.normalize polyfill for IE11 -const FoldDict = require("./fold_dict").FoldDict; const typeahead = require("../shared/js/typeahead"); + +const FoldDict = require("./fold_dict").FoldDict; const settings_data = require("./settings_data"); +const util = require("./util"); let people_dict; let people_by_name_dict; diff --git a/static/js/popovers.js b/static/js/popovers.js index f8cdae33e3..e44757cb06 100644 --- a/static/js/popovers.js +++ b/static/js/popovers.js @@ -1,6 +1,5 @@ -const util = require("./util"); -const settings_data = require("./settings_data"); const confirmDatePlugin = require("flatpickr/dist/plugins/confirmDate/confirmDate.js"); + const render_actions_popover_content = require("../templates/actions_popover_content.hbs"); const render_mobile_message_buttons_popover = require("../templates/mobile_message_buttons_popover.hbs"); const render_mobile_message_buttons_popover_content = require("../templates/mobile_message_buttons_popover_content.hbs"); @@ -12,6 +11,9 @@ const render_user_info_popover_content = require("../templates/user_info_popover const render_user_info_popover_title = require("../templates/user_info_popover_title.hbs"); const render_user_profile_modal = require("../templates/user_profile_modal.hbs"); +const settings_data = require("./settings_data"); +const util = require("./util"); + let current_actions_popover_elem; let current_flatpickr_instance; let current_message_info_popover_elem; diff --git a/static/js/portico/desktop-redirect.js b/static/js/portico/desktop-redirect.js index 247076db21..1a60d9d60d 100644 --- a/static/js/portico/desktop-redirect.js +++ b/static/js/portico/desktop-redirect.js @@ -1,3 +1,4 @@ const ClipboardJS = require("clipboard"); + new ClipboardJS("#copy"); document.querySelector("#copy").focus(); diff --git a/static/js/portico/help.js b/static/js/portico/help.js index c7a05d243a..bbbaa76165 100644 --- a/static/js/portico/help.js +++ b/static/js/portico/help.js @@ -1,5 +1,6 @@ -import * as google_analytics from "./google-analytics.js"; import SimpleBar from "simplebar"; + +import * as google_analytics from "./google-analytics.js"; import {activate_correct_tab} from "./tabbed-instructions.js"; function registerCodeSection($codeSection) { diff --git a/static/js/portico/integrations.js b/static/js/portico/integrations.js index 7c38d56e73..4e80cb89b1 100644 --- a/static/js/portico/integrations.js +++ b/static/js/portico/integrations.js @@ -1,6 +1,5 @@ -import * as google_analytics from "./google-analytics.js"; import blueslip from "./../blueslip"; - +import * as google_analytics from "./google-analytics.js"; import {path_parts} from "./landing-page"; // these constants are populated immediately with data from the DOM on page load diff --git a/static/js/recent_topics.js b/static/js/recent_topics.js index f9e65c1cb1..9bda62c7d5 100644 --- a/static/js/recent_topics.js +++ b/static/js/recent_topics.js @@ -1,6 +1,7 @@ -const render_recent_topics_body = require("../templates/recent_topics_table.hbs"); const render_recent_topic_row = require("../templates/recent_topic_row.hbs"); const render_recent_topics_filters = require("../templates/recent_topics_filters.hbs"); +const render_recent_topics_body = require("../templates/recent_topics_table.hbs"); + const topics = new Map(); // Key is stream-id:topic. let topics_widget; // Sets the number of avatars to display. diff --git a/static/js/reminder.js b/static/js/reminder.js index 9d157efc91..98f47b637d 100644 --- a/static/js/reminder.js +++ b/static/js/reminder.js @@ -1,4 +1,5 @@ const util = require("./util"); + const deferred_message_types = { scheduled: { delivery_type: "send_later", diff --git a/static/js/resize.js b/static/js/resize.js index 0b6f69fcff..c3418b3d12 100644 --- a/static/js/resize.js +++ b/static/js/resize.js @@ -1,6 +1,7 @@ -const util = require("./util"); const autosize = require("autosize"); +const util = require("./util"); + let narrow_window = false; function confine_to_range(lo, val, hi) { diff --git a/static/js/search_suggestion.js b/static/js/search_suggestion.js index a8d2f36c38..fcaa9506e1 100644 --- a/static/js/search_suggestion.js +++ b/static/js/search_suggestion.js @@ -1,5 +1,5 @@ -const settings_data = require("./settings_data"); const huddle_data = require("./huddle_data"); +const settings_data = require("./settings_data"); exports.max_num_of_search_results = 12; diff --git a/static/js/settings.js b/static/js/settings.js index 384048a51c..78e5ba0b52 100644 --- a/static/js/settings.js +++ b/static/js/settings.js @@ -1,6 +1,7 @@ -const settings_config = require("./settings_config"); const render_settings_tab = require("../templates/settings_tab.hbs"); +const settings_config = require("./settings_config"); + $("body").ready(() => { $("#settings_overlay_container").on("click", (e) => { if (!overlays.is_modal_open()) { diff --git a/static/js/settings_account.js b/static/js/settings_account.js index 464d7637b3..82a08e6e67 100644 --- a/static/js/settings_account.js +++ b/static/js/settings_account.js @@ -1,6 +1,6 @@ +const render_settings_api_key_modal = require("../templates/settings/api_key_modal.hbs"); const render_settings_custom_user_profile_field = require("../templates/settings/custom_user_profile_field.hbs"); const render_settings_dev_env_email_access = require("../templates/settings/dev_env_email_access.hbs"); -const render_settings_api_key_modal = require("../templates/settings/api_key_modal.hbs"); exports.update_email = function (new_email) { const email_input = $("#email_value"); diff --git a/static/js/settings_invites.js b/static/js/settings_invites.js index de9776b0c7..c67bb75bc1 100644 --- a/static/js/settings_invites.js +++ b/static/js/settings_invites.js @@ -1,8 +1,9 @@ -const util = require("./util"); -const settings_config = require("./settings_config"); const render_admin_invites_list = require("../templates/admin_invites_list.hbs"); const render_settings_revoke_invite_modal = require("../templates/settings/revoke_invite_modal.hbs"); +const settings_config = require("./settings_config"); +const util = require("./util"); + const meta = { loaded: false, }; diff --git a/static/js/settings_notifications.js b/static/js/settings_notifications.js index dda9744683..a5e2923d72 100644 --- a/static/js/settings_notifications.js +++ b/static/js/settings_notifications.js @@ -1,4 +1,5 @@ const render_stream_specific_notification_row = require("../templates/settings/stream_specific_notification_row.hbs"); + const settings_config = require("./settings_config"); exports.get_notifications_table_row_data = function (notify_settings) { diff --git a/static/js/settings_org.js b/static/js/settings_org.js index a4100d3996..1ae124cb69 100644 --- a/static/js/settings_org.js +++ b/static/js/settings_org.js @@ -1,7 +1,8 @@ -const settings_config = require("./settings_config"); +const pygments_data = require("../generated/pygments_data.json"); const render_settings_admin_auth_methods_list = require("../templates/settings/admin_auth_methods_list.hbs"); const render_settings_admin_realm_domains_list = require("../templates/settings/admin_realm_domains_list.hbs"); -const pygments_data = require("../generated/pygments_data.json"); + +const settings_config = require("./settings_config"); const meta = { loaded: false, diff --git a/static/js/settings_users.js b/static/js/settings_users.js index 70fdc27e60..e6c70df210 100644 --- a/static/js/settings_users.js +++ b/static/js/settings_users.js @@ -1,8 +1,9 @@ -const settings_data = require("./settings_data"); -const settings_config = require("./settings_config"); -const render_admin_user_list = require("../templates/admin_user_list.hbs"); -const render_admin_human_form = require("../templates/admin_human_form.hbs"); const render_admin_bot_form = require("../templates/admin_bot_form.hbs"); +const render_admin_human_form = require("../templates/admin_human_form.hbs"); +const render_admin_user_list = require("../templates/admin_user_list.hbs"); + +const settings_config = require("./settings_config"); +const settings_data = require("./settings_data"); const section = { active: {}, diff --git a/static/js/stream_data.js b/static/js/stream_data.js index cfde0978d3..be1669fc5a 100644 --- a/static/js/stream_data.js +++ b/static/js/stream_data.js @@ -1,7 +1,7 @@ -const util = require("./util"); const FoldDict = require("./fold_dict").FoldDict; const LazySet = require("./lazy_set").LazySet; const settings_config = require("./settings_config"); +const util = require("./util"); const BinaryDict = function (pred) { /* diff --git a/static/js/stream_edit.js b/static/js/stream_edit.js index 918ae8f146..3e64be46fe 100644 --- a/static/js/stream_edit.js +++ b/static/js/stream_edit.js @@ -1,10 +1,11 @@ -const util = require("./util"); const render_settings_deactivation_stream_modal = require("../templates/settings/deactivation_stream_modal.hbs"); const render_stream_member_list_entry = require("../templates/stream_member_list_entry.hbs"); const render_subscription_settings = require("../templates/subscription_settings.hbs"); const render_subscription_stream_privacy_modal = require("../templates/subscription_stream_privacy_modal.hbs"); -const settings_data = require("./settings_data"); + const settings_config = require("./settings_config"); +const settings_data = require("./settings_data"); +const util = require("./util"); function setup_subscriptions_stream_hash(sub) { const hash = hash_util.stream_edit_uri(sub); diff --git a/static/js/stream_popover.js b/static/js/stream_popover.js index af598a0f41..4b7a2d72c4 100644 --- a/static/js/stream_popover.js +++ b/static/js/stream_popover.js @@ -1,10 +1,10 @@ const render_all_messages_sidebar_actions = require("../templates/all_messages_sidebar_actions.hbs"); const render_delete_topic_modal = require("../templates/delete_topic_modal.hbs"); +const render_move_topic_to_stream = require("../templates/move_topic_to_stream.hbs"); const render_starred_messages_sidebar_actions = require("../templates/starred_messages_sidebar_actions.hbs"); const render_stream_sidebar_actions = require("../templates/stream_sidebar_actions.hbs"); const render_topic_sidebar_actions = require("../templates/topic_sidebar_actions.hbs"); const render_unstar_messages_modal = require("../templates/unstar_messages_modal.hbs"); -const render_move_topic_to_stream = require("../templates/move_topic_to_stream.hbs"); // We handle stream popovers and topic popovers in this // module. Both are popped up from the left sidebar. diff --git a/static/js/stream_sort.js b/static/js/stream_sort.js index 81d042144e..4356284646 100644 --- a/static/js/stream_sort.js +++ b/static/js/stream_sort.js @@ -1,4 +1,5 @@ const util = require("./util"); + let previous_pinned; let previous_normal; let previous_dormant; diff --git a/static/js/subs.js b/static/js/subs.js index 8e49ce8a37..86325d6d5c 100644 --- a/static/js/subs.js +++ b/static/js/subs.js @@ -1,9 +1,10 @@ -const util = require("./util"); const render_subscription = require("../templates/subscription.hbs"); const render_subscription_settings = require("../templates/subscription_settings.hbs"); const render_subscription_table_body = require("../templates/subscription_table_body.hbs"); const render_subscriptions = require("../templates/subscriptions.hbs"); +const util = require("./util"); + exports.show_subs_pane = { nothing_selected() { $(".nothing-selected, #stream_settings_title").show(); diff --git a/static/js/tab_bar.js b/static/js/tab_bar.js index ce3467cb77..bdf74d815b 100644 --- a/static/js/tab_bar.js +++ b/static/js/tab_bar.js @@ -1,4 +1,5 @@ const render_tab_bar = require("../templates/tab_bar.hbs"); + const rendered_markdown = require("./rendered_markdown"); function get_sub_count(current_stream) { diff --git a/static/js/topic_list.js b/static/js/topic_list.js index f94aea79e1..ad9deff855 100644 --- a/static/js/topic_list.js +++ b/static/js/topic_list.js @@ -1,6 +1,7 @@ const render_more_topics = require("../templates/more_topics.hbs"); const render_more_topics_spinner = require("../templates/more_topics_spinner.hbs"); const render_topic_list_item = require("../templates/topic_list_item.hbs"); + const topic_list_data = require("./topic_list_data"); /* diff --git a/static/js/typeahead_helper.js b/static/js/typeahead_helper.js index d039ffff3c..410a35762c 100644 --- a/static/js/typeahead_helper.js +++ b/static/js/typeahead_helper.js @@ -1,8 +1,9 @@ -const util = require("./util"); const pygments_data = require("../generated/pygments_data.json"); const typeahead = require("../shared/js/typeahead"); const render_typeahead_list_item = require("../templates/typeahead_list_item.hbs"); + const settings_data = require("./settings_data"); +const util = require("./util"); // Returns an array of private message recipients, removing empty elements. // For example, "a,,b, " => ["a", "b"] diff --git a/static/js/unread.js b/static/js/unread.js index 8c7cb2e5cd..7f3492c65e 100644 --- a/static/js/unread.js +++ b/static/js/unread.js @@ -1,5 +1,5 @@ -const util = require("./util"); const FoldDict = require("./fold_dict").FoldDict; +const util = require("./util"); // The unread module tracks the message IDs and locations of the // user's unread messages. The tracking is initialized with diff --git a/static/js/upload.js b/static/js/upload.js index c25485c891..e97f98c6e8 100644 --- a/static/js/upload.js +++ b/static/js/upload.js @@ -1,6 +1,6 @@ const Uppy = require("@uppy/core"); -const XHRUpload = require("@uppy/xhr-upload"); const ProgressBar = require("@uppy/progress-bar"); +const XHRUpload = require("@uppy/xhr-upload"); exports.make_upload_absolute = function (uri) { if (uri.startsWith(compose.uploads_path)) { diff --git a/static/js/user_events.js b/static/js/user_events.js index aeaf4d849e..ff5b7e8620 100644 --- a/static/js/user_events.js +++ b/static/js/user_events.js @@ -3,6 +3,7 @@ // dependencies that existed when this code was in people.js. // (We should do bot updates here too.) const settings_config = require("./settings_config"); + exports.update_person = function update(person) { const person_obj = people.get_by_user_id(person.user_id); diff --git a/tools/check-openapi b/tools/check-openapi index 25abfd294d..4aa4e88654 100755 --- a/tools/check-openapi +++ b/tools/check-openapi @@ -1,9 +1,10 @@ #!/usr/bin/env node const fs = require("fs"); + const jsyaml = require("js-yaml"); -const SwaggerParser = require("swagger-parser"); const ExampleValidator = require("openapi-examples-validator"); +const SwaggerParser = require("swagger-parser"); (async () => { // Iterate through the changed files, passed in the arguments. diff --git a/tools/debug-require-webpack-plugin.ts b/tools/debug-require-webpack-plugin.ts index 1cb1aadfda..be37ba60b8 100644 --- a/tools/debug-require-webpack-plugin.ts +++ b/tools/debug-require-webpack-plugin.ts @@ -2,9 +2,10 @@ // debugging. It also exposes the list of modules it knows about as the keys // of the require.ids object. -import webpack, {Template} from "webpack"; import path from "path"; +import webpack, {Template} from "webpack"; + export default class DebugRequirePlugin { apply(compiler: webpack.Compiler): void { const resolved = new Map(); diff --git a/tools/message-screenshot.js b/tools/message-screenshot.js index e5211a144a..2f098bc7f0 100644 --- a/tools/message-screenshot.js +++ b/tools/message-screenshot.js @@ -1,7 +1,9 @@ -const puppeteer = require("puppeteer"); -const commander = require("commander"); const path = require("path"); + +const commander = require("commander"); const mkdirp = require("mkdirp"); +const puppeteer = require("puppeteer"); + const host = "localhost:9991"; const options = {}; diff --git a/tools/webpack-helpers.ts b/tools/webpack-helpers.ts index bcad5d10fb..74f13dcfb0 100644 --- a/tools/webpack-helpers.ts +++ b/tools/webpack-helpers.ts @@ -1,6 +1,7 @@ -import {RuleSetRule, RuleSetUseItem} from "webpack"; import {basename, resolve} from "path"; +import {RuleSetRule, RuleSetUseItem} from "webpack"; + export const cacheLoader: RuleSetUseItem = { loader: "cache-loader", options: { diff --git a/tools/webpack.config.ts b/tools/webpack.config.ts index 3d4dc3bc80..534866efd2 100644 --- a/tools/webpack.config.ts +++ b/tools/webpack.config.ts @@ -1,17 +1,19 @@ import {basename, resolve} from "path"; -import {cacheLoader, getExposeLoaders} from "./webpack-helpers"; -import BundleTracker from "webpack4-bundle-tracker"; + import CleanCss from "clean-css"; -import DebugRequirePlugin from "./debug-require-webpack-plugin"; import HtmlWebpackPlugin from "html-webpack-plugin"; import MiniCssExtractPlugin from "mini-css-extract-plugin"; import OptimizeCssAssetsPlugin from "optimize-css-assets-webpack-plugin"; import TerserPlugin from "terser-webpack-plugin"; // The devServer member of webpack.Configuration is managed by the // webpack-dev-server package. We are only importing the type here. -import _webpackDevServer from "webpack-dev-server"; -import assets from "./webpack.assets.json"; import webpack from "webpack"; +import _webpackDevServer from "webpack-dev-server"; +import BundleTracker from "webpack4-bundle-tracker"; + +import DebugRequirePlugin from "./debug-require-webpack-plugin"; +import {cacheLoader, getExposeLoaders} from "./webpack-helpers"; +import assets from "./webpack.assets.json"; export default (env?: string): webpack.Configuration[] => { const production: boolean = env === "production";