From f5762510ae5b952bec4ccc32f230b6fb5b28b74a Mon Sep 17 00:00:00 2001 From: CharlieHelps Date: Thu, 24 Jul 2025 18:40:18 +0000 Subject: [PATCH] Add ESLint rules to disallow 'as' type assertions and non-null assertions --- config/eslint.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/config/eslint.js b/config/eslint.js index f05cc4c..6f16894 100644 --- a/config/eslint.js +++ b/config/eslint.js @@ -344,6 +344,18 @@ export const config = [ { allowTernary: true }, ], '@typescript-eslint/unified-signatures': ERROR, + // Disallow the TypeScript `as` operator for type assertions. + // Using `assertionStyle: "never"` forbids both `as` and angle-bracket + // assertions, effectively preventing all direct casts. + '@typescript-eslint/consistent-type-assertions': [ + ERROR, + { + assertionStyle: 'never', + }, + ], + + // Disallow non-null assertions (the `!` postfix operator). + '@typescript-eslint/no-non-null-assertion': ERROR, 'import/consistent-type-specifier-style': [ERROR, 'prefer-inline'], // Disable rules from presets