سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 3, 18:15 UTC
Guard script loading and collection getter uniqueness
davoodmehraban89 committed
Sep 28, 2026 at 14:31 UTC
96f83a4c55ac23628205c9e7a931f7e0a2e1173b
1 file changed
+3
scripts/quality-check.mjs
+3
@@ -11,6 +11,7 @@ const requiredIds=['view-dashboard','view-invoices','view-products','view-contac
11
for(const id of requiredIds)if(!ids.includes(id))throw new Error('Missing required element #'+id);
12
13
const requiredScripts=['js/core.js','js/sync.js','js/invoices.js','js/print.js','js/contacts.js','js/companies.js','js/projects.js','js/purchases.js','js/operations.js','js/drilldown.js','js/selfcheck.js'];
14
+if(index.includes('</script>\\n<script'))throw new Error('Literal \\n found between script tags');
15
for(const s of requiredScripts)if(!index.includes(s))throw new Error('Missing script load: '+s);
16
17
const files=fs.readdirSync(path.join(root,'js')).filter(n=>n.endsWith('.js'));
@@ -28,6 +29,8 @@ const must={
29
for(const [file,needles] of Object.entries(must)){
30
for(const needle of needles)if(!all[file]?.includes(needle))throw new Error(file+' missing '+needle);
31
}
32
+const purchaseGetterCount=(all['sync.js']?.match(/function getMyPurchases\s*\(/g)||[]).length;
33
+if(purchaseGetterCount!==1)throw new Error('Expected exactly one getMyPurchases definition, found '+purchaseGetterCount);
34
const securityWorkflow=fs.readFileSync(path.join(root,'.github','workflows','security.yml'),'utf8');
35
for(const needle of ['github/codeql-action/init@v3','github/codeql-action/analyze@v3','actions/dependency-review-action@v4'])if(!securityWorkflow.includes(needle))throw new Error('Security workflow missing '+needle);
36
if(!all['invoices.js']?.includes("q.status==='cleared'"))throw new Error('Dashboard must only settle cleared cheques');