Skip to content

Commit

Permalink
chore: remove a few eslint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed Sep 18, 2024
1 parent 9b864fc commit 407d425
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/convert/transformers/decomposeLabelsTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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 }),
}));
}
Expand Down
2 changes: 1 addition & 1 deletion src/resolve/metadataResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
])
),
Expand Down
7 changes: 3 additions & 4 deletions src/resolve/treeContainers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ export class ZipTreeContainer extends TreeContainer {
*/
export class VirtualTreeContainer extends TreeContainer {
private tree = new Map<SourcePath, Set<SourcePath>>();
private fileContents = new Map<SourcePath, Buffer>();

public constructor(virtualFs: VirtualDirectory[]) {
super();
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -22,7 +22,7 @@ export const parser = new XMLParser({
});

export function generateMetaXML(typeName: string, apiVersion: string, status: string): string {
let templateResult = '<?xml version="1.0" encoding="UTF-8"?>\n';
let templateResult = XML_DECL;
templateResult += `<${typeName} xmlns="http://soap.sforce.com/2006/04/metadata">\n`;
templateResult += `\t<apiVersion>${apiVersion}.0</apiVersion>\n`;
if (status) {
Expand Down
4 changes: 1 addition & 3 deletions src/utils/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('/');
}

Expand Down

2 comments on commit 407d425

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 407d425 Previous: b1f18d3 Ratio
eda-componentSetCreate-linux 236 ms 245 ms 0.96
eda-sourceToMdapi-linux 2312 ms 2452 ms 0.94
eda-sourceToZip-linux 1867 ms 1893 ms 0.99
eda-mdapiToSource-linux 2949 ms 2921 ms 1.01
lotsOfClasses-componentSetCreate-linux 409 ms 434 ms 0.94
lotsOfClasses-sourceToMdapi-linux 3844 ms 3864 ms 0.99
lotsOfClasses-sourceToZip-linux 3272 ms 3183 ms 1.03
lotsOfClasses-mdapiToSource-linux 3639 ms 3668 ms 0.99
lotsOfClassesOneDir-componentSetCreate-linux 718 ms 759 ms 0.95
lotsOfClassesOneDir-sourceToMdapi-linux 6660 ms 6637 ms 1.00
lotsOfClassesOneDir-sourceToZip-linux 5825 ms 5900 ms 0.99
lotsOfClassesOneDir-mdapiToSource-linux 6668 ms 6689 ms 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 407d425 Previous: b1f18d3 Ratio
eda-componentSetCreate-win32 660 ms 626 ms 1.05
eda-sourceToMdapi-win32 4256 ms 4264 ms 1.00
eda-sourceToZip-win32 3001 ms 2854 ms 1.05
eda-mdapiToSource-win32 5893 ms 5661 ms 1.04
lotsOfClasses-componentSetCreate-win32 1208 ms 1242 ms 0.97
lotsOfClasses-sourceToMdapi-win32 8058 ms 7830 ms 1.03
lotsOfClasses-sourceToZip-win32 5438 ms 5072 ms 1.07
lotsOfClasses-mdapiToSource-win32 8184 ms 7917 ms 1.03
lotsOfClassesOneDir-componentSetCreate-win32 2190 ms 2107 ms 1.04
lotsOfClassesOneDir-sourceToMdapi-win32 14666 ms 13843 ms 1.06
lotsOfClassesOneDir-sourceToZip-win32 9236 ms 9351 ms 0.99
lotsOfClassesOneDir-mdapiToSource-win32 13858 ms 14260 ms 0.97

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.