@yawlabs/ctxlint 0.9.11 → 0.9.12
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/.pre-commit-hooks.yaml +1 -1
- package/dist/index.js +7 -5
- package/package.json +1 -1
package/.pre-commit-hooks.yaml
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# Version-pinned so a checkout at `rev: vX.Y.Z` runs exactly that release
|
|
5
5
|
# of ctxlint — matches the pinning done by `ctxlint init`. release.sh keeps
|
|
6
6
|
# this in sync with package.json on each bump.
|
|
7
|
-
entry: npx @yawlabs/ctxlint@0.9.
|
|
7
|
+
entry: npx @yawlabs/ctxlint@0.9.12 --strict
|
|
8
8
|
language: node
|
|
9
9
|
always_run: true
|
|
10
10
|
pass_filenames: false
|
package/dist/index.js
CHANGED
|
@@ -41615,10 +41615,11 @@ async function checkRedundancy(file2, projectRoot) {
|
|
|
41615
41615
|
}
|
|
41616
41616
|
function checkDuplicateContent(files) {
|
|
41617
41617
|
const issues = [];
|
|
41618
|
+
const DUPLICATE_CONTENT_THRESHOLD = 0.6;
|
|
41618
41619
|
for (let i2 = 0; i2 < files.length; i2++) {
|
|
41619
41620
|
for (let j3 = i2 + 1; j3 < files.length; j3++) {
|
|
41620
41621
|
const overlap = calculateLineOverlap(files[i2].content, files[j3].content);
|
|
41621
|
-
if (overlap
|
|
41622
|
+
if (overlap >= DUPLICATE_CONTENT_THRESHOLD) {
|
|
41622
41623
|
issues.push({
|
|
41623
41624
|
severity: "warning",
|
|
41624
41625
|
check: "redundancy",
|
|
@@ -41640,11 +41641,12 @@ function calculateLineOverlap(contentA, contentB) {
|
|
|
41640
41641
|
contentB.split("\n").map((l) => l.trim()).filter((l) => l.length > 10)
|
|
41641
41642
|
);
|
|
41642
41643
|
if (linesA.size === 0 || linesB.size === 0) return 0;
|
|
41643
|
-
let
|
|
41644
|
+
let intersection2 = 0;
|
|
41644
41645
|
for (const line of linesA) {
|
|
41645
|
-
if (linesB.has(line))
|
|
41646
|
+
if (linesB.has(line)) intersection2++;
|
|
41646
41647
|
}
|
|
41647
|
-
|
|
41648
|
+
const unionSize = linesA.size + linesB.size - intersection2;
|
|
41649
|
+
return intersection2 / unionSize;
|
|
41648
41650
|
}
|
|
41649
41651
|
function escapeRegex2(str) {
|
|
41650
41652
|
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -43851,7 +43853,7 @@ import { readFileSync as readFileSync4 } from "node:fs";
|
|
|
43851
43853
|
import { resolve as resolve8, dirname as dirname3 } from "node:path";
|
|
43852
43854
|
import { fileURLToPath } from "node:url";
|
|
43853
43855
|
function loadVersion() {
|
|
43854
|
-
if (true) return "0.9.
|
|
43856
|
+
if (true) return "0.9.12";
|
|
43855
43857
|
const __dir = dirname3(fileURLToPath(import.meta.url));
|
|
43856
43858
|
const pkgPath = resolve8(__dir, "../package.json");
|
|
43857
43859
|
const pkg = JSON.parse(readFileSync4(pkgPath, "utf-8"));
|