Update TypeScript, Prettier and typescript-eslint for new TypeScript 3.8 syntax

This commit is contained in:
Scott Nonnenberg 2020-11-18 07:15:42 -08:00 committed by Josh Perez
parent 5758ed44ac
commit 26884432a2
65 changed files with 286 additions and 185 deletions

View file

@ -4,7 +4,7 @@
type WhatIsThis = typeof window.WhatIsThis;
// eslint-disable-next-line func-names
(async function() {
(async function () {
const eventHandlerQueue = new window.PQueue({
concurrency: 1,
timeout: 1000 * 60 * 2,
@ -136,9 +136,7 @@ type WhatIsThis = typeof window.WhatIsThis;
}
interactionMode = 'keyboard';
$(document.body)
.addClass('keyboard-mode')
.removeClass('mouse-mode');
$(document.body).addClass('keyboard-mode').removeClass('mouse-mode');
const { userChanged } = window.reduxActions.user;
const { clearSelectedMessage } = window.reduxActions.conversations;
if (clearSelectedMessage) {
@ -156,9 +154,7 @@ type WhatIsThis = typeof window.WhatIsThis;
}
interactionMode = 'mouse';
$(document.body)
.addClass('mouse-mode')
.removeClass('keyboard-mode');
$(document.body).addClass('mouse-mode').removeClass('keyboard-mode');
const { userChanged } = window.reduxActions.user;
const { clearSelectedMessage } = window.reduxActions.conversations;
if (clearSelectedMessage) {

View file

@ -115,9 +115,7 @@ const withSection = (referenceDateTime: moment.Moment) => (
mediaItem: MediaItemType
): MediaItemWithSection => {
const today = moment(referenceDateTime).startOf('day');
const yesterday = moment(referenceDateTime)
.subtract(1, 'day')
.startOf('day');
const yesterday = moment(referenceDateTime).subtract(1, 'day').startOf('day');
const thisWeek = moment(referenceDateTime).startOf('isoWeek');
const thisMonth = moment(referenceDateTime).startOf('month');

View file

@ -2987,8 +2987,9 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
);
if (preview.length < incomingPreview.length) {
window.log.info(
`${message.idForLogging()}: Eliminated ${preview.length -
incomingPreview.length} previews with invalid urls'`
`${message.idForLogging()}: Eliminated ${
preview.length - incomingPreview.length
} previews with invalid urls'`
);
}

View file

@ -222,10 +222,7 @@ export class EmojiCompletion {
): void {
const emoji = convertShortName(emojiData.short_name, this.options.skinTone);
const delta = new Delta()
.retain(index)
.delete(range)
.insert({ emoji });
const delta = new Delta().retain(index).delete(range).insert({ emoji });
if (withTrailingSpace) {
this.quill.updateContents(delta.insert(' '), 'user');

View file

@ -183,10 +183,7 @@ export class MentionCompletion {
range: number,
withTrailingSpace = false
): void {
const delta = new Delta()
.retain(index)
.delete(range)
.insert({ mention });
const delta = new Delta().retain(index).delete(range).insert({ mention });
if (withTrailingSpace) {
this.quill.updateContents(delta.insert(' '), 'user');

View file

@ -17,6 +17,7 @@ import { createLogger } from 'redux-logger';
import { reducer, StateType } from './reducer';
declare global {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Console {
_log: Console['log'];
}

View file

@ -15,8 +15,9 @@ export default function createTaskWithTimeout<T>(
let complete = false;
let timer: NodeJS.Timeout | null = setTimeout(() => {
if (!complete) {
const message = `${id ||
''} task did not complete in time. Calling stack: ${
const message = `${
id || ''
} task did not complete in time. Calling stack: ${
errorForStack.stack
}`;

View file

@ -5,7 +5,8 @@ import { w3cwebsocket } from 'websocket';
type ModifiedEventSource = Omit<EventSource, 'onerror'>;
declare class ModifiedWebSocket extends w3cwebsocket
declare class ModifiedWebSocket
extends w3cwebsocket
implements ModifiedEventSource {
withCredentials: boolean;
@ -17,4 +18,5 @@ declare class ModifiedWebSocket extends w3cwebsocket
}
export type WebSocket = ModifiedWebSocket;
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const WebSocket = w3cwebsocket as typeof ModifiedWebSocket;

View file

@ -441,29 +441,29 @@
{
"rule": "jQuery-$(",
"path": "js/views/debug_log_view.js",
"line": " this.$('.link')",
"line": " this.$('.link').focus().select();",
"lineNumber": 83,
"reasonCategory": "usageTrusted",
"updated": "2020-05-01T17:11:39.527Z",
"updated": "2020-11-18T03:39:29.033Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-$(",
"path": "js/views/debug_log_view.js",
"line": " this.$('.loading').removeClass('loading');",
"lineNumber": 91,
"lineNumber": 89,
"reasonCategory": "usageTrusted",
"updated": "2020-05-01T17:11:39.527Z",
"updated": "2020-11-18T03:39:29.033Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-$(",
"path": "js/views/debug_log_view.js",
"line": " this.$('.result').text(i18n('debugLogError'));",
"lineNumber": 92,
"lineNumber": 90,
"reasonCategory": "usageTrusted",
"updated": "2020-09-11T17:24:56.124Z",
"reasonDetail": "Static selector argument"
"updated": "2020-11-18T03:39:29.033Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-$(",
@ -1201,136 +1201,136 @@
{
"rule": "jQuery-$(",
"path": "js/views/standalone_registration_view.js",
"line": " const verificationCode = $('#code')",
"line": " const verificationCode = $('#code').val().replace(/\\D+/g, '');",
"lineNumber": 40,
"reasonCategory": "usageTrusted",
"updated": "2018-09-19T21:59:32.770Z",
"updated": "2020-11-18T03:39:29.033Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-$(",
"path": "js/views/standalone_registration_view.js",
"line": " this.$('#status').text(s);",
"lineNumber": 53,
"lineNumber": 51,
"reasonCategory": "usageTrusted",
"updated": "2018-09-19T21:59:32.770Z",
"updated": "2020-11-18T03:39:29.033Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-$(",
"path": "js/views/standalone_registration_view.js",
"line": " const verificationCode = $('#code')",
"lineNumber": 56,
"line": " const verificationCode = $('#code').val().replace(/\\D/g, '');",
"lineNumber": 54,
"reasonCategory": "usageTrusted",
"updated": "2018-09-19T21:59:32.770Z",
"updated": "2020-11-18T03:39:29.033Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-$(",
"path": "js/views/standalone_registration_view.js",
"line": " this.$('#error')",
"lineNumber": 67,
"line": " this.$('#error').hide().text(error).addClass('in').fadeIn();",
"lineNumber": 63,
"reasonCategory": "usageTrusted",
"updated": "2018-09-19T21:59:32.770Z",
"updated": "2020-11-18T03:39:29.033Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-$(",
"path": "js/views/standalone_registration_view.js",
"line": " if (this.$('#number-container').hasClass('valid')) {",
"lineNumber": 74,
"lineNumber": 66,
"reasonCategory": "usageTrusted",
"updated": "2018-09-19T21:59:32.770Z",
"updated": "2020-11-18T03:39:29.033Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-$(",
"path": "js/views/standalone_registration_view.js",
"line": " this.$('#request-sms, #request-voice').removeAttr('disabled');",
"lineNumber": 75,
"lineNumber": 67,
"reasonCategory": "usageTrusted",
"updated": "2020-09-11T17:24:56.124Z",
"reasonDetail": "Static selector argument"
"updated": "2020-11-18T03:39:29.033Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-$(",
"path": "js/views/standalone_registration_view.js",
"line": " this.$('#request-sms, #request-voice').prop('disabled', 'disabled');",
"lineNumber": 77,
"lineNumber": 69,
"reasonCategory": "usageTrusted",
"updated": "2018-09-19T21:59:32.770Z",
"updated": "2020-11-18T03:39:29.033Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-$(",
"path": "js/views/standalone_registration_view.js",
"line": " this.$('#code').addClass('invalid');",
"lineNumber": 82,
"lineNumber": 74,
"reasonCategory": "usageTrusted",
"updated": "2018-09-19T21:59:32.770Z",
"updated": "2020-11-18T03:39:29.033Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-$(",
"path": "js/views/standalone_registration_view.js",
"line": " this.$('#code').removeClass('invalid');",
"lineNumber": 84,
"lineNumber": 76,
"reasonCategory": "usageTrusted",
"updated": "2018-09-19T21:59:32.770Z",
"updated": "2020-11-18T03:39:29.033Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-$(",
"path": "js/views/standalone_registration_view.js",
"line": " this.$('#error').hide();",
"lineNumber": 89,
"lineNumber": 81,
"reasonCategory": "usageTrusted",
"updated": "2018-09-19T21:59:32.770Z",
"updated": "2020-11-18T03:39:29.033Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-$(",
"path": "js/views/standalone_registration_view.js",
"line": " this.$('#step2')",
"lineNumber": 95,
"line": " this.$('#step2').addClass('in').fadeIn();",
"lineNumber": 87,
"reasonCategory": "usageTrusted",
"updated": "2018-09-19T21:59:32.770Z",
"updated": "2020-11-18T03:39:29.033Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-$(",
"path": "js/views/standalone_registration_view.js",
"line": " this.$('#number-container').addClass('invalid');",
"lineNumber": 99,
"lineNumber": 89,
"reasonCategory": "usageTrusted",
"updated": "2018-09-19T21:59:32.770Z",
"updated": "2020-11-18T03:39:29.033Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-$(",
"path": "js/views/standalone_registration_view.js",
"line": " $('#error').hide();",
"lineNumber": 104,
"lineNumber": 94,
"reasonCategory": "usageTrusted",
"updated": "2018-09-19T21:59:32.770Z",
"updated": "2020-11-18T03:39:29.033Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-$(",
"path": "js/views/standalone_registration_view.js",
"line": " this.$('#step2')",
"lineNumber": 110,
"line": " this.$('#step2').addClass('in').fadeIn();",
"lineNumber": 100,
"reasonCategory": "usageTrusted",
"updated": "2018-09-19T21:59:32.770Z",
"updated": "2020-11-18T03:39:29.033Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-$(",
"path": "js/views/standalone_registration_view.js",
"line": " this.$('#number-container').addClass('invalid');",
"lineNumber": 114,
"lineNumber": 102,
"reasonCategory": "usageTrusted",
"updated": "2018-09-19T21:59:32.770Z",
"updated": "2020-11-18T03:39:29.033Z",
"reasonDetail": "Protected from arbitrary input"
},
{
@ -1667,15 +1667,6 @@
"updated": "2020-10-09T22:28:48.591Z",
"reasonDetail": "Test code. Also a false match."
},
{
"rule": "eval",
"path": "node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-implied-eval.js",
"line": " description: 'Disallow the use of `eval()`-like methods',",
"lineNumber": 38,
"reasonCategory": "falseMatch",
"updated": "2020-08-26T00:10:28.628Z",
"reasonDetail": "just a doc"
},
{
"rule": "jQuery-$(",
"path": "node_modules/@yarnpkg/lockfile/index.js",

View file

@ -161,6 +161,7 @@ const excludedFilesRegexps = [
'^node_modules/es6-shim/.+', // Currently only used in storybook
'^node_modules/escodegen/.+',
'^node_modules/eslint.+',
'^node_modules/@typescript-eslint.+',
'^node_modules/esprima/.+',
'^node_modules/express/.+',
'^node_modules/file-loader/.+',

View file

@ -148,10 +148,7 @@ export function deriveGroupID(
);
return compatArrayToArrayBuffer(
groupSecretParams
.getPublicParams()
.getGroupIdentifier()
.serialize()
groupSecretParams.getPublicParams().getGroupIdentifier().serialize()
);
}

View file

@ -1838,10 +1838,7 @@ Whisper.ConversationView = Whisper.View.extend({
return fileName;
}
return fileName
.split('.')
.slice(0, -1)
.join('.');
return fileName.split('.').slice(0, -1).join('.');
},
getType(contentType: any) {