UNPKG

env-sentinel

Version:

Zero-dependency tool that auto-validates .env files against schema.env, with optional fallback and secure warnings.

22 lines (21 loc) 907 B
const YAML_BOOLEAN_LITERALS = new Set(['true', 'false', 'yes', 'no', 'on', 'off']); export function noUnquotedYAMLBooleanLiteralCheck(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 isQuoted = (rawValue.startsWith('"') && rawValue.endsWith('"')) || (rawValue.startsWith("'") && rawValue.endsWith("'")); if (isQuoted) return; const value = rawValue.split('#')[0].trim().toLowerCase(); if (YAML_BOOLEAN_LITERALS.has(value)) { return { line: lineNumber, issue: `Unquoted YAML-style boolean literal "${value}" in "${rawKey}" may cause unexpected coercion`, content: lineContent, severity: 'warning', }; } return; }