Skip to content

fix: Rename path parameter to avoid shadowing path module#319

Open
thompson-tomo wants to merge 2 commits intothlorenz:masterfrom
thompson-tomo:patch-2
Open

fix: Rename path parameter to avoid shadowing path module#319
thompson-tomo wants to merge 2 commits intothlorenz:masterfrom
thompson-tomo:patch-2

Conversation

@thompson-tomo
Copy link
Contributor

@thompson-tomo thompson-tomo commented Mar 3, 2026

The path parameter in the cleanPath function was shadowing the path module imported at the top of the file. This blocks calling path.join(), as currently it is mistakenly treating path as a string method. Renaming the parameter to filepath resolves this issue and improves code clarity.

This is the precursor to #249

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Renames the cleanPath function parameter to avoid shadowing the top-level path module import, improving clarity and unblocking future path.* usage (noted as a precursor to #249).

Changes:

  • Renamed cleanPath(path) parameter to cleanPath(filePath) and updated its internal references.
Comments suppressed due to low confidence (2)

doctoc.js:13

  • cleanPath expands ~ using process.env.HOME, which is unset on some platforms (notably Windows). This can produce paths like undefined\... when a user passes ~...; consider using a cross-platform home lookup (e.g., os.homedir() or a HOME/USERPROFILE fallback) when expanding ~.
function cleanPath(filePath) {
  var homeExpanded = (filePath.indexOf('~') === 0) ? process.env.HOME + filePath.substr(1) : filePath;

doctoc.js:12

  • PR description mentions path.join() being blocked, but this file currently doesn't call path.join() anywhere. Consider updating the PR description to reflect that this rename is primarily a clarity/precursor change rather than fixing an immediate runtime error in this branch.
function cleanPath(filePath) {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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