Skip to content

Commit

Permalink
fix(eslint-plugin): [no-deprecated] report on deprecated variables us…
Browse files Browse the repository at this point in the history
…ed in destructuring assignment (#9978)
  • Loading branch information
auvred authored Sep 13, 2024
1 parent 2d6872a commit 9a80067
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
5 changes: 1 addition & 4 deletions packages/eslint-plugin/src/rules/no-deprecated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,7 @@ export default createRule({
function getSymbol(
node: IdentifierLike,
): ts.Signature | ts.Symbol | undefined {
if (
node.parent.type === AST_NODE_TYPES.AssignmentPattern ||
node.parent.type === AST_NODE_TYPES.Property
) {
if (node.parent.type === AST_NODE_TYPES.Property) {
return services
.getTypeAtLocation(node.parent.parent)
.getProperty(node.name);
Expand Down
32 changes: 32 additions & 0 deletions packages/eslint-plugin/tests/rules/no-deprecated.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,38 @@ ruleTester.run('no-deprecated', rule, {
},
],
},
{
code: `
/** @deprecated */ const a = { b: 1 };
const { c = a } = {};
`,
errors: [
{
column: 21,
endColumn: 22,
line: 3,
endLine: 3,
data: { name: 'a' },
messageId: 'deprecated',
},
],
},
{
code: `
/** @deprecated */ const a = { b: 1 };
const [c = a] = [];
`,
errors: [
{
column: 20,
endColumn: 21,
line: 3,
endLine: 3,
data: { name: 'a' },
messageId: 'deprecated',
},
],
},
{
code: `
/** @deprecated */ const a = { b: 1 };
Expand Down

0 comments on commit 9a80067

Please sign in to comment.