Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

14 changes: 0 additions & 14 deletions .eslintrc.cjs

This file was deleted.

23 changes: 23 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import tsconfigs from 'eslint-config-salesforce-typescript';
import plugin from 'eslint-plugin-sf-plugin';

const configs = [
...tsconfigs,
...plugin.configs.recommended,
{
rules: {
// Allow deleting object properties via rest operator.
'@typescript-eslint/no-unused-vars': [
'error',
{
ignoreRestSiblings: true,
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
},
},
];

export default configs;
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,19 @@
"devDependencies": {
"@oclif/plugin-command-snapshot": "^5.3.30",
"@salesforce/cli-plugins-testkit": "^5.3.57",
"@salesforce/dev-scripts": "^11.0.4",
"@salesforce/dev-scripts": "^13.0.2",
"@salesforce/plugin-command-reference": "^3.1.119",
"@salesforce/schemas": "^1.9.0",
"@salesforce/source-testkit": "^2.2.212",
"@salesforce/ts-sinon": "^1.4.34",
"@types/chai": "^4.3.17",
"@types/mocha": "^10.0.10",
"@types/node": "^18",
"@types/sinon": "^10.0.20",
"cross-env": "^7.0.3",
"eslint-plugin-sf-plugin": "^1.20.32",
"eslint": "^10.4.0",
"eslint-config-salesforce-typescript": "^6.0.0",
"eslint-plugin-sf-plugin": "^3.0.0",
"oclif": "^4.23.0",
"ts-node": "^10.9.2",
"typescript": "^5.8.3"
Expand Down Expand Up @@ -177,6 +183,7 @@
"src/**/*.ts",
"test/**/*.ts",
"messages/**",
"**/eslint.config.*",
"**/.eslint*",
"**/tsconfig.json"
],
Expand Down
2 changes: 1 addition & 1 deletion src/commands/project/deploy/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default class DeployMetadataReport extends SfCommand<DeployResultJson> {
this.project = await SfProject.resolve();
const sourcepath = this.project.getUniquePackageDirectories().map((pDir) => pDir.fullPath);
componentSet = await buildComponentSet({ 'source-dir': sourcepath, wait });
} catch (err) {
} catch (_err) {
// ignore the error. this was just to get improved command output.
}
} else if (deployOpts.status !== RequestStatus.Succeeded) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/project/list/ignored.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class Ignored extends SfCommand<SourceIgnoredResults> {
* Outputs all forceignored files from package directories of a project,
* or based on a sourcepath param that points to a specific file or directory.
*/
// eslint-disable-next-line @typescript-eslint/require-await
public async run(): Promise<SourceIgnoredResults> {
const flags = (await this.parse(Ignored)).flags;
try {
Expand Down
8 changes: 5 additions & 3 deletions src/commands/project/retrieve/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ export default class RetrieveMetadata extends SfCommand<RetrieveResultJson> {
preStagesBlock: [
{
type: 'message',
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
get: (data) =>
data?.apiData &&
messages.getMessage('apiVersionMsgDetailed', [
Expand All @@ -262,6 +263,7 @@ export default class RetrieveMetadata extends SfCommand<RetrieveResultJson> {
postStagesBlock: [
{
label: 'Status',
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
get: (data) => data?.status,
bold: true,
type: 'dynamic-key-value',
Expand Down Expand Up @@ -347,7 +349,7 @@ export default class RetrieveMetadata extends SfCommand<RetrieveResultJson> {
await rm(resolve(join(flags['target-metadata-dir'] ?? '', zipFileName)), {
recursive: true,
});
} catch (e) {
} catch (_e) {
// do nothing
}
}
Expand Down Expand Up @@ -451,10 +453,10 @@ const wantsToRetrieveCustomFields = (cs: ComponentSet, registry: RegistryAccess)
return hasCustomField && !hasCustomObject;
};

// eslint-disable-next-line complexity
const buildRetrieveAndDeleteTargets = async (
flags: RetrieveMetadataFlags,
format: Format
// eslint-disable-next-line complexity
): Promise<RetrieveAndDeleteTargets> => {
const isChanges =
!flags['source-dir'] &&
Expand Down Expand Up @@ -495,7 +497,7 @@ const buildRetrieveAndDeleteTargets = async (
}
const hasRegexMatch = flags.metadata?.some(isRegexMatch);
// Deliberately using logical or
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing

const retrieveFromOrg = hasRegexMatch || shouldResolvePseudoFromOrg ? flags['target-org'].getUsername() : undefined;
if (format === 'source' && (await flags['target-org'].supportsSourceTracking())) {
await SourceTracking.create({
Expand Down
2 changes: 1 addition & 1 deletion src/formatters/deployReportResultFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class DeployReportResultFormatter extends DeployResultFormatter {
if (key === 'status') {
return result.concat({ key, value: colorStatus(value as RequestStatus) });
} else {
return result.concat({ key, value: value as string | number | boolean });
return result.concat({ key, value });
}
}
return result;
Expand Down
1 change: 1 addition & 0 deletions src/formatters/metadataConvertResultFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export class MetadataConvertResultFormatter implements Formatter<ConvertMdapiJso
return this.convertResults;
}

// eslint-disable-next-line @typescript-eslint/no-misused-promises -- not fixing what isn't broken
public async display(): Promise<void> {
const convertData = await this.getJson();
if (convertData?.length) {
Expand Down
3 changes: 1 addition & 2 deletions src/formatters/metadataRetrieveResultFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ export class MetadataRetrieveResultFormatter implements Formatter<MetadataRetrie

// eslint-disable-next-line @typescript-eslint/require-await
public async getJson(): Promise<MetadataRetrieveResultJson> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { zipFile, ...responseWithoutZipFile } = this.result.response;
return { ...responseWithoutZipFile, zipFilePath: this.zipFilePath, files: this.files };
}

// eslint-disable-next-line @typescript-eslint/require-await
// eslint-disable-next-line @typescript-eslint/require-await, @typescript-eslint/no-misused-promises
public async display(): Promise<void> {
ux.log(retrieveMessages.getMessage('info.WroteZipFile', [this.zipFilePath]));
if (this.opts.unzip) {
Expand Down
1 change: 1 addition & 0 deletions src/formatters/retrieveResultFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class RetrieveResultFormatter implements Formatter<RetrieveResultJson> {
return { ...responseWithoutZip, files: this.files };
}

// eslint-disable-next-line @typescript-eslint/no-misused-promises
public async display(): Promise<void> {
this.displaySuccesses();
await this.displayPackages();
Expand Down
2 changes: 1 addition & 1 deletion src/utils/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export async function buildPreDestructiveFileResponses(

preDestructiveComponents.length = 0;
preDestructiveComponents.push(...resolvedComponents);
} catch (error) {
} catch (_error) {
// If this's not resolve, try to resolve with registry only
}

Expand Down
3 changes: 2 additions & 1 deletion src/utils/deployStages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,9 @@ export class DeployStages {
{
label: 'Failed',
alwaysPrintInCI: true,
// eslint-disable-next-line complexity
get: (data): string | undefined => {
let testFailures: Failures[] = [];
let testFailures: Failures[];

// only render new test failures
if (isCI() && Array.isArray(data?.mdapiDeploy.details.runTestResult?.failures)) {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/manifestCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const writeManifest = async (
export const maybeDestroyManifest = async (jobId: string): Promise<void> => {
try {
return await fs.promises.rm(getManifestFilePath(jobId));
} catch (e) {
} catch (_e) {
// that's ok in a maybe
}
};
Expand Down
3 changes: 2 additions & 1 deletion src/utils/previewOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const resolvePaths = (
.flatMap((filename) => {
try {
return resolver.getComponentsFromPath(filename);
} catch (e) {
} catch (_e) {
// resolver will do logging before throw we don't do it here
return [];
}
Expand All @@ -86,6 +86,7 @@ const resolvePaths = (
};

const calculateDeployOperation = (destructiveChangesType?: DestructiveChangesType): PreviewFile['operation'] => {
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
switch (destructiveChangesType) {
case DestructiveChangesType.POST:
return 'deletePost';
Expand Down
2 changes: 1 addition & 1 deletion src/utils/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export async function getSourceApiVersion(): Promise<Optional<string>> {
export async function getOptionalProject(): Promise<SfProject | undefined> {
try {
return await SfProject.resolve();
} catch (e) {
} catch (_e) {
return undefined;
}
}
23 changes: 0 additions & 23 deletions test/.eslintrc.cjs

This file was deleted.

6 changes: 3 additions & 3 deletions test/commands/deploy/start.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('project deploy start', () => {
});
try {
await DeployMetadata.run([]);
} catch (e) {
} catch (_e) {
expect(warnStub.getCalls().flatMap((call: { args: string[] }) => call.args)).to.deep.include(
messages.getMessage('pushPackageDirsWarning')
); // do nothing, only need to assert that it warns correctly, avoid too much UT setup
Expand All @@ -64,7 +64,7 @@ describe('project deploy start', () => {
});
try {
await DeployMetadata.run(['--source-dir', 'test']);
} catch (e) {
} catch (_e) {
expect(warnStub.called).to.be.false;
// do nothing, only need to assert that it warns correctly, avoid too much UT setup
}
Expand All @@ -79,7 +79,7 @@ describe('project deploy start', () => {
});
try {
await DeployMetadata.run(['--source-dir', 'test']);
} catch (e) {
} catch (_e) {
expect(warnStub.called).to.be.false;
// do nothing, only need to assert that it warns correctly, avoid too much UT setup
}
Expand Down
1 change: 0 additions & 1 deletion test/nuts/delete/source.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ describe('project delete source NUTs', () => {
execCmd(`project:deploy:start --source-dir ${lwcPath1} --source-dir ${lwcPath2}`);
// delete both helper.js files at the same time
const deleteResult = execCmd<DeleteSourceJson>(
// eslint-disable-next-line sf-plugin/no-execcmd-double-quotes
`project:delete:source -p "${lwcPath1},${lwcPath2}" --no-prompt --json`
).jsonOutput?.result;
assert(deleteResult?.deletedSource);
Expand Down
2 changes: 1 addition & 1 deletion test/nuts/digitalExperienceBundle/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/
// existing tests do a lot mutation. I decided to leave rather than refactor
/* eslint-disable no-param-reassign */

import { join, relative } from 'node:path';
import * as fs from 'node:fs';
Expand Down
3 changes: 1 addition & 2 deletions test/nuts/seeds/deploy.metadata.metadata-dir.seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import * as path from 'node:path';
import { fileURLToPath } from 'node:url';
import { SourceTestkit } from '@salesforce/source-testkit';
import { RequestStatus } from '@salesforce/source-deploy-retrieve';
import { JsonMap } from '@salesforce/ts-types';
import { assert } from 'chai';
import { TEST_REPOS_MAP } from '../testMatrix.js';
import { DeployResultJson } from '../../../src/utils/types.js';
Expand Down Expand Up @@ -56,7 +55,7 @@ context('deploy metadata --metadata-dir NUTs [name: %REPO_NAME%]', () => {

const deploy = await testkit.deploy<DeployResultJson>({ args: '--metadata-dir out' });
assert(deploy);
testkit.expect.toHavePropertyAndValue(deploy.result as unknown as JsonMap, 'status', RequestStatus.Succeeded);
testkit.expect.toHavePropertyAndValue(deploy.result, 'status', RequestStatus.Succeeded);
});
}

Expand Down
2 changes: 1 addition & 1 deletion test/nuts/tracking/conflicts.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('conflict detection and resolution', () => {
);
await conn.tooling.sobject('CustomApplication').update({
...app,
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
Metadata: {
...app.Metadata,
description: 'modified',
Expand Down
3 changes: 2 additions & 1 deletion test/utils/deployResponses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ export const getDeployResponse = (
deleted: false,
id: '01p2100000A6XiqAAF',
fullName: 'testClass1',
} as DeployMessage;
};
response.rollbackOnError = true;
response.numberComponentErrors = 1;
response.numberComponentsTotal = 2;
Expand All @@ -380,6 +380,7 @@ export const getDeployResult = (
return {
response,
getFileResponses() {
// eslint-disable-next-line no-useless-assignment -- not actually useless
let fileProps: DeployMessage[] = [];
if (type === 'failed') {
const failures = response.details.componentFailures ?? [];
Expand Down
4 changes: 2 additions & 2 deletions test/utils/output.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ describe('deployResultFormatter', () => {
// The formatter should call table() to display the Deleted Source
const deletesTableCall = tableStub.getCalls().find((call) => {
const callArg = call.args[0] as { title?: string };
return callArg?.title && callArg.title.includes('Deleted Source');
return callArg?.title?.includes('Deleted Source');
});

expect(deletesTableCall).to.exist;
Expand Down Expand Up @@ -247,7 +247,7 @@ describe('deployResultFormatter', () => {
// Verify no Deleted Source table is displayed
const deletesTableCall = tableStub.getCalls().find((call) => {
const callArg = call.args[0] as { title?: string };
return callArg?.title && callArg.title.includes('Deleted Source');
return callArg?.title?.includes('Deleted Source');
});

expect(deletesTableCall).to.not.exist;
Expand Down
1 change: 1 addition & 0 deletions test/utils/promiseQueue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ describe('promisesQueue', () => {
it('should reject at entry two', async () => {
await promisesQueue(
[1, 2],
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors -- don't want to mess with code that isn't broken
(n: number): Promise<number> => (n === 2 ? Promise.reject(n) : Promise.resolve(n)),
1
).catch((e) => expect(e).to.equal(2));
Expand Down
Loading
Loading