From ca6e9b5745e80b544c404bb74a968b68aea59c40 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Tue, 4 Jun 2024 09:26:59 -1000 Subject: [PATCH] chore: validate promise handling (#11842) * chore: don't swallow rejected promise errors * ignore rules rather than adding catch blocks. add async to functions returning promises * remove redundant asyncs * remove extremely pointless rule * remove another daft rule * this is what typescript is for * again, typescript already has this covered, we don't need it * simplify * this rule is harmless --------- Co-authored-by: Rich Harris --- eslint.config.js | 9 ++++++++- playgrounds/demo/.prettierignore | 1 - playgrounds/demo/package.json | 4 +--- playgrounds/sandbox/run.js | 2 +- playgrounds/sandbox/tsconfig.json | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) delete mode 100644 playgrounds/demo/.prettierignore diff --git a/eslint.config.js b/eslint.config.js index c15c17e7dc..d8875d37f9 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -5,10 +5,18 @@ import lube from 'eslint-plugin-lube'; export default [ ...svelte_config, { + languageOptions: { + parserOptions: { + project: true + } + }, plugins: { lube }, rules: { + '@typescript-eslint/await-thenable': 'error', + '@typescript-eslint/prefer-promise-reject-errors': 'error', + '@typescript-eslint/require-await': 'error', 'no-console': 'error', 'lube/svelte-naming-convention': ['error', { fixSameNames: true }], // eslint isn't that well-versed with JSDoc to know that `foo: /** @type{..} */ (foo)` isn't a violation of this rule, so turn it off @@ -43,7 +51,6 @@ export default [ 'documentation', // contains a fork of the REPL which doesn't adhere to eslint rules 'sites/svelte-5-preview/**', - 'playgrounds/demo/src/**', 'tmp/**', // wasn't checked previously, reenable at some point 'sites/svelte.dev/**' diff --git a/playgrounds/demo/.prettierignore b/playgrounds/demo/.prettierignore deleted file mode 100644 index 85de9cf933..0000000000 --- a/playgrounds/demo/.prettierignore +++ /dev/null @@ -1 +0,0 @@ -src diff --git a/playgrounds/demo/package.json b/playgrounds/demo/package.json index cc2739cb68..e96e8011ba 100644 --- a/playgrounds/demo/package.json +++ b/playgrounds/demo/package.json @@ -9,9 +9,7 @@ "ssr": "node ./server.js", "build": "vite build --outDir dist/client && vite build --outDir dist/server --ssr src/entry-server.ts", "prod": "npm run build && node dist", - "preview": "vite preview", - "format": "prettier --check --write .", - "lint": "prettier --check . && eslint" + "preview": "vite preview" }, "devDependencies": { "@sveltejs/vite-plugin-svelte": "^3.1.0", diff --git a/playgrounds/sandbox/run.js b/playgrounds/sandbox/run.js index 86ec3fc882..dffcc0af58 100644 --- a/playgrounds/sandbox/run.js +++ b/playgrounds/sandbox/run.js @@ -29,7 +29,7 @@ function mkdirp(dir) { const svelte_modules = glob('**/*.svelte', { cwd: `${cwd}/input` }); const js_modules = glob('**/*.js', { cwd: `${cwd}/input` }); -for (const generate of ['client', 'server']) { +for (const generate of /** @type {const} */ (['client', 'server'])) { console.error(`\n--- generating ${generate} ---\n`); for (const file of svelte_modules) { const input = `${cwd}/input/${file}`; diff --git a/playgrounds/sandbox/tsconfig.json b/playgrounds/sandbox/tsconfig.json index 44ef7add23..8aa4b6f1e9 100644 --- a/playgrounds/sandbox/tsconfig.json +++ b/playgrounds/sandbox/tsconfig.json @@ -13,5 +13,5 @@ "allowJs": true, "checkJs": true }, - "include": ["./input"] + "include": ["./run.js", "./input"] }