Skip to content

Commit 9a80067

Browse files
authored
fix(eslint-plugin): [no-deprecated] report on deprecated variables used in destructuring assignment (typescript-eslint#9978)
1 parent 2d6872a commit 9a80067

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

packages/eslint-plugin/src/rules/no-deprecated.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,7 @@ export default createRule({
193193
function getSymbol(
194194
node: IdentifierLike,
195195
): ts.Signature | ts.Symbol | undefined {
196-
if (
197-
node.parent.type === AST_NODE_TYPES.AssignmentPattern ||
198-
node.parent.type === AST_NODE_TYPES.Property
199-
) {
196+
if (node.parent.type === AST_NODE_TYPES.Property) {
200197
return services
201198
.getTypeAtLocation(node.parent.parent)
202199
.getProperty(node.name);

packages/eslint-plugin/tests/rules/no-deprecated.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,38 @@ ruleTester.run('no-deprecated', rule, {
295295
},
296296
],
297297
},
298+
{
299+
code: `
300+
/** @deprecated */ const a = { b: 1 };
301+
const { c = a } = {};
302+
`,
303+
errors: [
304+
{
305+
column: 21,
306+
endColumn: 22,
307+
line: 3,
308+
endLine: 3,
309+
data: { name: 'a' },
310+
messageId: 'deprecated',
311+
},
312+
],
313+
},
314+
{
315+
code: `
316+
/** @deprecated */ const a = { b: 1 };
317+
const [c = a] = [];
318+
`,
319+
errors: [
320+
{
321+
column: 20,
322+
endColumn: 21,
323+
line: 3,
324+
endLine: 3,
325+
data: { name: 'a' },
326+
messageId: 'deprecated',
327+
},
328+
],
329+
},
298330
{
299331
code: `
300332
/** @deprecated */ const a = { b: 1 };

0 commit comments

Comments
 (0)
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