Skip to content

Commit

Permalink
[patch] no-deprecated: report on the destructured property instead …
Browse files Browse the repository at this point in the history
…of the entire variable declarator

This also makes error ordering more consistent since certain eslint/node combinations reverse the ordering
  • Loading branch information
ljharb committed Aug 15, 2023
1 parent 3be1d19 commit f9e4fa9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
### Fixed
* [`no-deprecated`]: prevent false positive on commonjs import ([#3614][] @akulsr0)
* [`no-unsafe`]: report on the method instead of the entire component (@ljharb)
* [`no-deprecated`]: report on the destructured property instead of the entire variable declarator (@ljharb)

[#3614]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3614

Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ module.exports = {
return;
}
node.id.properties.filter((p) => p.type !== 'RestElement' && p.key).forEach((property) => {
checkDeprecation(node, `${reactModuleName || pragma}.${property.key.name}`);
checkDeprecation(node, `${reactModuleName || pragma}.${property.key.name}`, property);
});
},

Expand Down
8 changes: 4 additions & 4 deletions tests/lib/rules/no-deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,14 @@ ruleTester.run('no-deprecated', rule, {
'15.5.0',
'the npm module create-react-class',
null,
{ type: 'VariableDeclarator', column: 5 }
{ type: 'Property', column: 6 }
),
errorMessage(
'React.PropTypes',
'15.5.0',
'the npm module prop-types',
null,
{ type: 'VariableDeclarator', column: 5 }
{ type: 'Property', column: 19 }
),
],
},
Expand All @@ -269,14 +269,14 @@ ruleTester.run('no-deprecated', rule, {
'15.5.0',
'the npm module create-react-class',
null,
{ type: 'VariableDeclarator', line: 3, column: 13 }
{ type: 'Property', line: 3, column: 14 }
),
errorMessage(
'React.PropTypes',
'15.5.0',
'the npm module prop-types',
null,
{ type: 'VariableDeclarator', line: 3, column: 13 }
{ type: 'Property', line: 3, column: 27 }
),
],
},
Expand Down

0 comments on commit f9e4fa9

Please sign in to comment.