Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

eslint: Forbid unchecked casts in TypeScript.

Anders Kaseorg37f0a3b41bb2
diff --git a/.eslintrc.json b/.eslintrc.json
index d91f1f44140..88e2e54e8ab 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -172,6 +172,10 @@
// Disable base rule to avoid conflict
"no-use-before-define": "off",
+ "@typescript-eslint/consistent-type-assertions": [
+ "error",
+ {"assertionStyle": "never"}
+ ],
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/explicit-function-return-type": [
diff --git a/web/debug-require-webpack-plugin.ts b/web/debug-require-webpack-plugin.ts
index c5bd6e59bb3..d19fbb15a54 100644
--- a/web/debug-require-webpack-plugin.ts
+++ b/web/debug-require-webpack-plugin.ts
@@ -22,6 +22,7 @@ export default class DebugRequirePlugin implements WebpackPluginInstance {
.tap("DebugRequirePlugin", (resolver) => {
resolver.getHook("beforeRawModule").tap("DebugRequirePlugin", (req) => {
if (!(nameSymbol in req)) {
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
(req as NamedRequest)[nameSymbol] = req.request;
}
return undefined!;
@@ -31,6 +32,7 @@ export default class DebugRequirePlugin implements WebpackPluginInstance {
if (req.path !== false) {
const inPath = path.relative(compiler.context, req.path);
if (!inPath.startsWith("../") && !(nameSymbol in req)) {
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
(req as NamedRequest)[nameSymbol] = "./" + inPath;
}
}
@@ -40,6 +42,7 @@ export default class DebugRequirePlugin implements WebpackPluginInstance {
resolver
.getHook("beforeResolved")
.tap("DebugRequirePlugin", (req: ResolveRequest) => {
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
const name = (req as NamedRequest)[nameSymbol];
if (name !== undefined && req.path !== false) {
const names = resolved.get(req.path);