+
{props.children}
);
diff --git a/src/components/UserPreview.tsx b/src/components/UserPreview.tsx
index 04339d8..415b2a2 100644
--- a/src/components/UserPreview.tsx
+++ b/src/components/UserPreview.tsx
@@ -14,12 +14,12 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-import React from "react";
-import { User } from "matrix-cypher";
+import React from 'react';
+import { User } from 'matrix-cypher';
-import { UserAvatar } from "./Avatar";
+import { UserAvatar } from './Avatar';
-import "./UserPreview.scss";
+import './UserPreview.scss';
interface IProps {
user: User;
diff --git a/src/contexts/ClientContext.ts b/src/contexts/ClientContext.ts
index 95cb97e..cb530ce 100644
--- a/src/contexts/ClientContext.ts
+++ b/src/contexts/ClientContext.ts
@@ -14,9 +14,9 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-import React from "react";
+import React from 'react';
-import { prefixFetch, Client, discoverServer } from "matrix-cypher";
+import { prefixFetch, Client, discoverServer } from 'matrix-cypher';
type State = {
clientURL: string;
@@ -25,8 +25,8 @@ type State = {
// Actions are a discriminated union.
export enum ActionTypes {
- AddClient = "ADD_CLIENT",
- RemoveClient = "REMOVE_CLIENT",
+ AddClient = 'ADD_CLIENT',
+ RemoveClient = 'REMOVE_CLIENT',
}
export interface AddClient {
diff --git a/src/layouts/SingleColumn.tsx b/src/layouts/SingleColumn.tsx
index bacc1e6..ae2134e 100644
--- a/src/layouts/SingleColumn.tsx
+++ b/src/layouts/SingleColumn.tsx
@@ -14,9 +14,9 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-import React from "react";
+import React from 'react';
-import "./SingleColumn.scss";
+import './SingleColumn.scss';
interface IProps {
children?: React.ReactNode;
diff --git a/src/pages/LinkRouter.tsx b/src/pages/LinkRouter.tsx
index 827ff8f..fe4a2a1 100644
--- a/src/pages/LinkRouter.tsx
+++ b/src/pages/LinkRouter.tsx
@@ -14,12 +14,12 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-import React from "react";
+import React from 'react';
-import Tile from "../components/Tile";
-import LinkPreview from "../components/LinkPreview";
-import { parseHash } from "../parser/parser";
-import { LinkKind } from "../parser/types";
+import Tile from '../components/Tile';
+import LinkPreview from '../components/LinkPreview';
+import { parseHash } from '../parser/parser';
+import { LinkKind } from '../parser/types';
interface IProps {
link: string;
diff --git a/src/parser/parser.test.ts b/src/parser/parser.test.ts
index 758dce2..6086736 100644
--- a/src/parser/parser.test.ts
+++ b/src/parser/parser.test.ts
@@ -7,57 +7,57 @@ import {
verifiers,
identifyTypeFromRegex,
toURL,
-} from "./parser";
+} from './parser';
-import { LinkKind } from "./types";
+import { LinkKind } from './types';
const identifierType = (id: string): LinkKind =>
identifyTypeFromRegex(id, verifiers, LinkKind.ParseFailed);
-it("types identifiers correctly", () => {
- expect(identifierType("@user:matrix.org")).toEqual(LinkKind.UserId);
- expect(identifierType("!room:matrix.org")).toEqual(LinkKind.RoomId);
- expect(identifierType("!somewhere:example.org/$event:example.org")).toEqual(
+it('types identifiers correctly', () => {
+ expect(identifierType('@user:matrix.org')).toEqual(LinkKind.UserId);
+ expect(identifierType('!room:matrix.org')).toEqual(LinkKind.RoomId);
+ expect(identifierType('!somewhere:example.org/$event:example.org')).toEqual(
LinkKind.Permalink
);
- expect(identifierType("+group:matrix.org")).toEqual(LinkKind.GroupId);
- expect(identifierType("#alias:matrix.org")).toEqual(LinkKind.Alias);
+ expect(identifierType('+group:matrix.org')).toEqual(LinkKind.GroupId);
+ expect(identifierType('#alias:matrix.org')).toEqual(LinkKind.Alias);
});
-it("types garbage as such", () => {
- expect(identifierType("sdfa;fdlkja")).toEqual(LinkKind.ParseFailed);
- expect(identifierType("$event$matrix.org")).toEqual(LinkKind.ParseFailed);
- expect(identifierType("/user:matrix.org")).toEqual(LinkKind.ParseFailed);
+it('types garbage as such', () => {
+ expect(identifierType('sdfa;fdlkja')).toEqual(LinkKind.ParseFailed);
+ expect(identifierType('$event$matrix.org')).toEqual(LinkKind.ParseFailed);
+ expect(identifierType('/user:matrix.org')).toEqual(LinkKind.ParseFailed);
});
-it("parses args correctly", () => {
+it('parses args correctly', () => {
expect(
- parseArgs("via=example.org&via=alt.example.org")
- ).toHaveProperty("vias", ["example.org", "alt.example.org"]);
- expect(parseArgs("sharer=blah")).toHaveProperty("sharer", "blah");
- expect(parseArgs("client=blah.com")).toHaveProperty("client", "blah.com");
+ parseArgs('via=example.org&via=alt.example.org')
+ ).toHaveProperty('vias', ['example.org', 'alt.example.org']);
+ expect(parseArgs('sharer=blah')).toHaveProperty('sharer', 'blah');
+ expect(parseArgs('client=blah.com')).toHaveProperty('client', 'blah.com');
});
-it("parses permalinks", () => {
- expect(parsePermalink("!somewhere:example.org/$event:example.org")).toEqual(
+it('parses permalinks', () => {
+ expect(parsePermalink('!somewhere:example.org/$event:example.org')).toEqual(
{
roomKind: LinkKind.RoomId,
- roomLink: "!somewhere:example.org",
- eventId: "$event:example.org",
+ roomLink: '!somewhere:example.org',
+ eventId: '$event:example.org',
}
);
});
-it("formats links correctly", () => {
+it('formats links correctly', () => {
const bigLink =
- "!somewhere:example.org/$event:example.org?via=dfasdf&via=jfjafjaf";
- const origin = "https://matrix.org";
- const prefix = origin + "/#/";
+ '!somewhere:example.org/$event:example.org?via=dfasdf&via=jfjafjaf';
+ const origin = 'https://matrix.org';
+ const prefix = origin + '/#/';
const parse = parseHash(bigLink);
switch (parse.kind) {
case LinkKind.ParseFailed:
- fail("Parse failed");
+ fail('Parse failed');
default:
expect(toURL(origin, parse).toString()).toEqual(prefix + bigLink);
}
diff --git a/src/parser/parser.ts b/src/parser/parser.ts
index 0eb01fa..dbb1721 100644
--- a/src/parser/parser.ts
+++ b/src/parser/parser.ts
@@ -1,4 +1,4 @@
-import forEach from "lodash/forEach";
+import forEach from 'lodash/forEach';
import {
LinkKind,
@@ -7,7 +7,7 @@ import {
LinkContent,
Arguments,
Permalink,
-} from "./types";
+} from './types';
/*
* Verifiers are regexes which will match valid
@@ -58,8 +58,8 @@ export function identifyTypeFromRegex
(
*/
export function parsePermalink(
identifier: string
-): Pick {
- const [roomLink, eventId] = identifier.split("/");
+): Pick {
+ const [roomLink, eventId] = identifier.split('/');
const roomKind = identifyTypeFromRegex(
roomLink,
roomVerifiers,
@@ -89,9 +89,9 @@ export function parseArgs(args: string): Arguments {
const params = new URLSearchParams(args);
return {
- vias: params.getAll("via"),
- client: bottomExchange(params.get("client")),
- sharer: bottomExchange(params.get("sharer")),
+ vias: params.getAll('via'),
+ client: bottomExchange(params.get('client')),
+ sharer: bottomExchange(params.get('sharer')),
};
}
@@ -101,7 +101,7 @@ export function parseArgs(args: string): Arguments {
* be ParseFailed
*/
export function parseHash(hash: string): Link {
- const [identifier, args] = hash.split("?");
+ const [identifier, args] = hash.split('?');
const kind = identifyTypeFromRegex(
identifier,
@@ -150,9 +150,9 @@ export function toURL(origin: string, link: SafeLink): URL {
forEach(link.arguments, (value, key) => {
if (value === undefined) {
// do nothing
- } else if (key === "vias") {
+ } else if (key === 'vias') {
(value as string[]).forEach((via) =>
- params.append("via", via)
+ params.append('via', via)
);
} else {
params.append(key, value.toString());
diff --git a/src/parser/types.ts b/src/parser/types.ts
index 35c2d2a..5d8fa79 100644
--- a/src/parser/types.ts
+++ b/src/parser/types.ts
@@ -13,12 +13,12 @@ export interface LinkContent {
}
export enum LinkKind {
- Alias = "ALIAS",
- RoomId = "ROOM_ID",
- UserId = "USER_ID",
- Permalink = "PERMALINK",
- GroupId = "GROUP_ID",
- ParseFailed = "PARSE_FAILED",
+ Alias = 'ALIAS',
+ RoomId = 'ROOM_ID',
+ UserId = 'USER_ID',
+ Permalink = 'PERMALINK',
+ GroupId = 'GROUP_ID',
+ ParseFailed = 'PARSE_FAILED',
}
export interface Alias extends LinkContent {
diff --git a/src/utils/cypher-wrapper.ts b/src/utils/cypher-wrapper.ts
index dec580c..5a43a4c 100644
--- a/src/utils/cypher-wrapper.ts
+++ b/src/utils/cypher-wrapper.ts
@@ -14,6 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
+// disable camelcase check because our object keys come
+// from the matrix spec
+/* eslint-disable @typescript-eslint/camelcase */
+
import {
Client,
Room,
@@ -23,8 +27,8 @@ import {
searchPublicRooms,
getUserDetails,
convertMXCtoMediaQuery,
-} from "matrix-cypher";
-import { LinkKind, Permalink } from "../parser/types";
+} from 'matrix-cypher';
+import { LinkKind, Permalink } from '../parser/types';
/* This is a collection of methods for providing fallback metadata
* for cypher queries
@@ -55,13 +59,13 @@ export const fallbackRoom = ({
const roomAlias_ = roomAlias ? roomAlias : identifier;
return {
aliases: [roomAlias_],
- topic: "Unable to find room details.",
+ topic: 'Unable to find room details.',
canonical_alias: roomAlias_,
name: roomAlias_,
num_joined_members: 0,
room_id: roomId_,
guest_can_join: true,
- avatar_url: "",
+ avatar_url: '',
world_readable: false,
};
};
@@ -140,15 +144,15 @@ export async function getRoomFromPermalink(
*/
export function getMediaQueryFromMCX(mxc?: string): string {
if (!mxc) {
- return "";
+ return '';
}
try {
return convertMXCtoMediaQuery(
// TODO: replace with correct client
- "https://matrix.org",
+ 'https://matrix.org',
mxc
);
} catch {
- return "";
+ return '';
}
}