Skip to content

Commit

Permalink
fix(lint): current linter rules (#1159)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc authored Nov 12, 2023
1 parent d79eaed commit 5ae721a
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export type RetrieveRequest = {

export type RetrieveMessage = { fileName: string; problem: string };

enum ManageableState {
export enum ManageableState {
Beta = 'beta',
Deleted = 'deleted',
Deprecated = 'deprecated',
Expand Down
2 changes: 1 addition & 1 deletion src/collections/componentSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export class ComponentSet extends LazyCollection<MetadataComponent> {
resolveIncludeSet.add(component, deletionType);
}
const memberIsWildcard = component.fullName === ComponentSet.WILDCARD;
if (!memberIsWildcard || options.forceAddWildcards || !options.resolveSourcePaths) {
if (options.resolveSourcePaths === undefined || !memberIsWildcard || options.forceAddWildcards) {
result.add(component, deletionType);
}
};
Expand Down
3 changes: 2 additions & 1 deletion src/convert/replacements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ export const getReplacements = async (
export const matchesFile = (f: string, r: ReplacementConfig): boolean =>
// filenames will be absolute. We don't have convenient access to the pkgDirs,
// so we need to be more open than an exact match
Boolean((r.filename && posixifyPaths(f).endsWith(r.filename)) || (r.glob && minimatch(f, `**/${r.glob}`)));
(typeof r.filename === 'string' && posixifyPaths(f).endsWith(r.filename)) ||
(typeof r.glob === 'string' && minimatch(f, `**/${r.glob}`));

/**
* Regardless of any components, return the ReplacementConfig that are valid with the current env.
Expand Down
2 changes: 1 addition & 1 deletion src/convert/streams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export class ZipWriter extends ComponentWriter {
chunk.writeInfos.map(async (writeInfo) => {
// we don't want to prematurely zip folder types when their children might still be not in the zip
// those files we'll leave open as ReadableStreams until the zip finalizes
if (chunk.component.type.folderType || chunk.component.type.folderContentType) {
if (Boolean(chunk.component.type.folderType) || Boolean(chunk.component.type.folderContentType)) {
return this.addToZip(writeInfo.source, writeInfo.output);
}
// everything else can be zipped immediately to reduce the number of open files (windows has a low limit!) and help perf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ const getContentType = async (component: SourceComponent): Promise<string> => {

if (typeof output !== 'string') {
throw new SfError(
`Expected a string for contentType in ${component.name} (${component.xml}) but got ${output?.toString()}`
`Expected a string for contentType in ${component.name} (${component.xml}) but got ${JSON.stringify(output)}`
);
}
return output;
Expand Down
2 changes: 1 addition & 1 deletion src/resolve/adapters/baseSourceAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export abstract class BaseSourceAdapter implements SourceAdapter {

// inFolder types (report, dashboard, emailTemplate, document) and their folder
// container types (reportFolder, dashboardFolder, emailFolder, documentFolder)
if (inFolder || folderContentType) {
if (folderContentType ?? inFolder) {
return ensureString(
parseNestedFullName(rootMetadata.path, directoryName),
`Unable to calculate fullName from component at path: ${rootMetadata.path} (${this.type.name})`
Expand Down
2 changes: 1 addition & 1 deletion src/resolve/manifestResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,5 @@ const isMemberNestedInFolder = (
const isNestedInFolder = !fullName.includes('/') || members.some((m) => m.includes(`${fullName}/`));
const isNonMatchingFolder = parentType && parentType.folderType !== parentType.id;

return (isInFolderType && isNestedInFolder) || (!isInFolderType && isNonMatchingFolder);
return isInFolderType ? isNestedInFolder : isNonMatchingFolder;
};
5 changes: 3 additions & 2 deletions src/resolve/metadataResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ export class MetadataResolver {
(typeof type.strategies?.adapter === 'string' &&
['mixedContent', 'bundle'].includes(type.strategies.adapter)) ||
// the file suffix (in source or mdapi format) matches the type suffix we think it is
(type.suffix && [type.suffix, `${type.suffix}${META_XML_SUFFIX}`].some((s) => fsPath.endsWith(s))) ||
(typeof type.suffix === 'string' &&
[type.suffix, `${type.suffix}${META_XML_SUFFIX}`].some((s) => fsPath.endsWith(s))) ||
// the type has children and the file suffix (in source format) matches a child type suffix of the type we think it is
(type.children?.types &&
Object.values(type.children?.types)
Expand Down Expand Up @@ -283,7 +284,7 @@ export class MetadataResolver {
...guesses.map((guess) =>
messages.getMessage('suggest_type_did_you_mean', [
guess.suffixGuess,
metaSuffix || closeMetaSuffix ? '-meta.xml' : '',
typeof metaSuffix === 'string' || closeMetaSuffix ? '-meta.xml' : '',
guess.metadataTypeGuess.name,
])
),
Expand Down
4 changes: 2 additions & 2 deletions src/resolve/sourceComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ export class SourceComponent implements MetadataComponent {
// It also applies to DigitalExperienceBundle types as we need to maintain the folder structure
if (
!suffix ||
inFolder ||
folderContentType ||
Boolean(inFolder) ||
typeof folderContentType === 'string' ||
['digitalexperiencebundle', 'digitalexperience'].includes(this.type.id)
) {
return trimUntil(fsPath, directoryName, true);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/filePathGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const filePathsFromMetadataComponent = (

// basic metadata (with or without folders)
if (!type.children && !type.strategies) {
return (type.inFolder || type.folderType ? generateFolders({ fullName, type }, packageDirWithTypeDir) : []).concat([
return (type.inFolder ?? type.folderType ? generateFolders({ fullName, type }, packageDirWithTypeDir) : []).concat([
join(packageDirWithTypeDir, `${fullName}.${type.suffix}${META_XML_SUFFIX}`),
]);
}
Expand Down
1 change: 1 addition & 0 deletions test/mock/client/transferOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export async function stubMetadataDeploy(
const invokeResultStub = sandbox.stub();
invokeStub.returns({
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
then: (f: (result: unknown | null) => void) => f(invokeResultStub()),
});

Expand Down
3 changes: 2 additions & 1 deletion test/resolve/connectionResolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { assert, expect } from 'chai';
import { MockTestOrgData, TestContext } from '@salesforce/core/lib/testSetup';
import { Connection, Logger } from '@salesforce/core';
import { ManageableState } from '../../src/client/types';
import { ConnectionResolver } from '../../src/resolve';
import { MetadataComponent, registry } from '../../src/';

Expand Down Expand Up @@ -324,7 +325,7 @@ describe('ConnectionResolver', () => {

const resolver = new ConnectionResolver(connection);
const result = await resolver.resolve(
(component) => !(component.namespacePrefix && component.manageableState !== 'unmanaged')
(component) => !(component.namespacePrefix && component.manageableState !== ManageableState.Unmanaged)
);
expect(result.components).to.deep.equal([]);
});
Expand Down

0 comments on commit 5ae721a

Please sign in to comment.