Skip to content

Commit c3216f7

Browse files
authored
fix: eslint DeprecationWarning #5287
(node:99880) DeprecationWarning: "no-incorrect-once-usage" rule is using `context.getScope()`, which is deprecated and will be removed in ESLint v9. Please use `sourceCode.getScope()` instead. (Use `node --trace-deprecation ...` to show where the warning was created) Notes: Consider: ``` L1: const x = 1 L2: const y = 2, z = 3 ``` There are two `VariableDeclaration` here (L1, L2). L1 node.declarations is `[x=1]`. L2 node.declarations is `[y=2, z=3]`. Whether you take the root node level (L1/L2) or the individual declarations in each root, the scope is the same.
1 parent 62be19a commit c3216f7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

plugins/eslint-plugin-aws-toolkits/lib/rules/no-incorrect-once-usage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export default ESLintUtils.RuleCreator.withoutDocs({
122122
declaration.init.callee?.type === AST_NODE_TYPES.Identifier &&
123123
declaration.init.callee.name === 'once'
124124
) {
125-
const scope = context.getScope()
125+
const scope = context.sourceCode.getScope(declaration)
126126
const variable = scope.variables.find(
127127
v => v.name === (declaration.id as TSESTree.Identifier).name
128128
) // we already confirmed the type in the if statement... why is TS mad?

0 commit comments

Comments
 (0)