@next/eslint-plugin-next 13.4.9 → 13.4.10-canary.1
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.
- package/dist/utils/url.js +15 -28
- package/package.json +1 -1
package/dist/utils/url.js
CHANGED
|
@@ -85,44 +85,31 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
85
85
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
86
86
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
87
87
|
}
|
|
88
|
-
// Cache for fs.lstatSync lookup.
|
|
89
|
-
// Prevent multiple blocking IO requests that have already been calculated.
|
|
90
|
-
var fsLstatSyncCache = {};
|
|
91
|
-
var fsLstatSync = function(source) {
|
|
92
|
-
fsLstatSyncCache[source] = fsLstatSyncCache[source] || _fs.lstatSync(source);
|
|
93
|
-
return fsLstatSyncCache[source];
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* Checks if the source is a directory.
|
|
97
|
-
*/ function isDirectory(source) {
|
|
98
|
-
return fsLstatSync(source).isDirectory();
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Checks if the source is a directory.
|
|
102
|
-
*/ function isSymlink(source) {
|
|
103
|
-
return fsLstatSync(source).isSymbolicLink();
|
|
104
|
-
}
|
|
105
88
|
// Cache for fs.readdirSync lookup.
|
|
106
89
|
// Prevent multiple blocking IO requests that have already been calculated.
|
|
107
90
|
var fsReadDirSyncCache = {};
|
|
108
91
|
/**
|
|
109
92
|
* Recursively parse directory for page URLs.
|
|
110
93
|
*/ function parseUrlForPages(urlprefix, directory) {
|
|
111
|
-
|
|
94
|
+
var _fsReadDirSyncCache, _directory;
|
|
95
|
+
var _;
|
|
96
|
+
(_ = (_fsReadDirSyncCache = fsReadDirSyncCache)[_directory = directory]) !== null && _ !== void 0 ? _ : _fsReadDirSyncCache[_directory] = _fs.readdirSync(directory, {
|
|
97
|
+
withFileTypes: true
|
|
98
|
+
});
|
|
112
99
|
var res = [];
|
|
113
|
-
fsReadDirSyncCache[directory].forEach(function(
|
|
100
|
+
fsReadDirSyncCache[directory].forEach(function(dirent) {
|
|
114
101
|
// TODO: this should account for all page extensions
|
|
115
102
|
// not just js(x) and ts(x)
|
|
116
|
-
if (/(\.(j|t)sx?)$/.test(
|
|
117
|
-
if (/^index(\.(j|t)sx?)$/.test(
|
|
118
|
-
res.push("".concat(urlprefix).concat(
|
|
103
|
+
if (/(\.(j|t)sx?)$/.test(dirent.name)) {
|
|
104
|
+
if (/^index(\.(j|t)sx?)$/.test(dirent.name)) {
|
|
105
|
+
res.push("".concat(urlprefix).concat(dirent.name.replace(/^index(\.(j|t)sx?)$/, "")));
|
|
119
106
|
}
|
|
120
|
-
res.push("".concat(urlprefix).concat(
|
|
107
|
+
res.push("".concat(urlprefix).concat(dirent.name.replace(/(\.(j|t)sx?)$/, "")));
|
|
121
108
|
} else {
|
|
122
|
-
var dirPath = _path.join(directory,
|
|
123
|
-
if (isDirectory(
|
|
109
|
+
var dirPath = _path.join(directory, dirent.name);
|
|
110
|
+
if (dirent.isDirectory() && !dirent.isSymbolicLink()) {
|
|
124
111
|
var _res;
|
|
125
|
-
(_res = res).push.apply(_res, _to_consumable_array(parseUrlForPages(urlprefix +
|
|
112
|
+
(_res = res).push.apply(_res, _to_consumable_array(parseUrlForPages(urlprefix + dirent.name + "/", dirPath)));
|
|
126
113
|
}
|
|
127
114
|
}
|
|
128
115
|
});
|
|
@@ -144,9 +131,9 @@ function normalizeURL(url) {
|
|
|
144
131
|
}
|
|
145
132
|
function getUrlFromPagesDirectories(urlPrefix, directories) {
|
|
146
133
|
return Array.from(// De-duplicate similar pages across multiple directories.
|
|
147
|
-
new Set(directories.
|
|
134
|
+
new Set(directories.flatMap(function(directory) {
|
|
148
135
|
return parseUrlForPages(urlPrefix, directory);
|
|
149
|
-
}).
|
|
136
|
+
}).map(// Since the URLs are normalized we add `^` and `$` to the RegExp to make sure they match exactly.
|
|
150
137
|
function(url) {
|
|
151
138
|
return "^".concat(normalizeURL(url), "$");
|
|
152
139
|
}))).map(function(urlReg) {
|