Default to type-aware linting

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.
This commit is contained in:
Guangcong Luo 2020-10-18 13:07:39 +01:00
parent 9d87616176
commit 1ed9c9f12e
4 changed files with 5 additions and 18 deletions

View File

@ -220,6 +220,7 @@
// see bottom of file for source
"ignorePattern": "^\\s*(?:\\/\\/ \\s*)?(?:(?:export )?(?:let |const )?[a-zA-Z0-9_$.]+(?: \\+?=>? )|[a-zA-Z0-9$]+: \\[?|(?:return |throw )?(?:new )?(?:[a-zA-Z0-9$.]+\\()?)?(?:Utils\\.html|(?:this\\.)?(?:room\\.)?tr|\\$\\()?['\"`/]"
}],
"prefer-const": ["warn", {"destructuring": "all"}], // typescript-eslint/recommended forces this so we need to re-override
// PS code (code specific to PS)
"@typescript-eslint/no-namespace": "off",

View File

@ -1,11 +1,5 @@
{
"extends": "./.eslintrc-no-types.json",
"rules": {
// test only (should never be committed, but useful when testing)
"no-debugger": "error",
"no-unused-vars": ["error", {"args": "none"}],
"prefer-const": ["error", {"destructuring": "all"}]
},
"overrides": [
{
"files": ["./config/*.ts", "./data/**/*.ts", "./lib/*.ts", "./server/**/*.ts", "./sim/**/*.ts", "./tools/set-import/*.ts"],
@ -34,15 +28,6 @@
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/restrict-template-expressions": "off",
// test only (should never be committed, but useful when testing)
"max-len": ["error", {
"code": 120, "tabWidth": 0,
// see bottom of .eslintrc-no-types.json for source
"ignorePattern": "^\\s*(?:\\/\\/ \\s*)?(?:(?:export )?(?:let |const )?[a-zA-Z0-9_$.]+(?: \\+?=>? )|[a-zA-Z0-9$]+: \\[?|(?:return |throw )?(?:new )?(?:[a-zA-Z0-9$.]+\\()?)?(?:Utils\\.html|(?:this\\.)?(?:room\\.)?tr|\\$\\()?['\"`/]"
}],
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error", {"args": "none"}],
// probably bugs
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-for-in-array": "error",

2
.gitignore vendored
View File

@ -9,7 +9,7 @@
/server/chat-plugins/*-private.js
npm-debug.log
.eslintcache
.eslintfullcache
.eslintcache-no-types
package-lock.json
/tools/set-import/sets
databases/*.db*

View File

@ -26,8 +26,9 @@
"start": "node pokemon-showdown start",
"build": "node build",
"tsc": "tsc",
"lint": "eslint . --config .eslintrc-no-types.json --cache --ext .js,.ts",
"full-lint": "eslint . --config .eslintrc-types.json --cache --cache-location .eslintfullcache --ext .js,.ts",
"fast-lint": "eslint . --config .eslintrc-no-types.json --cache --cache-location .eslintcache-no-types --ext .js,.ts",
"lint": "eslint . --cache --ext .js,.ts",
"full-lint": "eslint . --cache --ext .js,.ts --max-warnings 0",
"pretest": "npm run lint && npm run build",
"test": "mocha",
"posttest": "npm run tsc",