diff --git a/packages/eslint-plugin-next/lib/rules/link-passhref.js b/packages/eslint-plugin-next/lib/rules/link-passhref.js
index 44f233395144d59..97c13029aff944c 100644
--- a/packages/eslint-plugin-next/lib/rules/link-passhref.js
+++ b/packages/eslint-plugin-next/lib/rules/link-passhref.js
@@ -23,7 +23,7 @@ module.exports = {
},
JSXOpeningElement(node) {
- if (node.name.name !== 'Link' || node.name.name !== linkImport) {
+ if (node.name.name !== linkImport) {
return
}
diff --git a/test/unit/eslint-plugin-next/link-passhref.test.ts b/test/unit/eslint-plugin-next/link-passhref.test.ts
index 6c864a879d621df..6b8f3668edf0f51 100644
--- a/test/unit/eslint-plugin-next/link-passhref.test.ts
+++ b/test/unit/eslint-plugin-next/link-passhref.test.ts
@@ -14,17 +14,23 @@ const ruleTester = new RuleTester()
ruleTester.run('link-passhref', rule, {
valid: [
- `export const Home = () => (
+ `
+ import Link from 'next/link'
+ export const Home = () => (
)`,
- `export const Home = () => (
+ `
+ import Link from 'next/link'
+ export const Home = () => (
Test
)`,
- `export const Home = () => (
+ `
+ import Link from 'next/link'
+ export const Home = () => (
Test
@@ -37,6 +43,14 @@ ruleTester.run('link-passhref', rule, {
)`,
+
+ `
+ import NextLink from 'next/link'
+ export const Home = () => (
+
+ Test
+
+ )`,
],
invalid: [
@@ -57,6 +71,23 @@ ruleTester.run('link-passhref', rule, {
},
],
},
+ {
+ code: `
+ import NextLink from 'next/link'
+
+ export const Home = () => (
+
+ Test
+
+ )`,
+ errors: [
+ {
+ message:
+ 'passHref is missing. See: https://nextjs.org/docs/messages/link-passhref',
+ type: 'JSXOpeningElement',
+ },
+ ],
+ },
{
code: `
import Link from 'next/link'