Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Mandate use of js-sdk/src/matrix import over js-sdk/src #7933

Merged
merged 6 commits into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,36 @@ module.exports = {
),
],

// Ban matrix-js-sdk/src imports in favour of matrix-js-sdk/src/matrix imports to prevent unleashing hell.
"no-restricted-imports": ["error", {
t3chguy marked this conversation as resolved.
Show resolved Hide resolved
"paths": [{
"name": "matrix-js-sdk",
"message": "Please use matrix-js-sdk/src/matrix instead",
}, {
"name": "matrix-js-sdk/",
"message": "Please use matrix-js-sdk/src/matrix instead",
}, {
"name": "matrix-js-sdk/src",
"message": "Please use matrix-js-sdk/src/matrix instead",
}, {
"name": "matrix-js-sdk/src/",
"message": "Please use matrix-js-sdk/src/matrix instead",
}, {
"name": "matrix-js-sdk/src/index",
"message": "Please use matrix-js-sdk/src/matrix instead",
}, {
"name": "matrix-react-sdk",
"message": "Please use matrix-react-sdk/src/index instead",
}, {
"name": "matrix-react-sdk/",
"message": "Please use matrix-react-sdk/src/index instead",
}],
"patterns": [{
"group": ["matrix-js-sdk/lib", "matrix-js-sdk/lib/", "matrix-js-sdk/lib/**"],
"message": "Please use matrix-js-sdk/src/* instead",
}],
}],

// There are too many a11y violations to fix at once
// Turn violated rules off until they are fixed
"jsx-a11y/alt-text": "off",
Expand Down
2 changes: 1 addition & 1 deletion src/AddThreepid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { IRequestMsisdnTokenResponse, IRequestTokenResponse } from "matrix-js-sdk/src";
import { IRequestMsisdnTokenResponse, IRequestTokenResponse } from "matrix-js-sdk/src/matrix";

import { MatrixClientPeg } from './MatrixClientPeg';
import Modal from './Modal';
Expand Down
2 changes: 1 addition & 1 deletion src/ContentMessages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import encrypt from "browser-encrypt-attachment";
import extractPngChunks from "png-chunks-extract";
import { IAbortablePromise, IImageInfo } from "matrix-js-sdk/src/@types/partials";
import { logger } from "matrix-js-sdk/src/logger";
import { IEventRelation, ISendEventResponse } from "matrix-js-sdk/src";
import { IEventRelation, ISendEventResponse } from "matrix-js-sdk/src/matrix";

import { IEncryptedFile, IMediaEventInfo } from "./customisations/models/IMediaEventContent";
import dis from './dispatcher/dispatcher';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import FileSaver from 'file-saver';
import { logger } from "matrix-js-sdk/src/logger";
import { IKeyBackupInfo } from "matrix-js-sdk/src/crypto/keybackup";
import { TrustInfo } from "matrix-js-sdk/src/crypto/backup";
import { CrossSigningKeys } from "matrix-js-sdk/src";
import { CrossSigningKeys } from "matrix-js-sdk/src/matrix";
import { IRecoveryKey } from "matrix-js-sdk/src/crypto/api";
import { CryptoEvent } from "matrix-js-sdk/src/crypto";

Expand Down
2 changes: 1 addition & 1 deletion src/components/structures/UploadBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
import React from 'react';
import { Room } from "matrix-js-sdk/src/models/room";
import filesize from "filesize";
import { IEventRelation } from 'matrix-js-sdk/src';
import { IEventRelation } from 'matrix-js-sdk/src/matrix';

import ContentMessages from '../../ContentMessages';
import dis from "../../dispatcher/dispatcher";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import React, { useCallback, useEffect } from "react";
import { MatrixEvent } from "matrix-js-sdk/src";
import { MatrixEvent } from "matrix-js-sdk/src/matrix";

import { ButtonEvent } from "../elements/AccessibleButton";
import dis from '../../../dispatcher/dispatcher';
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/dialogs/ExportDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import React, { useRef, useState, Dispatch, SetStateAction } from "react";
import { Room } from "matrix-js-sdk/src";
import { Room } from "matrix-js-sdk/src/matrix";
import { logger } from "matrix-js-sdk/src/logger";

import { _t } from "../../../languageHandler";
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/messages/DownloadActionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { MatrixEvent } from "matrix-js-sdk/src";
import { MatrixEvent } from "matrix-js-sdk/src/matrix";
import React from "react";
import classNames from "classnames";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import React from 'react';
import { MatrixEvent } from 'matrix-js-sdk/src';
import { MatrixEvent } from 'matrix-js-sdk/src/matrix';
import { logger } from "matrix-js-sdk/src/logger";
import { VerificationRequestEvent } from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";

Expand Down
2 changes: 1 addition & 1 deletion src/components/views/messages/UnknownBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.
*/

import React, { forwardRef } from "react";
import { MatrixEvent } from "matrix-js-sdk/src";
import { MatrixEvent } from "matrix-js-sdk/src/matrix";

interface IProps {
mxEvent: MatrixEvent;
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/messages/ViewSourceEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import React from 'react';
import { MatrixEvent, MatrixEventEvent } from 'matrix-js-sdk/src';
import { MatrixEvent, MatrixEventEvent } from 'matrix-js-sdk/src/matrix';
import classNames from 'classnames';

import { replaceableComponent } from "../../../utils/replaceableComponent";
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/rooms/RoomDetailList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import React from 'react';
import { Room } from 'matrix-js-sdk/src';
import { Room } from 'matrix-js-sdk/src/matrix';
import classNames from 'classnames';

import dis from '../../../dispatcher/dispatcher';
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/rooms/RoomHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ limitations under the License.
import React from 'react';
import classNames from 'classnames';
import { throttle } from 'lodash';
import { MatrixEvent, Room, RoomStateEvent } from 'matrix-js-sdk/src';
import { MatrixEvent, Room, RoomStateEvent } from 'matrix-js-sdk/src/matrix';
import { CallType } from "matrix-js-sdk/src/webrtc/call";

import { _t } from '../../../languageHandler';
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/settings/CrossSigningPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import React from 'react';
import { ClientEvent, MatrixEvent } from 'matrix-js-sdk/src';
import { ClientEvent, MatrixEvent } from 'matrix-js-sdk/src/matrix';
import { logger } from "matrix-js-sdk/src/logger";
import { CryptoEvent } from "matrix-js-sdk/src/crypto";

Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Skinner, { ISkinObject } from './Skinner';

// Import the js-sdk so the proper `request` object can be set. This does some
// magic with the browser injection to make all subsequent imports work fine.
import "matrix-js-sdk";
import "matrix-js-sdk/src/browser-index";

export function loadSkin(skinObject: ISkinObject): void {
Skinner.load(skinObject);
Expand Down
2 changes: 1 addition & 1 deletion src/indexing/BaseEventIndexManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import { IMatrixProfile, IEventWithRoomId as IMatrixEvent, IResultRoomEvents } from "matrix-js-sdk/src/@types/search";
import { Direction } from "matrix-js-sdk/src";
import { Direction } from "matrix-js-sdk/src/matrix";

// The following interfaces take their names and member names from seshat and the spec
/* eslint-disable camelcase */
Expand Down
2 changes: 1 addition & 1 deletion src/models/IUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { IEventRelation } from "matrix-js-sdk/src";
import { IEventRelation } from "matrix-js-sdk/src/matrix";
import { IAbortablePromise } from "matrix-js-sdk/src/@types/partials";

export interface IUpload {
Expand Down
2 changes: 1 addition & 1 deletion src/sendTimePerformanceMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { MatrixClient } from "matrix-js-sdk/src";
import { MatrixClient } from "matrix-js-sdk/src/matrix";

/**
* Decorates the given event content object with the "send start time". The
Expand Down
2 changes: 1 addition & 1 deletion src/stores/ActiveWidgetStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import EventEmitter from 'events';
import { MatrixEvent, RoomStateEvent } from "matrix-js-sdk/src";
import { MatrixEvent, RoomStateEvent } from "matrix-js-sdk/src/matrix";

import { MatrixClientPeg } from '../MatrixClientPeg';
import { WidgetMessagingStore } from "./widgets/WidgetMessagingStore";
Expand Down
2 changes: 1 addition & 1 deletion src/stores/AutoRageshakeStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { ClientEvent, MatrixEvent, MatrixEventEvent } from "matrix-js-sdk/src";
import { ClientEvent, MatrixEvent, MatrixEventEvent } from "matrix-js-sdk/src/matrix";
import { sleep } from "matrix-js-sdk/src/utils";
import { ISyncStateData, SyncState } from "matrix-js-sdk/src/sync";

Expand Down
2 changes: 1 addition & 1 deletion src/utils/MediaEventHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { MatrixEvent } from "matrix-js-sdk/src";
import { MatrixEvent } from "matrix-js-sdk/src/matrix";
import { EventType, MsgType } from "matrix-js-sdk/src/@types/event";
import { logger } from "matrix-js-sdk/src/logger";

Expand Down
2 changes: 1 addition & 1 deletion test/CallHandler-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

import './skinned-sdk';

import { IProtocol } from 'matrix-js-sdk/src';
import { IProtocol } from 'matrix-js-sdk/src/matrix';
import { CallEvent, CallState, CallType } from 'matrix-js-sdk/src/webrtc/call';
import EventEmitter from 'events';

Expand Down
2 changes: 1 addition & 1 deletion test/DecryptionFailureTracker-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { MatrixEvent } from 'matrix-js-sdk';
import { MatrixEvent } from 'matrix-js-sdk/src/matrix';

import './skinned-sdk'; // Must be first for skinning to work
import { DecryptionFailureTracker } from '../src/DecryptionFailureTracker';
Expand Down
2 changes: 1 addition & 1 deletion test/DeviceListener-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.

import { EventEmitter } from "events";
import { mocked } from "jest-mock";
import { Room } from "matrix-js-sdk";
import { Room } from "matrix-js-sdk/src/matrix";

import './skinned-sdk';
import DeviceListener from "../src/DeviceListener";
Expand Down
2 changes: 1 addition & 1 deletion test/Terms-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import * as Matrix from 'matrix-js-sdk';
import * as Matrix from 'matrix-js-sdk/src/matrix';

import { startTermsFlow, Service } from '../src/Terms';
import { stubClient } from './test-utils';
Expand Down
2 changes: 1 addition & 1 deletion test/TextForEvent-test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import './skinned-sdk';

import { EventType, MatrixEvent } from "matrix-js-sdk";
import { EventType, MatrixEvent } from "matrix-js-sdk/src/matrix";
import TestRenderer from 'react-test-renderer';

import { getSenderName, textForEvent } from "../src/TextForEvent";
Expand Down
2 changes: 1 addition & 1 deletion test/components/structures/CallEventGrouper-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import "../../skinned-sdk";
import { MatrixClient } from 'matrix-js-sdk';
import { MatrixClient } from 'matrix-js-sdk/src/matrix';
import { EventType } from "matrix-js-sdk/src/@types/event";
import { CallState } from "matrix-js-sdk/src/webrtc/call";

Expand Down
2 changes: 1 addition & 1 deletion test/components/structures/GroupView-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import React from 'react';
import ReactDOM from 'react-dom';
import ReactTestUtils from 'react-dom/test-utils';
import MockHttpBackend from 'matrix-mock-request';
import Matrix from 'matrix-js-sdk';
import * as Matrix from 'matrix-js-sdk/src/matrix';

import { MatrixClientPeg } from '../../../src/MatrixClientPeg';
import sdk from '../../skinned-sdk';
Expand Down
2 changes: 1 addition & 1 deletion test/components/structures/MessagePanel-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ limitations under the License.
import React from 'react';
import ReactDOM from "react-dom";
import { EventEmitter } from "events";
import Matrix from 'matrix-js-sdk';
import * as Matrix from 'matrix-js-sdk/src/matrix';
import FakeTimers from '@sinonjs/fake-timers';
import { mount } from "enzyme";

Expand Down
2 changes: 1 addition & 1 deletion test/components/structures/ThreadPanel-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
Room,
UNSTABLE_FILTER_RELATION_SENDERS,
UNSTABLE_FILTER_RELATION_TYPES,
} from 'matrix-js-sdk';
} from 'matrix-js-sdk/src/matrix';
import { mocked } from 'jest-mock';
import '../../skinned-sdk';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

import React from 'react';
import { mount } from 'enzyme';
import { Room } from 'matrix-js-sdk';
import { Room } from 'matrix-js-sdk/src/matrix';
import { mocked } from 'jest-mock';
import { act } from 'react-dom/test-utils';

Expand Down
2 changes: 1 addition & 1 deletion test/components/views/dialogs/ExportDialog-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import React from 'react';
import { mount } from 'enzyme';
import { mocked } from 'jest-mock';
import { act } from "react-dom/test-utils";
import { Room } from 'matrix-js-sdk';
import { Room } from 'matrix-js-sdk/src/matrix';

import '../../../skinned-sdk';
import ExportDialog from '../../../../src/components/views/dialogs/ExportDialog';
Expand Down
2 changes: 1 addition & 1 deletion test/components/views/groups/GroupMemberList-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import React from "react";
import ReactDOM from "react-dom";
import ReactTestUtils from "react-dom/test-utils";
import MockHttpBackend from "matrix-mock-request";
import Matrix from "matrix-js-sdk";
import * as Matrix from "matrix-js-sdk/src/matrix";

import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
import sdk from "../../../skinned-sdk";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import '../../../skinned-sdk'; // Must be first for skinning to work
import React from 'react';
import TestRenderer from 'react-test-renderer';
import { EventEmitter } from 'events';
import { MatrixEvent } from 'matrix-js-sdk';
import { MatrixEvent } from 'matrix-js-sdk/src/matrix';

import * as TestUtils from '../../../test-utils';
import { MatrixClientPeg } from '../../../../src/MatrixClientPeg';
Expand Down
2 changes: 1 addition & 1 deletion test/components/views/messages/MPollBody-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

import React from "react";
import { mount, ReactWrapper } from "enzyme";
import { Callback, IContent, MatrixClient, MatrixEvent, Room } from "matrix-js-sdk";
import { Callback, IContent, MatrixClient, MatrixEvent, Room } from "matrix-js-sdk/src/matrix";
import { ISendEventResponse } from "matrix-js-sdk/src/@types/requests";
import { Relations } from "matrix-js-sdk/src/models/relations";
import { RelatedRelations } from "matrix-js-sdk/src/models/related-relations";
Expand Down
2 changes: 1 addition & 1 deletion test/components/views/right_panel/UserInfo-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
import React from 'react';
import { mount } from 'enzyme';
import { act } from "react-dom/test-utils";
import { Room, User } from 'matrix-js-sdk';
import { Room, User } from 'matrix-js-sdk/src/matrix';
import { Phase, VerificationRequest } from 'matrix-js-sdk/src/crypto/verification/request/VerificationRequest';

import "../../../skinned-sdk";
Expand Down
2 changes: 1 addition & 1 deletion test/components/views/rooms/RoomHeader-test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { Room, PendingEventOrdering, MatrixEvent, MatrixClient } from 'matrix-js-sdk';
import { Room, PendingEventOrdering, MatrixEvent, MatrixClient } from 'matrix-js-sdk/src/matrix';

import "../../../skinned-sdk";
import * as TestUtils from '../../../test-utils';
Expand Down
2 changes: 1 addition & 1 deletion test/components/views/rooms/RoomList-test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import ReactTestUtils from 'react-dom/test-utils';
import ReactDOM from 'react-dom';
import { MatrixClient, Room, RoomMember } from 'matrix-js-sdk';
import { MatrixClient, Room, RoomMember } from 'matrix-js-sdk/src/matrix';

import * as TestUtils from '../../../test-utils';
import { MatrixClientPeg } from '../../../../src/MatrixClientPeg';
Expand Down
2 changes: 1 addition & 1 deletion test/components/views/rooms/RoomPreviewBar-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
findRenderedDOMComponentWithClass,
act,
} from 'react-dom/test-utils';
import { Room, RoomMember, MatrixError, IContent } from 'matrix-js-sdk';
import { Room, RoomMember, MatrixError, IContent } from 'matrix-js-sdk/src/matrix';

import "../../../skinned-sdk";
import { stubClient } from '../../../test-utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import '../../../skinned-sdk';

import React, { ReactElement } from 'react';
import ReactDOM from 'react-dom';
import { MatrixClient } from 'matrix-js-sdk';
import { MatrixClient } from 'matrix-js-sdk/src/matrix';

import { MatrixClientPeg } from '../../../../src/MatrixClientPeg';
import * as TestUtils from '../../../test-utils';
Expand Down
2 changes: 1 addition & 1 deletion test/components/views/settings/Notifications-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
import React from 'react';
import { mount } from 'enzyme';
import '../../../skinned-sdk';
import { IPushRule, IPushRules, RuleId } from 'matrix-js-sdk';
import { IPushRule, IPushRules, RuleId } from 'matrix-js-sdk/src/matrix';
import { ThreepidMedium } from 'matrix-js-sdk/src/@types/threepids';
import { act } from 'react-dom/test-utils';

Expand Down
Loading