==== Local install with useful commands ====
For people that work on other software projects as well, it may not
be feasible to install a particular version of ESLint globally. It
also means that people using a secure/isolated development environment,
that the tools for this project are not local to the directory and
thus may have to be re-installed every time.
This commit creates a build/eslint/ directory with a couple of useful
abilities:
* To install ESLint + plugins you just run `npm install` here.
Which packages to install is handled automatically. This also makes
updating easier since we would commit the version update, and then
people just run 'npm install' again.
This also avoids untimely or unexpected breaking upgrades, e.g. when
a new major version is released (ESLint 8), then `npm install -g eslint`
would always install the latest version and every contributor would
potentially end up with a slightly different install and obscure
bugs that might cause in differences of results. Global installs are
not a best practice within the the Node ecosystem.
The arclint config was updated to support this as well. Global install
is still supported as well, for Jenkins CI.
* The `npm test` command is made available, which runs the linter on
all JS files in the repository in about 10-20 seconds (cold run),
or <1 second (subsequent runs for modified files only, thx to
.eslintcache; this is based on files changed since the last run,
unlike arclint which would be specific to the current patch).
For this command to run as fast as it did, it was important to exclude
the large source/ and libraries/ directories which would otherwise
take considerable time to traverse only to find no JS files.
This is not meant to replace arclint. It is just an additional tool,
for those looking for lint issues to fix across the code base.
* The `npm run fix -- path/to/some/dir` command is made available for
letting ESLint automatically fix all issues it is capable of
automatically fixing. This should of course be manually reviewed and
improved/corrected as needed, but safes a lot of time, especially for
cosmetic changes.
== Fix IDE support ==
This commit adds the missing /.eslintrc.json at the top of the repo,
which means any text editors and IDEs that support ESLint will offer
real-time feedback while you work. The real config is kept where it
is, but if people prefer, we could move it to be in one place only.
I've added `root: true` as well to both files as otherwise ESLint will
keep traversing all ancestor directories on disk, including outside
the /0ad checkout and in /home, which is not only inefficient, but also
means `arclint` can sometimes report strange errors due to unrelated
config files the developer may have for other projects.