uilint-eslint 0.2.94 → 0.2.96
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/index.js +11 -7
- package/dist/index.js.map +1 -1
- package/dist/rules/no-semantic-duplicates.js +11 -7
- package/dist/rules/no-semantic-duplicates.js.map +1 -1
- package/package.json +2 -2
- package/src/rules/no-semantic-duplicates.test.ts +4 -2
- package/src/rules/no-semantic-duplicates.ts +17 -9
package/dist/index.js
CHANGED
|
@@ -4358,10 +4358,12 @@ var no_semantic_duplicates_default = createRule({
|
|
|
4358
4358
|
const minLines = options.minLines ?? 3;
|
|
4359
4359
|
const filename = context.filename || context.getFilename();
|
|
4360
4360
|
const projectRoot = findProjectRoot4(dirname6(filename), indexPath);
|
|
4361
|
+
const relativeFilename = relative3(projectRoot, filename);
|
|
4361
4362
|
initLog(projectRoot);
|
|
4362
4363
|
log(`
|
|
4363
4364
|
========== Rule create() ==========`);
|
|
4364
4365
|
log(`Filename: ${filename}`);
|
|
4366
|
+
log(`Relative filename: ${relativeFilename}`);
|
|
4365
4367
|
log(`Threshold: ${threshold}`);
|
|
4366
4368
|
log(`Index path: ${indexPath}`);
|
|
4367
4369
|
log(`Min lines: ${minLines}`);
|
|
@@ -4369,13 +4371,13 @@ var no_semantic_duplicates_default = createRule({
|
|
|
4369
4371
|
const index = loadIndex(projectRoot, indexPath);
|
|
4370
4372
|
const reportedChunks = /* @__PURE__ */ new Set();
|
|
4371
4373
|
function checkForDuplicates(node, name) {
|
|
4372
|
-
log(`checkForDuplicates: name=${name}, file=${
|
|
4374
|
+
log(`checkForDuplicates: name=${name}, file=${relativeFilename}`);
|
|
4373
4375
|
if (!index) {
|
|
4374
4376
|
log(` No index loaded`);
|
|
4375
4377
|
return;
|
|
4376
4378
|
}
|
|
4377
|
-
const fileChunks = index.fileToChunks.get(
|
|
4378
|
-
log(` Looking for chunks for file: ${
|
|
4379
|
+
const fileChunks = index.fileToChunks.get(relativeFilename);
|
|
4380
|
+
log(` Looking for chunks for file: ${relativeFilename}`);
|
|
4379
4381
|
log(` Files in index: ${Array.from(index.fileToChunks.keys()).join(", ")}`);
|
|
4380
4382
|
if (!fileChunks || fileChunks.length === 0) {
|
|
4381
4383
|
log(` No chunks found for this file`);
|
|
@@ -4412,15 +4414,16 @@ var no_semantic_duplicates_default = createRule({
|
|
|
4412
4414
|
continue;
|
|
4413
4415
|
}
|
|
4414
4416
|
reportedChunks.add(chunkId);
|
|
4415
|
-
const relPath =
|
|
4417
|
+
const relPath = bestMeta.filePath;
|
|
4416
4418
|
const similarity = Math.round(best.score * 100);
|
|
4417
4419
|
const sourceCode = extractCodeFromFile(
|
|
4418
4420
|
filename,
|
|
4419
4421
|
meta17.startLine,
|
|
4420
4422
|
meta17.endLine
|
|
4421
4423
|
);
|
|
4424
|
+
const targetAbsolutePath = join6(projectRoot, bestMeta.filePath);
|
|
4422
4425
|
const targetCode = extractCodeFromFile(
|
|
4423
|
-
|
|
4426
|
+
targetAbsolutePath,
|
|
4424
4427
|
bestMeta.startLine,
|
|
4425
4428
|
bestMeta.endLine
|
|
4426
4429
|
);
|
|
@@ -4438,11 +4441,11 @@ var no_semantic_duplicates_default = createRule({
|
|
|
4438
4441
|
similarity: String(similarity),
|
|
4439
4442
|
otherName: bestMeta.name || "(anonymous)",
|
|
4440
4443
|
otherLocation: `${relPath}:${bestMeta.startLine}`,
|
|
4441
|
-
// Extended data for inspector panel
|
|
4444
|
+
// Extended data for inspector panel (use relative paths for portability)
|
|
4442
4445
|
sourceCode: sourceCode || "",
|
|
4443
4446
|
targetCode: targetCode || "",
|
|
4444
4447
|
sourceLocation: JSON.stringify({
|
|
4445
|
-
filePath:
|
|
4448
|
+
filePath: relativeFilename,
|
|
4446
4449
|
startLine: meta17.startLine,
|
|
4447
4450
|
endLine: meta17.endLine,
|
|
4448
4451
|
startColumn: meta17.startColumn,
|
|
@@ -4450,6 +4453,7 @@ var no_semantic_duplicates_default = createRule({
|
|
|
4450
4453
|
}),
|
|
4451
4454
|
targetLocation: JSON.stringify({
|
|
4452
4455
|
filePath: bestMeta.filePath,
|
|
4456
|
+
// Already relative from index
|
|
4453
4457
|
startLine: bestMeta.startLine,
|
|
4454
4458
|
endLine: bestMeta.endLine,
|
|
4455
4459
|
startColumn: bestMeta.startColumn,
|