ESLint has a whole new config format, so I figure it's a good time to
make the config system saner.
- First, we no longer have separate eslint-no-types configs. Lint
performance shouldn't be enough of a problem to justify the
relevant maintenance complexity.
- Second, our base config should work out-of-the-box now. `npx eslint`
will work as expected, without any CLI flags. You should still use
`npm run lint` which adds the `--cached` flag for performance.
- Third, whatever updates I did fixed style linting, which apparently
has been bugged for quite some time, considering all the obvious
mixed-tabs-and-spaces issues I found in the upgrade.
Also here are some changes to our style rules. In particular:
- Curly brackets (for objects etc) now have spaces inside them. Sorry
for the huge change. ESLint doesn't support our old style, and most
projects use Prettier style, so we might as well match them in this way.
See https://github.com/eslint-stylistic/eslint-stylistic/issues/415
- String + number concatenation is no longer allowed. We now
consistently use template strings for this.
`./build decl` now builds TS declarations for everything exported by
`sim/`. Unfortunately, the built TS declarations still refer to global
types, so some things still have `any` type, but it's much better than
nothing.
Previously, if you deleted a file from `data/mods/`, it wouldn't also
get deleted from `.data-dist/mods/`. This fixes that, and the
corresponding issue in `server/chat-plugins/`.
For reasons of performance and/or laziness, I've chosen to only clean
those two directories, not all built directories.
Building from a fresh install currently fails since #7797
The problem is that `require('sucrase')` needs to be done _after_
sucrase is installed, which is a lot harder than it sounds.
simulate-battle now has a new option: --spectate.
As a recap:
-D --debug: simulate in debug mode
-R --replay: output only the omniscient (debug) replay, rather than the
full stream
-S --spectate: output only the spectator replay, rather than the full
stream
We were previously using `type Foo = import('bar').Foo` which works
actually equally well, because sucrase didn't support `import type`,
but now it does!
We try to feature-detect for dependencies, but this one is hard and
I don't want to actually do an actual sucrase compile to check if it's
up to date, hence digging through its version number. Too bad they
added a major feature in a minor version, complicating the check. :/
`node tools/set-import [version]` can be run to create a
`@pokemon-showdown/sets` package containing sets from Smogon, usage
stats and third party sources. Some notes:
- The build is set up so that `tools/set-import/importer.ts` is
compiled to `tools/set-import/importer.js` - creating a
`.tools-dist/set-import` directory for the sole artifact was
deemed to be overkill
- The sets package is generated such that it can be used easily on
Node or in a browser (where the large set JSON can be loaded
asynchronously)
- Supported tiers/formats are mostly arbitrary - those popular
enough to have a signficant playerbase or analyses on Smogon have
been included, but additional formats can be added based on demand
- Some set information is redundant for ease of use by downstream
users: certain formes are split out and information that could
theoretically be inferred like level/ability/HP IVs are included
to simplify parsing logic and make the sets more immediately
available. This results in what should mostly be negligible
size overhead.
- In a similar vein, display versions of effect names instead of IDs
are used (name -> ID is trivial, ID -> name requires data lookup)
- All sets pass validation, provided certain simple transformations
are applied (eg. reverting `battleOnly` formes like Megas)
This tool has primarily been tested to run on Linux - running on
other platforms is not guaranteed to result in error-free output.
- Refactor dev-tools/harness.js and dev-tools/smokes.js to separate
out the script/CLI code and implementation code into separate
files.
- Rename 'smoke' to 'exhaustive' ('multi' mode can also be used
for "smoke testing") to better describe its behavior.
- Rewrite the runners in Typescript for type safety.
- Refactor common build utilities into dev-tools/build.js and
introduce the notion of a 'full' build analogous to 'full' tests.
(This error wasn't caught because it still works without installing
the dependency, but makes the build script far slower because
`npx replace` would reinstall `replace` every time it's used.)
The modern `__esModule` fallback isn't compatible with Node, and also
entirely unnecessary in practice.
The approach of disabling all the fallback code allows us to once again
`import * as fs`.
Hotpatching and running `./pokemon-showdown` now automatically run
`./build`. There should now mostly not be any reason you'd want to
manually run `./build`, except if you're invoking tests directly.
In addition, a lot of redundant code has been removed.
I'm not 100% sure this works on Windows, but I'm sure I'll get reports
if anything breaks.