env-sentinel
Version:
Zero-dependency tool that auto-validates .env files against schema.env, with optional fallback and secure warnings.
21 lines (20 loc) • 739 B
JavaScript
export function noCommaSeparatedValueInScalarCheck(lineNumber, lineContent) {
const equalIndex = lineContent.indexOf('=');
if (equalIndex === -1)
return;
const rawKey = lineContent.slice(0, equalIndex).trim();
const rawValue = lineContent.slice(equalIndex + 1).trim();
const value = rawValue.split('#')[0].trim();
const isQuoted = (value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"));
if (isQuoted)
return;
if (value.includes(',')) {
return {
line: lineNumber,
issue: `Unquoted comma-separated value in "${rawKey}"`,
content: lineContent,
severity: 'warning',
};
}
return;
}