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.
* Fix move validation involving prevo-only moves
https://www.smogon.com/forums/threads/bug-report-validator.3759104/
This is something that should've always been in #10574. Setting setSources.babyOnly becomes useless here because it eventually gets set after validating a move is complete.
* Actually fix DW
* Properly validate HP type for events
https://www.smogon.com/forums/threads/bug-report-validator.3754044/
* Update team-validator.ts
* Update team-validator.ts
* Update sim/team-validator.ts
Co-authored-by: urkerab <urkerab@users.noreply.github.com>
* Update team-validator.ts
Just some CamelCase...
* Prevent HP Stellar from being usable
https://www.smogon.com/forums/threads/bug-report-validator.3755718/
* Apply suggestions from code review
---------
Co-authored-by: urkerab <urkerab@users.noreply.github.com>
Co-authored-by: Kris Johnson <11083252+KrisXV@users.noreply.github.com>
* Exclude unobtainable HM moves from movesearch
https://www.smogon.com/forums/threads/impossible-hm-moves-in-movesearch.3735989/
* Update dex-species.ts
* Update dex-species.ts
* Update dex-species.ts
* Properly deal with CAP
After doing some digging, I found that 08bca77cf4 is when the isNonstandard check was added to allow CAP Pokemon to know HM moves. This was untouched for over ten years and was inadvertently allowing dexited Pokemon to have HM moves in NatDex that should be illegal in most other formats.
I don't believe this was ever intentional based on knowing the general mechanics of NatDex, nor does it have any impact on the metagame.
* Fix display issues with Ursaluna-Bloodmoon's moves
https://www.smogon.com/forums/threads/bug-report-unsure.3752081/
These issues were probably also affecting Greninja-Ash and Cap Pikachu and this fix should cover them as well. This only fixes the server-side issues in the bug report; a separate fix will be needed for the teambuilder issue.
* Update sim/dex-species.ts
Co-authored-by: Kris Johnson <11083252+KrisXV@users.noreply.github.com>
---------
Co-authored-by: Kris Johnson <11083252+KrisXV@users.noreply.github.com>
* add crude profiling to runDexSearch
No behavioral changes (other than console.log spam), this commit is just to establish a baseline and pinpoint the slow portions
* optimize datasearch.ts - pull move filter prep out of loop
Based on preliminary benchmarks, most of the time was spent getting the move validator, even for queries that don't specify a move.
More importantly, the parameters for fetching the move validator are known very early in the function and don't change during the loop.
Pulling that portion out of the loop is an easy win.
* improve profiling for runDexSearch
- add subcategories for filtering on move (the next optimization target)
- report unaccounted time amounts ('known unknowns')
- make grand total stand out more
* optimize dexsearch - fetch move list in outer loop
Move list depends on 'alts', which does not change in the loop over mons. Minor win, but simple.
* optimize dexsearch - filter move list by gen in outer loop
Neither 'mod' nor 'altMoves' changes during the inner loop.
* log pokemonSource in runDexSearch - expose possible leak
pokemonSources, which appears to act as a set, grows with each iteration, adding seemingly redundant items.
Will need to look closely at TeamValidator to identify the problem. My guess is that it's putting object references into a Set,
which, for objects other than strings, only cares about object identity.
* profile runDexSearch - count checkCanLearn calls
Also, semi-fix issue identified in prior commit - the endless growth of the restrictiveMoves list.
Counting the calls to checkCanLearn helps us reason about whether the cost per call is reasonable.
* fix perf bug in TeamValidator.checkCanLearn
use the cached ruleTable, save 100x.
* optimize runDexSearch - only init move filters when needed
For queries that never mention a move, a considerable chunk of time is wasted getting the objects needed for
'checkCanLearn'. I measure ~1ms savings for the relevant queries, which is often a decent percentage.
* profile dexsearch - delete and format
This is to document that they are not the bottlenecks.
* remove nested profiling from dexsearch
We've gotten to the point where we actually *are* measuring microseconds, so the frequent calls
are too expensive. This is a good problem to have! What we can see from running npm test is
that 'filters' and 'unaccounted' still account for a majority of the time. So, there's still
room for improvement, if that's ever a serious concern.
Personally, I think working on the moves API would be more fruitful.
* remove all profiling code
No more console.log or performance.now() calls. Ready to merge.
* Update server/chat-plugins/datasearch.ts
Format the 'format' string in-line.
Co-authored-by: Mia <49593536+mia-pi-git@users.noreply.github.com>
* Remove ts-expect-error from datasearch.ts
* Fix uninit lint in runDexSearch
---------
Co-authored-by: Mia <49593536+mia-pi-git@users.noreply.github.com>
TypeScript 4.8+ supports Lowercase for lowercase strings, which isn't
exactly what ID is, but can be used to type IDs in object keys and data
entries that previously required string. I'm calling it IDEntry in places
where it should be an ID but TypeScript doesn't support that.
Very conveniently, no additional casts will be needed when using ID
where IDEntry is expected.
It's caught at least a few bugs, which is also why I'm PRing: I didn't
write the code for the bugs it found, and don't know if it's the right
way to fix them.
This ballooned into several other type refactors.
After seeing fifty different ways we use `getLearnset`, most of which
are just "haphazardly assemble a movepool", I decided to write
`getFullLearnset` and `getMovePool`, which centralizes the
implementations and prevents weird bugs like 9713dc6db5 which
we spent two years trying to figure out.