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)
PS apparently doesn't have gen-accurate Ability data for Pokémon in
Gen 3 that gained Abilities between Gen 3 and Gen 4 (like Pidgeot
still has Tangled Feet in Gen 3), but that will have to be left for
a future commit.
`server/chat-commands.js` is now a directory. It's been split into
`core`, `moderation`, and `admin`. `info` and `roomsettings` from
`chat-plugins` have also moved to `chat-commands`.
Some cleanup:
- Bot commands for inserting HTML into rooms like `/adduhtml` have been
moved from `info` into `admin`.
- `/a` has been renamed `/addline`, for clarity (and also moved from
`info` into `admin`).
- Room management commands like `/createroom` and `/roomintro` were
moved to `room-settings`
- `chat-commands/admin` has been TypeScripted
Dashycode had a bug that made it incorrectly encode non-ASCII
characters. I think this was fixed at some point but never made it
to PS's copy of Dashycode? Anyway, fixed now.
`import =` and `export =` are really only intended for backwards
compatibility with CommonJS. While I really don't like the new module
system TC39 has designed for us, it's what we should be using, and
consistency is important.
This is mostly a TypeScript refactor, but it does come with several
renames:
Dnsbl -> IPTools
Dnsbl.query -> IPTools.queryDnsbl
Dnsbl.reverse -> IPTools.getHost
When I originally wrote the Streams library, TypeScript-in-JS didn't
support generics. But now the library can have significantly nicer
typing, and so it now does.
PS prefers to keep battle streams open (for `/evalbattle`) until
manually ended, but this is confusing some other users. We now
automatically end streams unless the `keepAlive` option is set.
Fixes#5157
The old FS.writeUpdate throttle code was broken and unnecessarily
complicated. Since cancelable Promises don't exist and I was thinking
in Promises, I forgot about the existence of `clearTimeout`.
Rewriting with `clearTimeout` produces significantly more readable
code, which should no longer be bugged, and should in fact handle
complicated mixes of throttle times exactly the way I want them to
be handled.
(I rewrote this so many times in unpushed code, and each time turned
out unnecessarily complicated because I didn't remember `clearTimeout`
until now.)
PS's FS(...).writeUpdate(...) has a `throttle` option.
This changes it so it's possible to call it with the throttle on
sometimes and off sometimes, and "throttle off" will pre-empt "throttle
on" calls.
This contains a lot of minor refactors, but the main thing that's going
on here is that battle stream writes have been streamlined to be a lot
easier for others to use.
We even support:
./pokemon-showdown simulate-battle
which provides a stdio interface for anyone using any programming
language to simulate a battle.