Socket
Socket
Sign inDemoInstall

@next/eslint-plugin-next

Package Overview
Dependencies
Maintainers
5
Versions
1996
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@next/eslint-plugin-next - npm Package Compare versions

Comparing version 15.0.0-canary.157 to 15.0.0-canary.158

18

dist/rules/no-html-link-for-pages.js

@@ -15,2 +15,5 @@ "use strict";

}
function _array_without_holes(arr) {
if (Array.isArray(arr)) return _array_like_to_array(arr);
}
function _getRequireWildcardCache(nodeInterop) {

@@ -57,2 +60,5 @@ if (typeof WeakMap !== "function") return null;

}
function _iterable_to_array(iter) {
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
}
function _iterable_to_array_limit(arr, i) {

@@ -85,5 +91,11 @@ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];

}
function _non_iterable_spread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _sliced_to_array(arr, i) {
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
}
function _to_consumable_array(arr) {
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
}
function _unsupported_iterable_to_array(o, minLen) {

@@ -168,2 +180,4 @@ if (!o) return;

var pageUrls = (0, _url.getUrlFromPagesDirectories)('/', foundPagesDirs);
var appDirUrls = (0, _url.getUrlFromAppDirectory)('/', foundAppDirs);
var allUrls = _to_consumable_array(pageUrls).concat(_to_consumable_array(appDirUrls));
return {

@@ -200,4 +214,4 @@ JSXOpeningElement: function JSXOpeningElement(node) {

}
pageUrls.forEach(function(pageUrl) {
if (pageUrl.test((0, _url.normalizeURL)(hrefPath))) {
allUrls.forEach(function(foundUrl) {
if (foundUrl.test((0, _url.normalizeURL)(hrefPath))) {
context.report({

@@ -204,0 +218,0 @@ node: node,

@@ -15,5 +15,11 @@ "use strict";

},
getUrlFromAppDirectory: function() {
return getUrlFromAppDirectory;
},
getUrlFromPagesDirectories: function() {
return getUrlFromPagesDirectories;
},
normalizeAppPath: function() {
return normalizeAppPath;
},
normalizeURL: function() {

@@ -121,2 +127,30 @@ return normalizeURL;

}
/**
* Recursively parse app directory for URLs.
*/ function parseUrlForAppDir(urlprefix, directory) {
var _fsReadDirSyncCache, _directory;
var _;
(_ = (_fsReadDirSyncCache = fsReadDirSyncCache)[_directory = directory]) !== null && _ !== void 0 ? _ : _fsReadDirSyncCache[_directory] = _fs.readdirSync(directory, {
withFileTypes: true
});
var res = [];
fsReadDirSyncCache[directory].forEach(function(dirent) {
// TODO: this should account for all page extensions
// not just js(x) and ts(x)
if (/(\.(j|t)sx?)$/.test(dirent.name)) {
if (/^page(\.(j|t)sx?)$/.test(dirent.name)) {
res.push("".concat(urlprefix).concat(dirent.name.replace(/^page(\.(j|t)sx?)$/, '')));
} else if (!/^layout(\.(j|t)sx?)$/.test(dirent.name)) {
res.push("".concat(urlprefix).concat(dirent.name.replace(/(\.(j|t)sx?)$/, '')));
}
} else {
var dirPath = _path.join(directory, dirent.name);
if (dirent.isDirectory(dirPath) && !dirent.isSymbolicLink()) {
var _res;
(_res = res).push.apply(_res, _to_consumable_array(parseUrlForPages(urlprefix + dirent.name + '/', dirPath)));
}
}
});
return res;
}
function normalizeURL(url) {

@@ -136,2 +170,23 @@ if (!url) {

}
function normalizeAppPath(route) {
return ensureLeadingSlash(route.split('/').reduce(function(pathname, segment, index, segments) {
// Empty segments are ignored.
if (!segment) {
return pathname;
}
// Groups are ignored.
if (isGroupSegment(segment)) {
return pathname;
}
// Parallel segments are ignored.
if (segment[0] === '@') {
return pathname;
}
// The last segment (if it's a leaf) should be ignored.
if ((segment === 'page' || segment === 'route') && index === segments.length - 1) {
return pathname;
}
return "".concat(pathname, "/").concat(segment);
}, ''));
}
function getUrlFromPagesDirectories(urlPrefix, directories) {

@@ -149,2 +204,14 @@ return Array.from(// De-duplicate similar pages across multiple directories.

}
function getUrlFromAppDirectory(urlPrefix, directories) {
return Array.from(// De-duplicate similar pages across multiple directories.
new Set(directories.map(function(directory) {
return parseUrlForAppDir(urlPrefix, directory);
}).flat().map(// Since the URLs are normalized we add `^` and `$` to the RegExp to make sure they match exactly.
function(url) {
return "^".concat(normalizeAppPath(url), "$");
}))).map(function(urlReg) {
urlReg = urlReg.replace(/\[.*\]/g, '((?!.+?\\..+?).*?)');
return new RegExp(urlReg);
});
}
function execOnce(fn) {

@@ -164,1 +231,7 @@ var used = false;

}
function ensureLeadingSlash(route) {
return route.startsWith('/') ? route : "/".concat(route);
}
function isGroupSegment(segment) {
return segment[0] === '(' && segment.endsWith(')');
}

2

package.json
{
"name": "@next/eslint-plugin-next",
"version": "15.0.0-canary.157",
"version": "15.0.0-canary.158",
"description": "ESLint plugin for Next.js.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc