Skip to content

[Code Quality] Consolidate require-mkdirsync-try-catch into require-fs-sync-try-catch #45952

Closed as not planned

Description

@github-actions

Description

Two structurally identical ESLint rules have drifted apart:

  • require-mkdirsync-try-catch (resolves ESM import { mkdirSync } from "fs" correctly)
  • require-fs-sync-try-catch (only resolves require(...), missing ESM import { readFileSync } from "node:fs" silently)

The drift means import { readFileSync } from "node:fs" escapes the require-fs-sync-try-catch rule entirely.

Suggested Changes

  1. Create a shared factory function for the shared try-detection and fs-binding resolution logic
  2. Lift ESM ImportBinding resolution into try-catch-rule-utils (shared util)
  3. Make both rules delegate to the factory, differing only in method set
  4. Ensure the merged implementation covers both require(...) and ESM import forms

Files Affected

  • actions/setup/js/eslint-factory/rules/require-mkdirsync-try-catch.js
  • actions/setup/js/eslint-factory/rules/require-fs-sync-try-catch.js
  • actions/setup/js/eslint-factory/utils/try-catch-rule-utils.js (new or updated)

Success Criteria

  • Single factory handles both rules
  • ESM import { readFileSync } from "node:fs" is caught by require-fs-sync-try-catch
  • Existing tests pass, new tests cover ESM import form
  • No rule duplication remains between the two implementations

Priority

Medium — fixes a silent false-negative in require-fs-sync-try-catch

Source

Extracted from ESLint Refiner Daily Report — 2026-07-16 (discussion #45930)

🔍 Task mining by Discussion Task Miner - Code Quality Improvement Agent · 183.3 AIC · ⌖ 5.21 AIC · ⊞ 7K · ◷

  • expires on Jul 16, 2026, 11:43 PM UTC-08:00

Activity

  1. github-actions commented on Jul 17, 2026

    @github-actions
    ContributorAuthor

    This issue was automatically closed because it expired on 2026-07-17T07:43:56.676Z.

    Closed by Workflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions