js: Add "use strict" directive to CommonJS files.

ES and TypeScript modules are strict by default and don’t need this
directive.  ESLint will remind us to add it to new CommonJS files and
remove it from ES and TypeScript modules.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2020-07-31 18:43:15 -07:00 committed by Tim Abbott
parent 39c3a02736
commit 6ec808b8df
370 changed files with 746 additions and 2 deletions

View File

@ -7,7 +7,7 @@
"parser": "babel-eslint", "parser": "babel-eslint",
"parserOptions": { "parserOptions": {
"warnOnUnsupportedTypeScriptVersion": false, "warnOnUnsupportedTypeScriptVersion": false,
"sourceType": "module" "sourceType": "unambiguous"
}, },
"plugins": ["eslint-plugin-empty-returns"], "plugins": ["eslint-plugin-empty-returns"],
"rules": { "rules": {
@ -29,6 +29,7 @@
"newlines-between": "always" "newlines-between": "always"
} }
], ],
"import/unambiguous": "error",
"new-cap": [ "new-cap": [
"error", "error",
{ {
@ -88,7 +89,7 @@
], ],
"radix": "error", "radix": "error",
"spaced-comment": "off", "spaced-comment": "off",
"strict": "off", "strict": "error",
"valid-typeof": ["error", {"requireStringLiterals": true}], "valid-typeof": ["error", {"requireStringLiterals": true}],
"yoda": "error" "yoda": "error"
}, },
@ -331,6 +332,12 @@
"@typescript-eslint/unified-signatures": "error" "@typescript-eslint/unified-signatures": "error"
} }
}, },
{
"files": ["**/*.d.ts"],
"rules": {
"import/unambiguous": "off"
}
},
{ {
"files": ["frontend_tests/**"], "files": ["frontend_tests/**"],
"globals": { "globals": {

View File

@ -1,3 +1,5 @@
"use strict";
module.exports = { module.exports = {
presets: [ presets: [
[ [

View File

@ -1,3 +1,5 @@
"use strict";
var util = require("util"); var util = require("util");
var test_credentials = require("../../var/casper/test_credentials.js").test_credentials; var test_credentials = require("../../var/casper/test_credentials.js").test_credentials;

View File

@ -1,3 +1,5 @@
"use strict";
/* eslint-env browser */ /* eslint-env browser */
// PhantomJS doesnt support new DOMParser().parseFromString(…, "text/html"). // PhantomJS doesnt support new DOMParser().parseFromString(…, "text/html").

View File

@ -1,3 +1,5 @@
"use strict";
var common = require("../casper_lib/common.js"); var common = require("../casper_lib/common.js");
var email = "alice@test.example.com"; var email = "alice@test.example.com";

View File

@ -1,3 +1,5 @@
"use strict";
var common = require("../casper_lib/common.js"); var common = require("../casper_lib/common.js");
var realm_url = "http://zulip.zulipdev.com:9981/"; var realm_url = "http://zulip.zulipdev.com:9981/";

View File

@ -1,3 +1,5 @@
"use strict";
/* Script for testing the web client. /* Script for testing the web client.
This runs under CasperJS. It's an end-to-end black-box sort of test. It This runs under CasperJS. It's an end-to-end black-box sort of test. It

View File

@ -1,3 +1,5 @@
"use strict";
var common = require("../casper_lib/common.js"); var common = require("../casper_lib/common.js");
common.start_and_log_in(); common.start_and_log_in();

View File

@ -1,3 +1,5 @@
"use strict";
var common = require("../casper_lib/common.js"); var common = require("../casper_lib/common.js");
common.start_and_log_in(); common.start_and_log_in();

View File

@ -1,3 +1,5 @@
"use strict";
var common = require("../casper_lib/common.js"); var common = require("../casper_lib/common.js");
function stream_checkbox(stream_name) { function stream_checkbox(stream_name) {

View File

@ -1,3 +1,5 @@
"use strict";
var test_credentials = require("../../var/casper/test_credentials.js").test_credentials; var test_credentials = require("../../var/casper/test_credentials.js").test_credentials;
var common = require("../casper_lib/common.js"); var common = require("../casper_lib/common.js");

View File

@ -1,3 +1,5 @@
"use strict";
var common = require("../casper_lib/common.js"); var common = require("../casper_lib/common.js");
function star_count() { function star_count() {

View File

@ -1,3 +1,5 @@
"use strict";
var common = require("../casper_lib/common.js"); var common = require("../casper_lib/common.js");
casper.options.verbose = true; casper.options.verbose = true;

View File

@ -1,3 +1,5 @@
"use strict";
var common = require("../casper_lib/common.js"); var common = require("../casper_lib/common.js");
// Test basic tab navigation. // Test basic tab navigation.

View File

@ -1,3 +1,5 @@
"use strict";
var common = require("../casper_lib/common.js"); var common = require("../casper_lib/common.js");
common.start_and_log_in(); common.start_and_log_in();

View File

@ -1,3 +1,5 @@
"use strict";
var common = require("../casper_lib/common.js"); var common = require("../casper_lib/common.js");
common.start_and_log_in(); common.start_and_log_in();

View File

@ -1,3 +1,5 @@
"use strict";
var common = require("../casper_lib/common.js"); var common = require("../casper_lib/common.js");
common.start_and_log_in(); common.start_and_log_in();

View File

@ -1,3 +1,5 @@
"use strict";
var common = require("../casper_lib/common.js"); var common = require("../casper_lib/common.js");
function user_row(name) { function user_row(name) {

View File

@ -1,3 +1,5 @@
"use strict";
var common = require("../casper_lib/common.js"); var common = require("../casper_lib/common.js");
function waitWhileDraftsVisible(then) { function waitWhileDraftsVisible(then) {

View File

@ -1,3 +1,5 @@
"use strict";
var common = require("../casper_lib/common.js"); var common = require("../casper_lib/common.js");
common.start_and_log_in(); common.start_and_log_in();

View File

@ -1,3 +1,5 @@
"use strict";
var common = require("../casper_lib/common.js"); var common = require("../casper_lib/common.js");
common.start_and_log_in(); common.start_and_log_in();

View File

@ -1,3 +1,5 @@
"use strict";
var common = require("../casper_lib/common.js"); var common = require("../casper_lib/common.js");
common.start_and_log_in(); common.start_and_log_in();

View File

@ -1,3 +1,5 @@
"use strict";
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
const window_stub = $.create("window-stub"); const window_stub = $.create("window-stub");
set_global("to_$", () => window_stub); set_global("to_$", () => window_stub);

View File

@ -1,3 +1,5 @@
"use strict";
const params = { const params = {
alert_words: ["alertone", "alerttwo", "alertthree", "al*rt.*s", ".+", "emoji"], alert_words: ["alertone", "alerttwo", "alertthree", "al*rt.*s", ".+", "emoji"],
}; };

View File

@ -1,3 +1,5 @@
"use strict";
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
set_global("channel", {}); set_global("channel", {});

View File

@ -1,3 +1,5 @@
"use strict";
const noop = () => {}; const noop = () => {};
const fs = require("fs"); const fs = require("fs");

View File

@ -1,3 +1,5 @@
"use strict";
const fs = require("fs"); const fs = require("fs");
const JQuery = require("jquery"); const JQuery = require("jquery");

View File

@ -1,3 +1,5 @@
"use strict";
const blueslip_stacktrace = zrequire("blueslip_stacktrace"); const blueslip_stacktrace = zrequire("blueslip_stacktrace");
run_test("clean_path", () => { run_test("clean_path", () => {

View File

@ -1,3 +1,5 @@
"use strict";
const _settings_bots = { const _settings_bots = {
render_bots: () => {}, render_bots: () => {},
}; };

View File

@ -1,3 +1,5 @@
"use strict";
const _ = require("lodash"); const _ = require("lodash");
const _page_params = {}; const _page_params = {};

View File

@ -1,3 +1,5 @@
"use strict";
const _ = require("lodash"); const _ = require("lodash");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());

View File

@ -1,3 +1,5 @@
"use strict";
const _ = require("lodash"); const _ = require("lodash");
set_global("$", {}); set_global("$", {});

View File

@ -1,3 +1,5 @@
"use strict";
zrequire("color_data"); zrequire("color_data");
run_test("pick_color", () => { run_test("pick_color", () => {

View File

@ -1,3 +1,5 @@
"use strict";
zrequire("colorspace"); zrequire("colorspace");
run_test("sRGB_to_linear", () => { run_test("sRGB_to_linear", () => {

View File

@ -1,3 +1,5 @@
"use strict";
const noop = () => {}; const noop = () => {};
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());

View File

@ -1,3 +1,5 @@
"use strict";
const _ = require("lodash"); const _ = require("lodash");
zrequire("keydown_util"); zrequire("keydown_util");

View File

@ -1,3 +1,5 @@
"use strict";
const {JSDOM} = require("jsdom"); const {JSDOM} = require("jsdom");
const rewiremock = require("rewiremock/node"); const rewiremock = require("rewiremock/node");

View File

@ -1,3 +1,5 @@
"use strict";
const noop = function () {}; const noop = function () {};
const return_false = function () { const return_false = function () {
return false; return false;

View File

@ -1,3 +1,5 @@
"use strict";
zrequire("stream_data"); zrequire("stream_data");
zrequire("people"); zrequire("people");
zrequire("compose_fade"); zrequire("compose_fade");

View File

@ -1,3 +1,5 @@
"use strict";
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
const _people = { const _people = {

View File

@ -1,3 +1,5 @@
"use strict";
zrequire("compose_ui"); zrequire("compose_ui");
zrequire("people"); zrequire("people");
zrequire("user_status"); zrequire("user_status");

View File

@ -1,3 +1,5 @@
"use strict";
const emoji = zrequire("emoji", "shared/js/emoji"); const emoji = zrequire("emoji", "shared/js/emoji");
const typeahead = zrequire("typeahead", "shared/js/typeahead"); const typeahead = zrequire("typeahead", "shared/js/typeahead");
zrequire("compose_state"); zrequire("compose_state");

View File

@ -1,3 +1,5 @@
"use strict";
global.stub_out_jquery(); global.stub_out_jquery();
set_global("page_params", { set_global("page_params", {

View File

@ -1,3 +1,5 @@
"use strict";
const noop = function () {}; const noop = function () {};
const events = require("./lib/events.js"); const events = require("./lib/events.js");

View File

@ -1,3 +1,5 @@
"use strict";
const events = require("./lib/events.js"); const events = require("./lib/events.js");
const event_fixtures = events.fixtures; const event_fixtures = events.fixtures;

View File

@ -1,3 +1,5 @@
"use strict";
const XDate = require("xdate"); const XDate = require("xdate");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());

View File

@ -1,3 +1,5 @@
"use strict";
zrequire("dropdown_list_widget"); zrequire("dropdown_list_widget");
zrequire("scroll_util"); zrequire("scroll_util");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());

View File

@ -1,3 +1,5 @@
"use strict";
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
set_global("markdown", {}); set_global("markdown", {});
set_global("local_message", { set_global("local_message", {

View File

@ -1,3 +1,5 @@
"use strict";
const emoji_codes = zrequire("emoji_codes", "generated/emoji/emoji_codes.json"); const emoji_codes = zrequire("emoji_codes", "generated/emoji/emoji_codes.json");
const events = require("./lib/events.js"); const events = require("./lib/events.js");

View File

@ -1,3 +1,5 @@
"use strict";
const _ = require("lodash"); const _ = require("lodash");
const emoji = zrequire("emoji", "shared/js/emoji"); const emoji = zrequire("emoji", "shared/js/emoji");

View File

@ -1,3 +1,5 @@
"use strict";
const fenced_code = zrequire("fenced_code", "shared/js/fenced_code"); const fenced_code = zrequire("fenced_code", "shared/js/fenced_code");
run_test("get_unused_fence", () => { run_test("get_unused_fence", () => {

View File

@ -1,3 +1,5 @@
"use strict";
const FetchStatus = zrequire("fetch_status"); const FetchStatus = zrequire("fetch_status");
set_global("message_scroll", { set_global("message_scroll", {
hide_loading_older: () => {}, hide_loading_older: () => {},

View File

@ -1,3 +1,5 @@
"use strict";
zrequire("unread"); zrequire("unread");
zrequire("stream_data"); zrequire("stream_data");
zrequire("people"); zrequire("people");

View File

@ -1,3 +1,5 @@
"use strict";
const FoldDict = zrequire("fold_dict").FoldDict; const FoldDict = zrequire("fold_dict").FoldDict;
run_test("basic", () => { run_test("basic", () => {

View File

@ -1,3 +1,5 @@
"use strict";
// This is a general tour of how to write node tests that // This is a general tour of how to write node tests that
// may also give you some quick insight on how the Zulip // may also give you some quick insight on how the Zulip
// browser app is constructed. Let's start with testing // browser app is constructed. Let's start with testing

View File

@ -1,3 +1,5 @@
"use strict";
zrequire("hash_util"); zrequire("hash_util");
zrequire("stream_data"); zrequire("stream_data");
zrequire("people"); zrequire("people");

View File

@ -1,3 +1,5 @@
"use strict";
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
const window_stub = $.create("window-stub"); const window_stub = $.create("window-stub");
set_global("location", { set_global("location", {

View File

@ -1,3 +1,5 @@
"use strict";
// Important note on these tests: // Important note on these tests:
// //
// The way the Zulip hotkey tests work is as follows. First, we set // The way the Zulip hotkey tests work is as follows. First, we set

View File

@ -1,3 +1,5 @@
"use strict";
zrequire("templates"); zrequire("templates");
// We download our translations in `page_params` (which // We download our translations in `page_params` (which

View File

@ -1,3 +1,5 @@
"use strict";
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
zrequire("input_pill"); zrequire("input_pill");

View File

@ -1,3 +1,5 @@
"use strict";
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
zrequire("keydown_util"); zrequire("keydown_util");

View File

@ -1,3 +1,5 @@
"use strict";
const LazySet = zrequire("lazy_set").LazySet; const LazySet = zrequire("lazy_set").LazySet;
/* /*

View File

@ -1,3 +1,5 @@
"use strict";
// TODO: These events are not guaranteed to be perfectly // TODO: These events are not guaranteed to be perfectly
// representative of what the server sends. For // representative of what the server sends. For
// now we just want very basic test coverage. We // now we just want very basic test coverage. We

View File

@ -1,3 +1,5 @@
"use strict";
zrequire("rows"); zrequire("rows");
zrequire("lightbox"); zrequire("lightbox");

View File

@ -1,3 +1,5 @@
"use strict";
zrequire("list_cursor"); zrequire("list_cursor");
run_test("config errors", () => { run_test("config errors", () => {

View File

@ -1,3 +1,5 @@
"use strict";
zrequire("list_render"); zrequire("list_render");
// We need these stubs to get by instanceof checks. // We need these stubs to get by instanceof checks.

View File

@ -1,3 +1,5 @@
"use strict";
zrequire("hash_util"); zrequire("hash_util");
const emoji = zrequire("emoji", "shared/js/emoji"); const emoji = zrequire("emoji", "shared/js/emoji");

View File

@ -1,3 +1,5 @@
"use strict";
/* /*
This whole module is dedicated to adding This whole module is dedicated to adding
one line of coverage for markdown.js. one line of coverage for markdown.js.

View File

@ -1,3 +1,5 @@
"use strict";
set_global("document", null); set_global("document", null);
set_global("page_params", { set_global("page_params", {
realm_community_topic_editing_limit_seconds: 86400, realm_community_topic_editing_limit_seconds: 86400,

View File

@ -1,3 +1,5 @@
"use strict";
zrequire("message_events"); zrequire("message_events");
zrequire("message_store"); zrequire("message_store");
zrequire("muting"); zrequire("muting");

View File

@ -1,3 +1,5 @@
"use strict";
const _ = require("lodash"); const _ = require("lodash");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());

View File

@ -1,3 +1,5 @@
"use strict";
zrequire("unread"); zrequire("unread");
zrequire("unread_ops"); zrequire("unread_ops");
zrequire("message_flags"); zrequire("message_flags");

View File

@ -1,3 +1,5 @@
"use strict";
// These unit tests for static/js/message_list.js emphasize the model-ish // These unit tests for static/js/message_list.js emphasize the model-ish
// aspects of the MessageList class. We have to stub out a few functions // aspects of the MessageList class. We have to stub out a few functions
// related to views and events to get the tests working. // related to views and events to get the tests working.

View File

@ -1,3 +1,5 @@
"use strict";
zrequire("unread"); zrequire("unread");
zrequire("Filter", "js/filter"); zrequire("Filter", "js/filter");

View File

@ -1,3 +1,5 @@
"use strict";
const _ = require("lodash"); const _ = require("lodash");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());

View File

@ -1,3 +1,5 @@
"use strict";
const util = zrequire("util"); const util = zrequire("util");
zrequire("pm_conversations"); zrequire("pm_conversations");
zrequire("people"); zrequire("people");

View File

@ -1,3 +1,5 @@
"use strict";
zrequire("timerender"); zrequire("timerender");
zrequire("muting"); zrequire("muting");
zrequire("stream_data"); zrequire("stream_data");

View File

@ -1,3 +1,5 @@
"use strict";
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
zrequire("hash_util"); zrequire("hash_util");
zrequire("hashchange"); zrequire("hashchange");

View File

@ -1,3 +1,5 @@
"use strict";
const util = zrequire("util"); const util = zrequire("util");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());

View File

@ -1,3 +1,5 @@
"use strict";
zrequire("Filter", "js/filter"); zrequire("Filter", "js/filter");
zrequire("FetchStatus", "js/fetch_status"); zrequire("FetchStatus", "js/fetch_status");
zrequire("MessageListData", "js/message_list_data"); zrequire("MessageListData", "js/message_list_data");

View File

@ -1,3 +1,5 @@
"use strict";
zrequire("people"); zrequire("people");
zrequire("Filter", "js/filter"); zrequire("Filter", "js/filter");
zrequire("stream_data"); zrequire("stream_data");

View File

@ -1,3 +1,5 @@
"use strict";
zrequire("Filter", "js/filter"); zrequire("Filter", "js/filter");
zrequire("people"); zrequire("people");
zrequire("stream_data"); zrequire("stream_data");

View File

@ -1,3 +1,5 @@
"use strict";
// Dependencies // Dependencies
set_global( set_global(
"$", "$",

View File

@ -1,3 +1,5 @@
"use strict";
set_global("zxcvbn", zrequire("zxcvbn", "zxcvbn")); set_global("zxcvbn", zrequire("zxcvbn", "zxcvbn"));
zrequire("common"); zrequire("common");

View File

@ -1,3 +1,5 @@
"use strict";
const _ = require("lodash"); const _ = require("lodash");
const moment = require("moment-timezone"); const moment = require("moment-timezone");
const rewiremock = require("rewiremock/node"); const rewiremock = require("rewiremock/node");

View File

@ -1,3 +1,5 @@
"use strict";
zrequire("people"); zrequire("people");
const return_false = function () { const return_false = function () {

View File

@ -1,3 +1,5 @@
"use strict";
const pmc = zrequire("pm_conversations"); const pmc = zrequire("pm_conversations");
run_test("partners", () => { run_test("partners", () => {

View File

@ -1,3 +1,5 @@
"use strict";
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
set_global("narrow_state", {}); set_global("narrow_state", {});

View File

@ -1,3 +1,5 @@
"use strict";
zrequire("poll_widget"); zrequire("poll_widget");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());

View File

@ -1,3 +1,5 @@
"use strict";
const rewiremock = require("rewiremock/node"); const rewiremock = require("rewiremock/node");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());

View File

@ -1,3 +1,5 @@
"use strict";
const XDate = require("xdate"); const XDate = require("xdate");
zrequire("people"); zrequire("people");

View File

@ -1,3 +1,5 @@
"use strict";
set_global("document", "document-stub"); set_global("document", "document-stub");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());

View File

@ -1,3 +1,5 @@
"use strict";
const rs = zrequire("recent_senders"); const rs = zrequire("recent_senders");
let next_id = 0; let next_id = 0;

View File

@ -1,3 +1,5 @@
"use strict";
zrequire("message_util"); zrequire("message_util");
const noop = () => {}; const noop = () => {};

View File

@ -1,3 +1,5 @@
"use strict";
const rm = zrequire("rendered_markdown"); const rm = zrequire("rendered_markdown");
zrequire("people"); zrequire("people");
zrequire("user_groups"); zrequire("user_groups");

View File

@ -1,3 +1,5 @@
"use strict";
const rtl = zrequire("rtl"); const rtl = zrequire("rtl");
run_test("get_direction", () => { run_test("get_direction", () => {

View File

@ -1,3 +1,5 @@
"use strict";
zrequire("schema"); zrequire("schema");
run_test("basics", () => { run_test("basics", () => {

View File

@ -1,3 +1,5 @@
"use strict";
zrequire("scroll_util"); zrequire("scroll_util");
set_global("ui", { set_global("ui", {
get_scroll_element: (element) => element, get_scroll_element: (element) => element,

View File

@ -1,3 +1,5 @@
"use strict";
set_global("page_params", { set_global("page_params", {
search_pills_enabled: true, search_pills_enabled: true,
}); });

View File

@ -1,3 +1,5 @@
"use strict";
set_global("page_params", { set_global("page_params", {
search_pills_enabled: false, search_pills_enabled: false,
}); });

Some files were not shown because too many files have changed in this diff Show More