From ed9429e9b5aaf35eff0827dea0413dea83f24f84 Mon Sep 17 00:00:00 2001 From: SACHIN KUMAR <118827645+sAchin-680@users.noreply.github.com> Date: Tue, 31 Mar 2026 17:43:46 +0530 Subject: [PATCH] chore: setup eslint no-sync rule and document all sync FS usages (#15251) * chore: setup eslint no-sync rule and document all sync FS usages - Added eslint-plugin-n and configured n/no-sync rule as a warning - This enables tracking of synchronous FS API usages across the codebase - No code refactoring yet; warnings serve as documentation for migration planning Signed-off-by: SACHIN KUMAR --- eslint.config.mjs | 10 ++++++++ package.json | 1 + pnpm-lock.yaml | 63 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) diff --git a/eslint.config.mjs b/eslint.config.mjs index 9d3630d33ce..aa80ef5630d 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -35,6 +35,7 @@ import redundantUndefined from 'eslint-plugin-redundant-undefined'; import simpleImportSort from 'eslint-plugin-simple-import-sort'; import fileProgress from 'eslint-plugin-file-progress'; import vitest from '@vitest/eslint-plugin'; +import nodePlugin from 'eslint-plugin-n'; import svelteConfig from './svelte.config.js'; const __filename = fileURLToPath(import.meta.url); @@ -95,6 +96,7 @@ export default [ plugins: { // compliant v10 plug-ins unicorn, + n: nodePlugin, // non-compliant v10 plug-ins 'file-progress': fixupPluginRules(fileProgress), etc: fixupPluginRules(etc), @@ -194,6 +196,14 @@ export default [ // unicorn custom rules 'unicorn/prefer-node-protocol': 'error', + // node custom rules + 'n/no-sync': [ + 'warn', + { + ignores: ['existsSync'], + }, + ], + // sonarjs custom rules 'sonarjs/cognitive-complexity': 'off', 'sonarjs/no-duplicate-string': 'off', diff --git a/package.json b/package.json index ee1500d6848..e015f164bd9 100644 --- a/package.json +++ b/package.json @@ -163,6 +163,7 @@ "eslint-plugin-etc": "^2.0.3", "eslint-plugin-file-progress": "^4.0.0", "eslint-plugin-import": "^2.32.0", + "eslint-plugin-n": "^17.23.1", "eslint-plugin-no-null": "^1.0.2", "eslint-plugin-redundant-undefined": "^1.0.0", "eslint-plugin-simple-import-sort": "^12.1.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8918fb9f46c..f35d8eca7af 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -154,6 +154,9 @@ importers: eslint-plugin-import: specifier: ^2.32.0 version: 2.32.0(@typescript-eslint/parser@8.58.0(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-typescript@4.4.4)(eslint@10.1.0(jiti@2.6.1)) + eslint-plugin-n: + specifier: ^17.23.1 + version: 17.24.0(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3) eslint-plugin-no-null: specifier: ^1.0.2 version: 1.0.2(eslint@10.1.0(jiti@2.6.1)) @@ -6811,6 +6814,12 @@ packages: resolution: {integrity: sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==} engines: {node: '>=12'} + eslint-compat-utils@0.5.1: + resolution: {integrity: sha512-3z3vFexKIEnjHE3zCMRo6fn/e44U7T1khUjg+Hp0ZQMCigh28rALD0nPFBcGZuiLC5rLZa2ubQHDRln09JfU2Q==} + engines: {node: '>=12'} + peerDependencies: + eslint: '>=6.0.0' + eslint-etc@5.2.1: resolution: {integrity: sha512-lFJBSiIURdqQKq9xJhvSJFyPA+VeTh5xvk24e8pxVL7bwLBtGF60C/KRkLTMrvCZ6DA3kbPuYhLWY0TZMlqTsg==} peerDependencies: @@ -6868,6 +6877,12 @@ packages: eslint-import-resolver-webpack: optional: true + eslint-plugin-es-x@7.8.0: + resolution: {integrity: sha512-7Ds8+wAAoV3T+LAKeu39Y5BzXCrGKrcISfgKEqTS4BDN8SFEDQd0S43jiQ8vIa3wUKD07qitZdfzlenSi8/0qQ==} + engines: {node: ^14.18.0 || >=16.0.0} + peerDependencies: + eslint: '>=8' + eslint-plugin-etc@2.0.3: resolution: {integrity: sha512-o5RS/0YwtjlGKWjhKojgmm82gV1b4NQUuwk9zqjy9/EjxNFKKYCaF+0M7DkYBn44mJ6JYFZw3Ft249dkKuR1ew==} peerDependencies: @@ -6890,6 +6905,12 @@ packages: '@typescript-eslint/parser': optional: true + eslint-plugin-n@17.24.0: + resolution: {integrity: sha512-/gC7/KAYmfNnPNOb3eu8vw+TdVnV0zhdQwexsw6FLXbhzroVj20vRn2qL8lDWDGnAQ2J8DhdfvXxX9EoxvERvw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: '>=8.23.0' + eslint-plugin-no-null@1.0.2: resolution: {integrity: sha512-uRDiz88zCO/2rzGfgG15DBjNsgwWtWiSo4Ezy7zzajUgpnFIqd1TjepKeRmJZHEfBGu58o2a8S0D7vglvvhkVA==} engines: {node: '>=5.0.0'} @@ -7469,6 +7490,9 @@ packages: resolution: {integrity: sha512-dW7vl+yiAJSp6aCekaVnVJxurRv7DCOLyXqEG3RYMYUg7AuJ2jCqPkZTA8ooqC2vtnkaMcV5WfFBMuEnTu1OQg==} engines: {node: '>=20'} + globrex@0.1.2: + resolution: {integrity: sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==} + gopd@1.2.0: resolution: {integrity: sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==} engines: {node: '>= 0.4'} @@ -11328,6 +11352,11 @@ packages: peerDependencies: typescript: '>=4.8.4' + ts-declaration-location@1.0.7: + resolution: {integrity: sha512-EDyGAwH1gO0Ausm9gV6T2nUvBgXT5kGoCMJPllOaooZ+4VvJiKBdZE7wK18N1deEowhcUptS+5GXZK8U/fvpwA==} + peerDependencies: + typescript: '>=4.0.0' + ts-dedent@2.2.0: resolution: {integrity: sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ==} engines: {node: '>=6.10'} @@ -19405,6 +19434,11 @@ snapshots: escape-string-regexp@5.0.0: {} + eslint-compat-utils@0.5.1(eslint@10.1.0(jiti@2.6.1)): + dependencies: + eslint: 10.1.0(jiti@2.6.1) + semver: 7.7.4 + eslint-etc@5.2.1(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3): dependencies: '@typescript-eslint/experimental-utils': 5.62.0(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3) @@ -19462,6 +19496,13 @@ snapshots: transitivePeerDependencies: - supports-color + eslint-plugin-es-x@7.8.0(eslint@10.1.0(jiti@2.6.1)): + dependencies: + '@eslint-community/eslint-utils': 4.9.1(eslint@10.1.0(jiti@2.6.1)) + '@eslint-community/regexpp': 4.12.2 + eslint: 10.1.0(jiti@2.6.1) + eslint-compat-utils: 0.5.1(eslint@10.1.0(jiti@2.6.1)) + eslint-plugin-etc@2.0.3(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3): dependencies: '@phenomnomnominal/tsquery': 5.0.1(typescript@5.9.3) @@ -19510,6 +19551,21 @@ snapshots: - eslint-import-resolver-webpack - supports-color + eslint-plugin-n@17.24.0(eslint@10.1.0(jiti@2.6.1))(typescript@5.9.3): + dependencies: + '@eslint-community/eslint-utils': 4.9.1(eslint@10.1.0(jiti@2.6.1)) + enhanced-resolve: 5.20.1 + eslint: 10.1.0(jiti@2.6.1) + eslint-plugin-es-x: 7.8.0(eslint@10.1.0(jiti@2.6.1)) + get-tsconfig: 4.13.7 + globals: 15.15.0 + globrex: 0.1.2 + ignore: 5.3.2 + semver: 7.7.4 + ts-declaration-location: 1.0.7(typescript@5.9.3) + transitivePeerDependencies: + - typescript + eslint-plugin-no-null@1.0.2(eslint@10.1.0(jiti@2.6.1)): dependencies: eslint: 10.1.0(jiti@2.6.1) @@ -20259,6 +20315,8 @@ snapshots: slash: 5.1.0 unicorn-magic: 0.4.0 + globrex@0.1.2: {} + gopd@1.2.0: {} got@11.8.6: @@ -24895,6 +24953,11 @@ snapshots: dependencies: typescript: 5.9.3 + ts-declaration-location@1.0.7(typescript@5.9.3): + dependencies: + picomatch: 4.0.4 + typescript: 5.9.3 + ts-dedent@2.2.0: {} ts-morph@13.0.2: