Skip to content

Commit

Permalink
enable @typescript-eslint/no-floating-promises, pass lint+type check (
Browse files Browse the repository at this point in the history
#121)

* enable @typescript-eslint/no-floating-promises, pass lint+type check

Enabling that lint rule exposed a bunch of places where we weren't logging errors, and also caught at least 3 bugs. Glad I did this.

I also disabled prettier as an eslint error,  and added it to the `check` script instead.

I added `ioredis` as a root dependency. We don't use it, but we can't pass typecheck without it installed (because miniflare uses it, even tho it's an optional dep, and there's no good way to disable a third party's type errors in this fashion)

I also added `react-error-boundary` so we don't blow up completely, and have an option to handle errors from `dev` gracefully.

* add a changeset

* apply review suggestions
  • Loading branch information
threepointone authored Dec 16, 2021
1 parent c6eb564 commit 1df6b0c
Show file tree
Hide file tree
Showing 14 changed files with 286 additions and 47 deletions.
5 changes: 5 additions & 0 deletions .changeset/strong-penguins-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

enable @typescript-eslint/no-floating-promises, pass lint+type check
4 changes: 1 addition & 3 deletions .github/workflows/tests-typecheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,11 @@ jobs:
restore-keys: |
${{ runner.os }}-node-
# Prefer offline will skip registry verification with cached NPM packages
- name: Install NPM dependencies
run: npm install

- name: Run Type Checking & ESLint
#TODO remove the --skipLibCheck flag at some point
run: tsc --skipLibCheck && npm run lint
run: npm run check

- name: Test
run: npm run test
Expand Down
179 changes: 179 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.27.1",
"eslint-plugin-react-hooks": "^4.3.0",
"ioredis": "^4.28.2",
"jest": "^27.4.2",
"prettier": "^2.5.1",
"source-map-explorer": "^2.5.2",
"typescript": "^4.5.2"
},
"scripts": {
"lint": "eslint packages/**",
"check": "tsc && npm run lint",
"check": "prettier packages/** --check && tsc && npm run lint",
"prettify": "prettier packages/** --write"
},
"engines": {
Expand All @@ -42,6 +43,13 @@
"packages/wrangler/vendor"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"project": [
"tsconfig.json"
],
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
"eslint-plugin-react",
Expand All @@ -66,10 +74,10 @@
"plugin:react-hooks/recommended"
],
"rules": {
"prettier/prettier": "error",
"@typescript-eslint/consistent-type-imports": [
"error"
],
"@typescript-eslint/no-floating-promises": "error",
"no-empty": "off",
"require-yield": "off",
"no-empty-function": "off",
Expand Down
3 changes: 2 additions & 1 deletion packages/wrangler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
"tmp-promise": "^3.0.3",
"undici": "^4.11.1",
"ws": "^8.3.0",
"yargs": "^17.3.0"
"yargs": "^17.3.0",
"react-error-boundary": "^3.1.4"
},
"files": [
"src",
Expand Down
5 changes: 4 additions & 1 deletion packages/wrangler/scripts/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ async function run() {
});
}

run();
run().catch((e) => {
console.error(e);
process.exit(1);
});
11 changes: 0 additions & 11 deletions packages/wrangler/src/api/inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,6 @@ export type DtEvent = DtLogEvent | DtExceptionEvent;
*/
export type DtListener = (event: DtEvent) => void;

interface DtProtocolRequest<T> {
id: number;
method: string;
params?: T;
}

interface DtProtocolResponse<T> {
id: number;
result: T;
}

/**
* A DevTools inspector that listens to logs and debug events from a Worker.
*
Expand Down
Loading

0 comments on commit 1df6b0c

Please sign in to comment.