From 6e3066d444912275999cc747cd76ba8e128e6950 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Mon, 8 Jan 2024 21:45:50 +0000 Subject: [PATCH] sanitycheck: warn on boolean-formatters --- bin/sanitycheck.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bin/sanitycheck.js b/bin/sanitycheck.js index f1e795156..945bb8bff 100755 --- a/bin/sanitycheck.js +++ b/bin/sanitycheck.js @@ -256,9 +256,17 @@ apps.forEach((app,appIdx) => { if (a>=0 && b>=0 && a !d.name || !d.name.endsWith(".json")))) { - WARN(`App ${app.id} has a setting file but no corresponding data entry (add \`"data":[{"name":"${app.id}.settings.json"}]\`)`, {file:appDirRelative+file.url}); + // if settings + if (/\.settings?\.js$/.test(file.name)) { + // suggest adding to datafiles + if (!app.data || app.data.every(d => !d.name || !d.name.endsWith(".json"))) { + WARN(`App ${app.id} has a setting file but no corresponding data entry (add \`"data":[{"name":"${app.id}.settings.json"}]\`)`, {file:appDirRelative+file.url}); + } + // check for manual boolean formatter + const m = fileContents.match(/format: *\(\) *=>.*["']Yes["']/); + if (m) { + WARN(`Settings for ${app.id} has a boolean formatter - this is handled automatically, the line can be removed`, {file:appDirRelative+file.url, line: fileContents.substr(0, m.index).split("\n").length}); + } } } for (const key in file) {