env-sentinel
Version:
Zero-dependency tool that auto-validates .env files against schema.env, with optional fallback and secure warnings.
18 lines (17 loc) • 610 B
JavaScript
export function noQuotedKeyCheck(lineNumber, lineContent) {
const equalIndex = lineContent.indexOf('=');
if (equalIndex === -1)
return;
const rawKey = lineContent.slice(0, equalIndex).trim();
const startsWithQuote = rawKey.startsWith('"') || rawKey.startsWith("'");
const endsWithQuote = rawKey.endsWith('"') || rawKey.endsWith("'");
if (startsWithQuote || endsWithQuote) {
return {
line: lineNumber,
issue: `Quoted keys are not allowed: ${rawKey}`,
content: lineContent,
severity: 'error',
};
}
return;
}