Commit Graph

185 Commits

Author SHA1 Message Date
Mia
3fc757e958
Typescript chat-commands/moderation, refactor Punishments (#6490) 2020-04-08 11:56:19 -07:00
fart
80cfacc2b0
Support /hidetext [line count] (#6471) 2020-03-22 15:53:40 -07:00
Guangcong Luo
7de51956c5 Change BasicChatRoom to Room in some types
`user.can` and `user.authAtLeast` now take `Room | BasicChatRoom`
instead of `BasicChatRoom`. It's now significantly less necessary to
cast things to `BasicChatRoom`.
2020-03-15 19:52:59 -07:00
Guangcong Luo
125fe31d06 Improve eslintrc
Fixed some more code style, allowing these rules to be enabled:

- `comma-dangle`
- `function-paren-newline`
- `member-delimiter-style`
- `no-eval`
- `no-fallthrough`
- `no-misused-promises`
- `no-unused-vars`
- `operator-linebreak`
2020-03-06 22:35:55 -08:00
Waleed Hassan
8aa4f053bb
Use optional chaining and linter improvements (#6422)
This is mostly just a follow up to #6342.

`prefer-optional-chaining` was turned on and fixed in every location it
complained in. The transformed function [0] looks expensive from a
glance but from skimming through the replaced sites it doesn't appear
to be ran in any important place, so it should be OK.

The linter improvements are:
- Increase linter performance
	- Make `full-lint` and `lint` write to different caches so we
	  avoid overwriting their caches since they're different configs
	- Change husky's hook to `npm run lint` so as to write to the
	  same cache
	- Remove `@typescript-eslint/eslint-plugin-tslint` which is
	  essentially a wrapper to TSLint because the rules aren't worth
	  running another linter
- Convert `.eslintrc.json` and `.eslintrc-syntax.json` to two spaces
  rather than four tabs to respect PS' `.editorconfig`
- Rename `fulllint` to `full-lint` to ease spelling it

[0] - https://pastie.io/mmtxpf.js (prettified)
2020-03-06 11:44:32 -08:00
Guangcong Luo
b21c9047e2
Migrate to typescript-eslint (#6342) 2020-03-05 08:33:06 -08:00
whales
26fa367f75
Fix bugs with renaming rooms (#6392) 2020-02-24 23:54:10 -08:00
whales
38daf467fc
Add some common rooms to the roomid type (#6393) 2020-02-24 19:52:41 -08:00
whales
926970f765
Automatically upload replays when reporting (#6380) 2020-02-21 00:47:19 -08:00
Waleed Hassan
34e215c7a6
Support renaming rooms (#6295) 2020-02-21 00:47:07 -08:00
Kris Johnson
2ea84725e2
Typescript Daily Spotlight, RoomFAQs, and Wi-Fi (#6373) 2020-02-18 13:26:44 -08:00
Kris Johnson
36d6dc8b0c
Typescript Jeopardy, Blackjack, and Room Events (#6331) 2020-02-07 03:16:49 -08:00
Waleed Hassan
f7e024e009
Allow safer and exact type retrieval of Room#game (#6315)
By adding a `getGame` function of type:

```
// null is returned if the gameids don't match
// or the game doesn't exist
getGame<T extends RoomGame>(constructor: new (...args: any[]) => T) => T | null
```
(Credits @urkerab and @whalemer for the function signature.)

It allows refactoring previous code of:

```
if (room.game && room.game.gameid !== 'hangman') return;
const game = room.game as Hangman;
```

to:

```
const game = room.getGame(Hangman);
if (!game) return;
```

This has a couple of advantages:
- TypeScript will throw an error if the if condition is not present.

- In the new code, the template must extends `RoomGame` and be assignable to the same ID, so it's 100% typesafe
2020-02-03 05:09:37 -08:00
Waleed Hassan
02c862da31 Add a GroupSymbol type (#6285) 2020-01-14 14:07:11 -08:00
HoeenHero
86e3c81b8a Tickets: Ticket rooms expire and close after 40 minutes of inactivity 2020-01-01 20:45:17 -05:00
whales
65d904b6e5 Fix room desynch bug (#6239) 2019-12-31 00:27:40 +09:00
whales
dd1dee6fa9 Make subrooms inherit parent room mutes (#6161) 2019-12-11 16:58:39 +09:00
whales
20c708b20a Typescript roomsettings (#6117) 2019-11-30 17:34:14 +13:00
Konrad Borowski
5fcb840e3b Hide stack traces for private code (#5898) 2019-11-29 10:35:18 +13:00
MrEconomical
dea8411ad3 Fix file extensions in comments (#6062)
Update the extensions of a bunch of files that were migrated to TypeScript in comments
2019-11-24 12:57:12 +13:00
Guangcong Luo
f54410a44b Fix crash with /importinputlog 2019-11-17 13:10:43 +13:00
Kirk Scheibelhut
d62a2d9c69 Introduce /modchatnext command (#5934) 2019-11-12 11:37:37 +13:00
Guangcong Luo
411afba392 TypeScript Announcements/Poll chat plugins 2019-11-11 02:13:48 +13:00
Waleed Hassan
a518cf102a Take steps to statically type Config (#5920)
This commit changes the TypeScript global variable of `Config` from
`AnyObject` to `Config & AnyObject`.

It still falls back to `AnyObject` (hence the 'Take steps') because of
the main-specific `Config` properties that are used without being in the
`Config` object itself.

These can be added by someone with access to the PS main server.

Regardlesss, this is an improvement as IntelliSense can display and
autocomplete the known properies.

In addition, the TypeScript compiler will now report bugs
concerning the types of the properties, which I have fixed in this
commit.
2019-10-30 18:45:20 +10:30
Waleed Hassan
28e870c4fb Server: Use readonly where appropriate (#5902) 2019-10-21 16:12:32 +10:30
whales
ea2dea1283 Rooms: Rooms.get can return null (#5860) 2019-10-09 18:52:33 +11:00
Spandan Punwatkar
c8873aeec9 Add Announcements (#5404)
(Announcements can't coexist with polls)
2019-10-04 01:21:38 +10:00
Waleed Hassan
5607c158e4 Use void in promises to appease TSLint (#5827) 2019-10-03 19:08:30 +10:00
Waleed Hassan
da4b887054 Rename Room#id -> Room#roomid, User#userid -> User#id (#5826)
These should make it clearer that userids are IDs but roomids aren't.
2019-10-03 18:57:38 +10:00
whales
fc2c69eb99 Destroy groupchats on all global punishments (#5755) 2019-09-15 06:27:51 +02:00
TheJetOU
f2783c642d Add a RoomID type (#5759) 2019-09-07 14:15:27 -05:00
TheJetOU
2b28c9fd6b Refactor Rooms(), Users() to Rooms.get(), Users.get() (#5725) 2019-08-25 06:33:56 -07:00
TheJetOU
7fe2e5338c TypeScript Tournaments (#5723) 2019-08-24 03:48:13 -07:00
Guangcong Luo
e0a2cf07e1 Correctly define global types for .ts files
Global types are defined differently for `.ts` files than for `.js`
files, leading to some confusion for past refactors.

This commit defines them correctly.

I'm also considering making certain global types only available under
namespaces, but I don't want to do that to `User` or `Room`, so for
now, there are no changes there, besides putting streams in the
`Streams` namespace (so `WriteStream` is now `Streams.WriteStream`).
2019-08-23 09:33:49 -07:00
TheJetOU
5597916644 TypeScript Rooms and Roomlogs (#5699) 2019-08-14 20:44:57 +02:00