Fix lint errors in credentials.ts
- Fix prettier formatting for multi-line regex in expandPath - Add proper types to regex callback params to fix no-unsafe-assignment - Suppress no-unused-vars for destructured _rawContent in saveConfig
This commit is contained in:
@@ -34,10 +34,13 @@ export interface Config {
|
|||||||
*/
|
*/
|
||||||
function expandPath(filePath: string): string {
|
function expandPath(filePath: string): string {
|
||||||
// Expand environment variables: ${VAR} and $VAR formats
|
// Expand environment variables: ${VAR} and $VAR formats
|
||||||
let expanded = filePath.replace(/\$\{([^}]+)\}|\$([A-Za-z_][A-Za-z0-9_]*)/g, (_, braced, bare) => {
|
let expanded = filePath.replace(
|
||||||
const variable = braced || bare;
|
/\$\{([^}]+)\}|\$([A-Za-z_][A-Za-z0-9_]*)/g,
|
||||||
|
(_, braced: string | undefined, bare: string | undefined) => {
|
||||||
|
const variable = braced || bare || '';
|
||||||
return process.env[variable] || '';
|
return process.env[variable] || '';
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// Handle tilde for home directory
|
// Handle tilde for home directory
|
||||||
if (expanded.startsWith('~/')) {
|
if (expanded.startsWith('~/')) {
|
||||||
@@ -145,6 +148,7 @@ export function saveConfig(config: Config, filePath: string): void {
|
|||||||
const expandedPath = expandPath(filePath);
|
const expandedPath = expandPath(filePath);
|
||||||
|
|
||||||
// Strip internal field before dumping
|
// Strip internal field before dumping
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
const { _rawContent, ...configData } = config;
|
const { _rawContent, ...configData } = config;
|
||||||
|
|
||||||
const yamlContent = yaml.dump(configData, {
|
const yamlContent = yaml.dump(configData, {
|
||||||
|
|||||||
Reference in New Issue
Block a user