Support ESLint caching

Also rearrange the config a little.
This commit is contained in:
Guangcong Luo 2025-02-22 01:05:48 -08:00
parent 8c80d8a33a
commit 7c21d0f504
3 changed files with 18 additions and 13 deletions

View File

@ -6,4 +6,4 @@ This directory is for caches. Everything here should be safe to delete.
Things cached here:
- `pokemon-showdown` a checkout of the server repo, used in the build process (mostly for stuff in `play.pokemonshowdown.com/data/`)
- `eslint-*.json` eslint cache files
- `eslintcache.json` eslint cache files

View File

@ -267,6 +267,8 @@ export const defaultRulesTSChecked = {
/** @type {NonNullable<Config['rules']>} */
export const defaultRulesES3 = {
...defaultRules,
// required in ES3
// ================
"no-var": "off",
"object-shorthand": ["error", "never"],
"prefer-arrow-callback": "off",
@ -277,13 +279,6 @@ export const defaultRulesES3 = {
"prefer-spread": "off",
"radix": "off",
"@stylistic/comma-dangle": "error",
// treat var as let
// unfortunately incompatible with reusing i
// "block-scoped-var": "error",
"no-caller": "error",
"no-invalid-this": "error",
"no-new-wrappers": "error",
"no-restricted-globals": ["error", "Proxy", "Reflect", "Symbol", "WeakSet", "WeakMap"],
"no-unused-vars": ["warn", {
args: "all",
argsIgnorePattern: ".",
@ -292,6 +287,17 @@ export const defaultRulesES3 = {
destructuredArrayIgnorePattern: ".",
ignoreRestSiblings: true,
}],
// with no block scoping, coming up with original variable names is too hard
"no-redeclare": "off",
// treat var as let
// unfortunately doesn't actually let me redeclare
// "block-scoped-var": "error",
"no-caller": "error",
"no-invalid-this": "error",
"no-new-wrappers": "error",
"no-restricted-globals": ["error", "Proxy", "Reflect", "Symbol", "WeakSet", "WeakMap"],
"unicode-bom": "error",
};
@ -388,7 +394,6 @@ export default tseslint.config([
"@stylistic/max-len": "off",
// we use these for the big IIFEs that wrap entire files
"@stylistic/padded-blocks": "off",
"no-redeclare": "off",
// TODO: actually fix useless escapes
"no-useless-escape": "off",
"no-shadow-restricted-names": "error",
@ -398,7 +403,7 @@ export default tseslint.config([
{
name: "JavaScript for Node",
files: [
'*.mjs',
'*.mjs', // look mom I'm linting myself!
'build-tools/*.js',
'build-tools/update',
'build-tools/build-*',

View File

@ -9,9 +9,9 @@
"url": "https://github.com/Zarel/Pokemon-Showdown-Client.git"
},
"scripts": {
"lint": "eslint",
"test": "node build && tsc && npm run lint && mocha test/*.js",
"fix": "eslint --fix",
"lint": "eslint --cache --cache-location caches/eslintcache.json",
"test": "node build && tsc && eslint --cache --cache-location caches/eslintcache.json --max-warnings 0 && mocha test/*.js",
"fix": "eslint --cache --cache-location caches/eslintcache.json --fix",
"build": "node build",
"build-full": "node build full"
},