mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-06-11 19:11:38 +00:00
fix(check-css-vars): strip /* ... */ comments before scanning
Doc-blocks that mention `var(--name)` in prose (e.g. the z-index scale comment in style.css) were producing false positives. Strip comment spans before regex matching, replacing them with whitespace so line numbers stay stable for any genuine offender that follows. Refs #1128
This commit is contained in:
@@ -46,7 +46,13 @@ const defRe = /(?:^|[^a-zA-Z0-9_-])(--[a-zA-Z0-9_-]+)\s*:/g;
|
||||
const useRe = /var\(\s*(--[a-zA-Z0-9_-]+)\s*\)/g;
|
||||
|
||||
for (const f of files) {
|
||||
const lines = fs.readFileSync(f, 'utf8').split('\n');
|
||||
// Strip /* ... */ comments before scanning so doc-blocks that mention
|
||||
// var(--name) as prose don't trigger false positives. Replace each
|
||||
// comment span with newlines to keep line numbers stable for any
|
||||
// genuine offender that follows.
|
||||
const raw = fs.readFileSync(f, 'utf8');
|
||||
const stripped = raw.replace(/\/\*[\s\S]*?\*\//g, (m) => m.replace(/[^\n]/g, ' '));
|
||||
const lines = stripped.split('\n');
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const line = lines[i];
|
||||
let m;
|
||||
|
||||
Reference in New Issue
Block a user