Skip to content

Commit

Permalink
Update TypeScript, Prettier and typescript-eslint for new TypeScript …
Browse files Browse the repository at this point in the history
…3.8 syntax
  • Loading branch information
scottnonnenberg-signal authored and josh-signal committed Nov 23, 2020
1 parent 5758ed4 commit 2688443
Show file tree
Hide file tree
Showing 65 changed files with 286 additions and 185 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.js
Expand Up @@ -15,6 +15,12 @@ const rules = {
},
],

// Overrides recommended by typescript-eslint
// https://github.com/typescript-eslint/typescript-eslint/releases/tag/v4.0.0
'@typescript-eslint/no-redeclare': 'error',
'@typescript-eslint/no-shadow': 'error',
'no-shadow': 'off',

// prevents us from accidentally checking in exclusive tests (`.only`):
'mocha/no-exclusive-tests': 'error',

Expand Down
10 changes: 5 additions & 5 deletions .github/ISSUE_TEMPLATE.md
Expand Up @@ -13,11 +13,11 @@ Lastly, be sure to preview your issue before saving. Thanks!
-->

- [ ] I have searched open and closed issues for duplicates
<!--
You can search all issues here:
https://github.com/signalapp/Signal-Desktop/issues?utf8=%E2%9C%93&q=is%3Aissue
Replace [ ] with [X] once you've searched
-->
<!--
You can search all issues here:
https://github.com/signalapp/Signal-Desktop/issues?utf8=%E2%9C%93&q=is%3Aissue
Replace [ ] with [X] once you've searched
-->

---

Expand Down
1 change: 1 addition & 0 deletions .prettierrc.js
Expand Up @@ -3,5 +3,6 @@

module.exports = {
singleQuote: true,
arrowParens: 'avoid',
trailingComma: 'es5',
};
2 changes: 1 addition & 1 deletion js/database.js
Expand Up @@ -4,7 +4,7 @@
/* global Whisper: false */

// eslint-disable-next-line func-names
(function() {
(function () {
window.Whisper = window.Whisper || {};
window.Whisper.Database = window.Whisper.Database || {};
window.Whisper.Database.id = window.Whisper.Database.id || 'signal';
Expand Down
2 changes: 1 addition & 1 deletion js/deletes.js
Expand Up @@ -11,7 +11,7 @@
/* eslint-disable more/no-then */

// eslint-disable-next-line func-names
(function() {
(function () {
window.Whisper = window.Whisper || {};
Whisper.Deletes = new (Backbone.Collection.extend({
forMessage(message) {
Expand Down
2 changes: 1 addition & 1 deletion js/delivery_receipts.js
Expand Up @@ -12,7 +12,7 @@
/* eslint-disable more/no-then */

// eslint-disable-next-line func-names
(function() {
(function () {
window.Whisper = window.Whisper || {};

Whisper.DeliveryReceipts = new (Backbone.Collection.extend({
Expand Down
2 changes: 1 addition & 1 deletion js/expiring_messages.js
Expand Up @@ -8,7 +8,7 @@
*/

// eslint-disable-next-line func-names
(function() {
(function () {
window.Whisper = window.Whisper || {};

async function destroyExpiredMessages() {
Expand Down
2 changes: 1 addition & 1 deletion js/expiring_tap_to_view_messages.js
Expand Up @@ -8,7 +8,7 @@
*/

// eslint-disable-next-line func-names
(function() {
(function () {
window.Whisper = window.Whisper || {};

async function eraseTapToViewMessages() {
Expand Down
2 changes: 1 addition & 1 deletion js/keychange_listener.js
Expand Up @@ -6,7 +6,7 @@
/* eslint-disable more/no-then */

// eslint-disable-next-line func-names
(function() {
(function () {
window.Whisper = window.Whisper || {};

Whisper.KeyChangeListener = {
Expand Down
12 changes: 6 additions & 6 deletions js/libphonenumber-util.js
@@ -1,7 +1,7 @@
// Copyright 2014-2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only

(function() {
(function () {
'use strict';

/*
Expand All @@ -12,7 +12,7 @@

window.libphonenumber = window.libphonenumber || {};
window.libphonenumber.util = {
getRegionCodeForNumber: function(number) {
getRegionCodeForNumber: function (number) {
try {
var parsedNumber = libphonenumber.parse(number);
return libphonenumber.getRegionCodeForNumber(parsedNumber);
Expand All @@ -21,20 +21,20 @@
}
},

splitCountryCode: function(number) {
splitCountryCode: function (number) {
var parsedNumber = libphonenumber.parse(number);
return {
country_code: parsedNumber.values_[1],
national_number: parsedNumber.values_[2],
};
},

getCountryCode: function(regionCode) {
getCountryCode: function (regionCode) {
var cc = libphonenumber.getCountryCodeForRegion(regionCode);
return cc !== 0 ? cc : '';
},

parseNumber: function(number, defaultRegionCode) {
parseNumber: function (number, defaultRegionCode) {
try {
var parsedNumber = libphonenumber.parse(number, defaultRegionCode);

Expand All @@ -53,7 +53,7 @@
}
},

getAllRegionCodes: function() {
getAllRegionCodes: function () {
return {
AD: 'Andorra',
AE: 'United Arab Emirates',
Expand Down
2 changes: 1 addition & 1 deletion js/message_controller.js
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-only

// eslint-disable-next-line func-names
(function() {
(function () {
window.Whisper = window.Whisper || {};

const messageLookup = Object.create(null);
Expand Down
2 changes: 1 addition & 1 deletion js/message_requests.js
Expand Up @@ -10,7 +10,7 @@
/* eslint-disable more/no-then */

// eslint-disable-next-line func-names
(function() {
(function () {
window.Whisper = window.Whisper || {};
Whisper.MessageRequests = new (Backbone.Collection.extend({
forConversation(conversation) {
Expand Down
2 changes: 1 addition & 1 deletion js/models/blockedNumbers.js
Expand Up @@ -4,7 +4,7 @@
/* global storage, _ */

// eslint-disable-next-line func-names
(function() {
(function () {
const BLOCKED_NUMBERS_ID = 'blocked';
const BLOCKED_UUIDS_ID = 'blocked-uuids';
const BLOCKED_GROUPS_ID = 'blocked-groups';
Expand Down
5 changes: 3 additions & 2 deletions js/modules/attachment_downloads.js
Expand Up @@ -199,8 +199,9 @@ async function _runJob(job) {
logger.warn(
`_runJob: Got 404 from server for CDN ${
attachment.cdnNumber
}, marking attachment ${attachment.cdnId ||
attachment.cdnKey} from message ${message.idForLogging()} as permanent error`
}, marking attachment ${
attachment.cdnId || attachment.cdnKey
} from message ${message.idForLogging()} as permanent error`
);

await _finishJob(message, id);
Expand Down
2 changes: 1 addition & 1 deletion js/notifications.js
Expand Up @@ -11,7 +11,7 @@
/* global _: false */

// eslint-disable-next-line func-names
(function() {
(function () {
window.Whisper = window.Whisper || {};

// The keys and values don't match here. This is because the values correspond to old
Expand Down
2 changes: 1 addition & 1 deletion js/reactions.js
Expand Up @@ -11,7 +11,7 @@
/* eslint-disable more/no-then */

// eslint-disable-next-line func-names
(function() {
(function () {
window.Whisper = window.Whisper || {};
Whisper.Reactions = new (Backbone.Collection.extend({
forMessage(message) {
Expand Down
2 changes: 1 addition & 1 deletion js/read_receipts.js
Expand Up @@ -12,7 +12,7 @@
/* eslint-disable more/no-then */

// eslint-disable-next-line func-names
(function() {
(function () {
window.Whisper = window.Whisper || {};
Whisper.ReadReceipts = new (Backbone.Collection.extend({
forMessage(conversation, message) {
Expand Down
2 changes: 1 addition & 1 deletion js/read_syncs.js
Expand Up @@ -10,7 +10,7 @@
/* eslint-disable more/no-then */

// eslint-disable-next-line func-names
(function() {
(function () {
window.Whisper = window.Whisper || {};
Whisper.ReadSyncs = new (Backbone.Collection.extend({
forMessage(message) {
Expand Down
8 changes: 4 additions & 4 deletions js/reliable_trigger.js
Expand Up @@ -6,7 +6,7 @@
// This file was taken from Backbone and then modified. It does not conform to this
// project's standards.

(function() {
(function () {
'use strict';

// Note: this is all the code required to customize Backbone's trigger() method to make
Expand All @@ -32,7 +32,7 @@
// Implement fancy features of the Events API such as multiple event
// names `"change blur"` and jQuery-style event maps `{change: action}`
// in terms of the existing API.
const eventsApi = function(obj, action, name, rest) {
const eventsApi = function (obj, action, name, rest) {
if (!name) return true;

// Handle event maps.
Expand All @@ -58,14 +58,14 @@
// A difficult-to-believe, but optimized internal dispatch function for
// triggering events. Tries to keep the usual cases speedy (most internal
// Backbone events have 3 arguments).
const triggerEvents = function(events, name, args) {
const triggerEvents = function (events, name, args) {
let ev,
i = -1,
l = events.length,
a1 = args[0],
a2 = args[1],
a3 = args[2];
const logError = function(error) {
const logError = function (error) {
window.log.error(
'Model caught error triggering',
name,
Expand Down
2 changes: 1 addition & 1 deletion js/rotate_signed_prekey_listener.js
Expand Up @@ -4,7 +4,7 @@
/* global Whisper, storage, getAccountManager */

// eslint-disable-next-line func-names
(function() {
(function () {
window.Whisper = window.Whisper || {};
const ROTATION_INTERVAL = 48 * 60 * 60 * 1000;
let timeout;
Expand Down
2 changes: 1 addition & 1 deletion js/signal_protocol_store.js
Expand Up @@ -7,7 +7,7 @@
/* eslint-disable no-proto */

// eslint-disable-next-line func-names
(function() {
(function () {
const TIMESTAMP_THRESHOLD = 5 * 1000; // 5 seconds
const Direction = {
SENDING: 1,
Expand Down
2 changes: 1 addition & 1 deletion js/storage.js
Expand Up @@ -5,7 +5,7 @@
/* eslint-disable more/no-then */

// eslint-disable-next-line func-names
(function() {
(function () {
window.Whisper = window.Whisper || {};

let ready = false;
Expand Down
2 changes: 1 addition & 1 deletion js/view_syncs.js
Expand Up @@ -10,7 +10,7 @@
/* eslint-disable more/no-then */

// eslint-disable-next-line func-names
(function() {
(function () {
window.Whisper = window.Whisper || {};
Whisper.ViewSyncs = new (Backbone.Collection.extend({
forMessage(message) {
Expand Down
2 changes: 1 addition & 1 deletion js/views/app_view.js
Expand Up @@ -6,7 +6,7 @@
/* eslint-disable more/no-then */

// eslint-disable-next-line func-names
(function() {
(function () {
window.Whisper = window.Whisper || {};

function resolveTheme() {
Expand Down
2 changes: 1 addition & 1 deletion js/views/banner_view.js
Expand Up @@ -4,7 +4,7 @@
/* global Whisper */

// eslint-disable-next-line func-names
(function() {
(function () {
window.Whisper = window.Whisper || {};

Whisper.BannerView = Whisper.View.extend({
Expand Down
2 changes: 1 addition & 1 deletion js/views/clear_data_view.js
Expand Up @@ -7,7 +7,7 @@
/* eslint-disable no-new */

// eslint-disable-next-line func-names
(function() {
(function () {
window.Whisper = window.Whisper || {};
const { Logs } = window.Signal;

Expand Down
2 changes: 1 addition & 1 deletion js/views/confirmation_dialog_view.js
Expand Up @@ -4,7 +4,7 @@
/* global Backbone, Whisper, i18n */

// eslint-disable-next-line func-names
(function() {
(function () {
window.Whisper = window.Whisper || {};

Whisper.ConfirmationDialogView = Whisper.View.extend({
Expand Down
2 changes: 1 addition & 1 deletion js/views/contact_list_view.js
Expand Up @@ -5,7 +5,7 @@
/* global textsecure: false */

// eslint-disable-next-line func-names
(function() {
(function () {
window.Whisper = window.Whisper || {};

Whisper.ContactListView = Whisper.ListView.extend({
Expand Down
6 changes: 2 additions & 4 deletions js/views/debug_log_view.js
Expand Up @@ -5,7 +5,7 @@
/* global Whisper: false */

// eslint-disable-next-line func-names
(function() {
(function () {
window.Whisper = window.Whisper || {};

Whisper.LinkedCopiedToast = Whisper.ToastView.extend({
Expand Down Expand Up @@ -80,9 +80,7 @@
});
this.$('.loading').removeClass('loading');
view.render();
this.$('.link')
.focus()
.select();
this.$('.link').focus().select();
} catch (error) {
window.log.error(
'DebugLogView error:',
Expand Down
2 changes: 1 addition & 1 deletion js/views/group_member_list_view.js
Expand Up @@ -4,7 +4,7 @@
/* global Whisper, i18n */

// eslint-disable-next-line func-names
(function() {
(function () {
window.Whisper = window.Whisper || {};

// TODO: take a title string which could replace the 'members' header
Expand Down
2 changes: 1 addition & 1 deletion js/views/identicon_svg_view.js
Expand Up @@ -4,7 +4,7 @@
/* global Whisper, loadImage */

// eslint-disable-next-line func-names
(function() {
(function () {
window.Whisper = window.Whisper || {};

/*
Expand Down
2 changes: 1 addition & 1 deletion js/views/inbox_view.js
Expand Up @@ -9,7 +9,7 @@
*/

// eslint-disable-next-line func-names
(function() {
(function () {
window.Whisper = window.Whisper || {};

Whisper.StickerPackInstallFailedToast = Whisper.ToastView.extend({
Expand Down
2 changes: 1 addition & 1 deletion js/views/install_view.js
Expand Up @@ -6,7 +6,7 @@
/* eslint-disable more/no-then */

// eslint-disable-next-line func-names
(function() {
(function () {
window.Whisper = window.Whisper || {};

const Steps = {
Expand Down
2 changes: 1 addition & 1 deletion js/views/key_verification_view.js
Expand Up @@ -6,7 +6,7 @@
/* eslint-disable more/no-then */

// eslint-disable-next-line func-names
(function() {
(function () {
window.Whisper = window.Whisper || {};

Whisper.KeyVerificationPanelView = Whisper.View.extend({
Expand Down

0 comments on commit 2688443

Please sign in to comment.