Skip to content

feat: standardize debug namespaces to file paths #10599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

JoshuaKGoldberg
Copy link
Member

PR Checklist

Overview

Adds a new @typescript-eslint/internal/debug-namespace lint rule that makes sure any const log = debug('...') uses a namespace equivalent to the package name, file directory, and file path.

This caught several discrepancies in existing namespaces. I don't think we need to count this as a breaking change as those namespaces really aren't part of the public API. But this does constitute a feat: I think.

💖

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @JoshuaKGoldberg!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

Copy link

netlify bot commented Jan 3, 2025

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit e9fe780
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/678465d8b1a1890008263d01
😎 Deploy Preview https://deploy-preview-10599--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 94 (🟢 up 1 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 98 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

nx-cloud bot commented Jan 3, 2025

View your CI Pipeline Execution ↗ for commit e9fe780.

Command Status Duration Result
nx run-many --target=build --exclude website --... ✅ Succeeded 2s View ↗
nx run-many --target=clean ✅ Succeeded 11s View ↗

☁️ Nx Cloud last updated this comment at 2025-01-13 01:13:13 UTC

Copy link

codecov bot commented Jan 3, 2025

Codecov Report

Attention: Patch coverage is 96.42857% with 1 line in your changes missing coverage. Please review.

Project coverage is 86.91%. Comparing base (d63ea3b) to head (106bd47).
Report is 22 commits behind head on main.

Current head 106bd47 differs from pull request most recent head e9fe780

Please upload reports for the commit e9fe780 to get more accurate results.

Files with missing lines Patch % Lines
...slint-plugin-internal/src/rules/debug-namespace.ts 95.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10599      +/-   ##
==========================================
+ Coverage   86.90%   86.91%   +0.01%     
==========================================
  Files         446      447       +1     
  Lines       15505    15525      +20     
  Branches     4517     4521       +4     
==========================================
+ Hits        13475    13494      +19     
  Misses       1675     1675              
- Partials      355      356       +1     
Flag Coverage Δ
unittest 86.91% <96.42%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/type-utils/src/predicates.ts 21.21% <100.00%> (ø)
...estree/src/create-program/createIsolatedProgram.ts 64.00% <100.00%> (ø)
...-estree/src/create-program/createProjectProgram.ts 100.00% <100.00%> (ø)
...-estree/src/create-program/createProjectService.ts 95.65% <100.00%> (ø)
...ript-estree/src/create-program/createSourceFile.ts 90.00% <100.00%> (ø)
.../src/create-program/getWatchProgramsForProjects.ts 82.85% <100.00%> (ø)
...t-estree/src/create-program/useProvidedPrograms.ts 100.00% <100.00%> (ø)
...pt-estree/src/parseSettings/createParseSettings.ts 81.57% <ø> (ø)
...-estree/src/parseSettings/getProjectConfigFiles.ts 100.00% <100.00%> (ø)
...ipt-estree/src/parseSettings/resolveProjectList.ts 97.77% <ø> (ø)
... and 1 more

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review January 3, 2025 07:59
bradzacher
bradzacher previously approved these changes Jan 3, 2025
Comment on lines 8 to 9
const matched =
/typescript-eslint[\\/]+packages[\\/]+([a-z-]+)[\\/]+(.+)/.exec(filePath);
Copy link
Member

Choose a reason for hiding this comment

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

Probably better to just make this a path relative to this file? Eg pkgsRoot = path.resolve('..', '..', '..'); relativePath = file.replace(pkgsRoot, '..');

That way the rule doesn't rely on the folder name.

Copy link
Member Author

@JoshuaKGoldberg JoshuaKGoldberg Jan 13, 2025

Choose a reason for hiding this comment

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

Ah, those got irksome to deal with in unit tests with explicit filenames. But +1 that this regex is unseemly. I switched to .split(/packages[\\/]+/) and added a bit more testing.

@JoshuaKGoldberg JoshuaKGoldberg merged commit 49a94b3 into typescript-eslint:main Jan 13, 2025
45 of 61 checks passed
@JoshuaKGoldberg JoshuaKGoldberg deleted the debug-lint-rule branch January 13, 2025 12:43
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Repo: Standardize debug namespaces per-file
2 participants