mvp-ai's picture
download
raw
1.29 kB
#!/usr/bin/env node
import fs from "node:fs";
import path from "node:path";
import process from "node:process";
import {
ROOT,
collectCommentRanges,
listFiles,
} from "./lib/comments.mjs";
function shebangOffset(text) {
if (!text.startsWith("#!")) return 0;
const nl = text.indexOf("\n");
return nl === -1 ? text.length : nl + 1;
}
function lineOf(text, pos) {
return text.slice(0, pos).split(/\r?\n/).length;
}
const violations = [];
for (const file of listFiles(ROOT)) {
const text = fs.readFileSync(file, "utf8");
const offset = shebangOffset(text);
if (offset > 0 && offset >= text.length) continue;
const body = text.slice(offset);
for (const range of collectCommentRanges(body, path.basename(file))) {
violations.push({
file: path.relative(ROOT, file),
line: lineOf(text, range.pos + offset),
snippet: range.text.slice(0, 80).replace(/\s+/g, " "),
});
}
}
if (violations.length > 0) {
console.error(`Code comments are banned (${violations.length} found):`);
for (const v of violations.slice(0, 50)) {
console.error(` ${v.file}:${v.line}: ${v.snippet}`);
}
if (violations.length > 50) {
console.error(` ... and ${violations.length - 50} more`);
}
process.exit(1);
}
console.log("check-no-comments: ok");

Xet Storage Details

Size:
1.29 kB
·
Xet hash:
8c602b4dbfc157dbe7c2d42131ea87ab2c11227bfff7f83360b7d27810686571

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.