From 349c2c2587c2885bb69eda4aa078b5383724cf5e Mon Sep 17 00:00:00 2001 From: Michael Weimann Date: Fri, 9 Dec 2022 09:38:20 +0100 Subject: [PATCH] Apply prettier formatting --- .babelrc | 15 +- .eslintrc.js | 156 +- .github/PULL_REQUEST_TEMPLATE.md | 6 +- .github/renovate.json | 6 +- .github/workflows/backport.yml | 52 +- .github/workflows/docs-pr-netlify.yaml | 56 +- .github/workflows/notify-downstream.yaml | 44 +- .github/workflows/pull_request.yaml | 164 +- .github/workflows/release-npm.yml | 66 +- .github/workflows/release.yml | 108 +- .github/workflows/sonarcloud.yml | 88 +- .github/workflows/sonarqube.yml | 74 +- .github/workflows/static_analysis.yml | 112 +- .github/workflows/tests.yml | 100 +- .github/workflows/upgrade_dependencies.yml | 64 +- CHANGELOG.md | 8015 +++++++++-------- CONTRIBUTING.md | 4 +- README.md | 295 +- docs/storage-notes.md | 54 +- examples/browser/README.md | 2 +- examples/browser/browserTest.js | 2 +- examples/browser/index.html | 31 +- .../olm-device-export-import.html | 99 +- .../olm-device-export-import.js | 115 +- examples/node/README.md | 3 +- examples/node/app.js | 292 +- examples/node/package.json | 24 +- examples/voip/README.md | 2 +- examples/voip/browserTest.js | 49 +- examples/voip/index.html | 40 +- package.json | 284 +- scripts/switch_package_to_release.js | 12 +- spec/TestClient.ts | 86 +- spec/browserify/sync-browserify.spec.ts | 8 +- spec/integ/devicelist-integ.spec.ts | 472 +- spec/integ/matrix-client-crypto.spec.ts | 175 +- .../integ/matrix-client-event-emitter.spec.ts | 170 +- .../matrix-client-event-timeline.spec.ts | 1092 +-- spec/integ/matrix-client-methods.spec.ts | 1395 +-- spec/integ/matrix-client-opts.spec.ts | 118 +- spec/integ/matrix-client-relations.spec.ts | 75 +- spec/integ/matrix-client-retrying.spec.ts | 108 +- .../integ/matrix-client-room-timeline.spec.ts | 600 +- spec/integ/matrix-client-syncing.spec.ts | 1163 +-- spec/integ/megolm-backup.spec.ts | 127 +- spec/integ/megolm-integ.spec.ts | 752 +- spec/integ/sliding-sync-sdk.spec.ts | 207 +- spec/integ/sliding-sync.spec.ts | 1340 +-- spec/olm-loader.ts | 6 +- spec/slowReporter.js | 6 +- spec/test-utils/beacon.ts | 33 +- spec/test-utils/client.ts | 5 +- spec/test-utils/flushPromises.ts | 2 +- spec/test-utils/test-utils.ts | 42 +- spec/test-utils/thread.ts | 68 +- spec/test-utils/webrtc.ts | 211 +- spec/unit/ReEmitter.spec.ts | 16 +- spec/unit/autodiscovery.spec.ts | 697 +- spec/unit/content-helpers.spec.ts | 208 +- spec/unit/content-repo.spec.ts | 72 +- spec/unit/crypto.spec.ts | 543 +- spec/unit/crypto/CrossSigningInfo.spec.ts | 224 +- spec/unit/crypto/DeviceList.spec.ts | 170 +- spec/unit/crypto/algorithms/megolm.spec.ts | 737 +- spec/unit/crypto/algorithms/olm.spec.ts | 116 +- spec/unit/crypto/backup.spec.ts | 420 +- spec/unit/crypto/cross-signing.spec.ts | 402 +- spec/unit/crypto/crypto-utils.ts | 18 +- spec/unit/crypto/dehydration.spec.ts | 55 +- .../crypto/outgoing-room-key-requests.spec.ts | 72 +- spec/unit/crypto/secrets.spec.ts | 300 +- .../crypto/verification/InRoomChannel.spec.ts | 41 +- spec/unit/crypto/verification/qr_code.spec.ts | 6 +- spec/unit/crypto/verification/request.spec.ts | 14 +- spec/unit/crypto/verification/sas.spec.ts | 203 +- .../verification/secret_request.spec.ts | 41 +- .../setDeviceVerification.spec.ts | 10 +- spec/unit/crypto/verification/util.ts | 73 +- .../verification/verification_request.spec.ts | 131 +- spec/unit/embedded.spec.ts | 40 +- spec/unit/event-mapper.spec.ts | 6 +- spec/unit/event-timeline-set.spec.ts | 146 +- spec/unit/event-timeline.spec.ts | 377 +- spec/unit/filter-component.spec.ts | 106 +- spec/unit/filter.spec.ts | 22 +- spec/unit/http-api/fetch.spec.ts | 23 +- spec/unit/http-api/index.spec.ts | 16 +- spec/unit/http-api/utils.spec.ts | 188 +- spec/unit/interactive-auth.spec.ts | 153 +- spec/unit/local_notifications.spec.ts | 6 +- spec/unit/location.spec.ts | 33 +- spec/unit/login.spec.ts | 38 +- spec/unit/matrix-client.spec.ts | 546 +- spec/unit/models/MSC3089Branch.spec.ts | 162 +- spec/unit/models/MSC3089TreeSpace.spec.ts | 377 +- spec/unit/models/beacon.spec.ts | 255 +- spec/unit/models/event.spec.ts | 25 +- spec/unit/models/thread.spec.ts | 20 +- spec/unit/notifications.spec.ts | 21 +- spec/unit/pusher.spec.ts | 6 +- spec/unit/pushprocessor.spec.ts | 373 +- spec/unit/queueToDevice.spec.ts | 156 +- spec/unit/read-receipt.spec.ts | 128 +- spec/unit/realtime-callbacks.spec.ts | 36 +- spec/unit/relations.spec.ts | 98 +- spec/unit/rendezvous/DummyTransport.ts | 14 +- spec/unit/rendezvous/ecdh.spec.ts | 52 +- spec/unit/rendezvous/rendezvous.spec.ts | 170 +- .../rendezvous/simpleHttpTransport.spec.ts | 131 +- spec/unit/room-member.spec.ts | 291 +- spec/unit/room-state.spec.ts | 803 +- spec/unit/room.spec.ts | 2167 +++-- spec/unit/scheduler.spec.ts | 370 +- spec/unit/stores/indexeddb.spec.ts | 9 +- spec/unit/sync-accumulator.spec.ts | 329 +- spec/unit/timeline-window.spec.ts | 150 +- spec/unit/user.spec.ts | 34 +- spec/unit/utils.spec.ts | 313 +- spec/unit/webrtc/call.spec.ts | 751 +- spec/unit/webrtc/callEventHandler.spec.ts | 99 +- spec/unit/webrtc/groupCall.spec.ts | 414 +- .../unit/webrtc/groupCallEventHandler.spec.ts | 78 +- spec/unit/webrtc/mediaHandler.spec.ts | 120 +- src/@types/PushRules.ts | 29 +- src/@types/beacon.ts | 9 +- src/@types/event.ts | 28 +- src/@types/global.d.ts | 28 +- src/@types/location.ts | 11 +- src/@types/partials.ts | 3 +- src/@types/read_receipts.ts | 2 +- src/@types/sync.ts | 3 +- src/@types/uia.ts | 2 +- src/NamespacedValue.ts | 3 +- src/ReEmitter.ts | 7 +- src/ToDeviceMessageQueue.ts | 8 +- src/autodiscovery.ts | 39 +- src/client.ts | 1850 ++-- src/content-helpers.ts | 40 +- src/content-repo.ts | 6 +- src/crypto/CrossSigning.ts | 154 +- src/crypto/DeviceList.ts | 271 +- src/crypto/EncryptionSetup.ts | 47 +- src/crypto/OlmDevice.ts | 691 +- src/crypto/OutgoingRoomKeyRequestManager.ts | 180 +- src/crypto/RoomList.ts | 24 +- src/crypto/SecretStorage.ts | 87 +- src/crypto/aes.ts | 41 +- src/crypto/algorithms/base.ts | 20 +- src/crypto/algorithms/megolm.ts | 531 +- src/crypto/algorithms/olm.ts | 144 +- src/crypto/backup.ts | 158 +- src/crypto/dehydration.ts | 104 +- src/crypto/deviceinfo.ts | 4 +- src/crypto/index.ts | 851 +- src/crypto/key_passphrase.ts | 24 +- src/crypto/olmlib.ts | 116 +- src/crypto/recoverykey.ts | 18 +- src/crypto/store/base.ts | 13 +- .../store/indexeddb-crypto-store-backend.ts | 229 +- src/crypto/store/indexeddb-crypto-store.ts | 141 +- src/crypto/store/localStorage-crypto-store.ts | 89 +- src/crypto/store/memory-crypto-store.ts | 58 +- src/crypto/verification/Base.ts | 55 +- src/crypto/verification/Error.ts | 18 +- src/crypto/verification/QRCode.ts | 13 +- src/crypto/verification/SAS.ts | 259 +- src/crypto/verification/SASDecimal.ts | 6 +- .../verification/request/InRoomChannel.ts | 31 +- .../verification/request/ToDeviceChannel.ts | 30 +- .../request/VerificationRequest.ts | 105 +- src/embedded.ts | 68 +- src/errors.ts | 8 +- src/event-mapper.ts | 13 +- src/feature.ts | 9 +- src/filter-component.ts | 55 +- src/filter.ts | 22 +- src/http-api/fetch.ts | 24 +- src/http-api/index.ts | 32 +- src/index.ts | 1 - src/indexeddb-worker.ts | 1 - src/interactive-auth.ts | 25 +- src/logger.ts | 12 +- src/matrix.ts | 29 +- src/models/MSC3089Branch.ts | 72 +- src/models/MSC3089TreeSpace.ts | 121 +- src/models/beacon.ts | 42 +- src/models/event-timeline-set.ts | 124 +- src/models/event-timeline.ts | 44 +- src/models/event.ts | 132 +- src/models/invites-ignorer.ts | 53 +- src/models/read-receipt.ts | 39 +- src/models/related-relations.ts | 6 +- src/models/relations-container.ts | 20 +- src/models/relations.ts | 4 +- src/models/room-member.ts | 17 +- src/models/room-state.ts | 57 +- src/models/room-summary.ts | 1 - src/models/room.ts | 628 +- src/models/search-result.ts | 6 +- src/models/thread.ts | 122 +- src/models/typed-event-emitter.ts | 25 +- src/models/user.ts | 12 +- src/pushprocessor.ts | 91 +- src/realtime-callbacks.ts | 15 +- src/rendezvous/MSC3906Rendezvous.ts | 54 +- src/rendezvous/RendezvousChannel.ts | 6 +- src/rendezvous/RendezvousFailureReason.ts | 22 +- src/rendezvous/RendezvousIntent.ts | 4 +- src/rendezvous/RendezvousTransport.ts | 64 +- .../MSC3903ECDHv1RendezvousChannel.ts | 54 +- src/rendezvous/channels/index.ts | 3 +- src/rendezvous/index.ts | 14 +- .../MSC3886SimpleHttpRendezvousTransport.ts | 50 +- src/rendezvous/transports/index.ts | 2 +- src/room-hierarchy.ts | 17 +- src/scheduler.ts | 73 +- src/service-types.ts | 4 +- src/sliding-sync-sdk.ts | 195 +- src/sliding-sync.ts | 83 +- src/store/index.ts | 18 +- src/store/indexeddb-local-backend.ts | 92 +- src/store/indexeddb-remote-backend.ts | 44 +- src/store/indexeddb-store-worker.ts | 77 +- src/store/indexeddb.ts | 52 +- src/store/local-storage-events-emitter.ts | 12 +- src/store/memory.ts | 7 +- src/sync-accumulator.ts | 79 +- src/sync.ts | 534 +- src/timeline-window.ts | 78 +- src/utils.ts | 85 +- src/webrtc/call.ts | 518 +- src/webrtc/callEventHandler.ts | 76 +- src/webrtc/callEventTypes.ts | 4 +- src/webrtc/callFeed.ts | 6 +- src/webrtc/groupCall.ts | 308 +- src/webrtc/groupCallEventHandler.ts | 33 +- src/webrtc/mediaHandler.ts | 57 +- tsconfig-build.json | 22 +- tsconfig.json | 37 +- 239 files changed, 22143 insertions(+), 22067 deletions(-) diff --git a/.babelrc b/.babelrc index 6f4f54a93f1..6e6720bbf11 100644 --- a/.babelrc +++ b/.babelrc @@ -1,12 +1,15 @@ { "sourceMaps": true, "presets": [ - ["@babel/preset-env", { - "targets": { - "node": 10 - }, - "modules": "commonjs" - }], + [ + "@babel/preset-env", + { + "targets": { + "node": 10 + }, + "modules": "commonjs" + } + ], "@babel/preset-typescript" ], "plugins": [ diff --git a/.eslintrc.js b/.eslintrc.js index c73e8a44d3f..fd77e6c5e42 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,13 +1,6 @@ module.exports = { - plugins: [ - "matrix-org", - "import", - "jsdoc", - ], - extends: [ - "plugin:matrix-org/babel", - "plugin:import/typescript", - ], + plugins: ["matrix-org", "import", "jsdoc"], + extends: ["plugin:matrix-org/babel", "plugin:import/typescript"], env: { browser: true, node: true, @@ -28,12 +21,15 @@ module.exports = { "padded-blocks": ["error"], "no-extend-native": ["error"], "camelcase": ["error"], - "no-multi-spaces": ["error", { "ignoreEOLComments": true }], - "space-before-function-paren": ["error", { - "anonymous": "never", - "named": "never", - "asyncArrow": "always", - }], + "no-multi-spaces": ["error", { ignoreEOLComments: true }], + "space-before-function-paren": [ + "error", + { + anonymous: "never", + named: "never", + asyncArrow: "always", + }, + ], "arrow-parens": "off", "prefer-promise-reject-errors": "off", "no-constant-condition": "off", @@ -42,76 +38,78 @@ module.exports = { "no-console": "error", // restrict EventEmitters to force callers to use TypedEventEmitter - "no-restricted-imports": ["error", { - name: "events", - message: "Please use TypedEventEmitter instead", - }], - - "import/no-restricted-paths": ["error", { - "zones": [{ - "target": "./src/", - "from": "./src/index.ts", - "message": "The package index is dynamic between src and lib depending on " + - "whether release or development, target the specific module or matrix.ts instead", - }], - }], - }, - overrides: [{ - files: [ - "**/*.ts", - ], - plugins: [ - "eslint-plugin-tsdoc", + "no-restricted-imports": [ + "error", + { + name: "events", + message: "Please use TypedEventEmitter instead", + }, ], - extends: [ - "plugin:matrix-org/typescript", - ], - rules: { - // TypeScript has its own version of this - "@babel/no-invalid-this": "off", - // We're okay being explicit at the moment - "@typescript-eslint/no-empty-interface": "off", - // We disable this while we're transitioning - "@typescript-eslint/no-explicit-any": "off", - // We'd rather not do this but we do - "@typescript-eslint/ban-ts-comment": "off", - // We're okay with assertion errors when we ask for them - "@typescript-eslint/no-non-null-assertion": "off", + "import/no-restricted-paths": [ + "error", + { + zones: [ + { + target: "./src/", + from: "./src/index.ts", + message: + "The package index is dynamic between src and lib depending on " + + "whether release or development, target the specific module or matrix.ts instead", + }, + ], + }, + ], + }, + overrides: [ + { + files: ["**/*.ts"], + plugins: ["eslint-plugin-tsdoc"], + extends: ["plugin:matrix-org/typescript"], + rules: { + // TypeScript has its own version of this + "@babel/no-invalid-this": "off", - // The non-TypeScript rule produces false positives - "func-call-spacing": "off", - "@typescript-eslint/func-call-spacing": ["error"], + // We're okay being explicit at the moment + "@typescript-eslint/no-empty-interface": "off", + // We disable this while we're transitioning + "@typescript-eslint/no-explicit-any": "off", + // We'd rather not do this but we do + "@typescript-eslint/ban-ts-comment": "off", + // We're okay with assertion errors when we ask for them + "@typescript-eslint/no-non-null-assertion": "off", - "quotes": "off", - // We use a `logger` intermediary module - "no-console": "error", + // The non-TypeScript rule produces false positives + "func-call-spacing": "off", + "@typescript-eslint/func-call-spacing": ["error"], + "quotes": "off", + // We use a `logger` intermediary module + "no-console": "error", + }, }, - }, { - // We don't need amazing docs in our spec files - files: [ - "src/**/*.ts", - ], - rules: { - "tsdoc/syntax": "error", - // We use some select jsdoc rules as the tsdoc linter has only one rule - "jsdoc/no-types": "error", - "jsdoc/empty-tags": "error", - "jsdoc/check-property-names": "error", - "jsdoc/check-values": "error", - // These need a bit more work before we can enable - // "jsdoc/check-param-names": "error", - // "jsdoc/check-indentation": "error", + { + // We don't need amazing docs in our spec files + files: ["src/**/*.ts"], + rules: { + "tsdoc/syntax": "error", + // We use some select jsdoc rules as the tsdoc linter has only one rule + "jsdoc/no-types": "error", + "jsdoc/empty-tags": "error", + "jsdoc/check-property-names": "error", + "jsdoc/check-values": "error", + // These need a bit more work before we can enable + // "jsdoc/check-param-names": "error", + // "jsdoc/check-indentation": "error", + }, }, - }, { - files: [ - "spec/**/*.ts", - ], - rules: { - // We don't need super strict typing in test utilities - "@typescript-eslint/explicit-function-return-type": "off", - "@typescript-eslint/explicit-member-accessibility": "off", + { + files: ["spec/**/*.ts"], + rules: { + // We don't need super strict typing in test utilities + "@typescript-eslint/explicit-function-return-type": "off", + "@typescript-eslint/explicit-member-accessibility": "off", + }, }, - }], + ], }; diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index c0b7939a69b..bbaaa050791 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -2,9 +2,9 @@ ## Checklist -* [ ] Tests written for new code (and old code if feasible) -* [ ] Linter and other CI checks pass -* [ ] Sign-off given on the changes (see [CONTRIBUTING.md](https://github.com/matrix-org/matrix-js-sdk/blob/develop/CONTRIBUTING.md)) +- [ ] Tests written for new code (and old code if feasible) +- [ ] Linter and other CI checks pass +- [ ] Sign-off given on the changes (see [CONTRIBUTING.md](https://github.com/matrix-org/matrix-js-sdk/blob/develop/CONTRIBUTING.md))