From 2276cfedb24e77bdcec81cbb09eb06199976c534 Mon Sep 17 00:00:00 2001 From: dinwwwh Date: Tue, 15 Sep 2026 01:52:51 +0000 Subject: [PATCH 1/2] chore(eslint): enable guard-for-in and restrict for...in loops Enable the core `guard-for-in` rule and add a `ForInStatement` selector to `no-restricted-syntax` so that iterating over an object steers contributors toward `Object.keys()`, `Object.entries()`, or `Object.values()` instead of `for...in`. The antfu preset already configures `no-restricted-syntax` with its own selectors; overriding a rule replaces its options, so those selectors are carried over explicitly to keep the existing restrictions intact. No source changes were needed: the codebase already iterates objects via `Object.keys()`/`Object.entries()` and contains no `for...in` loops. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01HgmAA3VgHHTxew3CjB6KSM --- eslint.config.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/eslint.config.js b/eslint.config.js index cdfc48c..8f2a017 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -7,6 +7,17 @@ export default antfu({ 'pnpm/json-enforce-catalog': 'off', 'pnpm/yaml-enforce-settings': 'off', 'ts/method-signature-style': 'off', + 'guard-for-in': 'error', + 'no-restricted-syntax': [ + 'error', + // Keep the selectors from the antfu preset, since overriding a rule replaces its options. + 'TSEnumDeclaration[const=true]', + 'TSExportAssignment', + { + selector: 'ForInStatement', + message: 'Prefer Object.keys(), Object.entries(), or Object.values() to iterate over an object instead of for...in.', + }, + ], }, }, { files: ['**/*.test.ts', '**/*.test-d.ts'], From 489fd16a53f32ef6227cc93de8106dfd30574db1 Mon Sep 17 00:00:00 2001 From: dinwwwh Date: Tue, 15 Sep 2026 01:58:36 +0000 Subject: [PATCH 2/2] chore(eslint): keep guard-for-in only, drop for...in restriction Remove the `no-restricted-syntax` override that banned `for...in` outright. The preset's own `no-restricted-syntax` selectors apply again unchanged, and `guard-for-in` stays enabled so any `for...in` loop must filter its body. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01HgmAA3VgHHTxew3CjB6KSM --- eslint.config.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 8f2a017..7343a4a 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -8,16 +8,6 @@ export default antfu({ 'pnpm/yaml-enforce-settings': 'off', 'ts/method-signature-style': 'off', 'guard-for-in': 'error', - 'no-restricted-syntax': [ - 'error', - // Keep the selectors from the antfu preset, since overriding a rule replaces its options. - 'TSEnumDeclaration[const=true]', - 'TSExportAssignment', - { - selector: 'ForInStatement', - message: 'Prefer Object.keys(), Object.entries(), or Object.values() to iterate over an object instead of for...in.', - }, - ], }, }, { files: ['**/*.test.ts', '**/*.test-d.ts'],