@next/eslint-plugin-next 15.2.0-canary.8 → 15.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  var _definerule = require("../utils/define-rule");
3
+ var path = require("path");
3
4
  var url = 'https://nextjs.org/docs/messages/no-img-element';
4
5
  module.exports = (0, _definerule.defineRule)({
5
6
  meta: {
@@ -13,6 +14,9 @@ module.exports = (0, _definerule.defineRule)({
13
14
  schema: []
14
15
  },
15
16
  create: function create(context) {
17
+ // Get relative path of the file
18
+ var relativePath = context.filename.replace(path.sep, '/').replace(context.cwd, '').replace(/^\//, '');
19
+ var isAppDir = /^(src\/)?app\//.test(relativePath);
16
20
  return {
17
21
  JSXOpeningElement: function JSXOpeningElement(node) {
18
22
  var _node_parent_parent_openingElement_name, _node_parent_parent_openingElement, _node_parent_parent, _node_parent;
@@ -25,6 +29,9 @@ module.exports = (0, _definerule.defineRule)({
25
29
  if (((_node_parent = node.parent) === null || _node_parent === void 0 ? void 0 : (_node_parent_parent = _node_parent.parent) === null || _node_parent_parent === void 0 ? void 0 : (_node_parent_parent_openingElement = _node_parent_parent.openingElement) === null || _node_parent_parent_openingElement === void 0 ? void 0 : (_node_parent_parent_openingElement_name = _node_parent_parent_openingElement.name) === null || _node_parent_parent_openingElement_name === void 0 ? void 0 : _node_parent_parent_openingElement_name.name) === 'picture') {
26
30
  return;
27
31
  }
32
+ // If is metadata route files, ignore
33
+ // e.g. opengraph-image.js, twitter-image.js, icon.js
34
+ if (isAppDir && /\/opengraph-image|twitter-image|icon\.\w+$/.test(relativePath)) return;
28
35
  context.report({
29
36
  node: node,
30
37
  message: "Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` or a custom image loader to automatically optimize images. This may incur additional usage or cost from your provider. See: ".concat(url)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next/eslint-plugin-next",
3
- "version": "15.2.0-canary.8",
3
+ "version": "15.2.0",
4
4
  "description": "ESLint plugin for Next.js.",
5
5
  "main": "dist/index.js",
6
6
  "license": "MIT",