From d43d6abbae51649aad5973cd19bef544fb3f6752 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Wed, 26 Jul 2023 11:26:46 +0200 Subject: [PATCH 1/8] chore: replace tslint with eslint and fix linting issues --- .eslintignore | 3 +- .eslintrc.js | 66 +- about_preload.js | 1 + debug_log_preload.js | 1 + libsession.worker.config.js | 1 + package.json | 13 +- password_preload.js | 1 + playwright.config.ts | 3 +- preload.js | 3 +- sass.config.js | 4 +- ts/components/AboutView.tsx | 2 +- ts/components/CaptionEditor.tsx | 2 - ts/components/DebugLogView.tsx | 5 +- ts/components/MemberListItem.tsx | 5 +- ts/components/SessionInboxView.tsx | 46 +- ts/components/SessionPasswordPrompt.tsx | 15 +- ts/components/SessionToastContainer.tsx | 1 - ts/components/SessionWrapperModal.tsx | 7 +- ts/components/SplitViewContainer.tsx | 2 +- ts/components/avatar/Avatar.tsx | 5 +- .../AvatarPlaceHolder/AvatarPlaceHolder.tsx | 8 +- .../AvatarPlaceHolder/ClosedGroupAvatar.tsx | 4 +- ts/components/basic/Flex.tsx | 6 +- ts/components/basic/MessageBodyHighlight.tsx | 1 - ts/components/basic/SessionHTMLRenderer.tsx | 11 +- ts/components/basic/SessionIdEditable.tsx | 4 +- ts/components/basic/SessionRadio.tsx | 4 +- ts/components/basic/SessionRadioGroup.tsx | 8 +- ts/components/basic/SessionToast.tsx | 12 +- ts/components/basic/SessionToggle.tsx | 2 +- ts/components/button/MenuButton.tsx | 1 - ts/components/calling/CallButtons.tsx | 13 +- .../calling/CallInFullScreenContainer.tsx | 4 +- .../calling/DraggableCallContainer.tsx | 13 +- .../calling/InConversationCallContainer.tsx | 8 +- ts/components/calling/IncomingCallDialog.tsx | 6 +- ts/components/conversation/AddMentions.tsx | 4 +- ts/components/conversation/ContactName.tsx | 8 +- .../conversation/ConversationHeader.tsx | 4 +- ts/components/conversation/ExpireTimer.tsx | 5 +- ts/components/conversation/H5AudioPlayer.tsx | 2 +- ts/components/conversation/Image.tsx | 4 +- ts/components/conversation/ImageGrid.tsx | 3 +- .../conversation/SessionConversation.tsx | 16 +- .../conversation/SessionEmojiPanel.tsx | 6 +- .../conversation/SessionMessagesList.tsx | 2 +- .../SessionMessagesListContainer.tsx | 9 +- .../SessionQuotedMessageComposition.tsx | 9 +- .../conversation/SessionRecording.tsx | 14 +- .../conversation/SessionRightPanel.tsx | 40 +- .../conversation/SessionStagedLinkPreview.tsx | 6 +- .../conversation/StagedLinkPreview.tsx | 2 +- .../StagedPlaceholderAttachment.tsx | 1 - ts/components/conversation/Timestamp.tsx | 1 - ts/components/conversation/TypingBubble.tsx | 2 +- .../composition/CompositionBox.tsx | 96 +-- .../composition/CompositionButtons.tsx | 1 + .../composition/EmojiQuickResult.tsx | 2 +- .../media-gallery/DocumentListItem.tsx | 2 +- .../media-gallery/MediaGridItem.tsx | 4 +- .../media-gallery/groupMediaItemsByDate.ts | 10 +- .../message-content/ClickToTrustSender.tsx | 2 +- .../message-content/MessageAttachment.tsx | 12 +- .../message-content/MessageAuthorText.tsx | 2 +- .../message/message-content/MessageAvatar.tsx | 26 +- .../message/message-content/MessageBody.tsx | 35 +- .../message-content/MessageContent.tsx | 18 +- .../MessageContentWithStatus.tsx | 15 +- .../message-content/MessageContextMenu.tsx | 273 +++++---- .../message/message-content/MessageQuote.tsx | 117 ++-- .../message-content/MessageReactBar.tsx | 14 +- .../message/message-content/Quote.tsx | 10 +- .../message/message-content/quote/Quote.tsx | 3 +- .../quote/QuoteIconContainer.tsx | 7 +- .../message-content/quote/QuoteImage.tsx | 6 +- .../message-item/GenericReadableMessage.tsx | 18 +- .../message/message-item/GroupInvitation.tsx | 7 +- .../message-item/GroupUpdateMessage.tsx | 2 +- .../message/message-item/Message.tsx | 5 +- .../message/message-item/MessageDetail.tsx | 15 +- .../message/message-item/ReadableMessage.tsx | 10 +- .../message/reactions/Reaction.tsx | 1 - .../message/reactions/ReactionPopup.tsx | 17 +- ts/components/dialog/BanOrUnbanUserDialog.tsx | 27 +- ts/components/dialog/DeleteAccountModal.tsx | 2 +- ts/components/dialog/EditProfileDialog.tsx | 14 +- ts/components/dialog/InviteContactsDialog.tsx | 10 +- ts/components/dialog/ModeratorsAddDialog.tsx | 7 +- .../dialog/ModeratorsRemoveDialog.tsx | 16 +- .../dialog/OnionStatusPathDialog.tsx | 11 +- ts/components/dialog/ReactClearAllModal.tsx | 1 - ts/components/dialog/ReactListModal.tsx | 26 +- ts/components/dialog/SessionConfirm.tsx | 12 +- ts/components/dialog/SessionModal.tsx | 136 ----- .../dialog/SessionNicknameDialog.tsx | 5 +- .../dialog/SessionPasswordDialog.tsx | 9 +- ts/components/dialog/SessionSeedModal.tsx | 76 +-- .../dialog/UpdateGroupMembersDialog.tsx | 12 +- .../dialog/UpdateGroupNameDialog.tsx | 9 +- ts/components/dialog/UserDetailsDialog.tsx | 2 +- .../icon/DropDownAndToggleButton.tsx | 1 - ts/components/icon/Icons.tsx | 2 + .../icon/MemberAvatarPlaceHolder.tsx | 1 - ts/components/icon/SessionIcon.tsx | 47 +- ts/components/icon/SessionIconButton.tsx | 8 +- ts/components/leftpane/ActionsPanel.tsx | 45 +- ts/components/leftpane/ContactListItem.tsx | 2 +- .../leftpane/LeftPaneMessageSection.tsx | 10 +- .../leftpane/LeftPaneSettingSection.tsx | 8 +- .../ConversationListItem.tsx | 15 +- .../conversation-list-item/HeaderItem.tsx | 2 +- .../leftpane/overlay/OverlayClosedGroup.tsx | 11 +- .../leftpane/overlay/OverlayCommunity.tsx | 15 +- .../leftpane/overlay/OverlayMessage.tsx | 24 +- .../overlay/OverlayMessageRequest.tsx | 2 +- .../overlay/SessionJoinableDefaultRooms.tsx | 5 +- .../overlay/choose-action/ContactRow.tsx | 2 +- .../choose-action/OverlayChooseAction.tsx | 43 +- ts/components/lightbox/Lightbox.tsx | 11 +- ts/components/lightbox/LightboxGallery.tsx | 23 +- ts/components/menu/ConversationHeaderMenu.tsx | 4 +- .../menu/ConversationListItemContextMenu.tsx | 5 +- ts/components/menu/Menu.tsx | 32 +- .../menu/MessageRequestBannerContextMenu.tsx | 4 +- .../registration/RegistrationStages.tsx | 17 +- .../registration/RegistrationUserDetails.tsx | 4 - ts/components/registration/SignInTab.tsx | 2 - ts/components/registration/SignUpTab.tsx | 4 +- ts/components/search/MessageSearchResults.tsx | 3 +- ts/components/search/SearchResults.tsx | 8 +- ts/components/settings/BlockedList.tsx | 2 - .../SessionNotificationGroupSettings.tsx | 4 +- .../settings/SessionSettingListItem.tsx | 3 +- ts/components/settings/SessionSettings.tsx | 11 +- .../settings/SettingsThemeSwitcher.tsx | 10 +- .../settings/ZoomingSessionSlider.tsx | 3 +- .../settings/section/CategoryAppearance.tsx | 2 +- .../section/CategoryConversations.tsx | 4 +- .../settings/section/CategoryPermissions.tsx | 3 +- .../settings/section/CategoryPrivacy.tsx | 7 +- ts/data/configDump/configDump.ts | 1 + ts/data/data.ts | 13 +- ts/data/dataInit.ts | 4 - ts/data/dataUtils.ts | 4 +- ts/data/opengroups.ts | 3 +- ts/hooks/useAppFocused.ts | 2 +- ts/hooks/useEncryptedFileFetch.ts | 25 +- ts/hooks/useFocusMount.ts | 2 +- ts/hooks/useModulo.ts | 2 +- ts/hooks/useParamSelector.ts | 2 +- ts/hooks/useSet.ts | 1 - ts/hooks/useVideoEventListener.ts | 9 +- ts/interactions/conversationInteractions.ts | 12 +- .../conversations/unsendingInteractions.ts | 34 +- ts/interactions/messageInteractions.ts | 1 - ts/mains/about_start.tsx | 1 - ts/mains/main_node.ts | 19 +- ts/mains/main_renderer.tsx | 30 +- ts/mains/password_start.tsx | 1 - ts/models/conversation.ts | 45 +- ts/models/message.ts | 72 +-- ts/models/messageFactory.ts | 1 + ts/node/attachment_channel.ts | 7 +- ts/node/config.ts | 6 +- ts/node/config/base_config.ts | 1 - ts/node/config/user_config.ts | 1 - ts/node/database_utility.ts | 7 +- ts/node/encrypt_attachment_buffer.ts | 3 - ts/node/global_errors.ts | 3 +- ts/node/locale.ts | 1 - ts/node/logging.ts | 5 +- ts/node/menu.ts | 8 +- ts/node/migration/sessionMigrations.ts | 29 +- ts/node/migration/signalMigrations.ts | 10 +- ts/node/permissions.ts | 3 +- ts/node/protocol_filter.ts | 3 +- ts/node/spell_check.ts | 2 - ts/node/sql.ts | 17 +- ts/node/sql_calls/config_dump.ts | 1 + ts/node/sql_channel.ts | 1 - ts/receiver/attachments.ts | 3 +- ts/receiver/cache.ts | 7 +- ts/receiver/closedGroups.ts | 30 +- ts/receiver/configMessage.ts | 8 +- ts/receiver/contentMessage.ts | 100 +-- ts/receiver/dataMessage.ts | 24 +- ts/receiver/queuedJob.ts | 8 +- ts/receiver/receiver.ts | 13 +- .../apis/file_server_api/FileServerApi.ts | 3 +- .../open_group_api/opengroupV2/ApiUtil.ts | 6 +- .../opengroupV2/JoinOpenGroupV2.ts | 7 +- .../opengroupV2/OpenGroupManagerV2.ts | 12 +- .../opengroupV2/OpenGroupPollingUtils.ts | 5 +- .../opengroupV2/OpenGroupServerPoller.ts | 9 +- .../opengroupV2/SogsFilterDuplicate.ts | 2 +- .../open_group_api/sogsv3/knownBlindedkeys.ts | 8 +- .../apis/open_group_api/sogsv3/sogsApiV3.ts | 17 +- .../open_group_api/sogsv3/sogsBlinding.ts | 14 +- .../open_group_api/sogsv3/sogsV3BatchPoll.ts | 3 +- .../sogsv3/sogsV3Capabilities.ts | 7 +- .../sogsv3/sogsV3ClearReaction.ts | 3 +- .../open_group_api/sogsv3/sogsV3FetchFile.ts | 2 +- .../sogsv3/sogsV3MutationCache.ts | 3 +- .../open_group_api/sogsv3/sogsV3RoomInfos.ts | 2 +- .../sogsv3/sogsV3SendMessage.ts | 2 +- .../sogsv3/sogsV3SendReaction.ts | 1 - .../open_group_api/utils/OpenGroupUtils.ts | 7 +- ts/session/apis/seed_node_api/SeedNodeAPI.ts | 10 +- ts/session/apis/snode_api/SNodeAPI.ts | 6 +- .../apis/snode_api/SnodeRequestTypes.ts | 4 +- ts/session/apis/snode_api/batchRequest.ts | 1 + ts/session/apis/snode_api/expire.ts | 2 + ts/session/apis/snode_api/getNetworkTime.ts | 1 - ts/session/apis/snode_api/hfHandling.ts | 3 +- ts/session/apis/snode_api/namespaces.ts | 2 + ts/session/apis/snode_api/onions.ts | 32 +- ts/session/apis/snode_api/onsResolve.ts | 2 +- ts/session/apis/snode_api/sessionRpc.ts | 8 +- ts/session/apis/snode_api/snodePool.ts | 9 +- ts/session/apis/snode_api/swarmPolling.ts | 11 +- ts/session/constants.ts | 3 - .../conversations/ConversationController.ts | 7 +- ts/session/conversations/createClosedGroup.ts | 76 +-- ts/session/crypto/BufferPadding.ts | 4 +- .../crypto/DecryptedAttachmentsManager.ts | 30 +- ts/session/crypto/MessageEncrypter.ts | 5 +- ts/session/crypto/index.ts | 11 +- ts/session/crypto/mnemonic.ts | 22 +- ts/session/group/closed-group.ts | 7 +- .../messages/incoming/IncomingMessage.ts | 5 +- .../outgoing/controlMessage/CallMessage.ts | 1 + .../DataExtractionNotificationMessage.ts | 4 +- .../controlMessage/MessageRequestResponse.ts | 1 - .../controlMessage/SharedConfigMessage.ts | 2 +- .../group/ClosedGroupAddedMembersMessage.ts | 1 - .../group/ClosedGroupEncryptionPairMessage.ts | 3 +- .../ClosedGroupEncryptionPairReplyMessage.ts | 2 +- .../group/ClosedGroupMemberLeftMessage.ts | 1 - .../group/ClosedGroupNameChangeMessage.ts | 1 - .../group/ClosedGroupRemovedMembersMessage.ts | 1 - .../ClosedGroupVisibleMessage.ts | 2 +- ts/session/onions/onionPath.ts | 29 +- ts/session/onions/onionSend.ts | 10 +- ts/session/onions/onionv4.ts | 2 +- ts/session/sending/MessageQueue.ts | 10 +- ts/session/sending/MessageSender.ts | 16 +- ts/session/sending/MessageSentHandler.ts | 1 - ts/session/sending/PendingMessageCache.ts | 10 +- ts/session/tslint.json | 7 - ts/session/types/PubKey.ts | 5 +- ts/session/utils/Attachments.ts | 3 +- ts/session/utils/AttachmentsDownload.ts | 16 +- ts/session/utils/AttachmentsV2.ts | 6 +- ts/session/utils/JobQueue.ts | 2 +- ts/session/utils/Messages.ts | 4 +- ts/session/utils/Performance.ts | 2 - ts/session/utils/Promise.ts | 18 +- ts/session/utils/TaskWithTimeout.ts | 7 +- ts/session/utils/User.ts | 2 +- ts/session/utils/calling/CallManager.ts | 63 +- ts/session/utils/job_runners/JobRunner.ts | 5 +- ts/session/utils/job_runners/PersistedJob.ts | 1 - .../job_runners/jobs/AvatarDownloadJob.ts | 13 +- .../job_runners/jobs/ConfigurationSyncJob.ts | 44 +- .../utils/libsession/libsession_utils.ts | 5 + .../libsession/libsession_utils_contacts.ts | 14 +- .../libsession_utils_convo_info_volatile.ts | 7 +- .../libsession_utils_user_groups.ts | 9 +- ts/session/utils/sync/syncUtils.ts | 9 +- ts/shims/events.ts | 1 - ts/state/actions.ts | 2 +- ts/state/createStore.ts | 20 +- ts/state/ducks/conversations.ts | 14 +- ts/state/ducks/defaultRooms.tsx | 2 +- ts/state/ducks/modalDialog.tsx | 3 +- ts/state/ducks/search.ts | 5 +- ts/state/ducks/section.tsx | 1 + ts/state/ducks/settings.tsx | 4 +- ts/state/ducks/sogsRoomInfo.tsx | 2 +- ts/state/ducks/stagedAttachments.ts | 2 +- ts/state/reducer.ts | 1 - ts/state/selectors/conversations.ts | 37 +- ts/state/selectors/messages.ts | 50 +- ts/state/selectors/onions.ts | 2 +- ts/state/selectors/search.ts | 2 +- ts/test/automation/create_user.spec.ts | 4 +- ts/test/automation/delete_account.spec.ts | 3 +- .../automation/disappearing_messages.spec.ts | 2 - ts/test/automation/linked_device_user.spec.ts | 1 - ts/test/automation/message_checks.spec.ts | 1 + ts/test/automation/password.spec.ts | 1 - ts/test/automation/setup/beforeEach.ts | 3 +- ts/test/automation/setup/create_group.ts | 2 +- ts/test/automation/setup/new_user.ts | 4 +- ts/test/automation/setup/open.ts | 1 - .../automation/setup/recovery_using_seed.ts | 2 +- ts/test/automation/setup/sessionTest.ts | 2 + ts/test/automation/setup/test_user.ts | 2 - ts/test/automation/tslint.json | 10 - ts/test/automation/user_actions.spec.ts | 4 +- ts/test/automation/utilities/leave_group.ts | 2 +- ts/test/automation/utilities/linked_device.ts | 1 - ts/test/automation/utilities/message.ts | 3 +- ts/test/automation/utilities/rename_group.ts | 2 +- ts/test/automation/utilities/send_message.ts | 2 +- ts/test/automation/utilities/utils.ts | 14 +- .../media-gallery/groupMessagesByDate_test.ts | 1 - .../unit/crypto/MessageEncrypter_test.ts | 11 +- .../crypto/OpenGroupAuthentication_test.ts | 15 +- .../decryptedAttachmentsManager_test.ts | 4 +- .../libsession_wrapper_contacts_test.ts | 3 - .../libsession_wrapper_test.ts | 4 +- .../libsession_wrapper_usergroups_test.ts | 3 - .../session/unit/messages/ChatMessage_test.ts | 22 +- .../messages/ConfigurationMessage_test.ts | 1 - .../messages/MessageRequestResponse_test.ts | 2 - .../unit/messages/ReceiptMessage_test.ts | 2 +- .../unit/messages/TypingMessage_test.ts | 2 +- .../unit/models/ConversationModels_test.ts | 3 - .../models/formatRowOfConversation_test.ts | 3 - ts/test/session/unit/onion/GuardNodes_test.ts | 9 +- .../session/unit/onion/OnionErrors_test.ts | 29 +- ts/test/session/unit/onion/OnionPaths_test.ts | 7 +- .../session/unit/onion/SeedNodeAPI_test.ts | 8 +- .../session/unit/onion/SnodeNamespace_test.ts | 1 - .../unit/onion/SnodePoolUpdate_test.ts | 8 +- ts/test/session/unit/onion/hfHandling_test.ts | 2 - ts/test/session/unit/padding/Padding_test.ts | 8 +- ts/test/session/unit/privacy/Privacy_test.ts | 3 +- .../unit/reactions/ReactionMessage_test.ts | 12 +- .../receiver/opengroup/deduplicate_test.ts | 3 - .../receiving/ConfigurationMessage_test.ts | 8 +- .../unit/selectors/conversations_test.ts | 2 - .../session/unit/sending/MessageQueue_test.ts | 15 +- .../unit/sending/MessageSender_test.ts | 2 - .../unit/sending/PendingMessageCache_test.ts | 6 +- ts/test/session/unit/sogsv3/ApiUtil_test.ts | 3 +- .../unit/sogsv3/FetchCapabilities_test.ts | 3 - .../session/unit/sogsv3/MutationCache_test.ts | 4 +- .../unit/sogsv3/knownBlindedKeys_test.ts | 4 +- .../unit/swarm_polling/SwarmPolling_test.ts | 5 - ts/test/session/unit/updater/updater_test.ts | 1 - ts/test/session/unit/utils/JobQueue_test.ts | 5 +- ts/test/session/unit/utils/Messages_test.ts | 19 +- .../session/unit/utils/OpenGroupUtils_test.ts | 4 +- ts/test/session/unit/utils/Promise_test.ts | 10 +- ts/test/session/unit/utils/RingBuffer_test.ts | 2 - ts/test/session/unit/utils/String_test.ts | 32 +- .../unit/utils/TaskWithTimeout_test.ts | 8 +- .../unit/utils/job_runner/JobRunner_test.ts | 22 +- .../stubs/sending/PendingMessageCacheStub.ts | 5 +- ts/test/test-utils/utils/envelope.ts | 5 +- ts/test/test-utils/utils/message.ts | 3 +- ts/test/test-utils/utils/pubkey.ts | 2 - ts/test/test-utils/utils/stubbing.ts | 9 +- ts/test/test-utils/utils/timeout.ts | 5 +- ts/test/tslint.json | 12 - ts/test/types/Attachment_test.ts | 1 - ts/test/types/Settings_test.ts | 3 +- .../initializeAttachmentMetadata_test.ts | 52 +- ts/test/util/blockedNumberController_test.ts | 9 +- ts/themes/SessionTheme.tsx | 2 +- ts/themes/constants/colors.tsx | 1 - ts/themes/globals.tsx | 1 + ts/themes/oceanDark.ts | 1 - ts/themes/oceanLight.ts | 1 - ts/themes/variableColors.tsx | 5 +- ts/types/Attachment.ts | 9 +- ts/types/MessageAttachment.ts | 2 - ts/types/attachments/VisualAttachment.ts | 68 ++- ts/types/attachments/migrations.ts | 21 +- .../message/initializeAttachmentMetadata.ts | 2 +- ts/types/sqlSharedTypes.ts | 8 +- ts/updater/index.ts | 4 +- ts/updater/updater.ts | 16 +- ts/util/abbreviateNumber.ts | 4 +- ts/util/accountManager.ts | 6 +- ts/util/attachmentsUtil.ts | 21 +- ts/util/attachments_files.ts | 4 - ts/util/blockedNumberController.ts | 2 +- ts/util/crypto/attachmentsEncrypter.ts | 23 +- ts/util/crypto/profileEncrypter.ts | 3 +- ts/util/emoji.ts | 16 +- ts/util/expiringMessages.ts | 8 +- ts/util/i18n.ts | 8 +- ts/util/index.ts | 10 +- ts/util/linkPreviewFetch.ts | 1 - ts/util/linkPreviews.ts | 1 + ts/util/makeLookup.ts | 9 - ts/util/notifications.ts | 1 - ts/util/privacy.ts | 1 - ts/util/reactions.ts | 39 +- ts/util/readReceipts.ts | 1 - ts/util/releaseFeature.ts | 2 + ts/util/saveQRCode.ts | 1 - ts/util/storage.ts | 7 +- ts/webworker/worker_interface.ts | 3 +- .../browser/libsession_worker_interface.ts | 10 +- .../workers/browser/util_worker_interface.ts | 2 +- ts/webworker/workers/index.ts | 1 + .../node/libsession/libsession.worker.ts | 6 +- ts/webworker/workers/node/util/util.worker.ts | 10 +- ts/window.d.ts | 9 +- tslint.json | 99 --- utils.worker.config.js | 1 + yarn.lock | 571 +++++++++++++----- 406 files changed, 2437 insertions(+), 2466 deletions(-) delete mode 100644 ts/components/dialog/SessionModal.tsx delete mode 100644 ts/session/tslint.json delete mode 100644 ts/test/automation/tslint.json delete mode 100644 ts/test/tslint.json delete mode 100644 ts/util/makeLookup.ts delete mode 100644 tslint.json diff --git a/.eslintignore b/.eslintignore index 34c660b798..23d7f95896 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,5 +1,4 @@ build/** -components/** dist/** mnemonic_languages/** @@ -13,3 +12,5 @@ ts/**/*.js playwright.config.js preload.js stylesheets/dist/ +compiled.d.ts +.eslintrc.js \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js index a01420ef15..27afc3b430 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,13 +1,23 @@ -// For reference: https://github.com/airbnb/javascript - module.exports = { + root: true, settings: { 'import/core-modules': ['electron'], + react: { + version: 'detect', + }, }, - extends: ['airbnb-base', 'prettier'], + extends: [ + 'airbnb-base', + 'prettier', + 'plugin:@typescript-eslint/recommended', + 'plugin:react/recommended', + 'plugin:react-hooks/recommended', + ], - plugins: ['mocha', 'more'], + plugins: ['mocha', 'more', '@typescript-eslint'], + parser: '@typescript-eslint/parser', + parserOptions: { project: ['tsconfig.json'] }, rules: { 'comma-dangle': [ @@ -47,10 +57,38 @@ module.exports = { 'linebreak-style': ['error', 'unix'], quotes: ['error', 'single', { avoidEscape: true, allowTemplateLiterals: true }], + '@typescript-eslint/no-floating-promises': ['error'], + '@typescript-eslint/await-thenable': 'error', + '@typescript-eslint/array-type': ['error', { default: 'generic' }], + '@typescript-eslint/no-misused-promises': 'error', // Prettier overrides: 'arrow-parens': 'off', + 'no-nested-ternary': 'off', 'function-paren-newline': 'off', + + 'import/prefer-default-export': 'off', + 'operator-linebreak': 'off', + 'prefer-destructuring': 'off', + 'max-classes-per-file': 'off', + 'lines-between-class-members': 'off', + '@typescript-eslint/no-explicit-any': 'off', // to reenable later + 'arrow-body-style': 'off', + 'no-plusplus': 'off', + 'no-continue': 'off', + 'no-void': 'off', + 'default-param-last': 'off', + + 'no-shadow': 'off', + '@typescript-eslint/no-shadow': 'error', + 'class-methods-use-this': 'off', + camelcase: 'off', + + 'no-unused-vars': 'off', + '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], + // 'no-unused-expressions': 'off', + // '@typescript-eslint/no-unused-expressions': 'error', + 'max-len': [ 'error', { @@ -59,10 +97,28 @@ module.exports = { // high value as a buffer to let Prettier control the line length: code: 999, // We still want to limit comments as before: - comments: 150, + comments: 200, ignoreUrls: true, ignoreRegExpLiterals: true, }, ], }, + overrides: [ + { + files: ['*_test.ts'], + rules: { + 'no-unused-expressions': 'off', + 'no-await-in-loop': 'off', + 'no-empty': 'off', + }, + }, + { + files: ['ts/state/ducks/*.tsx', 'ts/state/ducks/*.ts'], + rules: { 'no-param-reassign': ['error', { props: false }] }, + }, + { + files: ['ts/node/**/*.ts', 'ts/test/**/*.ts'], + rules: { 'no-console': 'off' }, + }, + ], }; diff --git a/about_preload.js b/about_preload.js index 6c72bee6d0..27f48d231e 100644 --- a/about_preload.js +++ b/about_preload.js @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ /* global window */ const { ipcRenderer } = require('electron'); diff --git a/debug_log_preload.js b/debug_log_preload.js index 9321a01a9a..d5af17afe3 100644 --- a/debug_log_preload.js +++ b/debug_log_preload.js @@ -1,4 +1,5 @@ /* global window */ +/* eslint-disable @typescript-eslint/no-var-requires */ const { ipcRenderer } = require('electron'); const url = require('url'); diff --git a/libsession.worker.config.js b/libsession.worker.config.js index 44f78c29d7..fe1741bea8 100644 --- a/libsession.worker.config.js +++ b/libsession.worker.config.js @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ const path = require('path'); module.exports = { diff --git a/package.json b/package.json index b548351496..40cae5167d 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "protobuf": "pbjs --target static-module --wrap commonjs --out ts/protobuf/compiled.js protos/*.proto && pbts --out ts/protobuf/compiled.d.ts ts/protobuf/compiled.js --force-long", "sass": "rimraf 'stylesheets/dist/' && webpack --config=./sass.config.js", "clean": "rimraf 'ts/**/*.js' 'ts/*.js' 'ts/*.js.map' 'ts/**/*.js.map' && rimraf tsconfig.tsbuildinfo;", - "lint-full": "yarn format-full && eslint . && tslint --format stylish --project .", + "lint-full": "yarn format-full && eslint .", "format-full": "prettier --list-different --write \"*.{css,js,json,scss,ts,tsx}\" \"./**/*.{css,js,json,scss,ts,tsx}\"", "integration-test": "npx playwright test", "start-prod-test": "cross-env NODE_ENV=production NODE_APP_INSTANCE=$MULTI electron .", @@ -178,6 +178,8 @@ "@types/sinon": "9.0.4", "@types/styled-components": "^5.1.4", "@types/uuid": "8.3.4", + "@typescript-eslint/eslint-plugin": "^6.1.0", + "@typescript-eslint/parser": "^6.1.0", "asar": "3.1.0", "buffer": "^6.0.3", "chai": "^4.3.4", @@ -191,12 +193,14 @@ "electron": "25.3.0", "electron-builder": "23.0.8", "esbuild": "^0.14.29", - "eslint": "^8.15.0", + "eslint": "^8.45.0", "eslint-config-airbnb-base": "^15.0.0", "eslint-config-prettier": "^8.8.0", "eslint-plugin-import": "^2.27.5", "eslint-plugin-mocha": "^10.1.0", "eslint-plugin-more": "^1.0.5", + "eslint-plugin-react": "^7.33.0", + "eslint-plugin-react-hooks": "^4.6.0", "events": "^3.3.0", "jsdom": "^19.0.0", "jsdom-global": "^3.0.2", @@ -219,10 +223,7 @@ "style-loader": "^3.3.1", "ts-loader": "^9.4.2", "ts-mock-imports": "^1.3.0", - "tslint": "5.19.0", - "tslint-microsoft-contrib": "6.0.0", - "tslint-react": "3.6.0", - "typescript": "^4.6.3", + "typescript": "^5.1.6", "webpack": "^5.76.3", "webpack-cli": "^5.0.1" }, diff --git a/password_preload.js b/password_preload.js index 7463ad9b0a..ed8262bc39 100644 --- a/password_preload.js +++ b/password_preload.js @@ -1,4 +1,5 @@ /* global window */ +/* eslint-disable @typescript-eslint/no-var-requires */ const { ipcRenderer } = require('electron'); const url = require('url'); diff --git a/playwright.config.ts b/playwright.config.ts index dd2a231dd4..e5f200855e 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -1,4 +1,5 @@ -// tslint:disable-next-line: no-implicit-dependencies +/* eslint-disable import/no-extraneous-dependencies */ +/* eslint-disable import/no-import-module-exports */ import { PlaywrightTestConfig } from '@playwright/test'; import { toNumber } from 'lodash'; diff --git a/preload.js b/preload.js index 37d5765e0d..3ddc14cc43 100644 --- a/preload.js +++ b/preload.js @@ -1,3 +1,4 @@ +// eslint:disable: no-require-imports no-var-requires const { clipboard, ipcRenderer, webFrame } = require('electron/main'); const { Storage } = require('./ts/util/storage'); @@ -15,7 +16,6 @@ if (config.environment !== 'production') { if (config.appInstance) { title += ` - ${config.appInstance}`; } -// tslint:disable: no-require-imports no-var-requires window.platform = process.platform; window.getTitle = () => title; @@ -240,7 +240,6 @@ const { getConversationController } = require('./ts/session/conversations/Conver window.getConversationController = getConversationController; // Linux seems to periodically let the event loop stop, so this is a global workaround setInterval(() => { - // tslint:disable-next-line: no-empty window.nodeSetImmediate(() => {}); }, 1000); diff --git a/sass.config.js b/sass.config.js index 9c689eb4ed..ff48bd5ec5 100644 --- a/sass.config.js +++ b/sass.config.js @@ -1,9 +1,9 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +/* eslint-disable import/no-extraneous-dependencies */ const path = require('path'); -// eslint-disable-next-line import/no-extraneous-dependencies const sass = require('sass'); // Prefer `dart-sass` -// eslint-disable-next-line import/no-extraneous-dependencies const MiniCssExtractPlugin = require('mini-css-extract-plugin'); module.exports = { diff --git a/ts/components/AboutView.tsx b/ts/components/AboutView.tsx index bea3ff915b..abffacdd11 100644 --- a/ts/components/AboutView.tsx +++ b/ts/components/AboutView.tsx @@ -40,7 +40,7 @@ export const AboutView = () => { theme: window.theme, }); } - }, [window.theme]); + }, []); return ( diff --git a/ts/components/CaptionEditor.tsx b/ts/components/CaptionEditor.tsx index e3ea2b0bf3..20e51b2cef 100644 --- a/ts/components/CaptionEditor.tsx +++ b/ts/components/CaptionEditor.tsx @@ -1,5 +1,3 @@ -// tslint:disable:react-a11y-anchors - import React from 'react'; import * as GoogleChrome from '../util/GoogleChrome'; diff --git a/ts/components/DebugLogView.tsx b/ts/components/DebugLogView.tsx index ee8a87317f..3caa50b485 100644 --- a/ts/components/DebugLogView.tsx +++ b/ts/components/DebugLogView.tsx @@ -48,7 +48,6 @@ const StyledContent = styled.div` `; const DebugLogTextArea = (props: { content: string }) => { - // tslint:disable-next-line: react-a11y-input-elements return