From 407d4253aa38be0fe606dec723dbd63e7b5b2617 Mon Sep 17 00:00:00 2001 From: Willie Ruemmele Date: Wed, 18 Sep 2024 13:53:07 -0600 Subject: [PATCH] chore: remove a few eslint issues --- src/convert/transformers/decomposeLabelsTransformer.ts | 3 ++- src/resolve/metadataResolver.ts | 2 +- src/resolve/treeContainers.ts | 7 +++---- src/utils/metadata.ts | 4 ++-- src/utils/path.ts | 4 +--- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/convert/transformers/decomposeLabelsTransformer.ts b/src/convert/transformers/decomposeLabelsTransformer.ts index ed6079280..a9b4cb387 100644 --- a/src/convert/transformers/decomposeLabelsTransformer.ts +++ b/src/convert/transformers/decomposeLabelsTransformer.ts @@ -13,6 +13,7 @@ import { SourceComponent } from '../../resolve/sourceComponent'; import { ToSourceFormatInput, WriteInfo } from '../types'; import { JsToXml } from '../streams'; import { unwrapAndOmitNS } from '../../utils/decomposed'; +import { META_XML_SUFFIX } from '../../common'; import { DefaultMetadataTransformer } from './defaultMetadataTransformer'; /* Use for the metadata type CustomLabels */ @@ -31,7 +32,7 @@ export class LabelsMetadataTransformer extends DefaultMetadataTransformer { output: // if present in the merge set, use that xml path, otherwise use the default path mergeSet?.getComponentFilenamesByNameAndType({ fullName: l.fullName, type: labelType.name })?.[0] ?? - partiallyAppliedPathCalculator(l.fullName)(`${l.fullName}.label-meta.xml`), + partiallyAppliedPathCalculator(l.fullName)(`${l.fullName}.label${META_XML_SUFFIX}`), source: new JsToXml({ CustomLabel: l }), })); } diff --git a/src/resolve/metadataResolver.ts b/src/resolve/metadataResolver.ts index a70dabc4c..f5d852f37 100644 --- a/src/resolve/metadataResolver.ts +++ b/src/resolve/metadataResolver.ts @@ -271,7 +271,7 @@ const getSuggestionsForUnresolvedTypes = ...guesses.map((guess) => messages.getMessage('suggest_type_did_you_mean', [ guess.suffixGuess, - typeof metaSuffix === 'string' || closeMetaSuffix ? '-meta.xml' : '', + typeof metaSuffix === 'string' || closeMetaSuffix ? META_XML_SUFFIX : '', guess.metadataTypeGuess.name, ]) ), diff --git a/src/resolve/treeContainers.ts b/src/resolve/treeContainers.ts index 38a470bfc..5dfdb2fe4 100644 --- a/src/resolve/treeContainers.ts +++ b/src/resolve/treeContainers.ts @@ -237,7 +237,6 @@ export class ZipTreeContainer extends TreeContainer { */ export class VirtualTreeContainer extends TreeContainer { private tree = new Map>(); - private fileContents = new Map(); public constructor(virtualFs: VirtualDirectory[]) { super(); @@ -298,10 +297,10 @@ export class VirtualTreeContainer extends TreeContainer { public readFileSync(fsPath: SourcePath): Buffer { if (this.exists(fsPath)) { - let data = this.fileContents.get(fsPath); + let data = this.fileContentMap.get(fsPath); if (!data) { data = Buffer.from(''); - this.fileContents.set(fsPath, data); + this.fileContentMap.set(fsPath, data); } return data; } @@ -327,7 +326,7 @@ export class VirtualTreeContainer extends TreeContainer { dirPathFromTree.add(childPath); if (typeof child === 'object' && child.data) { - this.fileContents.set(childPath, child.data); + this.fileContentMap.set(childPath, child.data); } } } diff --git a/src/utils/metadata.ts b/src/utils/metadata.ts index d09c72aad..6a89e45f9 100644 --- a/src/utils/metadata.ts +++ b/src/utils/metadata.ts @@ -8,7 +8,7 @@ import type { CustomLabel } from '@jsforce/jsforce-node/lib/api/metadata'; import { SfError } from '@salesforce/core'; import { XMLParser } from 'fast-xml-parser'; -import { META_XML_SUFFIX, XML_COMMENT_PROP_NAME } from '../common/constants'; +import { META_XML_SUFFIX, XML_COMMENT_PROP_NAME, XML_DECL } from '../common/constants'; export const parser = new XMLParser({ // include tag attributes and don't parse text node as number @@ -22,7 +22,7 @@ export const parser = new XMLParser({ }); export function generateMetaXML(typeName: string, apiVersion: string, status: string): string { - let templateResult = '\n'; + let templateResult = XML_DECL; templateResult += `<${typeName} xmlns="http://soap.sforce.com/2006/04/metadata">\n`; templateResult += `\t${apiVersion}.0\n`; if (status) { diff --git a/src/utils/path.ts b/src/utils/path.ts index 33181dff1..82a865d1f 100644 --- a/src/utils/path.ts +++ b/src/utils/path.ts @@ -117,9 +117,7 @@ export function parseNestedFullName(fsPath: string, directoryName: string): stri return; } const pathPrefix = pathSplits.slice(pathSplits.lastIndexOf(directoryName) + 1); - // the eslint comment should remain until strictMode is fully implemented - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion - pathPrefix[pathPrefix.length - 1] = (pathSplits.pop() as string).replace('-meta.xml', '').split('.')[0]; + pathPrefix[pathPrefix.length - 1] = (pathSplits.pop() as string).replace(META_XML_SUFFIX, '').split('.')[0]; return pathPrefix.join('/'); }