From dcfd8a69a39c1e2c29bb9b9443190c7db126c506 Mon Sep 17 00:00:00 2001 From: Christian Gunderman Date: Tue, 17 Mar 2026 23:16:19 -0700 Subject: [PATCH] Correct linter rule. --- eslint.config.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 99b1b28f4b..96950360a1 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -37,6 +37,15 @@ const commonRestrictedSyntaxRules = [ }, ]; +const typeSafePropertyCheckRules = [ + { + selector: + 'UnaryExpression[operator="typeof"] > MemberExpression[computed=true][property.type="Literal"]', + message: + 'Do not use typeof to check object properties. Define a TypeScript interface and a type guard function instead.', + }, +]; + export default tseslint.config( { // Global ignores @@ -136,12 +145,7 @@ export default tseslint.config( 'no-restricted-syntax': [ 'error', ...commonRestrictedSyntaxRules, - { - selector: - 'UnaryExpression[operator="typeof"] > MemberExpression[computed=true][property.type="Literal"]', - message: - 'Do not use typeof to check object properties. Define a TypeScript interface and a type guard function instead.', - }, + ...typeSafePropertyCheckRules, ], 'no-unsafe-finally': 'error', 'no-unused-expressions': 'off', // Disable base rule @@ -189,6 +193,7 @@ export default tseslint.config( 'no-restricted-syntax': [ 'error', ...commonRestrictedSyntaxRules, + ...typeSafePropertyCheckRules, { selector: 'TSInterfaceDeclaration[id.name=/.+Response$/] TSPropertySignature:not([optional=true])', @@ -215,6 +220,7 @@ export default tseslint.config( 'no-restricted-syntax': [ 'error', ...commonRestrictedSyntaxRules, + ...typeSafePropertyCheckRules, { selector: 'CallExpression[callee.object.name="Object"][callee.property.name="create"]',