pickier 0.1.23 → 0.1.25
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/bin/cli.js +292 -91
- package/dist/src/index.js +292 -91
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -16153,6 +16153,7 @@ ${lines.slice(bodyRange.from + 1, bodyRange.to + 1).join(`
|
|
|
16153
16153
|
if (openParenIdx !== -1) {
|
|
16154
16154
|
let isTypeSignature = false;
|
|
16155
16155
|
let angleDepthBack = 0;
|
|
16156
|
+
let parenDepthBack = 0;
|
|
16156
16157
|
for (let k = openParenIdx - 1;k >= 0; k--) {
|
|
16157
16158
|
const ch = line[k];
|
|
16158
16159
|
if (ch === ">") {
|
|
@@ -16164,10 +16165,13 @@ ${lines.slice(bodyRange.from + 1, bodyRange.to + 1).join(`
|
|
|
16164
16165
|
angleDepthBack--;
|
|
16165
16166
|
continue;
|
|
16166
16167
|
}
|
|
16167
|
-
|
|
16168
|
-
|
|
16168
|
+
if (parenDepthBack === 0) {
|
|
16169
|
+
isTypeSignature = true;
|
|
16170
|
+
break;
|
|
16171
|
+
}
|
|
16172
|
+
continue;
|
|
16169
16173
|
}
|
|
16170
|
-
if (ch === ":" && angleDepthBack === 0) {
|
|
16174
|
+
if (ch === ":" && angleDepthBack === 0 && parenDepthBack === 0) {
|
|
16171
16175
|
isTypeSignature = true;
|
|
16172
16176
|
break;
|
|
16173
16177
|
}
|
|
@@ -16175,11 +16179,34 @@ ${lines.slice(bodyRange.from + 1, bodyRange.to + 1).join(`
|
|
|
16175
16179
|
continue;
|
|
16176
16180
|
if (ch === ",")
|
|
16177
16181
|
continue;
|
|
16178
|
-
if (ch === "
|
|
16182
|
+
if (ch === ")") {
|
|
16183
|
+
parenDepthBack++;
|
|
16184
|
+
continue;
|
|
16185
|
+
}
|
|
16186
|
+
if (ch === "(") {
|
|
16187
|
+
parenDepthBack--;
|
|
16188
|
+
continue;
|
|
16189
|
+
}
|
|
16190
|
+
if (ch === "|" || ch === "&") {
|
|
16191
|
+
isTypeSignature = true;
|
|
16179
16192
|
break;
|
|
16180
16193
|
}
|
|
16194
|
+
if (ch === "=" || ch === "{" || ch === "[") {
|
|
16195
|
+
if (parenDepthBack >= 0)
|
|
16196
|
+
break;
|
|
16197
|
+
continue;
|
|
16198
|
+
}
|
|
16181
16199
|
if (ch !== " " && ch !== "\t" && !/[\w.]/.test(ch)) {
|
|
16182
|
-
|
|
16200
|
+
if (parenDepthBack >= 0)
|
|
16201
|
+
break;
|
|
16202
|
+
}
|
|
16203
|
+
}
|
|
16204
|
+
if (!isTypeSignature) {
|
|
16205
|
+
const beforeParen = line.slice(0, openParenIdx);
|
|
16206
|
+
if (/^\s*(?:export\s+)?(?:declare\s+)?type\s+\w[\w$]*\s*(?:<[^>]*>)?\s*=\s*$/.test(beforeParen)) {
|
|
16207
|
+
isTypeSignature = true;
|
|
16208
|
+
} else if (/\bas\s+$/.test(beforeParen)) {
|
|
16209
|
+
isTypeSignature = true;
|
|
16183
16210
|
}
|
|
16184
16211
|
}
|
|
16185
16212
|
if (isTypeSignature) {
|
|
@@ -18586,16 +18613,12 @@ var init_heading_increment = __esm(() => {
|
|
|
18586
18613
|
check: (text, ctx) => {
|
|
18587
18614
|
const issues = [];
|
|
18588
18615
|
const lines = text.split(/\r?\n/);
|
|
18616
|
+
const inCode = getCodeBlockLines(lines);
|
|
18589
18617
|
let previousLevel = 0;
|
|
18590
|
-
let inFence = false;
|
|
18591
18618
|
for (let i = 0;i < lines.length; i++) {
|
|
18592
|
-
|
|
18593
|
-
if (/^(?:`{3,}|~{3,})/.test(line.trim())) {
|
|
18594
|
-
inFence = !inFence;
|
|
18595
|
-
continue;
|
|
18596
|
-
}
|
|
18597
|
-
if (inFence)
|
|
18619
|
+
if (inCode.has(i))
|
|
18598
18620
|
continue;
|
|
18621
|
+
const line = lines[i];
|
|
18599
18622
|
const atxMatch = line.match(/^(#{1,6})\s/);
|
|
18600
18623
|
if (atxMatch) {
|
|
18601
18624
|
const level = atxMatch[1].length;
|
|
@@ -18613,6 +18636,29 @@ var init_heading_increment = __esm(() => {
|
|
|
18613
18636
|
}
|
|
18614
18637
|
}
|
|
18615
18638
|
return issues;
|
|
18639
|
+
},
|
|
18640
|
+
fix: (text) => {
|
|
18641
|
+
const lines = text.split(/\r?\n/);
|
|
18642
|
+
const inCode = getCodeBlockLines(lines);
|
|
18643
|
+
let previousLevel = 0;
|
|
18644
|
+
let changed = false;
|
|
18645
|
+
for (let i = 0;i < lines.length; i++) {
|
|
18646
|
+
if (inCode.has(i))
|
|
18647
|
+
continue;
|
|
18648
|
+
const line = lines[i];
|
|
18649
|
+
const atxMatch = line.match(/^(#{1,6})(\s.*)$/);
|
|
18650
|
+
if (!atxMatch)
|
|
18651
|
+
continue;
|
|
18652
|
+
const original = atxMatch[1].length;
|
|
18653
|
+
const allowed = previousLevel === 0 ? original : Math.min(original, previousLevel + 1);
|
|
18654
|
+
if (allowed !== original) {
|
|
18655
|
+
lines[i] = "#".repeat(allowed) + atxMatch[2];
|
|
18656
|
+
changed = true;
|
|
18657
|
+
}
|
|
18658
|
+
previousLevel = allowed;
|
|
18659
|
+
}
|
|
18660
|
+
return changed ? lines.join(`
|
|
18661
|
+
`) : text;
|
|
18616
18662
|
}
|
|
18617
18663
|
};
|
|
18618
18664
|
});
|
|
@@ -18990,6 +19036,42 @@ var init_link_image_reference_definitions = __esm(() => {
|
|
|
18990
19036
|
}
|
|
18991
19037
|
}
|
|
18992
19038
|
return issues;
|
|
19039
|
+
},
|
|
19040
|
+
fix: (text) => {
|
|
19041
|
+
const lines = text.split(/\r?\n/);
|
|
19042
|
+
const inCode = getCodeBlockLines(lines);
|
|
19043
|
+
const defLines = new Map;
|
|
19044
|
+
for (let i = 0;i < lines.length; i++) {
|
|
19045
|
+
if (inCode.has(i))
|
|
19046
|
+
continue;
|
|
19047
|
+
const m = lines[i].match(/^\s*\[([^\]]+)\]:\s*\S+/);
|
|
19048
|
+
if (m)
|
|
19049
|
+
defLines.set(i, m[1].toLowerCase());
|
|
19050
|
+
}
|
|
19051
|
+
if (defLines.size === 0)
|
|
19052
|
+
return text;
|
|
19053
|
+
const usages = new Set;
|
|
19054
|
+
for (let i = 0;i < lines.length; i++) {
|
|
19055
|
+
if (inCode.has(i))
|
|
19056
|
+
continue;
|
|
19057
|
+
if (defLines.has(i))
|
|
19058
|
+
continue;
|
|
19059
|
+
const line = lines[i];
|
|
19060
|
+
const refMatches = line.matchAll(/\[([^\]]+)\](?:\[([^\]]*)\])?(?!\()/g);
|
|
19061
|
+
for (const m of refMatches) {
|
|
19062
|
+
const label = (m[2] && m[2].length > 0 ? m[2] : m[1]).toLowerCase();
|
|
19063
|
+
usages.add(label);
|
|
19064
|
+
}
|
|
19065
|
+
}
|
|
19066
|
+
const toRemove = new Set;
|
|
19067
|
+
for (const [idx, label] of defLines) {
|
|
19068
|
+
if (!usages.has(label))
|
|
19069
|
+
toRemove.add(idx);
|
|
19070
|
+
}
|
|
19071
|
+
if (toRemove.size === 0)
|
|
19072
|
+
return text;
|
|
19073
|
+
return lines.filter((_, idx) => !toRemove.has(idx)).join(`
|
|
19074
|
+
`);
|
|
18993
19075
|
}
|
|
18994
19076
|
};
|
|
18995
19077
|
});
|
|
@@ -19007,19 +19089,39 @@ var init_link_image_style = __esm(() => {
|
|
|
19007
19089
|
check: (text, ctx) => {
|
|
19008
19090
|
const issues = [];
|
|
19009
19091
|
const lines = text.split(/\r?\n/);
|
|
19092
|
+
const inCode = getCodeBlockLines(lines);
|
|
19010
19093
|
const options = ctx.options || {};
|
|
19011
19094
|
const style = options.style || "consistent";
|
|
19012
|
-
let
|
|
19013
|
-
|
|
19095
|
+
let target = style === "consistent" ? null : style;
|
|
19096
|
+
if (target === null) {
|
|
19097
|
+
let inlineCount = 0;
|
|
19098
|
+
let refCount = 0;
|
|
19099
|
+
let inHtmlCommentScan = false;
|
|
19100
|
+
for (let i = 0;i < lines.length; i++) {
|
|
19101
|
+
if (inCode.has(i))
|
|
19102
|
+
continue;
|
|
19103
|
+
const line = lines[i];
|
|
19104
|
+
if (line.includes("<!--"))
|
|
19105
|
+
inHtmlCommentScan = true;
|
|
19106
|
+
if (line.includes("-->")) {
|
|
19107
|
+
inHtmlCommentScan = false;
|
|
19108
|
+
continue;
|
|
19109
|
+
}
|
|
19110
|
+
if (inHtmlCommentScan)
|
|
19111
|
+
continue;
|
|
19112
|
+
if (/^\s*\[(?:[^\]]+)\]:\s*\S+/.test(line))
|
|
19113
|
+
continue;
|
|
19114
|
+
const scrubbed = stripInlineCode(line);
|
|
19115
|
+
inlineCount += (scrubbed.match(/\[[^\]]+\]\([^)]+\)/g) || []).length;
|
|
19116
|
+
refCount += (scrubbed.match(/\[[^\]]+\]\[(?:[^\]]*)\]/g) || []).length;
|
|
19117
|
+
}
|
|
19118
|
+
target = refCount > inlineCount ? "reference" : "inline";
|
|
19119
|
+
}
|
|
19014
19120
|
let inHtmlComment = false;
|
|
19015
19121
|
for (let i = 0;i < lines.length; i++) {
|
|
19016
|
-
|
|
19017
|
-
if (/^(?:`{3,}|~{3,})/.test(line.trim())) {
|
|
19018
|
-
inFence = !inFence;
|
|
19019
|
-
continue;
|
|
19020
|
-
}
|
|
19021
|
-
if (inFence)
|
|
19122
|
+
if (inCode.has(i))
|
|
19022
19123
|
continue;
|
|
19124
|
+
const line = lines[i];
|
|
19023
19125
|
if (line.includes("<!--"))
|
|
19024
19126
|
inHtmlComment = true;
|
|
19025
19127
|
if (line.includes("-->")) {
|
|
@@ -19028,64 +19130,104 @@ var init_link_image_style = __esm(() => {
|
|
|
19028
19130
|
}
|
|
19029
19131
|
if (inHtmlComment)
|
|
19030
19132
|
continue;
|
|
19031
|
-
if (line.match(/^\[(?:[^\]]+)\]:\s*\S+/))
|
|
19133
|
+
if (line.match(/^\[(?:[^\]]+)\]:\s*\S+/))
|
|
19032
19134
|
continue;
|
|
19033
|
-
}
|
|
19034
19135
|
const scrubbed = stripInlineCode(line);
|
|
19035
19136
|
const inlineMatches = scrubbed.matchAll(/\[[^\]]+\]\([^)]+\)/g);
|
|
19036
19137
|
for (const match of inlineMatches) {
|
|
19037
|
-
if (
|
|
19138
|
+
if (target === "reference") {
|
|
19038
19139
|
issues.push({
|
|
19039
19140
|
filePath: ctx.filePath,
|
|
19040
19141
|
line: i + 1,
|
|
19041
19142
|
column: match.index + 1,
|
|
19042
19143
|
ruleId: "markdown/link-image-style",
|
|
19043
|
-
message: "Expected reference style link",
|
|
19044
|
-
severity: "error"
|
|
19144
|
+
message: style === "consistent" ? "Link style should be consistent throughout document" : "Expected reference style link",
|
|
19145
|
+
severity: style === "consistent" ? "warning" : "error"
|
|
19045
19146
|
});
|
|
19046
|
-
} else if (style === "consistent") {
|
|
19047
|
-
if (detectedStyle === null) {
|
|
19048
|
-
detectedStyle = "inline";
|
|
19049
|
-
} else if (detectedStyle === "reference") {
|
|
19050
|
-
issues.push({
|
|
19051
|
-
filePath: ctx.filePath,
|
|
19052
|
-
line: i + 1,
|
|
19053
|
-
column: match.index + 1,
|
|
19054
|
-
ruleId: "markdown/link-image-style",
|
|
19055
|
-
message: "Link style should be consistent throughout document",
|
|
19056
|
-
severity: "warning"
|
|
19057
|
-
});
|
|
19058
|
-
}
|
|
19059
19147
|
}
|
|
19060
19148
|
}
|
|
19061
19149
|
const refMatches = scrubbed.matchAll(/\[[^\]]+\]\[(?:[^\]]+)\]/g);
|
|
19062
19150
|
for (const match of refMatches) {
|
|
19063
|
-
if (
|
|
19151
|
+
if (target === "inline") {
|
|
19064
19152
|
issues.push({
|
|
19065
19153
|
filePath: ctx.filePath,
|
|
19066
19154
|
line: i + 1,
|
|
19067
19155
|
column: match.index + 1,
|
|
19068
19156
|
ruleId: "markdown/link-image-style",
|
|
19069
|
-
message: "Expected inline style link",
|
|
19070
|
-
severity: "error"
|
|
19157
|
+
message: style === "consistent" ? "Link style should be consistent throughout document" : "Expected inline style link",
|
|
19158
|
+
severity: style === "consistent" ? "warning" : "error"
|
|
19071
19159
|
});
|
|
19072
|
-
} else if (style === "consistent") {
|
|
19073
|
-
if (detectedStyle === null) {
|
|
19074
|
-
detectedStyle = "reference";
|
|
19075
|
-
} else if (detectedStyle === "inline") {
|
|
19076
|
-
issues.push({
|
|
19077
|
-
filePath: ctx.filePath,
|
|
19078
|
-
line: i + 1,
|
|
19079
|
-
column: match.index + 1,
|
|
19080
|
-
ruleId: "markdown/link-image-style",
|
|
19081
|
-
message: "Link style should be consistent throughout document",
|
|
19082
|
-
severity: "warning"
|
|
19083
|
-
});
|
|
19084
|
-
}
|
|
19085
19160
|
}
|
|
19086
19161
|
}
|
|
19087
19162
|
}
|
|
19088
19163
|
return issues;
|
|
19164
|
+
},
|
|
19165
|
+
fix: (text, ctx) => {
|
|
19166
|
+
const options = ctx.options || {};
|
|
19167
|
+
const style = options.style || "consistent";
|
|
19168
|
+
const lines = text.split(/\r?\n/);
|
|
19169
|
+
const inCode = getCodeBlockLines(lines);
|
|
19170
|
+
const defs = new Map;
|
|
19171
|
+
for (let i = 0;i < lines.length; i++) {
|
|
19172
|
+
if (inCode.has(i))
|
|
19173
|
+
continue;
|
|
19174
|
+
const m = lines[i].match(/^\s*\[([^\]]+)\]:\s*(\S+)(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?\s*$/);
|
|
19175
|
+
if (m) {
|
|
19176
|
+
const label = m[1].toLowerCase();
|
|
19177
|
+
const url = m[2];
|
|
19178
|
+
const title = m[3] ?? m[4] ?? m[5];
|
|
19179
|
+
if (!defs.has(label))
|
|
19180
|
+
defs.set(label, { url, title });
|
|
19181
|
+
}
|
|
19182
|
+
}
|
|
19183
|
+
if (defs.size === 0)
|
|
19184
|
+
return text;
|
|
19185
|
+
let target = style === "reference" ? "reference" : "inline";
|
|
19186
|
+
if (style === "consistent") {
|
|
19187
|
+
let inlineCount = 0;
|
|
19188
|
+
let refCount = 0;
|
|
19189
|
+
for (let i = 0;i < lines.length; i++) {
|
|
19190
|
+
if (inCode.has(i))
|
|
19191
|
+
continue;
|
|
19192
|
+
const line = lines[i];
|
|
19193
|
+
if (/^\s*\[(?:[^\]]+)\]:\s*\S+/.test(line))
|
|
19194
|
+
continue;
|
|
19195
|
+
const scrubbed = stripInlineCode(line);
|
|
19196
|
+
inlineCount += (scrubbed.match(/\[[^\]]+\]\([^)]+\)/g) || []).length;
|
|
19197
|
+
refCount += (scrubbed.match(/\[[^\]]+\]\[(?:[^\]]*)\]/g) || []).length;
|
|
19198
|
+
}
|
|
19199
|
+
target = refCount > inlineCount ? "reference" : "inline";
|
|
19200
|
+
}
|
|
19201
|
+
if (target !== "inline")
|
|
19202
|
+
return text;
|
|
19203
|
+
let changed = false;
|
|
19204
|
+
for (let i = 0;i < lines.length; i++) {
|
|
19205
|
+
if (inCode.has(i))
|
|
19206
|
+
continue;
|
|
19207
|
+
const original = lines[i];
|
|
19208
|
+
if (/^\s*\[(?:[^\]]+)\]:\s*\S+/.test(original))
|
|
19209
|
+
continue;
|
|
19210
|
+
let rewritten = original;
|
|
19211
|
+
for (let pass = 0;pass < 8; pass++) {
|
|
19212
|
+
const next = rewritten.replace(/(!?)\[((?:[^[\]]|\[[^\]]*\]\([^)]*\))+)\]\[([^\]]*)\]/g, (whole, bang, textPart, labelPart) => {
|
|
19213
|
+
const labelKey = (labelPart.trim() === "" ? textPart : labelPart).toLowerCase();
|
|
19214
|
+
const def = defs.get(labelKey);
|
|
19215
|
+
if (!def)
|
|
19216
|
+
return whole;
|
|
19217
|
+
const titlePart = def.title ? ` "${def.title}"` : "";
|
|
19218
|
+
return `${bang}[${textPart}](${def.url}${titlePart})`;
|
|
19219
|
+
});
|
|
19220
|
+
if (next === rewritten)
|
|
19221
|
+
break;
|
|
19222
|
+
rewritten = next;
|
|
19223
|
+
}
|
|
19224
|
+
if (rewritten !== original) {
|
|
19225
|
+
lines[i] = rewritten;
|
|
19226
|
+
changed = true;
|
|
19227
|
+
}
|
|
19228
|
+
}
|
|
19229
|
+
return changed ? lines.join(`
|
|
19230
|
+
`) : text;
|
|
19089
19231
|
}
|
|
19090
19232
|
};
|
|
19091
19233
|
});
|
|
@@ -20489,24 +20631,18 @@ var init_single_title = __esm(() => {
|
|
|
20489
20631
|
check: (text, ctx) => {
|
|
20490
20632
|
const issues = [];
|
|
20491
20633
|
const lines = text.split(/\r?\n/);
|
|
20634
|
+
const inCode = getCodeBlockLines(lines);
|
|
20492
20635
|
let firstH1Line = -1;
|
|
20493
|
-
let inFencedCodeBlock = false;
|
|
20494
20636
|
for (let i = 0;i < lines.length; i++) {
|
|
20637
|
+
if (inCode.has(i))
|
|
20638
|
+
continue;
|
|
20495
20639
|
const line = lines[i];
|
|
20496
20640
|
const nextLine = i + 1 < lines.length ? lines[i + 1] : "";
|
|
20497
|
-
if (/^(?:`{3,}|~{3,})/.test(line.trim())) {
|
|
20498
|
-
inFencedCodeBlock = !inFencedCodeBlock;
|
|
20499
|
-
continue;
|
|
20500
|
-
}
|
|
20501
|
-
if (inFencedCodeBlock)
|
|
20502
|
-
continue;
|
|
20503
20641
|
let isH1 = false;
|
|
20504
|
-
if (/^#\s/.test(line))
|
|
20642
|
+
if (/^#\s/.test(line))
|
|
20505
20643
|
isH1 = true;
|
|
20506
|
-
|
|
20507
|
-
if (/^=+\s*$/.test(nextLine) && line.trim().length > 0) {
|
|
20644
|
+
if (/^=+\s*$/.test(nextLine) && line.trim().length > 0 && !inCode.has(i + 1))
|
|
20508
20645
|
isH1 = true;
|
|
20509
|
-
}
|
|
20510
20646
|
if (isH1) {
|
|
20511
20647
|
if (firstH1Line === -1) {
|
|
20512
20648
|
firstH1Line = i + 1;
|
|
@@ -20523,6 +20659,47 @@ var init_single_title = __esm(() => {
|
|
|
20523
20659
|
}
|
|
20524
20660
|
}
|
|
20525
20661
|
return issues;
|
|
20662
|
+
},
|
|
20663
|
+
fix: (text) => {
|
|
20664
|
+
const lines = text.split(/\r?\n/);
|
|
20665
|
+
const inCode = getCodeBlockLines(lines);
|
|
20666
|
+
const result = [];
|
|
20667
|
+
let seenH1 = false;
|
|
20668
|
+
let changed = false;
|
|
20669
|
+
for (let i = 0;i < lines.length; i++) {
|
|
20670
|
+
if (inCode.has(i)) {
|
|
20671
|
+
result.push(lines[i]);
|
|
20672
|
+
continue;
|
|
20673
|
+
}
|
|
20674
|
+
const line = lines[i];
|
|
20675
|
+
const nextLine = i + 1 < lines.length ? lines[i + 1] : "";
|
|
20676
|
+
const atxH1 = /^#\s/.test(line);
|
|
20677
|
+
const setextH1 = /^=+\s*$/.test(nextLine) && line.trim().length > 0 && !inCode.has(i + 1);
|
|
20678
|
+
if (atxH1) {
|
|
20679
|
+
if (!seenH1) {
|
|
20680
|
+
seenH1 = true;
|
|
20681
|
+
result.push(line);
|
|
20682
|
+
} else {
|
|
20683
|
+
result.push(`#${line}`);
|
|
20684
|
+
changed = true;
|
|
20685
|
+
}
|
|
20686
|
+
continue;
|
|
20687
|
+
}
|
|
20688
|
+
if (setextH1) {
|
|
20689
|
+
if (!seenH1) {
|
|
20690
|
+
seenH1 = true;
|
|
20691
|
+
result.push(line);
|
|
20692
|
+
continue;
|
|
20693
|
+
}
|
|
20694
|
+
result.push(`## ${line.trim()}`);
|
|
20695
|
+
i++;
|
|
20696
|
+
changed = true;
|
|
20697
|
+
continue;
|
|
20698
|
+
}
|
|
20699
|
+
result.push(line);
|
|
20700
|
+
}
|
|
20701
|
+
return changed ? result.join(`
|
|
20702
|
+
`) : text;
|
|
20526
20703
|
}
|
|
20527
20704
|
};
|
|
20528
20705
|
});
|
|
@@ -21123,6 +21300,13 @@ function splitFrontmatter(content) {
|
|
|
21123
21300
|
}
|
|
21124
21301
|
return { header: null, body: content };
|
|
21125
21302
|
}
|
|
21303
|
+
function markdownOnlyWholeFile(rule) {
|
|
21304
|
+
return {
|
|
21305
|
+
meta: rule.meta,
|
|
21306
|
+
check: (content, context) => context.filePath.endsWith(".md") ? rule.check(content, context) : [],
|
|
21307
|
+
fix: rule.fix ? (content, context) => context.filePath.endsWith(".md") ? rule.fix(content, context) : content : undefined
|
|
21308
|
+
};
|
|
21309
|
+
}
|
|
21126
21310
|
function markdownOnly(rule) {
|
|
21127
21311
|
return {
|
|
21128
21312
|
meta: rule.meta,
|
|
@@ -21230,7 +21414,7 @@ var init_markdown = __esm(() => {
|
|
|
21230
21414
|
"no-multiple-space-blockquote": markdownOnly(noMultipleSpaceBlockquoteRule),
|
|
21231
21415
|
"no-blanks-blockquote": markdownOnly(noBlanksBlockquoteRule),
|
|
21232
21416
|
"blanks-around-fences": markdownOnly(blanksAroundFencesRule),
|
|
21233
|
-
"single-trailing-newline":
|
|
21417
|
+
"single-trailing-newline": markdownOnlyWholeFile(singleTrailingNewlineRule),
|
|
21234
21418
|
"blanks-around-tables": markdownOnly(blanksAroundTablesRule),
|
|
21235
21419
|
"no-reversed-links": markdownOnly(noReversedLinksRule),
|
|
21236
21420
|
"no-bare-urls": markdownOnly(noBareUrlsRule),
|
|
@@ -22154,7 +22338,20 @@ var init_exports_module_should_be_esm = __esm(() => {
|
|
|
22154
22338
|
|
|
22155
22339
|
// src/rules/publint/file-does-not-exist.ts
|
|
22156
22340
|
import { existsSync as existsSync13 } from "fs";
|
|
22341
|
+
import { dirname as dirname7, isAbsolute as isAbsolute3, resolve as resolve12 } from "path";
|
|
22342
|
+
function baseDirectoryMissing(pkgDir, value) {
|
|
22343
|
+
let v = value;
|
|
22344
|
+
while (v.startsWith("./"))
|
|
22345
|
+
v = v.slice(2);
|
|
22346
|
+
const firstSegment = v.split("/")[0];
|
|
22347
|
+
if (!firstSegment || firstSegment === ".." || firstSegment.startsWith("."))
|
|
22348
|
+
return false;
|
|
22349
|
+
const baseDir = isAbsolute3(value) ? dirname7(value).split("/")[0] || "/" : resolve12(pkgDir, firstSegment);
|
|
22350
|
+
return !existsSync13(baseDir);
|
|
22351
|
+
}
|
|
22157
22352
|
function checkFileRef(value, path, issues, filePath, content, pkgDir) {
|
|
22353
|
+
if (baseDirectoryMissing(pkgDir, value))
|
|
22354
|
+
return;
|
|
22158
22355
|
const resolved = resolvePkgPath(pkgDir, value);
|
|
22159
22356
|
if (!fileExistsWithFallbacks(resolved)) {
|
|
22160
22357
|
issues.push(createIssue(filePath, content, path, "publint/file-does-not-exist", `${formatPkgPath(path)} is "${value}" but the file does not exist.`, "error", "The referenced file path cannot be found. Check the path for typos."));
|
|
@@ -22188,6 +22385,8 @@ var init_file_does_not_exist = __esm(() => {
|
|
|
22188
22385
|
const [value, path] = getPublishedField(pkg, field);
|
|
22189
22386
|
if (value == null || typeof value !== "string")
|
|
22190
22387
|
continue;
|
|
22388
|
+
if (baseDirectoryMissing(pkgDir, value))
|
|
22389
|
+
continue;
|
|
22191
22390
|
const resolved = resolvePkgPath(pkgDir, value);
|
|
22192
22391
|
if (!fileExistsWithFallbacks(resolved)) {
|
|
22193
22392
|
issues.push(createIssue(context.filePath, content, path, "publint/file-does-not-exist", `${formatPkgPath(path)} is "${value}" but the file does not exist.`, "error", "The referenced file path cannot be found. Check the path for typos."));
|
|
@@ -22214,6 +22413,8 @@ var init_file_does_not_exist = __esm(() => {
|
|
|
22214
22413
|
return;
|
|
22215
22414
|
if (value.includes("*"))
|
|
22216
22415
|
return;
|
|
22416
|
+
if (baseDirectoryMissing(pkgDir, value))
|
|
22417
|
+
return;
|
|
22217
22418
|
const resolved = resolvePkgPath(pkgDir, value);
|
|
22218
22419
|
if (!existsSync13(resolved)) {
|
|
22219
22420
|
issues.push(createIssue(context.filePath, content, ctx.path, "publint/file-does-not-exist", `${formatPkgPath(ctx.path)} is "${value}" but the file does not exist.`, "error", "The referenced file path cannot be found. Check the path for typos."));
|
|
@@ -22456,7 +22657,7 @@ var init_import_dedupe = __esm(() => {
|
|
|
22456
22657
|
|
|
22457
22658
|
// src/rules/imports/named.ts
|
|
22458
22659
|
import { existsSync as existsSync16, readFileSync as readFileSync6 } from "fs";
|
|
22459
|
-
import { dirname as
|
|
22660
|
+
import { dirname as dirname8, resolve as resolve14 } from "path";
|
|
22460
22661
|
var namedRule;
|
|
22461
22662
|
var init_named = __esm(() => {
|
|
22462
22663
|
namedRule = {
|
|
@@ -22467,7 +22668,7 @@ var init_named = __esm(() => {
|
|
|
22467
22668
|
check: (text, ctx) => {
|
|
22468
22669
|
const issues = [];
|
|
22469
22670
|
const lines = text.split(/\r?\n/);
|
|
22470
|
-
const currentDir =
|
|
22671
|
+
const currentDir = dirname8(ctx.filePath);
|
|
22471
22672
|
for (let i = 0;i < lines.length; i++) {
|
|
22472
22673
|
const line = lines[i];
|
|
22473
22674
|
const namedImportMatch = line.match(/\bimport\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/);
|
|
@@ -22480,7 +22681,7 @@ var init_named = __esm(() => {
|
|
|
22480
22681
|
const extensions = [".ts", ".tsx", ".js", ".jsx", ""];
|
|
22481
22682
|
let targetContent = "";
|
|
22482
22683
|
for (const ext of extensions) {
|
|
22483
|
-
const fullPath =
|
|
22684
|
+
const fullPath = resolve14(currentDir, importPath + ext);
|
|
22484
22685
|
if (existsSync16(fullPath)) {
|
|
22485
22686
|
targetContent = readFileSync6(fullPath, "utf8");
|
|
22486
22687
|
break;
|
|
@@ -22516,7 +22717,7 @@ var init_named = __esm(() => {
|
|
|
22516
22717
|
|
|
22517
22718
|
// src/rules/imports/no-cycle.ts
|
|
22518
22719
|
import { existsSync as existsSync17, readFileSync as readFileSync7 } from "fs";
|
|
22519
|
-
import { dirname as
|
|
22720
|
+
import { dirname as dirname9, resolve as resolve15 } from "path";
|
|
22520
22721
|
var noCycleRule;
|
|
22521
22722
|
var init_no_cycle = __esm(() => {
|
|
22522
22723
|
noCycleRule = {
|
|
@@ -22541,7 +22742,7 @@ var init_no_cycle = __esm(() => {
|
|
|
22541
22742
|
stack.add(filePath);
|
|
22542
22743
|
try {
|
|
22543
22744
|
const content = readFileSync7(filePath, "utf8");
|
|
22544
|
-
const imports = extractImports(content,
|
|
22745
|
+
const imports = extractImports(content, dirname9(filePath));
|
|
22545
22746
|
for (const imp of imports) {
|
|
22546
22747
|
if (detectCycle(imp, [...importChain, imp])) {
|
|
22547
22748
|
return true;
|
|
@@ -22560,7 +22761,7 @@ var init_no_cycle = __esm(() => {
|
|
|
22560
22761
|
if (importPath.startsWith(".") || importPath.startsWith("/")) {
|
|
22561
22762
|
const extensions = [".ts", ".tsx", ".js", ".jsx", ""];
|
|
22562
22763
|
for (const ext of extensions) {
|
|
22563
|
-
const fullPath =
|
|
22764
|
+
const fullPath = resolve15(baseDir, importPath + ext);
|
|
22564
22765
|
if (existsSync17(fullPath)) {
|
|
22565
22766
|
imports.push(fullPath);
|
|
22566
22767
|
break;
|
|
@@ -22579,7 +22780,7 @@ var init_no_cycle = __esm(() => {
|
|
|
22579
22780
|
const extensions = [".ts", ".tsx", ".js", ".jsx", ""];
|
|
22580
22781
|
let resolvedPath = "";
|
|
22581
22782
|
for (const ext of extensions) {
|
|
22582
|
-
const fullPath =
|
|
22783
|
+
const fullPath = resolve15(dirname9(currentFile), importPath + ext);
|
|
22583
22784
|
if (existsSync17(fullPath)) {
|
|
22584
22785
|
resolvedPath = fullPath;
|
|
22585
22786
|
break;
|
|
@@ -22747,7 +22948,7 @@ var init_no_import_node_modules_by_path = __esm(() => {
|
|
|
22747
22948
|
|
|
22748
22949
|
// src/rules/imports/no-unresolved.ts
|
|
22749
22950
|
import { existsSync as existsSync18 } from "fs";
|
|
22750
|
-
import { dirname as
|
|
22951
|
+
import { dirname as dirname10, join as join7, resolve as resolve16 } from "path";
|
|
22751
22952
|
var noUnresolvedRule;
|
|
22752
22953
|
var init_no_unresolved = __esm(() => {
|
|
22753
22954
|
noUnresolvedRule = {
|
|
@@ -22758,7 +22959,7 @@ var init_no_unresolved = __esm(() => {
|
|
|
22758
22959
|
check: (text, ctx) => {
|
|
22759
22960
|
const issues = [];
|
|
22760
22961
|
const lines = text.split(/\r?\n/);
|
|
22761
|
-
const currentDir =
|
|
22962
|
+
const currentDir = dirname10(ctx.filePath);
|
|
22762
22963
|
for (let i = 0;i < lines.length; i++) {
|
|
22763
22964
|
const line = lines[i];
|
|
22764
22965
|
const importMatches = [
|
|
@@ -22774,7 +22975,7 @@ var init_no_unresolved = __esm(() => {
|
|
|
22774
22975
|
const possiblePaths = [];
|
|
22775
22976
|
const extensions = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ""];
|
|
22776
22977
|
for (const ext of extensions) {
|
|
22777
|
-
const fullPath =
|
|
22978
|
+
const fullPath = resolve16(currentDir, importPath + ext);
|
|
22778
22979
|
possiblePaths.push(fullPath);
|
|
22779
22980
|
possiblePaths.push(join7(fullPath, `index${ext}`));
|
|
22780
22981
|
}
|
|
@@ -31917,7 +32118,7 @@ var init_plugins = __esm(() => {
|
|
|
31917
32118
|
|
|
31918
32119
|
// src/utils.ts
|
|
31919
32120
|
import { readdirSync as readdirSync6, readFileSync as readFileSync8, statSync as statSync3 } from "fs";
|
|
31920
|
-
import { extname as extname4, isAbsolute as
|
|
32121
|
+
import { extname as extname4, isAbsolute as isAbsolute4, join as join9, resolve as resolve17 } from "path";
|
|
31921
32122
|
import process18 from "process";
|
|
31922
32123
|
function globToRegex(pattern) {
|
|
31923
32124
|
let src = "";
|
|
@@ -32002,7 +32203,7 @@ async function glob(patterns, opts = {}) {
|
|
|
32002
32203
|
for (const pattern of patterns) {
|
|
32003
32204
|
const g = new BunGlob(pattern);
|
|
32004
32205
|
for await (const file of g.scan({ cwd, dot, onlyFiles: opts.onlyFiles ?? true, followSymlinks: false })) {
|
|
32005
|
-
const full =
|
|
32206
|
+
const full = isAbsolute4(file) ? file : join9(cwd, file);
|
|
32006
32207
|
const rel = full.startsWith(`${cwd}/`) ? full.slice(cwd.length + 1) : full;
|
|
32007
32208
|
if (ignore.length && matchesAnyPattern(rel, ignore))
|
|
32008
32209
|
continue;
|
|
@@ -32014,7 +32215,7 @@ async function glob(patterns, opts = {}) {
|
|
|
32014
32215
|
const results = [];
|
|
32015
32216
|
for (const pattern of patterns) {
|
|
32016
32217
|
if (!/[*?[{]/.test(pattern)) {
|
|
32017
|
-
const full =
|
|
32218
|
+
const full = isAbsolute4(pattern) ? pattern : join9(cwd, pattern);
|
|
32018
32219
|
try {
|
|
32019
32220
|
const st = statSync3(full);
|
|
32020
32221
|
if (!st.isDirectory()) {
|
|
@@ -32155,7 +32356,7 @@ async function loadConfigFromPath(pathLike) {
|
|
|
32155
32356
|
} catch {}
|
|
32156
32357
|
return mergeConfig(defaultConfig2, {});
|
|
32157
32358
|
}
|
|
32158
|
-
const abs =
|
|
32359
|
+
const abs = isAbsolute4(pathLike) ? pathLike : resolve17(process18.cwd(), pathLike);
|
|
32159
32360
|
const ext = extname4(abs).toLowerCase();
|
|
32160
32361
|
if (ext === ".json") {
|
|
32161
32362
|
try {
|
|
@@ -32299,7 +32500,7 @@ var init_utils4 = __esm(() => {
|
|
|
32299
32500
|
|
|
32300
32501
|
// src/formatter.ts
|
|
32301
32502
|
import { readFileSync as readFileSync9, writeFileSync as writeFileSync7 } from "fs";
|
|
32302
|
-
import { isAbsolute as
|
|
32503
|
+
import { isAbsolute as isAbsolute5, relative as relative5, resolve as resolve18 } from "path";
|
|
32303
32504
|
import process20 from "process";
|
|
32304
32505
|
function getLogger() {
|
|
32305
32506
|
if (!_logger)
|
|
@@ -32431,7 +32632,7 @@ async function runFormat(globs, options) {
|
|
|
32431
32632
|
const timeoutMs = ENV.TIMEOUT_MS;
|
|
32432
32633
|
const isGlobbingOutsideProject = patterns.some((p) => {
|
|
32433
32634
|
const base = p.replace(/\/?\*\*(?:\/\*+)?$/, "");
|
|
32434
|
-
const absBase =
|
|
32635
|
+
const absBase = isAbsolute5(base) ? base : resolve18(process20.cwd(), base);
|
|
32435
32636
|
return !absBase.startsWith(process20.cwd());
|
|
32436
32637
|
});
|
|
32437
32638
|
const globIgnores = isGlobbingOutsideProject ? [...UNIVERSAL_IGNORES] : cfg.ignores;
|
|
@@ -32535,7 +32736,7 @@ __export(exports_linter, {
|
|
|
32535
32736
|
applyPlugins: () => applyPlugins
|
|
32536
32737
|
});
|
|
32537
32738
|
import { readdirSync as readdirSync7, readFileSync as readFileSync10, statSync as statSync4, writeFileSync as writeFileSync9 } from "fs";
|
|
32538
|
-
import { isAbsolute as
|
|
32739
|
+
import { isAbsolute as isAbsolute6, join as join10, relative as relative6, resolve as resolve19 } from "path";
|
|
32539
32740
|
import process21 from "process";
|
|
32540
32741
|
function getLogger2() {
|
|
32541
32742
|
if (!_logger2)
|
|
@@ -32594,7 +32795,7 @@ async function runLintProgrammatic(globs, options, signal) {
|
|
|
32594
32795
|
const timeoutMs = ENV.TIMEOUT_MS;
|
|
32595
32796
|
const isGlobbingOutsideProject = patterns.some((p) => {
|
|
32596
32797
|
const base = p.replace(/\/?\*\*\/*\*\*$/, "");
|
|
32597
|
-
const absBase =
|
|
32798
|
+
const absBase = isAbsolute6(base) ? base : resolve19(process21.cwd(), base);
|
|
32598
32799
|
return !absBase.startsWith(process21.cwd());
|
|
32599
32800
|
});
|
|
32600
32801
|
const globIgnores = isGlobbingOutsideProject ? [...UNIVERSAL_IGNORES] : cfg.ignores;
|
|
@@ -32604,7 +32805,7 @@ async function runLintProgrammatic(globs, options, signal) {
|
|
|
32604
32805
|
try {
|
|
32605
32806
|
const st = statSync4(patterns[0]);
|
|
32606
32807
|
if (st.isFile()) {
|
|
32607
|
-
const abs =
|
|
32808
|
+
const abs = isAbsolute6(patterns[0]) ? patterns[0] : resolve19(process21.cwd(), patterns[0]);
|
|
32608
32809
|
entries = [abs];
|
|
32609
32810
|
}
|
|
32610
32811
|
} catch {}
|
|
@@ -32612,7 +32813,7 @@ async function runLintProgrammatic(globs, options, signal) {
|
|
|
32612
32813
|
const simpleDirPattern = patterns.length === 1 && /\*\*\/*\*$/.test(patterns[0]);
|
|
32613
32814
|
if (!entries.length && simpleDirPattern) {
|
|
32614
32815
|
const base = patterns[0].replace(/\/?\*\*\/*\*\*$/, "");
|
|
32615
|
-
const rootBase =
|
|
32816
|
+
const rootBase = isAbsolute6(base) ? base : resolve19(process21.cwd(), base);
|
|
32616
32817
|
try {
|
|
32617
32818
|
const stack = [rootBase];
|
|
32618
32819
|
while (stack.length) {
|
|
@@ -33714,7 +33915,7 @@ async function runLint(globs, options) {
|
|
|
33714
33915
|
getLogger2().info(`[pickier:diagnostics] Glob timeout: ${timeoutMs}ms`);
|
|
33715
33916
|
const isGlobbingOutsideProject = patterns.some((p) => {
|
|
33716
33917
|
const base = p.replace(/\/?\*\*\/*\*\*$/, "");
|
|
33717
|
-
const absBase =
|
|
33918
|
+
const absBase = isAbsolute6(base) ? base : resolve19(process21.cwd(), base);
|
|
33718
33919
|
return !absBase.startsWith(process21.cwd());
|
|
33719
33920
|
});
|
|
33720
33921
|
const globIgnores = isGlobbingOutsideProject ? [...UNIVERSAL_IGNORES] : cfg.ignores;
|
|
@@ -33731,7 +33932,7 @@ async function runLint(globs, options) {
|
|
|
33731
33932
|
try {
|
|
33732
33933
|
const st = statSync4(patterns[0]);
|
|
33733
33934
|
if (st.isFile()) {
|
|
33734
|
-
const abs =
|
|
33935
|
+
const abs = isAbsolute6(patterns[0]) ? patterns[0] : resolve19(process21.cwd(), patterns[0]);
|
|
33735
33936
|
entries = [abs];
|
|
33736
33937
|
}
|
|
33737
33938
|
} catch {}
|
|
@@ -33742,7 +33943,7 @@ async function runLint(globs, options) {
|
|
|
33742
33943
|
if (enableDiagnostics)
|
|
33743
33944
|
getLogger2().info(`[pickier:diagnostics] Using fast directory scan for: ${base}`);
|
|
33744
33945
|
try {
|
|
33745
|
-
const rootBase =
|
|
33946
|
+
const rootBase = isAbsolute6(base) ? base : resolve19(process21.cwd(), base);
|
|
33746
33947
|
const stack = [rootBase];
|
|
33747
33948
|
let dirCount = 0;
|
|
33748
33949
|
while (stack.length) {
|
|
@@ -34032,14 +34233,14 @@ __export(exports_run, {
|
|
|
34032
34233
|
runUnified: () => runUnified
|
|
34033
34234
|
});
|
|
34034
34235
|
import { readFileSync as readFileSync11, statSync as statSync5, writeFileSync as writeFileSync10 } from "fs";
|
|
34035
|
-
import { isAbsolute as
|
|
34236
|
+
import { isAbsolute as isAbsolute7, resolve as resolve20 } from "path";
|
|
34036
34237
|
import process23 from "process";
|
|
34037
34238
|
async function runUnified(globs, options) {
|
|
34038
34239
|
const mode = options.mode || "auto";
|
|
34039
34240
|
if (mode === "format" && globs.length === 1 && !/[*?[\]{}()!]/.test(globs[0])) {
|
|
34040
34241
|
try {
|
|
34041
34242
|
const p = globs[0];
|
|
34042
|
-
const filePath =
|
|
34243
|
+
const filePath = isAbsolute7(p) ? p : resolve20(process23.cwd(), p);
|
|
34043
34244
|
const st = statSync5(filePath);
|
|
34044
34245
|
if (st.isFile()) {
|
|
34045
34246
|
const cfg = await loadConfigFromPath(options.config);
|