Skip to content

False positive on esnext 'using' declaration #55

@erictheswift

Description

@erictheswift

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch eslint-plugin-prefer-let@3.0.1 for the project I'm working on.

Explicit resource management proposal (using keyword) landed in typescript 5.2. prefer-let plugin false positively reacts on using aiming to replace it with let

Here is the diff that solved my problem:

diff --git a/node_modules/eslint-plugin-prefer-let/lib/rules/prefer-let.js b/node_modules/eslint-plugin-prefer-let/lib/rules/prefer-let.js
index 73d487f..abab361 100644
--- a/node_modules/eslint-plugin-prefer-let/lib/rules/prefer-let.js
+++ b/node_modules/eslint-plugin-prefer-let/lib/rules/prefer-let.js
@@ -55,7 +55,7 @@ module.exports = {
             message: 'prefer `let` over `var` to declare value bindings',
             node
           });
-        } else if (node.kind !== 'let' && !isTopLevelScope(node)) {
+        } else if (node.kind === 'const' && !isTopLevelScope(node)) {
           let constToken = sourceCode.getFirstToken(node);
 
           context.report({

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions