microsoft / microsoft/vscode

perf(eslint): cache package.json read in AMD module import rule

Open
#334,810 0 comments 0 reactions 1 assignee Claimed by @meganrogge View on GitHub
stale triage-needed
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

- **VS Code Version:** Main branch (Dev)
- **OS Version:** N/A

### Problem Description
In the ESLint rule responsible for checking AMD module imports (`vscode-eslint-plugin-local`), `readFileSync` and `JSON.parse` are executed inside the `create(context)` method.

Because `create(context)` runs for every evaluated file during linting, `package.json` is repeatedly read from the file system and parsed into memory hundreds or thousands of times.

### Proposed Solution / Steps
Move `package.json` reading logic outside of the `create()` method (to module scope) so it only runs once per linting session, eliminating unnecessary disk I/O.

I have a fix ready and would be happy to submit a PR for this!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.