Skip to content

Commit 85daccc

Browse files
committed
refactor: cleanup markVariableAsUsed
1 parent b1a63d3 commit 85daccc

File tree

3 files changed

+4
-28
lines changed

3 files changed

+4
-28
lines changed

lib/rules/jsx-uses-vars.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ module.exports = {
6565
return
6666
}
6767

68-
utils.markVariableAsUsed(context, name, node)
68+
context.sourceCode.markVariableAsUsed(name, node)
6969
}
7070
}
7171
}

lib/utils/index.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,10 +2015,6 @@ module.exports = {
20152015
withinTypeNode,
20162016
findVariableByIdentifier,
20172017
getScope,
2018-
/**
2019-
* Marks a variable with the given name in the current scope as used. This affects the no-unused-vars rule.
2020-
*/
2021-
markVariableAsUsed,
20222018
/**
20232019
* Checks whether the given node is in export default.
20242020
* @param {ASTNode} node
@@ -2664,26 +2660,6 @@ function isTypeScriptFile(path) {
26642660
return path.endsWith('.ts') || path.endsWith('.tsx') || path.endsWith('.mts')
26652661
}
26662662

2667-
// ------------------------------------------------------------------------------
2668-
// ESLint Helpers
2669-
// ------------------------------------------------------------------------------
2670-
/**
2671-
* Marks a variable with the given name in the current scope as used. This affects the no-unused-vars rule.
2672-
* @param {RuleContext} context
2673-
* @param {string} name
2674-
* @param {ASTNode} node The node to get the current scope.
2675-
*/
2676-
function markVariableAsUsed(context, name, node) {
2677-
const sourceCode = context.sourceCode
2678-
if (sourceCode.markVariableAsUsed) {
2679-
sourceCode.markVariableAsUsed(name, node)
2680-
} else {
2681-
// This function does not use the given node, but the currently visited node.
2682-
// If we need to determine the scope of a given node, we need to implement it yourself.
2683-
context.markVariableAsUsed?.(name)
2684-
}
2685-
}
2686-
26872663
// ------------------------------------------------------------------------------
26882664
// Vue Helpers
26892665
// ------------------------------------------------------------------------------

typings/eslint/index.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,9 @@ export class SourceCode /*extends ESLintSourceCode*/ {
233233
getCommentsInside(node: VNODE.HasLocation): VNODE.Comment[]
234234

235235
/** @since ESLint v8.39.0 */
236-
markVariableAsUsed?(name: string, node?: VNODE.HasLocation): void
236+
markVariableAsUsed(name: string, node?: VNODE.HasLocation): void
237237
/** @since ESLint v8.37.0 */
238-
getScope?(node: VNODE.HasLocation): Scope.Scope
238+
getScope(node: VNODE.HasLocation): Scope.Scope
239239
}
240240
export namespace SourceCode {
241241
interface Config {
@@ -351,7 +351,7 @@ export namespace Rule {
351351
/** @since ESLint v8.40.0 */
352352
sourceCode: SourceCode
353353
/** @deprecated removed in ESLint v9 */
354-
markVariableAsUsed?(name: string): boolean
354+
markVariableAsUsed(name: string): boolean
355355
report(descriptor: ReportDescriptor): void
356356

357357
/** @deprecated removed in ESLint v10 */

0 commit comments

Comments
 (0)