This introduces a new class, BattleActions, available as `battle.actions`,
moving all functions from `data/scripts.ts` to `sim/battle-actions.ts`.
This makes it so that "go to definition" will now work correctly for
functions previously in scripts; we no longer need UnimplementedError,
and there's now a clean conceptual separation between `battle` and
`battle-actions` (whereas the previous distinction between `battle` and
`scripts` was basically nonexistent).
This will be a difficult migration if you maintain a fork with custom
scripted mods. I'm sorry! Migration instructions are here:
https://github.com/smogon/pokemon-showdown/pull/8138
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.
In the past, we used non-type-aware linting in our pre-push hook, as
well as in `npm test`. This was for performance reasons.
In practice, though, we use an eslint cache, which makes even
type-aware incremental linting instantaneous. My rule is that you
should be able to make a small change and lint in under 10 seconds, and
`npm test` should take under 30 seconds, and linting with no changes
(for the pre-push hook) should be under 2 seconds. This is still true
for type-aware linting, so there's no actual need for fast linting.
We've also switched to using `--max-warnings 0` to convert warnings to
errors. This seems to allow them to use the same cache file.
A big improvement here is that `npm test` should now be enough for
testing. I think everyone ran `npm run full-test` for a while because
`npm test` didn't have type-aware lint errors, but now that it does,
you'll be able to use it again and have your tests run a lot faster.
We're skipping two major typescript-eslint versions, so there are a
bunch of changes here, including:
- it's catching a lot of things it didn't catch in the past, for
reasons unclear to me
- no-unused-vars has to be explicitly disabled in global-types now
- a lot of `ts-ignore`s were never necessary and have been fixed
- Crashlogger can now handle being thrown things that aren't errors.
This has never been a problem in the past, but to satisfy TypeScript
we might as well not die in a fire on the off chance someone tries to
`throw null` or something.
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!
@smogon is the preferred namespace for packages (eg. @smogon/calc),
but the fact that this import logic previously contained code from
two non-Smogon sources made such naming awkward. Given the damage
calc didn't end up using these sources (and the Pokémon Showdown
client doesn't either), its simpler to just remove the logic for
third party imports entirely. This allows us to remove ugly 'hidden'
JSON5 dependency, as well as `smogon.com/` namespacing on the
sources.
This commit also tidies up the package.json and type definitions to
be more robust. It makes `--access public` the default when
publishing and cleans up unpkg support.
This is obviously a breaking change, but it's also a package rename
so we get to start the version from zero there :). A corresponding
commit will be added to the client to account for these changes.
- updates smogon package dependency to the latest version
- make sure no old artifacts are left around from previous runs
- revert change from 7aa42b12: for whatever reason we do encounter
instances where `typeof species.battleOnly !== 'string'` and
`throw`-ing means no sets get output.
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)