From 4f51d23ae41bb3054e11b8adf511af266a9ddb17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B2=81=E7=8F=AD=E4=B8=83=E5=8F=B7?= <9159450+luban-71@user.noreply.gitee.com> Date: Tue, 1 Sep 2026 18:19:58 +0800 Subject: [PATCH] chore(lint): forbid local withTimeout copies (#457) Add no-restricted-syntax rule that bans: - FunctionDeclaration named withTimeout - VariableDeclarator named withTimeout initialized with a function or arrow function Allow the canonical implementation in lib/with-timeout.ts via overrides. Closes #457 --- .eslintrc.json | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index a2569c2..f66808f 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,4 +1,25 @@ { "root": true, - "extends": "next/core-web-vitals" + "extends": "next/core-web-vitals", + "rules": { + "no-restricted-syntax": [ + "error", + { + "selector": "FunctionDeclaration[id.name='withTimeout']", + "message": "Use withTimeout from @/lib/with-timeout instead of defining a local copy." + }, + { + "selector": "VariableDeclarator[id.name='withTimeout'][init.type='FunctionExpression'], VariableDeclarator[id.name='withTimeout'][init.type='ArrowFunctionExpression']", + "message": "Use withTimeout from @/lib/with-timeout instead of assigning a local copy." + } + ] + }, + "overrides": [ + { + "files": ["lib/with-timeout.ts"], + "rules": { + "no-restricted-syntax": "off" + } + } + ] }