添加所有菜谱的预估卡路里数据并更新lint规则
Some checks failed
Continuous Deployment / build-readme-file (push) Has been cancelled

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Anduin Xue
2026-05-15 06:36:48 +00:00
parent 88f2636c9f
commit 1448b50e0d
363 changed files with 734 additions and 3 deletions

View File

@@ -67,15 +67,17 @@ const validators = [
}
});
// 检查烹饪难度
// 检查烹饪难度和卡路里
const mainTitleIndex = titles.length > 0 ? lines.indexOf(titles[0]) : -1;
const firstSecondTitleIndex = sections.length > 0 ? lines.indexOf(sections[0]) : -1;
if (mainTitleIndex >= 0 && firstSecondTitleIndex >= 0 && mainTitleIndex < firstSecondTitleIndex) {
const contentBetweenTitles = lines.slice(mainTitleIndex + 1, firstSecondTitleIndex);
let hasDifficultyLine = false;
let hasCalorieLine = false;
const difficultyPatternGeneral = /^预估烹饪难度:(★*)$/;
const difficultyPatternStrict = /^预估烹饪难度:★{1,5}$/;
const caloriePattern = /^预估卡路里:\d+大卡$/;
for (const line of contentBetweenTitles) {
if (difficultyPatternGeneral.test(line)) {
@@ -85,12 +87,17 @@ const validators = [
const starCount = starMatch ? starMatch.length : 0;
errors.push(`文件 ${filePath} 不符合仓库的规范烹饪难度的星星数量必须在1-5颗之间(当前为 ${starCount} 颗)`);
}
break;
}
if (caloriePattern.test(line)) {
hasCalorieLine = true;
}
}
if (!hasDifficultyLine) {
errors.push(`文件 ${filePath} 不符合仓库的规范!在大标题和第一个二级标题之间必须包含"预估烹饪难度:★★"格式的难度评级星星数量必须在1-5颗之间`);
}
if (!hasCalorieLine) {
errors.push(`文件 ${filePath} 不符合仓库的规范!在大标题和第一个二级标题之间必须包含"预估卡路里XXX大卡"。`);
}
} else if (mainTitleIndex === -1 || firstSecondTitleIndex === -1) {
errors.push(`文件 ${filePath} 结构错误,无法定位烹饪难度区域。`);
}