Skip to content

Commit

Permalink
Updates message.
Browse files Browse the repository at this point in the history
  • Loading branch information
manovotny committed Mar 1, 2023
1 parent 430044e commit 1edba22
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/eslint-plugin-next/src/rules/no-img-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export = defineRule({

context.report({
node,
message: `Using \`<img>\` could result in slower LCP and higher bandwidth due to image sizes. Consider using \`<Image />\` from \`next/image\` to automatically optimize images. Note: when self-hosting, Image Optimization runs on your Next.js server. If using an external loader, additional usage or cost could be incurred, depending on your provider. See: ${url}`,
message: `Using \`<img>\` could result in slower LCP and higher bandwidth. Consider using \`<Image />\` from \`next/image\` to automatically optimize images. Note: check your provider's pricing of bandwidth and image optimization to see how this may impact your bill. See: ${url}`,
})
},
}
Expand Down
20 changes: 10 additions & 10 deletions test/integration/eslint/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe('ESLint', () => {
'Error: `next/head` should not be imported in `pages/_document.js`. Use `<Head />` from `next/document` instead'
)
expect(output).toContain(
'Warning: Using `<img>` could result in slower LCP and higher bandwidth due to image sizes. Consider using `<Image />` from `next/image` to automatically optimize images.'
'Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images.'
)
expect(output).toContain('Warning: Do not include stylesheets manually')
expect(output).toContain(
Expand Down Expand Up @@ -143,7 +143,7 @@ describe('ESLint', () => {
'Error: `next/head` should not be imported in `pages/_document.js`. Use `<Head />` from `next/document` instead'
)
expect(output).toContain(
'Warning: Using `<img>` could result in slower LCP and higher bandwidth due to image sizes. Consider using `<Image />` from `next/image` to automatically optimize images.'
'Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images.'
)
expect(output).toContain('Warning: Do not include stylesheets manually')
expect(output).toContain(
Expand Down Expand Up @@ -417,7 +417,7 @@ describe('ESLint', () => {
'Error: `next/head` should not be imported in `pages/_document.js`. Use `<Head />` from `next/document` instead'
)
expect(output).toContain(
'Warning: Using `<img>` could result in slower LCP and higher bandwidth due to image sizes. Consider using `<Image />` from `next/image` to automatically optimize images.'
'Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images.'
)
expect(output).toContain('Warning: Do not include stylesheets manually')
expect(output).toContain(
Expand Down Expand Up @@ -453,7 +453,7 @@ describe('ESLint', () => {
'Error: `next/head` should not be imported in `pages/_document.js`. Use `<Head />` from `next/document` instead'
)
expect(output).toContain(
'Warning: Using `<img>` could result in slower LCP and higher bandwidth due to image sizes. Consider using `<Image />` from `next/image` to automatically optimize images.'
'Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images.'
)
expect(output).toContain('Warning: Do not include stylesheets manually')
expect(output).toContain(
Expand All @@ -479,7 +479,7 @@ describe('ESLint', () => {

const output = stdout + stderr
expect(output).toContain(
'Warning: Using `<img>` could result in slower LCP and higher bandwidth due to image sizes. Consider using `<Image />` from `next/image` to automatically optimize images.'
'Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images.'
)
expect(output).toContain('Error: Synchronous scripts should not be used.')
})
Expand Down Expand Up @@ -515,7 +515,7 @@ describe('ESLint', () => {

const output = stdout + stderr
expect(output).toContain(
'Warning: Using `<img>` could result in slower LCP and higher bandwidth due to image sizes. Consider using `<Image />` from `next/image` to automatically optimize images.'
'Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images.'
)
expect(output).toContain('Error: Synchronous scripts should not be used.')
})
Expand Down Expand Up @@ -788,7 +788,7 @@ describe('ESLint', () => {

expect(output).toContain('pages/bar.js')
expect(output).toContain(
'Warning: Using `<img>` could result in slower LCP and higher bandwidth due to image sizes. Consider using `<Image />` from `next/image` to automatically optimize images.'
'Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images.'
)

expect(output).not.toContain('pages/index.js')
Expand Down Expand Up @@ -833,7 +833,7 @@ describe('ESLint', () => {
}),
expect.objectContaining({
message:
'Using `<img>` could result in slower LCP and higher bandwidth due to image sizes. Consider using `<Image />` from `next/image` to automatically optimize images. Note: when self-hosting, Image Optimization runs on your Next.js server. If using an external loader, additional usage or cost could be incurred, depending on your provider. See: https://nextjs.org/docs/messages/no-img-element',
"Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. Note: check your provider's pricing of bandwidth and image optimization to see how this may impact your bill. See: https://nextjs.org/docs/messages/no-img-element",
}),
])
)
Expand Down Expand Up @@ -872,7 +872,7 @@ describe('ESLint', () => {
'img elements must have an alt prop, either with meaningful text, or an empty string for decorative images.'
)
expect(fileOutput).toContain(
'Using `<img>` could result in slower LCP and higher bandwidth due to image sizes. Consider using `<Image />` from `next/image` to automatically optimize images. Note: when self-hosting, Image Optimization runs on your Next.js server. If using an external loader, additional usage or cost could be incurred, depending on your provider. See: https://nextjs.org/docs/messages/no-img-element'
"Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. Note: check your provider's pricing of bandwidth and image optimization to see how this may impact your bill. See: https://nextjs.org/docs/messages/no-img-element"
)

expect(fileOutput).toContain('file-linting/pages/index.js')
Expand Down Expand Up @@ -912,7 +912,7 @@ describe('ESLint', () => {
'img elements must have an alt prop, either with meaningful text, or an empty string for decorative images.'
)
expect(output).toContain(
'Using `<img>` could result in slower LCP and higher bandwidth due to image sizes. Consider using `<Image />` from `next/image` to automatically optimize images. Note: when self-hosting, Image Optimization runs on your Next.js server. If using an external loader, additional usage or cost could be incurred, depending on your provider. See: https://nextjs.org/docs/messages/no-img-element'
"Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. Note: check your provider's pricing of bandwidth and image optimization to see how this may impact your bill. See: https://nextjs.org/docs/messages/no-img-element"
)

expect(output).toContain('pages/index.cjs')
Expand Down
4 changes: 2 additions & 2 deletions test/unit/eslint-plugin-next/no-img-element.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ ruleTester.run('no-img-element', rule, {
errors: [
{
message:
'Using `<img>` could result in slower LCP and higher bandwidth due to image sizes. Consider using `<Image />` from `next/image` to automatically optimize images. Note: when self-hosting, Image Optimization runs on your Next.js server. If using an external loader, additional usage or cost could be incurred, depending on your provider. See: https://nextjs.org/docs/messages/no-img-element',
"Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. Note: check your provider's pricing of bandwidth and image optimization to see how this may impact your bill. See: https://nextjs.org/docs/messages/no-img-element",
type: 'JSXOpeningElement',
},
],
Expand All @@ -103,7 +103,7 @@ ruleTester.run('no-img-element', rule, {
errors: [
{
message:
'Using `<img>` could result in slower LCP and higher bandwidth due to image sizes. Consider using `<Image />` from `next/image` to automatically optimize images. Note: when self-hosting, Image Optimization runs on your Next.js server. If using an external loader, additional usage or cost could be incurred, depending on your provider. See: https://nextjs.org/docs/messages/no-img-element',
"Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. Note: check your provider's pricing of bandwidth and image optimization to see how this may impact your bill. See: https://nextjs.org/docs/messages/no-img-element",
type: 'JSXOpeningElement',
},
],
Expand Down

0 comments on commit 1edba22

Please sign in to comment.