Skip to content

Commit 3636689

Browse files
committed
[patch] no-deprecated: report on the imported specifier instead of the entire import statement
This also makes error ordering more consistent since certain eslint/node combinations reverse the ordering
1 parent f9e4fa9 commit 3636689

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
99
* [`no-deprecated`]: prevent false positive on commonjs import ([#3614][] @akulsr0)
1010
* [`no-unsafe`]: report on the method instead of the entire component (@ljharb)
1111
* [`no-deprecated`]: report on the destructured property instead of the entire variable declarator (@ljharb)
12+
* [`no-deprecated`]: report on the imported specifier instead of the entire import statement (@ljharb)
1213

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

lib/rules/no-deprecated.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ module.exports = {
226226
return;
227227
}
228228
node.specifiers.filter(((s) => s.imported)).forEach((specifier) => {
229-
checkDeprecation(node, `${MODULES[node.source.value][0]}.${specifier.imported.name}`);
229+
checkDeprecation(node, `${MODULES[node.source.value][0]}.${specifier.imported.name}`, specifier);
230230
});
231231
},
232232

tests/lib/rules/no-deprecated.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ ruleTester.run('no-deprecated', rule, {
533533
'18.0.0',
534534
'createRoot',
535535
'https://reactjs.org/link/switch-to-createroot',
536-
{ type: 'ImportDeclaration', line: 2, column: 9 }
536+
{ type: 'ImportSpecifier', line: 2, column: 18 }
537537
),
538538
errorMessage(
539539
'ReactDOM.render',
@@ -555,7 +555,7 @@ ruleTester.run('no-deprecated', rule, {
555555
'18.0.0',
556556
'hydrateRoot',
557557
'https://reactjs.org/link/switch-to-createroot',
558-
{ type: 'ImportDeclaration', line: 2, column: 9 }
558+
{ type: 'ImportSpecifier', line: 2, column: 18 }
559559
),
560560
errorMessage(
561561
'ReactDOM.hydrate',
@@ -577,7 +577,7 @@ ruleTester.run('no-deprecated', rule, {
577577
'18.0.0',
578578
'root.unmount',
579579
'https://reactjs.org/link/switch-to-createroot',
580-
{ type: 'ImportDeclaration', line: 2, column: 9 }
580+
{ type: 'ImportSpecifier', line: 2, column: 18 }
581581
),
582582
errorMessage(
583583
'ReactDOM.unmountComponentAtNode',
@@ -599,7 +599,7 @@ ruleTester.run('no-deprecated', rule, {
599599
'18.0.0',
600600
'renderToPipeableStream',
601601
'https://reactjs.org/docs/react-dom-server.html#rendertonodestream',
602-
{ type: 'ImportDeclaration', line: 2, column: 9 }
602+
{ type: 'ImportSpecifier', line: 2, column: 18 }
603603
),
604604
errorMessage(
605605
'ReactDOMServer.renderToNodeStream',

0 commit comments

Comments
 (0)