This finally removes the tslint dependency and switches to eslint.
There are a lot of other changes here, too, to bring the codebase up to
server standards. TSLint never had much in the way of indentation
enforcement.
Not very happy about eslint splitting itself up over 6 dependencies,
or its documentation over three websites, nor how poorly documented the
new flat config is, but I mean, eslint's gonna eslint. Customizing
would be even harder if we tried to use Biome or something. They mostly
seem to go full Prettier.
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 (except in ES3
code). We otherwise now consistently use template strings for this.
Files meant to be served have been moved into
`play.pokemonshowdown.com/` and `pokemonshowdown.com/`.
We now have three directories for the three subdomains handled by this
repo:
- `pokemonshowdown.com/`
- `play.pokemonshowdown.com/`
- `replay.pokemonshowdown.com/`
Naming them after the subdomains will make it much easier to tell where
the files for each go.
The diff is probably useless; it'll be easier if you just look at the
new tree:
https://github.com/smogon/pokemon-showdown-client/tree/reorganize
At this point, we might as well use babel-core directly.
New system supports source maps for `battledata` and `graphics`! Woo!
It also logs the compile step.
The new Babel version gives us access to transforming `||=` and `??`,
and removes the need for a lot of dependencies that are now included in
`@babel/preset-env` thanks to them being released rather than proposals.
This also adds a new Babel plugin to simply remove import/export when
building, which seems to be the best way to make `import` and `export`
usable on the client.
Similar to styles/STYLING.html and styles/hpbartest.html, test pages
prove to be more robust and convenient for testing than the unit
tests (which are already broken).
These pages are primarily intended to help with delivering #1369,
but can be used to test improvements to sprites across the board.
This build error doesn't appear locally and I can't reproduce it, but
I've heard others report it, and now Travis is having it as an issue.
I'm going to try to explicitly specify this dependency to see if it
makes a difference.
This is something I probably wouldn't have rushed nearly as much,
except I have a serious use-case coming up; specifically
```js
foo = document.querySelector('foo')?.bar;
```
in a class property.
`document.querySelector('foo') && document.querySelector('foo').bar`
is incredibly inefficient here, but TypeScript doesn't consider
`(document.querySelector('foo') || {}).bar` to be valid because `{}`
doesn't have the `.bar` property. Creating a temporary variable
would have been a huge mess because this was a class property
initializer.
In hindsight, `(document.querySelector('foo')! || {}).bar` would
probably have worked, but too late now.
Most of these update the pokemon/item/etc lists to be slightly more
modern, in preparation for their use in the Preact client.
(Also update TypeScript)
I'm reasonably confident that the tslint settings are where I want
them to be, at this point. Going over the line length limit is a
warning, not an error, so I don't have to worry about that being
too harsh.
Probably the most controversial change here is that I have a max line
length limit, currently set to 140 columns. Lines that set up a
string buffer, lines involving regexes, and the text parser's replace
chains are excluded from the limit.
PS has otherwise been moving towards a line length limit, it just
hasn't been linter-enforced yet. I worry about contributors being
annoyed by it, especially since it's not like it's handled
automatically by Prettier or something.
Oh well, it's set to "warning" so Travis won't yell about it.
This is the first step of moving the entire client over to
TypeScript + Preact!!!!
The main change here is that battledata.js has been split into three
files:
- `src/battle-dex.ts`
- `src/battle-dex-data.ts`
- `src/battle-dex-misc.js`
These are concatenated back into `battledata.js` in the client, so
third parties (and specifically, old replay files) should be
unaffected. Also, this makes sure that we don't have more than two
dependencies right now.
The compilation is done with Babel 7 beta, because no stable version
of Babel supports TypeScript. We're not using `tsc` because it can't
compile to ES3 and it doesn't support preserving line numbers.
`toRoomid` has been moved from client.js to battle-dex.ts.
We no longer have the relevant Githook for automatic building, so
putting it in `githooks/` no longer makes much sense. It's now manually
called with a build script `./build`, like other PS websites (most
notably PSDex and the damagecalc).
Chrome peer-pressuring us by locking Notification behind HTTPS... they
also lock plenty of other things behind HTTPS and the trade-off seems
worth-it now.
BW animated sprites are now also automatically generated. In addition,
the generation script can now handle female sprites and cosmetic forms.
The storage format has also changed to be more concise.