Skip to content

refactor(config-utl): only imports json5 when it's used#1062

Merged
sverweij merged 1 commit into
mainfrom
refactor/conditionally-import-json5
May 31, 2026
Merged

refactor(config-utl): only imports json5 when it's used#1062
sverweij merged 1 commit into
mainfrom
refactor/conditionally-import-json5

Conversation

@sverweij

Copy link
Copy Markdown
Owner

Description

  • only imports json5 when it's used

Motivation and Context

What you don't load doesn't cost memory or speed.

How Has This Been Tested?

  • green ci

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Documentation only change
  • Refactor (non-breaking change which fixes an issue without changing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • 📖

    • My change doesn't require a documentation update, or ...
    • it does and I have updated it
  • ⚖️

    • The contribution will be subject to The MIT license, and I'm OK with that.
    • The contribution is my own original work.
    • I am ok with the stuff in CONTRIBUTING.md.

@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactor config utilities to lazy-load json5 so it’s only loaded on code paths that actually parse JSON/JSON5, reducing baseline module load cost.

Changes:

  • Replace static import json5 from "json5" with await import("json5") in config-reading helpers.
  • Ensure json5 is only loaded when JSON/JSON5 parsing is required (e.g., not for JS-based configs).
  • Keep existing parsing behavior (still uses json5.parse where applicable).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/config-utl/extract-known-violations.mjs Lazy-load json5 for known-violations parsing.
src/config-utl/extract-depcruise-config/read-config.mjs Lazy-load json5 only for non-JS config files.
src/config-utl/extract-babel-config.mjs Lazy-load json5 only when parsing JSON/JSON5 babel configs.

Comment thread src/config-utl/extract-known-violations.mjs
@sverweij sverweij merged commit 0d8becb into main May 31, 2026
7 checks passed
@sverweij sverweij deleted the refactor/conditionally-import-json5 branch May 31, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants