Skip to content

feat(eslint-plugin): [no-unused-vars] support explicit resource management with ignoreUsingDeclarations option #11456

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

nayounsang
Copy link
Contributor

@nayounsang nayounsang commented Aug 5, 2025

PR Checklist

Overview

TODO: docs? maybe it can skip. Because option depends on eslint

  • As eslint supports explict resource management(using, await using) with ignoreUsingDeclarations option,
    Add boolean type option, default is false. [ref](Ignore even if not referenced in the code block.)
  • When ignoreUsingDeclarations is enable, ignore even if not referenced in the code block.
// pass
{
  using foo = getResource();
}
  • Implement this with options.ignoreUsingDeclarations is enable && def.parent.kind is using or await using conditions.

ref

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @nayounsang!

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 Aug 5, 2025

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit afa9b92
🔍 Latest deploy log https://app.netlify.com/projects/typescript-eslint/deploys/68946db093170000084bb9e4
😎 Deploy Preview https://deploy-preview-11456--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: 95 (🟢 up 4 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 92 (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 project configuration.

@nayounsang nayounsang marked this pull request as draft August 5, 2025 06:28
Copy link

nx-cloud bot commented Aug 5, 2025

View your CI Pipeline Execution ↗ for commit afa9b92

Command Status Duration Result
nx test eslint-plugin --coverage=false ✅ Succeeded 5m 30s View ↗
nx run-many -t lint ✅ Succeeded 3m 17s View ↗
nx run-many -t typecheck ✅ Succeeded 2m 13s View ↗
nx run types:build ✅ Succeeded 5s View ↗
nx test eslint-plugin-internal --coverage=false ✅ Succeeded 2s View ↗
nx test typescript-estree --coverage=false ✅ Succeeded 1s View ↗
nx run integration-tests:test ✅ Succeeded 3s View ↗
nx run generate-configs ✅ Succeeded 6s View ↗
Additional runs (27) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2025-08-07 09:22:22 UTC

Copy link

codecov bot commented Aug 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.88%. Comparing base (88b063e) to head (afa9b92).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #11456   +/-   ##
=======================================
  Coverage   90.88%   90.88%           
=======================================
  Files         505      505           
  Lines       51121    51137   +16     
  Branches     8413     8419    +6     
=======================================
+ Hits        46459    46475   +16     
  Misses       4648     4648           
  Partials       14       14           
Flag Coverage Δ
unittest 90.88% <100.00%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
packages/eslint-plugin/src/rules/no-unused-vars.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nayounsang nayounsang marked this pull request as ready for review August 6, 2025 07:44
Copy link
Member

@kirkwaiblinger kirkwaiblinger left a comment

Choose a reason for hiding this comment

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

LGTM, just requesting a bit of alignment with eslint/eslint#19828

Thanks!

@@ -546,6 +557,12 @@ export default createRule<Options, MessageIds>({
});
}
continue;
} else if (
Copy link
Member

Choose a reason for hiding this comment

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

Surprised this isn't caught by a lint rule, but we shouldn't have else if after the unconditional continue (along the lines of no-else-return).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on lint option(allowElseIf:false), conditional statement is separated into single if.

Copy link
Member

Choose a reason for hiding this comment

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

For consistency, could you make sure that the tests equivalent to https://github.com/eslint/eslint/pull/19828/files#diff-a011296b092c66311bc2ef19de30721cb1c5e9164be696f6f581ad4ba6231998 are included?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I specified the ECMA version and aligned the variable names. I also added a test case from the reference.

@kirkwaiblinger kirkwaiblinger added the awaiting response Issues waiting for a reply from the OP or another party label Aug 6, 2025
@github-actions github-actions bot removed the awaiting response Issues waiting for a reply from the OP or another party label Aug 7, 2025
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.

Enhancement: [no-unused-vars] support explicit resource management
2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy