Skip to content

Commit 34dcede

Browse files
authored
fix(eslint-plugin-next): Broken links in eslint output (vercel#32837)
This fixes broken links in the eslint output by removing the trailing full stop. It also makes the formatting of (the output of) the various rules consistent. ## Documentation / Examples - [x] Make sure the linting passes by running `yarn lint` > I don't think this is a bug, nor a feature, nor is it really documentation. > It's just a small nuisance that I bumped into and felt compelled to fix. > I went with documentation as that seems the closest match ## What does this pull request do? The elslint output of `eslint-plugin-next` contains useful links to the documentation about the various rules. Unfortunately, on most (but not all) rules, those links are immediately followed by a full stop (`.`). The terminal (or any parser) has no way of knowing that the full stop is not part of the URL. So it includes it and clicking the link leads to a 404 on the nextjs.org website. ![eslint](https://user-images.githubusercontent.com/1708494/147452577-43ad4ce7-df75-4d48-ab78-70b9b8212b7e.png) This PR fixes that by removing the full stop. ## But a final full stop is better grammar I considered alternatives (such as [a zero-width space character](https://en.wikipedia.org/wiki/Zero-width_space#Prohibited_in_URLs)) in case the final full stop was part of the style guide or something. However, as I went through the eslint rules, I notices that the messages for various rules were formatted inconsistently. Some with final full stop, some without. As such, I made the all consistent with this structure: > [message]. See: [url] I feel this is a better solution than using the zero-width space as these sort of invisible characters in code can be a red flag that something fishy is going on. I submit this pull request in the hope it will be useful, and a positive contribution to a project I have a great deal of appreciation for. That being said, I fully understand if people would consider this a non-issue.
1 parent a989469 commit 34dcede

32 files changed

+54
-54
lines changed

packages/eslint-plugin-next/lib/rules/google-font-display.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ module.exports = {
4848
if (message) {
4949
context.report({
5050
node,
51-
message: `${message} See https://nextjs.org/docs/messages/google-font-display.`,
51+
message: `${message} See: https://nextjs.org/docs/messages/google-font-display`,
5252
})
5353
}
5454
},

packages/eslint-plugin-next/lib/rules/google-font-preconnect.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module.exports = {
3333
) {
3434
context.report({
3535
node,
36-
message: `Preconnect is missing. See https://nextjs.org/docs/messages/google-font-preconnect.`,
36+
message: `Preconnect is missing. See: https://nextjs.org/docs/messages/google-font-preconnect`,
3737
})
3838
}
3939
},

packages/eslint-plugin-next/lib/rules/link-passhref.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ module.exports = {
5555
attributes.value('passHref') !== true
5656
? 'must be set to true'
5757
: 'is missing'
58-
}. See https://nextjs.org/docs/messages/link-passhref`,
58+
}. See: https://nextjs.org/docs/messages/link-passhref`,
5959
})
6060
}
6161
},

packages/eslint-plugin-next/lib/rules/next-script-for-ga.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const SUPPORTED_HTML_CONTENT_URLS = [
99
'www.googletagmanager.com/gtm.js',
1010
]
1111
const ERROR_MSG =
12-
'Use the `next/script` component for loading third party scripts. See: https://nextjs.org/docs/messages/next-script-for-ga.'
12+
'Use the `next/script` component for loading third party scripts. See: https://nextjs.org/docs/messages/next-script-for-ga'
1313

1414
// Check if one of the items in the list is a substring of the passed string
1515
const containsStr = (str, strList) => {

packages/eslint-plugin-next/lib/rules/no-css-tags.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = function (context) {
2626
context.report({
2727
node,
2828
message:
29-
'Do not include stylesheets manually. See: https://nextjs.org/docs/messages/no-css-tags.',
29+
'Do not include stylesheets manually. See: https://nextjs.org/docs/messages/no-css-tags',
3030
})
3131
}
3232
},

packages/eslint-plugin-next/lib/rules/no-document-import-in-page.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = {
2929

3030
context.report({
3131
node,
32-
message: `next/document should not be imported outside of pages/_document.js. See https://nextjs.org/docs/messages/no-document-import-in-page.`,
32+
message: `next/document should not be imported outside of pages/_document.js. See: https://nextjs.org/docs/messages/no-document-import-in-page`,
3333
})
3434
},
3535
}

packages/eslint-plugin-next/lib/rules/no-head-import-in-document.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = {
2828
) {
2929
context.report({
3030
node,
31-
message: `next/head should not be imported in pages${document}. Import Head from next/document instead. See https://nextjs.org/docs/messages/no-head-import-in-document.`,
31+
message: `next/head should not be imported in pages${document}. Import Head from next/document instead. See: https://nextjs.org/docs/messages/no-head-import-in-document`,
3232
})
3333
}
3434
},

packages/eslint-plugin-next/lib/rules/no-html-link-for-pages.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ module.exports = {
125125
if (url.test(normalizeURL(hrefPath))) {
126126
context.report({
127127
node,
128-
message: `Do not use the HTML <a> tag to navigate to ${hrefPath}. Use Link from 'next/link' instead. See: https://nextjs.org/docs/messages/no-html-link-for-pages.`,
128+
message: `Do not use the HTML <a> tag to navigate to ${hrefPath}. Use Link from 'next/link' instead. See: https://nextjs.org/docs/messages/no-html-link-for-pages`,
129129
})
130130
}
131131
})

packages/eslint-plugin-next/lib/rules/no-img-element.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = {
2222

2323
context.report({
2424
node,
25-
message: `Do not use <img>. Use Image from 'next/image' instead. See https://nextjs.org/docs/messages/no-img-element.`,
25+
message: `Do not use <img>. Use Image from 'next/image' instead. See: https://nextjs.org/docs/messages/no-img-element`,
2626
})
2727
},
2828
}

packages/eslint-plugin-next/lib/rules/no-page-custom-font.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ module.exports = {
138138

139139
if (isGoogleFont) {
140140
const end =
141-
'This is discouraged. See https://nextjs.org/docs/messages/no-page-custom-font.'
141+
'This is discouraged. See: https://nextjs.org/docs/messages/no-page-custom-font'
142142

143143
const message = is_Document
144144
? `Rendering this <link /> not inline within <Head> of Document disables font optimization. ${end}`

0 commit comments

Comments
 (0)