Skip to content

Commit

Permalink
js: Add "use strict" directive to CommonJS files.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
andersk authored and timabbott committed Aug 1, 2020
1 parent 39c3a02 commit 6ec808b
Show file tree
Hide file tree
Showing 370 changed files with 746 additions and 2 deletions.
11 changes: 9 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"parser": "babel-eslint",
"parserOptions": {
"warnOnUnsupportedTypeScriptVersion": false,
"sourceType": "module"
"sourceType": "unambiguous"
},
"plugins": ["eslint-plugin-empty-returns"],
"rules": {
Expand All @@ -29,6 +29,7 @@
"newlines-between": "always"
}
],
"import/unambiguous": "error",
"new-cap": [
"error",
{
Expand Down Expand Up @@ -88,7 +89,7 @@
],
"radix": "error",
"spaced-comment": "off",
"strict": "off",
"strict": "error",
"valid-typeof": ["error", {"requireStringLiterals": true}],
"yoda": "error"
},
Expand Down Expand Up @@ -331,6 +332,12 @@
"@typescript-eslint/unified-signatures": "error"
}
},
{
"files": ["**/*.d.ts"],
"rules": {
"import/unambiguous": "off"
}
},
{
"files": ["frontend_tests/**"],
"globals": {
Expand Down
2 changes: 2 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

module.exports = {
presets: [
[
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/casper_lib/common.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

var util = require("util");

var test_credentials = require("../../var/casper/test_credentials.js").test_credentials;
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/casper_lib/polyfill.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

/* eslint-env browser */

// PhantomJS doesn’t support new DOMParser().parseFromString(…, "text/html").
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/casper_tests/00-realm-creation.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

var common = require("../casper_lib/common.js");

var email = "[email protected]";
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/casper_tests/01-login.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

var common = require("../casper_lib/common.js");

var realm_url = "http://zulip.zulipdev.com:9981/";
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/casper_tests/02-site.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

/* Script for testing the web client.
This runs under CasperJS. It's an end-to-end black-box sort of test. It
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/casper_tests/03-narrow.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

var common = require("../casper_lib/common.js");

common.start_and_log_in();
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/casper_tests/04-compose.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

var common = require("../casper_lib/common.js");

common.start_and_log_in();
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/casper_tests/05-subscriptions.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

var common = require("../casper_lib/common.js");

function stream_checkbox(stream_name) {
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/casper_tests/06-settings.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

var test_credentials = require("../../var/casper/test_credentials.js").test_credentials;
var common = require("../casper_lib/common.js");

Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/casper_tests/07-stars.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

var common = require("../casper_lib/common.js");

function star_count() {
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/casper_tests/08-edit.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

var common = require("../casper_lib/common.js");

casper.options.verbose = true;
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/casper_tests/09-navigation.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

var common = require("../casper_lib/common.js");

// Test basic tab navigation.
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/casper_tests/10-admin.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

var common = require("../casper_lib/common.js");

common.start_and_log_in();
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/casper_tests/11-mention.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

var common = require("../casper_lib/common.js");

common.start_and_log_in();
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/casper_tests/12-custom-profile.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

var common = require("../casper_lib/common.js");

common.start_and_log_in();
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/casper_tests/13-user-deactivation.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

var common = require("../casper_lib/common.js");

function user_row(name) {
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/casper_tests/14-drafts.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

var common = require("../casper_lib/common.js");

function waitWhileDraftsVisible(then) {
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/casper_tests/15-delete-message.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

var common = require("../casper_lib/common.js");

common.start_and_log_in();
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/casper_tests/16-copy-and-paste.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

var common = require("../casper_lib/common.js");

common.start_and_log_in();
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/casper_tests/17-realm-linkifier.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

var common = require("../casper_lib/common.js");

common.start_and_log_in();
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/activity.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

set_global("$", global.make_zjquery());
const window_stub = $.create("window-stub");
set_global("to_$", () => window_stub);
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/alert_words.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

const params = {
alert_words: ["alertone", "alerttwo", "alertthree", "al*rt.*s", ".+", "emoji"],
};
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/alert_words_ui.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

set_global("$", global.make_zjquery());

set_global("channel", {});
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/billing.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

const noop = () => {};
const fs = require("fs");

Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/billing_helpers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

const fs = require("fs");

const JQuery = require("jquery");
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/blueslip_stacktrace.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

const blueslip_stacktrace = zrequire("blueslip_stacktrace");

run_test("clean_path", () => {
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/bot_data.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

const _settings_bots = {
render_bots: () => {},
};
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/buddy_data.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

const _ = require("lodash");

const _page_params = {};
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/buddy_list.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

const _ = require("lodash");

set_global("$", global.make_zjquery());
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/channel.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

const _ = require("lodash");

set_global("$", {});
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/color_data.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

zrequire("color_data");

run_test("pick_color", () => {
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/colorspace.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

zrequire("colorspace");

run_test("sRGB_to_linear", () => {
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/common.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

const noop = () => {};

set_global("$", global.make_zjquery());
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/components.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

const _ = require("lodash");

zrequire("keydown_util");
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/compose.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

const {JSDOM} = require("jsdom");
const rewiremock = require("rewiremock/node");

Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/compose_actions.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

const noop = function () {};
const return_false = function () {
return false;
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/compose_fade.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

zrequire("stream_data");
zrequire("people");
zrequire("compose_fade");
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/compose_pm_pill.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

set_global("$", global.make_zjquery());

const _people = {
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/compose_ui.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

zrequire("compose_ui");
zrequire("people");
zrequire("user_status");
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/composebox_typeahead.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

const emoji = zrequire("emoji", "shared/js/emoji");
const typeahead = zrequire("typeahead", "shared/js/typeahead");
zrequire("compose_state");
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/copy_and_paste.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

global.stub_out_jquery();

set_global("page_params", {
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/dispatch.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

const noop = function () {};

const events = require("./lib/events.js");
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/dispatch_subs.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

const events = require("./lib/events.js");

const event_fixtures = events.fixtures;
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/drafts.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

const XDate = require("xdate");

set_global("$", global.make_zjquery());
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/dropdown_list_widget.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

zrequire("dropdown_list_widget");
zrequire("scroll_util");
set_global("$", global.make_zjquery());
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/echo.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

set_global("$", global.make_zjquery());
set_global("markdown", {});
set_global("local_message", {
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/emoji.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

const emoji_codes = zrequire("emoji_codes", "generated/emoji/emoji_codes.json");

const events = require("./lib/events.js");
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/emoji_picker.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

const _ = require("lodash");

const emoji = zrequire("emoji", "shared/js/emoji");
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/fenced_code.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

const fenced_code = zrequire("fenced_code", "shared/js/fenced_code");

run_test("get_unused_fence", () => {
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/fetch_status.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

const FetchStatus = zrequire("fetch_status");
set_global("message_scroll", {
hide_loading_older: () => {},
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/filter.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

zrequire("unread");
zrequire("stream_data");
zrequire("people");
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/fold_dict.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

const FoldDict = zrequire("fold_dict").FoldDict;

run_test("basic", () => {
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/general.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

// This is a general tour of how to write node tests that
// may also give you some quick insight on how the Zulip
// browser app is constructed. Let's start with testing
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/hash_util.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

zrequire("hash_util");
zrequire("stream_data");
zrequire("people");
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/hashchange.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

set_global("$", global.make_zjquery());
const window_stub = $.create("window-stub");
set_global("location", {
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/hotkey.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

// Important note on these tests:
//
// The way the Zulip hotkey tests work is as follows. First, we set
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/i18n.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

zrequire("templates");

// We download our translations in `page_params` (which
Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/input_pill.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

set_global("$", global.make_zjquery());
zrequire("input_pill");

Expand Down
2 changes: 2 additions & 0 deletions frontend_tests/node_tests/keydown_util.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

set_global("$", global.make_zjquery());

zrequire("keydown_util");
Expand Down
Loading

0 comments on commit 6ec808b

Please sign in to comment.