Skip to content

Commit e761a19

Browse files
authored
Fix eslint patterns. (#1067)
Closes the-draupnir-project/planning#110
1 parent 30611aa commit e761a19

8 files changed

Lines changed: 27 additions & 14 deletions

File tree

apps/draupnir/src/appservice/AppServiceDraupnirManager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,15 +477,15 @@ export async function makeManagementRoom(
477477
"Failed to fetch room versions from client capabilities"
478478
);
479479
}
480-
const isRoomVersionWithPrivilidgedCreators =
480+
const isRoomVersionWithPriviligedCreators =
481481
RoomVersionMirror.isVersionWithPrivilegedCreators(
482482
capabilities.ok.capabilities["m.room_versions"].default
483483
);
484484
return await roomCreator.createRoom({
485485
preset: "private_chat",
486486
invite: [requestingUserID],
487487
name: `${requestingUserID}'s Draupnir`,
488-
power_level_content_override: isRoomVersionWithPrivilidgedCreators
488+
power_level_content_override: isRoomVersionWithPriviligedCreators
489489
? {
490490
users: {
491491
[requestingUserID]: 150,

apps/draupnir/src/commands/ProtectionsCommands.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ async function findSettingDetailsForCommand(
400400
if (isError(protectionDescription)) {
401401
return protectionDescription;
402402
}
403-
const settingsDescription = protectionDescription.ok.protectionSettings;
403+
type SettingsDescription = typeof protectionDescription.ok.protectionSettings;
404404
const previousSettings = await protectionsManager.getProtectionSettings(
405405
protectionDescription.ok
406406
);
@@ -410,7 +410,7 @@ async function findSettingDetailsForCommand(
410410
return Ok({
411411
protectionDescription: protectionDescription.ok,
412412
propertyKey:
413-
settingName as keyof typeof settingsDescription.schema.properties,
413+
settingName as keyof SettingsDescription["schema"]["properties"],
414414
description: protectionDescription.ok.protectionSettings,
415415
previousSettings: previousSettings.ok,
416416
});

apps/draupnir/src/protections/BanPropagation.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,13 @@ export class BanPropagationProtection
211211
extends AbstractProtection<BanPropagationProtectionCapabilitiesDescription>
212212
implements DraupnirProtection<BanPropagationProtectionCapabilitiesDescription>
213213
{
214-
private readonly banPropagationPromptListener =
215-
this.banReactionListener.bind(this);
214+
private readonly banPropagationPromptListener = (
215+
key: string,
216+
item: unknown,
217+
context: BanPropagationMessageContext
218+
) => {
219+
void Task(this.banReactionListener(key, item, context), { log });
220+
};
216221
constructor(
217222
description: BanPropagationProtectionCapabilitiesDescription,
218223
lifetime: OwnLifetime<

apps/draupnir/src/protections/DraupnirNews/DraupnirNews.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export class DraupnirNewsLifecycle {
127127
const FSNews = (() => {
128128
const content = JSON.parse(
129129
readFileSync(path.join(__dirname, "./news.json"), "utf8")
130-
);
130+
) as unknown;
131131
return Value.Decode(DraupnirNewsBlob, content).expect(
132132
"File system news should match the schema"
133133
);
@@ -144,7 +144,7 @@ async function fetchNews(newsURL: string): Promise<Result<DraupnirNewsBlob>> {
144144
.then((response) => response.json())
145145
.then(
146146
(json) => Value.Decode(DraupnirNewsBlob, json),
147-
(error) =>
147+
(error: unknown) =>
148148
ActionException.Result("unable to fetch news", {
149149
exception: error,
150150
exceptionKind: ActionExceptionKind.Unknown,

apps/draupnir/src/protections/ProtectedRooms/WatchReplacementPolicyRooms.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
renderMentionPill,
4141
sendMatrixEventsFromDeadDocument,
4242
renderErrorDetails,
43+
ReactionListener,
4344
} from "@the-draupnir-project/mps-interface-adaptor";
4445
import { RoomReactionSender } from "matrix-protection-suite/dist/Client/RoomReactionSender";
4546

@@ -195,8 +196,13 @@ async function sendPromptForReplacementRoom(
195196
* - `syncTombstonedPolicyRooms` must be called if you want it to detect stale tombstones at startup.
196197
*/
197198
export class WatchReplacementPolicyRooms {
198-
private readonly watchReplacementPolicyRoomsPromptListener =
199-
this.handlePromptReaction.bind(this);
199+
private readonly watchReplacementPolicyRoomsPromptListener = (
200+
...args: Parameters<ReactionListener<WatchPolicyRoomPromptContext>>
201+
) => {
202+
void Task(this.handlePromptReaction(...args), {
203+
log,
204+
});
205+
};
200206
public constructor(
201207
private readonly managementRoomID: StringRoomID,
202208
private readonly roomJoiner: RoomJoiner,

apps/draupnir/src/safemode/PersistentConfigRenderer.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ function renderConfigPropertyValue(value: unknown): DocumentNode {
7878
return <ul>{value.map((value) => renderConfigPropertyValue(value))}</ul>;
7979
} else {
8080
return (
81+
// FIXME: We should probably try walk this but ya.
82+
// We don't have time for that and no one uses objects here yet.
8183
<fragment>
82-
<code>{String(value)}</code>{" "}
84+
<code>{"[object Object]"}</code>{" "}
8385
<span data-mx-color="#D2691E">(object)</span>
8486
</fragment>
8587
);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"build:all": "tsc -b tsconfig.all.json && npm run -ws build:assets --if-present",
2222
"build:clean": "tsc -b --clean",
2323
"test": "npm run -ws test --if-present && npm run -w apps/draupnir test:unit",
24-
"lint": "eslint --cache 'packages/**/*{ts, tsx}' 'apps/**/*{ts, tsx}' && prettier --cache --ignore-unknown --check apps packages README.md CHANGELOG.md DEPENDENCIES.md"
24+
"lint": "eslint --cache 'packages/**/*.{ts,tsx}' 'apps/**/*.{ts,tsx}' && prettier --cache --ignore-unknown --check apps packages README.md CHANGELOG.md DEPENDENCIES.md"
2525
},
2626
"devDependencies": {
2727
"@changesets/cli": "^2.30.0",

packages/mps-interface-adaptor/src/MPSInterfaceAdaptor/MatrixReactionHandler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ type ItemByReactionKey = Map<
3636
string /*reaction key*/,
3737
string /*serialized presentation*/
3838
>;
39-
export type ReactionListener = (
39+
export type ReactionListener<Context = unknown> = (
4040
key: string,
4141
item: string,
42-
additionalContext: unknown,
42+
additionalContext: Context,
4343
reactionMap: ItemByReactionKey,
4444
annotatedEvent: RoomEvent
4545
) => void;

0 commit comments

Comments
 (0)