eslint-plugin-nextjs 0.0.0 → 0.1.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.
- package/README.md +9 -380
- package/dist/index.cjs +1494 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +43 -0
- package/dist/index.d.ts +42 -1
- package/dist/index.js +1455 -1
- package/dist/index.js.map +1 -1
- package/dist/rules/google-font-display.cjs +119 -0
- package/dist/rules/google-font-display.cjs.map +1 -0
- package/dist/rules/google-font-display.d.cts +8 -0
- package/dist/rules/google-font-display.d.ts +8 -0
- package/dist/rules/google-font-display.js +92 -0
- package/dist/rules/google-font-display.js.map +1 -0
- package/dist/rules/google-font-preconnect.cjs +109 -0
- package/dist/rules/google-font-preconnect.cjs.map +1 -0
- package/dist/rules/google-font-preconnect.d.cts +5 -0
- package/dist/rules/google-font-preconnect.d.ts +5 -0
- package/dist/rules/google-font-preconnect.js +82 -0
- package/dist/rules/google-font-preconnect.js.map +1 -0
- package/dist/rules/inline-script-id.cjs +94 -0
- package/dist/rules/inline-script-id.cjs.map +1 -0
- package/dist/rules/inline-script-id.d.cts +5 -0
- package/dist/rules/inline-script-id.d.ts +5 -0
- package/dist/rules/inline-script-id.js +67 -0
- package/dist/rules/inline-script-id.js.map +1 -0
- package/dist/rules/next-script-for-ga.cjs +129 -0
- package/dist/rules/next-script-for-ga.cjs.map +1 -0
- package/dist/rules/next-script-for-ga.d.cts +5 -0
- package/dist/rules/next-script-for-ga.d.ts +5 -0
- package/dist/rules/next-script-for-ga.js +102 -0
- package/dist/rules/next-script-for-ga.js.map +1 -0
- package/dist/rules/no-assign-module-variable.cjs +64 -0
- package/dist/rules/no-assign-module-variable.cjs.map +1 -0
- package/dist/rules/no-assign-module-variable.d.cts +5 -0
- package/dist/rules/no-assign-module-variable.d.ts +5 -0
- package/dist/rules/no-assign-module-variable.js +37 -0
- package/dist/rules/no-assign-module-variable.js.map +1 -0
- package/dist/rules/no-async-client-component.cjs +99 -0
- package/dist/rules/no-async-client-component.cjs.map +1 -0
- package/dist/rules/no-async-client-component.d.cts +5 -0
- package/dist/rules/no-async-client-component.d.ts +5 -0
- package/dist/rules/no-async-client-component.js +72 -0
- package/dist/rules/no-async-client-component.js.map +1 -0
- package/dist/rules/no-before-interactive-script-outside-document.cjs +94 -0
- package/dist/rules/no-before-interactive-script-outside-document.cjs.map +1 -0
- package/dist/rules/no-before-interactive-script-outside-document.d.cts +5 -0
- package/dist/rules/no-before-interactive-script-outside-document.d.ts +5 -0
- package/dist/rules/no-before-interactive-script-outside-document.js +59 -0
- package/dist/rules/no-before-interactive-script-outside-document.js.map +1 -0
- package/dist/rules/no-css-tags.cjs +70 -0
- package/dist/rules/no-css-tags.cjs.map +1 -0
- package/dist/rules/no-css-tags.d.cts +5 -0
- package/dist/rules/no-css-tags.d.ts +5 -0
- package/dist/rules/no-css-tags.js +43 -0
- package/dist/rules/no-css-tags.js.map +1 -0
- package/dist/rules/no-document-import-in-page.cjs +74 -0
- package/dist/rules/no-document-import-in-page.cjs.map +1 -0
- package/dist/rules/no-document-import-in-page.d.cts +5 -0
- package/dist/rules/no-document-import-in-page.d.ts +5 -0
- package/dist/rules/no-document-import-in-page.js +39 -0
- package/dist/rules/no-document-import-in-page.js.map +1 -0
- package/dist/rules/no-duplicate-head.cjs +87 -0
- package/dist/rules/no-duplicate-head.cjs.map +1 -0
- package/dist/rules/no-duplicate-head.d.cts +5 -0
- package/dist/rules/no-duplicate-head.d.ts +5 -0
- package/dist/rules/no-duplicate-head.js +60 -0
- package/dist/rules/no-duplicate-head.js.map +1 -0
- package/dist/rules/no-head-element.cjs +76 -0
- package/dist/rules/no-head-element.cjs.map +1 -0
- package/dist/rules/no-head-element.d.cts +5 -0
- package/dist/rules/no-head-element.d.ts +5 -0
- package/dist/rules/no-head-element.js +41 -0
- package/dist/rules/no-head-element.js.map +1 -0
- package/dist/rules/no-head-import-in-document.cjs +76 -0
- package/dist/rules/no-head-import-in-document.cjs.map +1 -0
- package/dist/rules/no-head-import-in-document.d.cts +5 -0
- package/dist/rules/no-head-import-in-document.d.ts +5 -0
- package/dist/rules/no-head-import-in-document.js +41 -0
- package/dist/rules/no-head-import-in-document.js.map +1 -0
- package/dist/rules/no-html-link-for-pages.cjs +302 -0
- package/dist/rules/no-html-link-for-pages.cjs.map +1 -0
- package/dist/rules/no-html-link-for-pages.d.cts +5 -0
- package/dist/rules/no-html-link-for-pages.d.ts +5 -0
- package/dist/rules/no-html-link-for-pages.js +267 -0
- package/dist/rules/no-html-link-for-pages.js.map +1 -0
- package/dist/rules/no-img-element.cjs +83 -0
- package/dist/rules/no-img-element.cjs.map +1 -0
- package/dist/rules/no-img-element.d.cts +5 -0
- package/dist/rules/no-img-element.d.ts +5 -0
- package/dist/rules/no-img-element.js +48 -0
- package/dist/rules/no-img-element.js.map +1 -0
- package/dist/rules/no-page-custom-font.cjs +184 -0
- package/dist/rules/no-page-custom-font.cjs.map +1 -0
- package/dist/rules/no-page-custom-font.d.cts +5 -0
- package/dist/rules/no-page-custom-font.d.ts +5 -0
- package/dist/rules/no-page-custom-font.js +159 -0
- package/dist/rules/no-page-custom-font.js.map +1 -0
- package/dist/rules/no-script-component-in-head.cjs +74 -0
- package/dist/rules/no-script-component-in-head.cjs.map +1 -0
- package/dist/rules/no-script-component-in-head.d.cts +5 -0
- package/dist/rules/no-script-component-in-head.d.ts +5 -0
- package/dist/rules/no-script-component-in-head.js +47 -0
- package/dist/rules/no-script-component-in-head.js.map +1 -0
- package/dist/rules/no-styled-jsx-in-document.cjs +78 -0
- package/dist/rules/no-styled-jsx-in-document.cjs.map +1 -0
- package/dist/rules/no-styled-jsx-in-document.d.cts +5 -0
- package/dist/rules/no-styled-jsx-in-document.d.ts +5 -0
- package/dist/rules/no-styled-jsx-in-document.js +43 -0
- package/dist/rules/no-styled-jsx-in-document.js.map +1 -0
- package/dist/rules/no-sync-scripts.cjs +64 -0
- package/dist/rules/no-sync-scripts.cjs.map +1 -0
- package/dist/rules/no-sync-scripts.d.cts +5 -0
- package/dist/rules/no-sync-scripts.d.ts +5 -0
- package/dist/rules/no-sync-scripts.js +37 -0
- package/dist/rules/no-sync-scripts.js.map +1 -0
- package/dist/rules/no-title-in-document-head.cjs +78 -0
- package/dist/rules/no-title-in-document-head.cjs.map +1 -0
- package/dist/rules/no-title-in-document-head.d.cts +5 -0
- package/dist/rules/no-title-in-document-head.d.ts +5 -0
- package/dist/rules/no-title-in-document-head.js +51 -0
- package/dist/rules/no-title-in-document-head.js.map +1 -0
- package/dist/rules/no-typos.cjs +133 -0
- package/dist/rules/no-typos.cjs.map +1 -0
- package/dist/rules/no-typos.d.cts +5 -0
- package/dist/rules/no-typos.d.ts +5 -0
- package/dist/rules/no-typos.js +98 -0
- package/dist/rules/no-typos.js.map +1 -0
- package/dist/rules/no-unwanted-polyfillio.cjs +164 -0
- package/dist/rules/no-unwanted-polyfillio.cjs.map +1 -0
- package/dist/rules/no-unwanted-polyfillio.d.cts +5 -0
- package/dist/rules/no-unwanted-polyfillio.d.ts +5 -0
- package/dist/rules/no-unwanted-polyfillio.js +137 -0
- package/dist/rules/no-unwanted-polyfillio.js.map +1 -0
- package/dist/utils/define-rule.cjs +31 -0
- package/dist/utils/define-rule.cjs.map +1 -0
- package/dist/utils/define-rule.d.cts +5 -0
- package/dist/utils/define-rule.d.ts +5 -0
- package/dist/utils/define-rule.js +6 -0
- package/dist/utils/define-rule.js.map +1 -0
- package/dist/utils/get-root-dirs.cjs +60 -0
- package/dist/utils/get-root-dirs.cjs.map +1 -0
- package/dist/utils/get-root-dirs.d.cts +8 -0
- package/dist/utils/get-root-dirs.d.ts +8 -0
- package/dist/utils/get-root-dirs.js +25 -0
- package/dist/utils/get-root-dirs.js.map +1 -0
- package/dist/utils/node-attributes.cjs +67 -0
- package/dist/utils/node-attributes.cjs.map +1 -0
- package/dist/utils/node-attributes.d.cts +15 -0
- package/dist/utils/node-attributes.d.ts +15 -0
- package/dist/utils/node-attributes.js +46 -0
- package/dist/utils/node-attributes.js.map +1 -0
- package/dist/utils/url.cjs +167 -0
- package/dist/utils/url.cjs.map +1 -0
- package/dist/utils/url.d.cts +35 -0
- package/dist/utils/url.d.ts +35 -0
- package/dist/utils/url.js +128 -0
- package/dist/utils/url.js.map +1 -0
- package/package.json +15 -2
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/utils/get-root-dirs.ts"],"sourcesContent":["import type { Rule } from \"eslint\";\n\nimport fastGlob from \"fast-glob\";\n\n/**\n * Process a Next.js root directory glob.\n */\nconst processRootDir = (rootDir: string): string[] => {\n return fastGlob.globSync(rootDir.replaceAll(\"\\\\\", \"/\"), {\n onlyDirectories: true,\n });\n};\n\n/**\n * Gets one or more Root, returns an array of root directories.\n */\nexport const getRootDirs = (context: Rule.RuleContext) => {\n let rootDirs = [context.cwd];\n\n const nextSettings: { rootDir?: string | string[] } =\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n context.settings.next || {};\n const rootDir = nextSettings.rootDir;\n\n if (typeof rootDir === \"string\") {\n rootDirs = processRootDir(rootDir);\n } else if (Array.isArray(rootDir)) {\n rootDirs = rootDir\n .map((dir) => (typeof dir === \"string\" ? processRootDir(dir) : []))\n .flat();\n }\n\n return rootDirs;\n};\n"],"mappings":";AAEA,OAAO,cAAc;AAKrB,IAAM,iBAAiB,CAAC,YAA8B;AACpD,SAAO,SAAS,SAAS,QAAQ,WAAW,MAAM,GAAG,GAAG;AAAA,IACtD,iBAAiB;AAAA,EACnB,CAAC;AACH;AAKO,IAAM,cAAc,CAAC,YAA8B;AACxD,MAAI,WAAW,CAAC,QAAQ,GAAG;AAE3B,QAAM;AAAA;AAAA,IAEJ,QAAQ,SAAS,QAAQ,CAAC;AAAA;AAC5B,QAAM,UAAU,aAAa;AAE7B,MAAI,OAAO,YAAY,UAAU;AAC/B,eAAW,eAAe,OAAO;AAAA,EACnC,WAAW,MAAM,QAAQ,OAAO,GAAG;AACjC,eAAW,QACR,IAAI,CAAC,QAAS,OAAO,QAAQ,WAAW,eAAe,GAAG,IAAI,CAAC,CAAE,EACjE,KAAK;AAAA,EACV;AAEA,SAAO;AACT;","names":[]}
|
@@ -0,0 +1,67 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
|
20
|
+
// src/utils/node-attributes.ts
|
21
|
+
var node_attributes_exports = {};
|
22
|
+
__export(node_attributes_exports, {
|
23
|
+
default: () => NodeAttributes
|
24
|
+
});
|
25
|
+
module.exports = __toCommonJS(node_attributes_exports);
|
26
|
+
var NodeAttributes = class {
|
27
|
+
attributes;
|
28
|
+
constructor(ASTnode) {
|
29
|
+
this.attributes = {};
|
30
|
+
ASTnode.attributes.forEach((attribute) => {
|
31
|
+
if (!attribute.type || attribute.type !== "JSXAttribute") {
|
32
|
+
return;
|
33
|
+
}
|
34
|
+
if (attribute.value) {
|
35
|
+
const value = typeof attribute.value.value === "string" ? attribute.value.value : typeof attribute.value.expression?.value !== "undefined" ? attribute.value.expression.value : attribute.value.expression?.properties;
|
36
|
+
this.attributes[attribute.name.name] = {
|
37
|
+
hasValue: true,
|
38
|
+
value
|
39
|
+
};
|
40
|
+
} else {
|
41
|
+
this.attributes[attribute.name.name] = {
|
42
|
+
hasValue: false
|
43
|
+
};
|
44
|
+
}
|
45
|
+
});
|
46
|
+
}
|
47
|
+
has(attrName) {
|
48
|
+
return Boolean(this.attributes[attrName]);
|
49
|
+
}
|
50
|
+
hasAny() {
|
51
|
+
return Boolean(Object.keys(this.attributes).length);
|
52
|
+
}
|
53
|
+
hasValue(attrName) {
|
54
|
+
return Boolean(this.attributes[attrName]?.hasValue);
|
55
|
+
}
|
56
|
+
value(attrName) {
|
57
|
+
const attr = this.attributes[attrName];
|
58
|
+
if (!attr) {
|
59
|
+
return true;
|
60
|
+
}
|
61
|
+
if ("hasValue" in attr && attr.hasValue) {
|
62
|
+
return attr.value;
|
63
|
+
}
|
64
|
+
return void 0;
|
65
|
+
}
|
66
|
+
};
|
67
|
+
//# sourceMappingURL=node-attributes.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/utils/node-attributes.ts"],"sourcesContent":["// Return attributes and values of a node in a convenient way:\n/* example: \n <ExampleElement attr1=\"15\" attr2>\n { attr1: {\n hasValue: true,\n value: 15\n },\n attr2: {\n hasValue: false\n }\nInclusion of hasValue is in case an eslint rule cares about boolean values\nexplicitly assigned to attribute vs the attribute being used as a flag\n*/\nexport default class NodeAttributes {\n attributes: Record<\n string,\n | {\n hasValue: true;\n value: any;\n }\n | {\n hasValue?: false;\n }\n >;\n\n constructor(ASTnode: any) {\n this.attributes = {};\n ASTnode.attributes.forEach((attribute: any) => {\n if (!attribute.type || attribute.type !== \"JSXAttribute\") {\n return;\n }\n\n if (attribute.value) {\n // hasValue\n const value =\n typeof attribute.value.value === \"string\" ? attribute.value.value\n : typeof attribute.value.expression?.value !== \"undefined\" ?\n attribute.value.expression.value\n : attribute.value.expression?.properties;\n\n this.attributes[attribute.name.name] = {\n hasValue: true,\n value,\n };\n } else {\n this.attributes[attribute.name.name] = {\n hasValue: false,\n };\n }\n });\n }\n\n has(attrName: string): boolean {\n return Boolean(this.attributes[attrName]);\n }\n\n hasAny(): boolean {\n return Boolean(Object.keys(this.attributes).length);\n }\n\n hasValue(attrName: string): boolean {\n return Boolean(this.attributes[attrName]?.hasValue);\n }\n\n value(attrName: string): any {\n const attr = this.attributes[attrName];\n\n if (!attr) {\n return true;\n }\n\n if (\"hasValue\" in attr && attr.hasValue) {\n return attr.value;\n }\n\n return undefined;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,IAAqB,iBAArB,MAAoC;AAAA,EAClC;AAAA,EAWA,YAAY,SAAc;AACxB,SAAK,aAAa,CAAC;AACnB,YAAQ,WAAW,QAAQ,CAAC,cAAmB;AAC7C,UAAI,CAAC,UAAU,QAAQ,UAAU,SAAS,gBAAgB;AACxD;AAAA,MACF;AAEA,UAAI,UAAU,OAAO;AAEnB,cAAM,QACJ,OAAO,UAAU,MAAM,UAAU,WAAW,UAAU,MAAM,QAC1D,OAAO,UAAU,MAAM,YAAY,UAAU,cAC7C,UAAU,MAAM,WAAW,QAC3B,UAAU,MAAM,YAAY;AAEhC,aAAK,WAAW,UAAU,KAAK,IAAI,IAAI;AAAA,UACrC,UAAU;AAAA,UACV;AAAA,QACF;AAAA,MACF,OAAO;AACL,aAAK,WAAW,UAAU,KAAK,IAAI,IAAI;AAAA,UACrC,UAAU;AAAA,QACZ;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,IAAI,UAA2B;AAC7B,WAAO,QAAQ,KAAK,WAAW,QAAQ,CAAC;AAAA,EAC1C;AAAA,EAEA,SAAkB;AAChB,WAAO,QAAQ,OAAO,KAAK,KAAK,UAAU,EAAE,MAAM;AAAA,EACpD;AAAA,EAEA,SAAS,UAA2B;AAClC,WAAO,QAAQ,KAAK,WAAW,QAAQ,GAAG,QAAQ;AAAA,EACpD;AAAA,EAEA,MAAM,UAAuB;AAC3B,UAAM,OAAO,KAAK,WAAW,QAAQ;AAErC,QAAI,CAAC,MAAM;AACT,aAAO;AAAA,IACT;AAEA,QAAI,cAAc,QAAQ,KAAK,UAAU;AACvC,aAAO,KAAK;AAAA,IACd;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
declare class NodeAttributes {
|
2
|
+
attributes: Record<string, {
|
3
|
+
hasValue: true;
|
4
|
+
value: any;
|
5
|
+
} | {
|
6
|
+
hasValue?: false;
|
7
|
+
}>;
|
8
|
+
constructor(ASTnode: any);
|
9
|
+
has(attrName: string): boolean;
|
10
|
+
hasAny(): boolean;
|
11
|
+
hasValue(attrName: string): boolean;
|
12
|
+
value(attrName: string): any;
|
13
|
+
}
|
14
|
+
|
15
|
+
export { NodeAttributes as default };
|
@@ -0,0 +1,15 @@
|
|
1
|
+
declare class NodeAttributes {
|
2
|
+
attributes: Record<string, {
|
3
|
+
hasValue: true;
|
4
|
+
value: any;
|
5
|
+
} | {
|
6
|
+
hasValue?: false;
|
7
|
+
}>;
|
8
|
+
constructor(ASTnode: any);
|
9
|
+
has(attrName: string): boolean;
|
10
|
+
hasAny(): boolean;
|
11
|
+
hasValue(attrName: string): boolean;
|
12
|
+
value(attrName: string): any;
|
13
|
+
}
|
14
|
+
|
15
|
+
export { NodeAttributes as default };
|
@@ -0,0 +1,46 @@
|
|
1
|
+
// src/utils/node-attributes.ts
|
2
|
+
var NodeAttributes = class {
|
3
|
+
attributes;
|
4
|
+
constructor(ASTnode) {
|
5
|
+
this.attributes = {};
|
6
|
+
ASTnode.attributes.forEach((attribute) => {
|
7
|
+
if (!attribute.type || attribute.type !== "JSXAttribute") {
|
8
|
+
return;
|
9
|
+
}
|
10
|
+
if (attribute.value) {
|
11
|
+
const value = typeof attribute.value.value === "string" ? attribute.value.value : typeof attribute.value.expression?.value !== "undefined" ? attribute.value.expression.value : attribute.value.expression?.properties;
|
12
|
+
this.attributes[attribute.name.name] = {
|
13
|
+
hasValue: true,
|
14
|
+
value
|
15
|
+
};
|
16
|
+
} else {
|
17
|
+
this.attributes[attribute.name.name] = {
|
18
|
+
hasValue: false
|
19
|
+
};
|
20
|
+
}
|
21
|
+
});
|
22
|
+
}
|
23
|
+
has(attrName) {
|
24
|
+
return Boolean(this.attributes[attrName]);
|
25
|
+
}
|
26
|
+
hasAny() {
|
27
|
+
return Boolean(Object.keys(this.attributes).length);
|
28
|
+
}
|
29
|
+
hasValue(attrName) {
|
30
|
+
return Boolean(this.attributes[attrName]?.hasValue);
|
31
|
+
}
|
32
|
+
value(attrName) {
|
33
|
+
const attr = this.attributes[attrName];
|
34
|
+
if (!attr) {
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
if ("hasValue" in attr && attr.hasValue) {
|
38
|
+
return attr.value;
|
39
|
+
}
|
40
|
+
return void 0;
|
41
|
+
}
|
42
|
+
};
|
43
|
+
export {
|
44
|
+
NodeAttributes as default
|
45
|
+
};
|
46
|
+
//# sourceMappingURL=node-attributes.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/utils/node-attributes.ts"],"sourcesContent":["// Return attributes and values of a node in a convenient way:\n/* example: \n <ExampleElement attr1=\"15\" attr2>\n { attr1: {\n hasValue: true,\n value: 15\n },\n attr2: {\n hasValue: false\n }\nInclusion of hasValue is in case an eslint rule cares about boolean values\nexplicitly assigned to attribute vs the attribute being used as a flag\n*/\nexport default class NodeAttributes {\n attributes: Record<\n string,\n | {\n hasValue: true;\n value: any;\n }\n | {\n hasValue?: false;\n }\n >;\n\n constructor(ASTnode: any) {\n this.attributes = {};\n ASTnode.attributes.forEach((attribute: any) => {\n if (!attribute.type || attribute.type !== \"JSXAttribute\") {\n return;\n }\n\n if (attribute.value) {\n // hasValue\n const value =\n typeof attribute.value.value === \"string\" ? attribute.value.value\n : typeof attribute.value.expression?.value !== \"undefined\" ?\n attribute.value.expression.value\n : attribute.value.expression?.properties;\n\n this.attributes[attribute.name.name] = {\n hasValue: true,\n value,\n };\n } else {\n this.attributes[attribute.name.name] = {\n hasValue: false,\n };\n }\n });\n }\n\n has(attrName: string): boolean {\n return Boolean(this.attributes[attrName]);\n }\n\n hasAny(): boolean {\n return Boolean(Object.keys(this.attributes).length);\n }\n\n hasValue(attrName: string): boolean {\n return Boolean(this.attributes[attrName]?.hasValue);\n }\n\n value(attrName: string): any {\n const attr = this.attributes[attrName];\n\n if (!attr) {\n return true;\n }\n\n if (\"hasValue\" in attr && attr.hasValue) {\n return attr.value;\n }\n\n return undefined;\n }\n}\n"],"mappings":";AAaA,IAAqB,iBAArB,MAAoC;AAAA,EAClC;AAAA,EAWA,YAAY,SAAc;AACxB,SAAK,aAAa,CAAC;AACnB,YAAQ,WAAW,QAAQ,CAAC,cAAmB;AAC7C,UAAI,CAAC,UAAU,QAAQ,UAAU,SAAS,gBAAgB;AACxD;AAAA,MACF;AAEA,UAAI,UAAU,OAAO;AAEnB,cAAM,QACJ,OAAO,UAAU,MAAM,UAAU,WAAW,UAAU,MAAM,QAC1D,OAAO,UAAU,MAAM,YAAY,UAAU,cAC7C,UAAU,MAAM,WAAW,QAC3B,UAAU,MAAM,YAAY;AAEhC,aAAK,WAAW,UAAU,KAAK,IAAI,IAAI;AAAA,UACrC,UAAU;AAAA,UACV;AAAA,QACF;AAAA,MACF,OAAO;AACL,aAAK,WAAW,UAAU,KAAK,IAAI,IAAI;AAAA,UACrC,UAAU;AAAA,QACZ;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,IAAI,UAA2B;AAC7B,WAAO,QAAQ,KAAK,WAAW,QAAQ,CAAC;AAAA,EAC1C;AAAA,EAEA,SAAkB;AAChB,WAAO,QAAQ,OAAO,KAAK,KAAK,UAAU,EAAE,MAAM;AAAA,EACpD;AAAA,EAEA,SAAS,UAA2B;AAClC,WAAO,QAAQ,KAAK,WAAW,QAAQ,GAAG,QAAQ;AAAA,EACpD;AAAA,EAEA,MAAM,UAAuB;AAC3B,UAAM,OAAO,KAAK,WAAW,QAAQ;AAErC,QAAI,CAAC,MAAM;AACT,aAAO;AAAA,IACT;AAEA,QAAI,cAAc,QAAQ,KAAK,UAAU;AACvC,aAAO,KAAK;AAAA,IACd;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
|
@@ -0,0 +1,167 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
+
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
|
30
|
+
// src/utils/url.ts
|
31
|
+
var url_exports = {};
|
32
|
+
__export(url_exports, {
|
33
|
+
execOnce: () => execOnce,
|
34
|
+
getUrlFromAppDirectory: () => getUrlFromAppDirectory,
|
35
|
+
getUrlFromPagesDirectories: () => getUrlFromPagesDirectories,
|
36
|
+
normalizeAppPath: () => normalizeAppPath,
|
37
|
+
normalizeURL: () => normalizeURL
|
38
|
+
});
|
39
|
+
module.exports = __toCommonJS(url_exports);
|
40
|
+
var fs = __toESM(require("fs"), 1);
|
41
|
+
var path = __toESM(require("path"), 1);
|
42
|
+
var fsReadDirSyncCache = {};
|
43
|
+
var parseUrlForPages = (urlprefix, directory) => {
|
44
|
+
fsReadDirSyncCache[directory] ??= fs.readdirSync(directory, {
|
45
|
+
withFileTypes: true
|
46
|
+
});
|
47
|
+
const res = [];
|
48
|
+
fsReadDirSyncCache[directory].forEach((dirent) => {
|
49
|
+
if (/(?<temp2>\.(?<temp1>j|t)sx?)$/.test(dirent.name)) {
|
50
|
+
if (/^index(?<temp2>\.(?<temp1>j|t)sx?)$/.test(dirent.name)) {
|
51
|
+
res.push(
|
52
|
+
`${urlprefix}${dirent.name.replace(/^index(?<temp2>\.(?<temp1>j|t)sx?)$/, "")}`
|
53
|
+
);
|
54
|
+
}
|
55
|
+
res.push(
|
56
|
+
`${urlprefix}${dirent.name.replace(/(?<temp2>\.(?<temp1>j|t)sx?)$/, "")}`
|
57
|
+
);
|
58
|
+
} else {
|
59
|
+
const dirPath = path.join(directory, dirent.name);
|
60
|
+
if (dirent.isDirectory() && !dirent.isSymbolicLink()) {
|
61
|
+
res.push(...parseUrlForPages(`${urlprefix + dirent.name}/`, dirPath));
|
62
|
+
}
|
63
|
+
}
|
64
|
+
});
|
65
|
+
return res;
|
66
|
+
};
|
67
|
+
var parseUrlForAppDir = (urlprefix, directory) => {
|
68
|
+
fsReadDirSyncCache[directory] ??= fs.readdirSync(directory, {
|
69
|
+
withFileTypes: true
|
70
|
+
});
|
71
|
+
const res = [];
|
72
|
+
fsReadDirSyncCache[directory].forEach((dirent) => {
|
73
|
+
if (/(?<temp2>\.(?<temp1>j|t)sx?)$/.test(dirent.name)) {
|
74
|
+
if (/^page(?<temp2>\.(?<temp1>j|t)sx?)$/.test(dirent.name)) {
|
75
|
+
res.push(
|
76
|
+
`${urlprefix}${dirent.name.replace(/^page(?<temp2>\.(?<temp1>j|t)sx?)$/, "")}`
|
77
|
+
);
|
78
|
+
} else if (!/^layout(?<temp2>\.(?<temp1>j|t)sx?)$/.test(dirent.name)) {
|
79
|
+
res.push(
|
80
|
+
`${urlprefix}${dirent.name.replace(/(?<temp2>\.(?<temp1>j|t)sx?)$/, "")}`
|
81
|
+
);
|
82
|
+
}
|
83
|
+
} else {
|
84
|
+
const dirPath = path.join(directory, dirent.name);
|
85
|
+
if (dirent.isDirectory(dirPath) && !dirent.isSymbolicLink()) {
|
86
|
+
res.push(...parseUrlForPages(`${urlprefix + dirent.name}/`, dirPath));
|
87
|
+
}
|
88
|
+
}
|
89
|
+
});
|
90
|
+
return res;
|
91
|
+
};
|
92
|
+
var normalizeURL = (url) => {
|
93
|
+
if (!url) {
|
94
|
+
return;
|
95
|
+
}
|
96
|
+
url = url.split("?", 1)[0];
|
97
|
+
url = url.split("#", 1)[0];
|
98
|
+
url = url.replace(/(?<temp1>\/index\.html)$/, "/");
|
99
|
+
if (url === "") {
|
100
|
+
return url;
|
101
|
+
}
|
102
|
+
url = url.endsWith("/") ? url : `${url}/`;
|
103
|
+
return url;
|
104
|
+
};
|
105
|
+
var normalizeAppPath = (route) => ensureLeadingSlash(
|
106
|
+
route.split("/").reduce((pathname, segment, index, segments) => {
|
107
|
+
if (!segment) {
|
108
|
+
return pathname;
|
109
|
+
}
|
110
|
+
if (isGroupSegment(segment)) {
|
111
|
+
return pathname;
|
112
|
+
}
|
113
|
+
if (segment.startsWith("@")) {
|
114
|
+
return pathname;
|
115
|
+
}
|
116
|
+
if ((segment === "page" || segment === "route") && index === segments.length - 1) {
|
117
|
+
return pathname;
|
118
|
+
}
|
119
|
+
return `${pathname}/${segment}`;
|
120
|
+
}, "")
|
121
|
+
);
|
122
|
+
var getUrlFromPagesDirectories = (urlPrefix, directories) => Array.from(
|
123
|
+
// De-duplicate similar pages across multiple directories.
|
124
|
+
new Set(
|
125
|
+
directories.flatMap((directory) => parseUrlForPages(urlPrefix, directory)).map(
|
126
|
+
// Since the URLs are normalized we add `^` and `$` to the RegExp to make sure they match exactly.
|
127
|
+
(url) => `^${normalizeURL(url)}$`
|
128
|
+
)
|
129
|
+
)
|
130
|
+
).map((urlReg) => {
|
131
|
+
urlReg = urlReg.replaceAll(/\[.*]/g, "((?!.+?\\..+?).*?)");
|
132
|
+
return new RegExp(urlReg);
|
133
|
+
});
|
134
|
+
var getUrlFromAppDirectory = (urlPrefix, directories) => Array.from(
|
135
|
+
// De-duplicate similar pages across multiple directories.
|
136
|
+
new Set(
|
137
|
+
directories.map((directory) => parseUrlForAppDir(urlPrefix, directory)).flat().map(
|
138
|
+
// Since the URLs are normalized we add `^` and `$` to the RegExp to make sure they match exactly.
|
139
|
+
(url) => `^${normalizeAppPath(url)}$`
|
140
|
+
)
|
141
|
+
)
|
142
|
+
).map((urlReg) => {
|
143
|
+
urlReg = urlReg.replaceAll(/\[.*]/g, "((?!.+?\\..+?).*?)");
|
144
|
+
return new RegExp(urlReg);
|
145
|
+
});
|
146
|
+
var execOnce = (fn) => {
|
147
|
+
let used = false;
|
148
|
+
let result;
|
149
|
+
return (...args) => {
|
150
|
+
if (!used) {
|
151
|
+
used = true;
|
152
|
+
result = fn(...args);
|
153
|
+
}
|
154
|
+
return result;
|
155
|
+
};
|
156
|
+
};
|
157
|
+
var ensureLeadingSlash = (route) => route.startsWith("/") ? route : `/${route}`;
|
158
|
+
var isGroupSegment = (segment) => segment.startsWith("(") && segment.endsWith(")");
|
159
|
+
// Annotate the CommonJS export names for ESM import in node:
|
160
|
+
0 && (module.exports = {
|
161
|
+
execOnce,
|
162
|
+
getUrlFromAppDirectory,
|
163
|
+
getUrlFromPagesDirectories,
|
164
|
+
normalizeAppPath,
|
165
|
+
normalizeURL
|
166
|
+
});
|
167
|
+
//# sourceMappingURL=url.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/utils/url.ts"],"sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\n// Cache for fs.readdirSync lookup.\n// Prevent multiple blocking IO requests that have already been calculated.\nconst fsReadDirSyncCache: Record<string, fs.Dirent[]> = {};\n\n/**\n * Recursively parse directory for page URLs.\n */\nconst parseUrlForPages = (urlprefix: string, directory: string) => {\n fsReadDirSyncCache[directory] ??= fs.readdirSync(directory, {\n withFileTypes: true,\n });\n const res: string[] = [];\n fsReadDirSyncCache[directory].forEach((dirent) => {\n // TODO: this should account for all page extensions\n // not just js(x) and ts(x)\n if (/(?<temp2>\\.(?<temp1>j|t)sx?)$/.test(dirent.name)) {\n if (/^index(?<temp2>\\.(?<temp1>j|t)sx?)$/.test(dirent.name)) {\n res.push(\n `${urlprefix}${dirent.name.replace(/^index(?<temp2>\\.(?<temp1>j|t)sx?)$/, \"\")}`,\n );\n }\n res.push(\n `${urlprefix}${dirent.name.replace(/(?<temp2>\\.(?<temp1>j|t)sx?)$/, \"\")}`,\n );\n } else {\n const dirPath = path.join(directory, dirent.name);\n if (dirent.isDirectory() && !dirent.isSymbolicLink()) {\n res.push(...parseUrlForPages(`${urlprefix + dirent.name}/`, dirPath));\n }\n }\n });\n return res;\n};\n\n/**\n * Recursively parse app directory for URLs.\n */\nconst parseUrlForAppDir = (urlprefix: string, directory: string) => {\n fsReadDirSyncCache[directory] ??= fs.readdirSync(directory, {\n withFileTypes: true,\n });\n const res: string[] = [];\n fsReadDirSyncCache[directory].forEach((dirent) => {\n // TODO: this should account for all page extensions\n // not just js(x) and ts(x)\n if (/(?<temp2>\\.(?<temp1>j|t)sx?)$/.test(dirent.name)) {\n if (/^page(?<temp2>\\.(?<temp1>j|t)sx?)$/.test(dirent.name)) {\n res.push(\n `${urlprefix}${dirent.name.replace(/^page(?<temp2>\\.(?<temp1>j|t)sx?)$/, \"\")}`,\n );\n } else if (!/^layout(?<temp2>\\.(?<temp1>j|t)sx?)$/.test(dirent.name)) {\n res.push(\n `${urlprefix}${dirent.name.replace(/(?<temp2>\\.(?<temp1>j|t)sx?)$/, \"\")}`,\n );\n }\n } else {\n const dirPath = path.join(directory, dirent.name);\n // @ts-expect-error - types suggest this shouldn't take an arg, but I don't want to change anything\n if (dirent.isDirectory(dirPath) && !dirent.isSymbolicLink()) {\n res.push(...parseUrlForPages(`${urlprefix + dirent.name}/`, dirPath));\n }\n }\n });\n return res;\n};\n\n/**\n * Takes a URL and does the following things.\n * - Replaces `index.html` with `/`\n * - Makes sure all URLs are have a trailing `/`\n * - Removes query string\n */\nexport const normalizeURL = (url: string) => {\n if (!url) {\n return;\n }\n url = url.split(\"?\", 1)[0] as string;\n url = url.split(\"#\", 1)[0] as string;\n url = url.replace(/(?<temp1>\\/index\\.html)$/, \"/\");\n // Empty URLs should not be trailed with `/`, e.g. `#heading`\n if (url === \"\") {\n return url;\n }\n url = url.endsWith(\"/\") ? url : `${url}/`;\n return url;\n};\n\n/**\n * Normalizes an app route so it represents the actual request path. Essentially\n * performing the following transformations:\n *\n * - `/(dashboard)/user/[id]/page` to `/user/[id]`\n * - `/(dashboard)/account/page` to `/account`\n * - `/user/[id]/page` to `/user/[id]`\n * - `/account/page` to `/account`\n * - `/page` to `/`\n * - `/(dashboard)/user/[id]/route` to `/user/[id]`\n * - `/(dashboard)/account/route` to `/account`\n * - `/user/[id]/route` to `/user/[id]`\n * - `/account/route` to `/account`\n * - `/route` to `/`\n * - `/` to `/`\n *\n * @param route the app route to normalize\n * @returns the normalized pathname\n */\nexport const normalizeAppPath = (route: string) =>\n ensureLeadingSlash(\n route.split(\"/\").reduce((pathname, segment, index, segments) => {\n // Empty segments are ignored.\n if (!segment) {\n return pathname;\n }\n\n // Groups are ignored.\n if (isGroupSegment(segment)) {\n return pathname;\n }\n\n // Parallel segments are ignored.\n if (segment.startsWith(\"@\")) {\n return pathname;\n }\n\n // The last segment (if it's a leaf) should be ignored.\n if (\n (segment === \"page\" || segment === \"route\") &&\n index === segments.length - 1\n ) {\n return pathname;\n }\n\n return `${pathname}/${segment}`;\n }, \"\"),\n );\n\n/**\n * Gets the possible URLs from a directory.\n */\nexport const getUrlFromPagesDirectories = (\n urlPrefix: string,\n directories: string[],\n) =>\n Array.from(\n // De-duplicate similar pages across multiple directories.\n new Set(\n directories\n .flatMap((directory) => parseUrlForPages(urlPrefix, directory))\n .map(\n // Since the URLs are normalized we add `^` and `$` to the RegExp to make sure they match exactly.\n (url) => `^${normalizeURL(url)}$`,\n ),\n ),\n ).map((urlReg) => {\n urlReg = urlReg.replaceAll(/\\[.*]/g, \"((?!.+?\\\\..+?).*?)\");\n return new RegExp(urlReg);\n });\n\nexport const getUrlFromAppDirectory = (\n urlPrefix: string,\n directories: string[],\n) =>\n Array.from(\n // De-duplicate similar pages across multiple directories.\n new Set(\n directories\n .map((directory) => parseUrlForAppDir(urlPrefix, directory))\n .flat()\n .map(\n // Since the URLs are normalized we add `^` and `$` to the RegExp to make sure they match exactly.\n (url) => `^${normalizeAppPath(url)}$`,\n ),\n ),\n ).map((urlReg) => {\n urlReg = urlReg.replaceAll(/\\[.*]/g, \"((?!.+?\\\\..+?).*?)\");\n return new RegExp(urlReg);\n });\n\nexport const execOnce = <TArgs extends any[], TResult>(\n fn: (...args: TArgs) => TResult,\n): ((...args: TArgs) => TResult) => {\n let used = false;\n let result: TResult;\n\n return (...args: TArgs) => {\n if (!used) {\n used = true;\n result = fn(...args);\n }\n return result;\n };\n};\n\nconst ensureLeadingSlash = (route: string) =>\n route.startsWith(\"/\") ? route : `/${route}`;\n\nconst isGroupSegment = (segment: string) =>\n segment.startsWith(\"(\") && segment.endsWith(\")\");\n"],"mappings":"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","names":[]}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
/**
|
2
|
+
* Takes a URL and does the following things.
|
3
|
+
* - Replaces `index.html` with `/`
|
4
|
+
* - Makes sure all URLs are have a trailing `/`
|
5
|
+
* - Removes query string
|
6
|
+
*/
|
7
|
+
declare const normalizeURL: (url: string) => string | undefined;
|
8
|
+
/**
|
9
|
+
* Normalizes an app route so it represents the actual request path. Essentially
|
10
|
+
* performing the following transformations:
|
11
|
+
*
|
12
|
+
* - `/(dashboard)/user/[id]/page` to `/user/[id]`
|
13
|
+
* - `/(dashboard)/account/page` to `/account`
|
14
|
+
* - `/user/[id]/page` to `/user/[id]`
|
15
|
+
* - `/account/page` to `/account`
|
16
|
+
* - `/page` to `/`
|
17
|
+
* - `/(dashboard)/user/[id]/route` to `/user/[id]`
|
18
|
+
* - `/(dashboard)/account/route` to `/account`
|
19
|
+
* - `/user/[id]/route` to `/user/[id]`
|
20
|
+
* - `/account/route` to `/account`
|
21
|
+
* - `/route` to `/`
|
22
|
+
* - `/` to `/`
|
23
|
+
*
|
24
|
+
* @param route the app route to normalize
|
25
|
+
* @returns the normalized pathname
|
26
|
+
*/
|
27
|
+
declare const normalizeAppPath: (route: string) => string;
|
28
|
+
/**
|
29
|
+
* Gets the possible URLs from a directory.
|
30
|
+
*/
|
31
|
+
declare const getUrlFromPagesDirectories: (urlPrefix: string, directories: string[]) => RegExp[];
|
32
|
+
declare const getUrlFromAppDirectory: (urlPrefix: string, directories: string[]) => RegExp[];
|
33
|
+
declare const execOnce: <TArgs extends any[], TResult>(fn: (...args: TArgs) => TResult) => ((...args: TArgs) => TResult);
|
34
|
+
|
35
|
+
export { execOnce, getUrlFromAppDirectory, getUrlFromPagesDirectories, normalizeAppPath, normalizeURL };
|
@@ -0,0 +1,35 @@
|
|
1
|
+
/**
|
2
|
+
* Takes a URL and does the following things.
|
3
|
+
* - Replaces `index.html` with `/`
|
4
|
+
* - Makes sure all URLs are have a trailing `/`
|
5
|
+
* - Removes query string
|
6
|
+
*/
|
7
|
+
declare const normalizeURL: (url: string) => string | undefined;
|
8
|
+
/**
|
9
|
+
* Normalizes an app route so it represents the actual request path. Essentially
|
10
|
+
* performing the following transformations:
|
11
|
+
*
|
12
|
+
* - `/(dashboard)/user/[id]/page` to `/user/[id]`
|
13
|
+
* - `/(dashboard)/account/page` to `/account`
|
14
|
+
* - `/user/[id]/page` to `/user/[id]`
|
15
|
+
* - `/account/page` to `/account`
|
16
|
+
* - `/page` to `/`
|
17
|
+
* - `/(dashboard)/user/[id]/route` to `/user/[id]`
|
18
|
+
* - `/(dashboard)/account/route` to `/account`
|
19
|
+
* - `/user/[id]/route` to `/user/[id]`
|
20
|
+
* - `/account/route` to `/account`
|
21
|
+
* - `/route` to `/`
|
22
|
+
* - `/` to `/`
|
23
|
+
*
|
24
|
+
* @param route the app route to normalize
|
25
|
+
* @returns the normalized pathname
|
26
|
+
*/
|
27
|
+
declare const normalizeAppPath: (route: string) => string;
|
28
|
+
/**
|
29
|
+
* Gets the possible URLs from a directory.
|
30
|
+
*/
|
31
|
+
declare const getUrlFromPagesDirectories: (urlPrefix: string, directories: string[]) => RegExp[];
|
32
|
+
declare const getUrlFromAppDirectory: (urlPrefix: string, directories: string[]) => RegExp[];
|
33
|
+
declare const execOnce: <TArgs extends any[], TResult>(fn: (...args: TArgs) => TResult) => ((...args: TArgs) => TResult);
|
34
|
+
|
35
|
+
export { execOnce, getUrlFromAppDirectory, getUrlFromPagesDirectories, normalizeAppPath, normalizeURL };
|
@@ -0,0 +1,128 @@
|
|
1
|
+
// src/utils/url.ts
|
2
|
+
import * as fs from "node:fs";
|
3
|
+
import * as path from "node:path";
|
4
|
+
var fsReadDirSyncCache = {};
|
5
|
+
var parseUrlForPages = (urlprefix, directory) => {
|
6
|
+
fsReadDirSyncCache[directory] ??= fs.readdirSync(directory, {
|
7
|
+
withFileTypes: true
|
8
|
+
});
|
9
|
+
const res = [];
|
10
|
+
fsReadDirSyncCache[directory].forEach((dirent) => {
|
11
|
+
if (/(?<temp2>\.(?<temp1>j|t)sx?)$/.test(dirent.name)) {
|
12
|
+
if (/^index(?<temp2>\.(?<temp1>j|t)sx?)$/.test(dirent.name)) {
|
13
|
+
res.push(
|
14
|
+
`${urlprefix}${dirent.name.replace(/^index(?<temp2>\.(?<temp1>j|t)sx?)$/, "")}`
|
15
|
+
);
|
16
|
+
}
|
17
|
+
res.push(
|
18
|
+
`${urlprefix}${dirent.name.replace(/(?<temp2>\.(?<temp1>j|t)sx?)$/, "")}`
|
19
|
+
);
|
20
|
+
} else {
|
21
|
+
const dirPath = path.join(directory, dirent.name);
|
22
|
+
if (dirent.isDirectory() && !dirent.isSymbolicLink()) {
|
23
|
+
res.push(...parseUrlForPages(`${urlprefix + dirent.name}/`, dirPath));
|
24
|
+
}
|
25
|
+
}
|
26
|
+
});
|
27
|
+
return res;
|
28
|
+
};
|
29
|
+
var parseUrlForAppDir = (urlprefix, directory) => {
|
30
|
+
fsReadDirSyncCache[directory] ??= fs.readdirSync(directory, {
|
31
|
+
withFileTypes: true
|
32
|
+
});
|
33
|
+
const res = [];
|
34
|
+
fsReadDirSyncCache[directory].forEach((dirent) => {
|
35
|
+
if (/(?<temp2>\.(?<temp1>j|t)sx?)$/.test(dirent.name)) {
|
36
|
+
if (/^page(?<temp2>\.(?<temp1>j|t)sx?)$/.test(dirent.name)) {
|
37
|
+
res.push(
|
38
|
+
`${urlprefix}${dirent.name.replace(/^page(?<temp2>\.(?<temp1>j|t)sx?)$/, "")}`
|
39
|
+
);
|
40
|
+
} else if (!/^layout(?<temp2>\.(?<temp1>j|t)sx?)$/.test(dirent.name)) {
|
41
|
+
res.push(
|
42
|
+
`${urlprefix}${dirent.name.replace(/(?<temp2>\.(?<temp1>j|t)sx?)$/, "")}`
|
43
|
+
);
|
44
|
+
}
|
45
|
+
} else {
|
46
|
+
const dirPath = path.join(directory, dirent.name);
|
47
|
+
if (dirent.isDirectory(dirPath) && !dirent.isSymbolicLink()) {
|
48
|
+
res.push(...parseUrlForPages(`${urlprefix + dirent.name}/`, dirPath));
|
49
|
+
}
|
50
|
+
}
|
51
|
+
});
|
52
|
+
return res;
|
53
|
+
};
|
54
|
+
var normalizeURL = (url) => {
|
55
|
+
if (!url) {
|
56
|
+
return;
|
57
|
+
}
|
58
|
+
url = url.split("?", 1)[0];
|
59
|
+
url = url.split("#", 1)[0];
|
60
|
+
url = url.replace(/(?<temp1>\/index\.html)$/, "/");
|
61
|
+
if (url === "") {
|
62
|
+
return url;
|
63
|
+
}
|
64
|
+
url = url.endsWith("/") ? url : `${url}/`;
|
65
|
+
return url;
|
66
|
+
};
|
67
|
+
var normalizeAppPath = (route) => ensureLeadingSlash(
|
68
|
+
route.split("/").reduce((pathname, segment, index, segments) => {
|
69
|
+
if (!segment) {
|
70
|
+
return pathname;
|
71
|
+
}
|
72
|
+
if (isGroupSegment(segment)) {
|
73
|
+
return pathname;
|
74
|
+
}
|
75
|
+
if (segment.startsWith("@")) {
|
76
|
+
return pathname;
|
77
|
+
}
|
78
|
+
if ((segment === "page" || segment === "route") && index === segments.length - 1) {
|
79
|
+
return pathname;
|
80
|
+
}
|
81
|
+
return `${pathname}/${segment}`;
|
82
|
+
}, "")
|
83
|
+
);
|
84
|
+
var getUrlFromPagesDirectories = (urlPrefix, directories) => Array.from(
|
85
|
+
// De-duplicate similar pages across multiple directories.
|
86
|
+
new Set(
|
87
|
+
directories.flatMap((directory) => parseUrlForPages(urlPrefix, directory)).map(
|
88
|
+
// Since the URLs are normalized we add `^` and `$` to the RegExp to make sure they match exactly.
|
89
|
+
(url) => `^${normalizeURL(url)}$`
|
90
|
+
)
|
91
|
+
)
|
92
|
+
).map((urlReg) => {
|
93
|
+
urlReg = urlReg.replaceAll(/\[.*]/g, "((?!.+?\\..+?).*?)");
|
94
|
+
return new RegExp(urlReg);
|
95
|
+
});
|
96
|
+
var getUrlFromAppDirectory = (urlPrefix, directories) => Array.from(
|
97
|
+
// De-duplicate similar pages across multiple directories.
|
98
|
+
new Set(
|
99
|
+
directories.map((directory) => parseUrlForAppDir(urlPrefix, directory)).flat().map(
|
100
|
+
// Since the URLs are normalized we add `^` and `$` to the RegExp to make sure they match exactly.
|
101
|
+
(url) => `^${normalizeAppPath(url)}$`
|
102
|
+
)
|
103
|
+
)
|
104
|
+
).map((urlReg) => {
|
105
|
+
urlReg = urlReg.replaceAll(/\[.*]/g, "((?!.+?\\..+?).*?)");
|
106
|
+
return new RegExp(urlReg);
|
107
|
+
});
|
108
|
+
var execOnce = (fn) => {
|
109
|
+
let used = false;
|
110
|
+
let result;
|
111
|
+
return (...args) => {
|
112
|
+
if (!used) {
|
113
|
+
used = true;
|
114
|
+
result = fn(...args);
|
115
|
+
}
|
116
|
+
return result;
|
117
|
+
};
|
118
|
+
};
|
119
|
+
var ensureLeadingSlash = (route) => route.startsWith("/") ? route : `/${route}`;
|
120
|
+
var isGroupSegment = (segment) => segment.startsWith("(") && segment.endsWith(")");
|
121
|
+
export {
|
122
|
+
execOnce,
|
123
|
+
getUrlFromAppDirectory,
|
124
|
+
getUrlFromPagesDirectories,
|
125
|
+
normalizeAppPath,
|
126
|
+
normalizeURL
|
127
|
+
};
|
128
|
+
//# sourceMappingURL=url.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/utils/url.ts"],"sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\n// Cache for fs.readdirSync lookup.\n// Prevent multiple blocking IO requests that have already been calculated.\nconst fsReadDirSyncCache: Record<string, fs.Dirent[]> = {};\n\n/**\n * Recursively parse directory for page URLs.\n */\nconst parseUrlForPages = (urlprefix: string, directory: string) => {\n fsReadDirSyncCache[directory] ??= fs.readdirSync(directory, {\n withFileTypes: true,\n });\n const res: string[] = [];\n fsReadDirSyncCache[directory].forEach((dirent) => {\n // TODO: this should account for all page extensions\n // not just js(x) and ts(x)\n if (/(?<temp2>\\.(?<temp1>j|t)sx?)$/.test(dirent.name)) {\n if (/^index(?<temp2>\\.(?<temp1>j|t)sx?)$/.test(dirent.name)) {\n res.push(\n `${urlprefix}${dirent.name.replace(/^index(?<temp2>\\.(?<temp1>j|t)sx?)$/, \"\")}`,\n );\n }\n res.push(\n `${urlprefix}${dirent.name.replace(/(?<temp2>\\.(?<temp1>j|t)sx?)$/, \"\")}`,\n );\n } else {\n const dirPath = path.join(directory, dirent.name);\n if (dirent.isDirectory() && !dirent.isSymbolicLink()) {\n res.push(...parseUrlForPages(`${urlprefix + dirent.name}/`, dirPath));\n }\n }\n });\n return res;\n};\n\n/**\n * Recursively parse app directory for URLs.\n */\nconst parseUrlForAppDir = (urlprefix: string, directory: string) => {\n fsReadDirSyncCache[directory] ??= fs.readdirSync(directory, {\n withFileTypes: true,\n });\n const res: string[] = [];\n fsReadDirSyncCache[directory].forEach((dirent) => {\n // TODO: this should account for all page extensions\n // not just js(x) and ts(x)\n if (/(?<temp2>\\.(?<temp1>j|t)sx?)$/.test(dirent.name)) {\n if (/^page(?<temp2>\\.(?<temp1>j|t)sx?)$/.test(dirent.name)) {\n res.push(\n `${urlprefix}${dirent.name.replace(/^page(?<temp2>\\.(?<temp1>j|t)sx?)$/, \"\")}`,\n );\n } else if (!/^layout(?<temp2>\\.(?<temp1>j|t)sx?)$/.test(dirent.name)) {\n res.push(\n `${urlprefix}${dirent.name.replace(/(?<temp2>\\.(?<temp1>j|t)sx?)$/, \"\")}`,\n );\n }\n } else {\n const dirPath = path.join(directory, dirent.name);\n // @ts-expect-error - types suggest this shouldn't take an arg, but I don't want to change anything\n if (dirent.isDirectory(dirPath) && !dirent.isSymbolicLink()) {\n res.push(...parseUrlForPages(`${urlprefix + dirent.name}/`, dirPath));\n }\n }\n });\n return res;\n};\n\n/**\n * Takes a URL and does the following things.\n * - Replaces `index.html` with `/`\n * - Makes sure all URLs are have a trailing `/`\n * - Removes query string\n */\nexport const normalizeURL = (url: string) => {\n if (!url) {\n return;\n }\n url = url.split(\"?\", 1)[0] as string;\n url = url.split(\"#\", 1)[0] as string;\n url = url.replace(/(?<temp1>\\/index\\.html)$/, \"/\");\n // Empty URLs should not be trailed with `/`, e.g. `#heading`\n if (url === \"\") {\n return url;\n }\n url = url.endsWith(\"/\") ? url : `${url}/`;\n return url;\n};\n\n/**\n * Normalizes an app route so it represents the actual request path. Essentially\n * performing the following transformations:\n *\n * - `/(dashboard)/user/[id]/page` to `/user/[id]`\n * - `/(dashboard)/account/page` to `/account`\n * - `/user/[id]/page` to `/user/[id]`\n * - `/account/page` to `/account`\n * - `/page` to `/`\n * - `/(dashboard)/user/[id]/route` to `/user/[id]`\n * - `/(dashboard)/account/route` to `/account`\n * - `/user/[id]/route` to `/user/[id]`\n * - `/account/route` to `/account`\n * - `/route` to `/`\n * - `/` to `/`\n *\n * @param route the app route to normalize\n * @returns the normalized pathname\n */\nexport const normalizeAppPath = (route: string) =>\n ensureLeadingSlash(\n route.split(\"/\").reduce((pathname, segment, index, segments) => {\n // Empty segments are ignored.\n if (!segment) {\n return pathname;\n }\n\n // Groups are ignored.\n if (isGroupSegment(segment)) {\n return pathname;\n }\n\n // Parallel segments are ignored.\n if (segment.startsWith(\"@\")) {\n return pathname;\n }\n\n // The last segment (if it's a leaf) should be ignored.\n if (\n (segment === \"page\" || segment === \"route\") &&\n index === segments.length - 1\n ) {\n return pathname;\n }\n\n return `${pathname}/${segment}`;\n }, \"\"),\n );\n\n/**\n * Gets the possible URLs from a directory.\n */\nexport const getUrlFromPagesDirectories = (\n urlPrefix: string,\n directories: string[],\n) =>\n Array.from(\n // De-duplicate similar pages across multiple directories.\n new Set(\n directories\n .flatMap((directory) => parseUrlForPages(urlPrefix, directory))\n .map(\n // Since the URLs are normalized we add `^` and `$` to the RegExp to make sure they match exactly.\n (url) => `^${normalizeURL(url)}$`,\n ),\n ),\n ).map((urlReg) => {\n urlReg = urlReg.replaceAll(/\\[.*]/g, \"((?!.+?\\\\..+?).*?)\");\n return new RegExp(urlReg);\n });\n\nexport const getUrlFromAppDirectory = (\n urlPrefix: string,\n directories: string[],\n) =>\n Array.from(\n // De-duplicate similar pages across multiple directories.\n new Set(\n directories\n .map((directory) => parseUrlForAppDir(urlPrefix, directory))\n .flat()\n .map(\n // Since the URLs are normalized we add `^` and `$` to the RegExp to make sure they match exactly.\n (url) => `^${normalizeAppPath(url)}$`,\n ),\n ),\n ).map((urlReg) => {\n urlReg = urlReg.replaceAll(/\\[.*]/g, \"((?!.+?\\\\..+?).*?)\");\n return new RegExp(urlReg);\n });\n\nexport const execOnce = <TArgs extends any[], TResult>(\n fn: (...args: TArgs) => TResult,\n): ((...args: TArgs) => TResult) => {\n let used = false;\n let result: TResult;\n\n return (...args: TArgs) => {\n if (!used) {\n used = true;\n result = fn(...args);\n }\n return result;\n };\n};\n\nconst ensureLeadingSlash = (route: string) =>\n route.startsWith(\"/\") ? route : `/${route}`;\n\nconst isGroupSegment = (segment: string) =>\n segment.startsWith(\"(\") && segment.endsWith(\")\");\n"],"mappings":"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","names":[]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "eslint-plugin-nextjs",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.1.0",
|
4
4
|
"description": "A fork of @next/eslint-plugin-next that's been upgraded for TypeScript and ESLint V9.",
|
5
5
|
"keywords": [
|
6
6
|
"eslint",
|
@@ -18,7 +18,12 @@
|
|
18
18
|
"author": "Nathan Drake <nathan@drakewest.dev>",
|
19
19
|
"type": "module",
|
20
20
|
"exports": {
|
21
|
-
".":
|
21
|
+
".": {
|
22
|
+
"types": "./dist/index.d.ts",
|
23
|
+
"import": "./dist/index.js",
|
24
|
+
"require": "./dist/index.cjs",
|
25
|
+
"default": "./dist/index.js"
|
26
|
+
}
|
22
27
|
},
|
23
28
|
"main": "./dist/index.js",
|
24
29
|
"types": "./dist/index.d.ts",
|
@@ -36,13 +41,21 @@
|
|
36
41
|
"test": "bun test",
|
37
42
|
"test:coverage": "bun test --coverage --coverage-reporter=lcov"
|
38
43
|
},
|
44
|
+
"dependencies": {
|
45
|
+
"fast-glob": "^3.3.3"
|
46
|
+
},
|
39
47
|
"devDependencies": {
|
40
48
|
"@repo/typescript-config": "workspace:*",
|
41
49
|
"@types/bun": "^1.2.8",
|
42
50
|
"@types/node": "^22.13.14",
|
51
|
+
"eslint": "^9.23.0",
|
52
|
+
"eslint-v8": "npm:eslint@^8.57.0",
|
43
53
|
"tsup": "^8.4.0",
|
44
54
|
"typescript": "^5.8.2"
|
45
55
|
},
|
56
|
+
"peerDependencies": {
|
57
|
+
"eslint": "^8.56.0 || ^9.0.0"
|
58
|
+
},
|
46
59
|
"engines": {
|
47
60
|
"node": "^20.11.0 || >=21.2.0"
|
48
61
|
},
|