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.

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

This file was deleted.

1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'eslint-config-salesforce-typescript';
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,15 @@
"@oclif/plugin-command-snapshot": "^5.3.34",
"@oclif/test": "^4.1.21",
"@salesforce/cli-plugins-testkit": "^5.3.64",
"@salesforce/dev-scripts": "^11.0.4",
"@salesforce/dev-scripts": "^13.0.2",
"@salesforce/plugin-command-reference": "^3.1.131",
"@salesforce/types": "^1.8.0",
"@types/chai": "^4.3.17",
"@types/mocha": "^10.0.10",
"@types/node": "^18",
"@types/sinon": "^10.0.20",
"eslint": "^10.4.0",
"eslint-config-salesforce-typescript": "^6.0.0",
"eslint-plugin-sf-plugin": "^1.20.33",
"oclif": "^4.23.29",
"ts-node": "^10.9.2",
Expand Down Expand Up @@ -193,6 +199,7 @@
"src/**/*.ts",
"test/**/*.ts",
"messages/**",
"**/eslint.config.*",
"**/.eslint*",
"**/tsconfig.json"
],
Expand Down
4 changes: 1 addition & 3 deletions src/api/data/tree/exportApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,7 @@ export class ExportApi {

if (parentRef && this.config.plan) {
const parentFieldName = parentRef.fieldName;
if (!treeRecord[parentFieldName]) {
treeRecord[parentFieldName] = parentRef.id;
}
treeRecord[parentFieldName] ??= parentRef.id;
}
// add record to tree
sobjectTree.records.push(treeRecord);
Expand Down
6 changes: 2 additions & 4 deletions src/batcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ export class Batcher {
const newBatch = job.createBatch();

return new Promise((resolve, reject) => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
newBatch.on('error', (err: Error) => {
// reword no external id error message to direct it to org user rather than api user
if (err.message.startsWith('External ID was blank')) {
Expand Down Expand Up @@ -175,7 +174,6 @@ export class Batcher {
);

if (!wait) {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
newBatch.on(
'queue',
// we're using an async method on an event listener which doesn't fit the .on method parameter types
Expand All @@ -184,7 +182,7 @@ export class Batcher {
this.ux.log(messages.getMessage('CheckStatusCommand', [i + 1, batchInfo.jobId, batchInfo.id]));
const result = await newBatch.check();
if (result.state === 'Failed') {
reject(result.stateMessage);
reject(new SfError(result.stateMessage));
} else {
resolve(batchInfo);
}
Expand Down Expand Up @@ -248,7 +246,7 @@ export class Batcher {
async (batchInfo: BatchInfo): Promise<void> => {
const result = await newBatch.check();
if (result.state === 'Failed') {
reject(result.stateMessage);
reject(new SfError(result.stateMessage));
} else if (!overallInfo) {
this.ux.log(messages.getMessage('PollingInfo', [POLL_FREQUENCY_MS / 1000, batchInfo.jobId, batchInfo.id]));
overallInfo = true;
Expand Down
2 changes: 1 addition & 1 deletion src/bulkUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const validateSobjectType = async (sobjectType: string, connection: Conne
await connection.sobject(sobjectType).describe();
return sobjectType;
} catch (e) {
throw new Error(messages.getMessage('invalidSobject', [sobjectType, (e as Error).message]));
throw new Error(messages.getMessage('invalidSobject', [sobjectType, (e as Error).message]), { cause: e });
}
};

Expand Down
2 changes: 0 additions & 2 deletions src/commands/data/create/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ export default class DataCreateFile extends SfCommand<ContentVersion> {
required: true,
exists: true,
}),
// it really could be most any valid ID
// eslint-disable-next-line sf-plugin/id-flag-suggestions
'parent-id': Flags.salesforceId({
summary: messages.getMessage('flags.parent-id.summary'),
char: 'i',
Expand Down
3 changes: 1 addition & 2 deletions src/commands/data/delete/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export default class Delete extends SfCommand<SaveResult> {
aliases: ['sobjecttype'],
deprecateAliases: true,
}),
// eslint-disable-next-line sf-plugin/id-flag-suggestions
'record-id': Flags.salesforceId({
length: 'both',
char: 'i',
Expand Down Expand Up @@ -72,7 +71,7 @@ export default class Delete extends SfCommand<SaveResult> {
? flags['target-org'].getConnection(flags['api-version']).tooling
: flags['target-org'].getConnection(flags['api-version']);
// "where flag" will be defined if sobjectId is not
const sObjectId = flags['record-id'] ?? ((await query(conn, flags.sobject, flags.where as string)).Id as string);
const sObjectId = (flags['record-id'] ?? (await query(conn, flags.sobject, flags.where as string)).Id) as string;
const result = await conn.sobject(flags.sobject).destroy(sObjectId);
if (result.success) {
this.log(messages.getMessage('deleteSuccess', [sObjectId]));
Expand Down
4 changes: 2 additions & 2 deletions src/commands/data/export/bulk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ export default class DataExportBulk extends SfCommand<DataExportBulkResult> {
label: 'Status',
type: 'dynamic-key-value',
bold: true,
get: (data) => data?.state,
get: (data): string | undefined => data?.state,
},
{
label: 'Job Id',
type: 'dynamic-key-value',
bold: true,
get: (data) =>
get: (data): string | undefined =>
data?.id &&
terminalLink(
data.id,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/data/export/resume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default class DataExportResume extends SfCommand<DataExportResumeResult>
label: 'Status',
type: 'dynamic-key-value',
bold: true,
get: (data) => data?.state,
get: (data): string | undefined => data?.state,
},
],
});
Expand Down
5 changes: 2 additions & 3 deletions src/commands/data/get/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export default class Get extends SfCommand<Record> {
aliases: ['sobjecttype'],
deprecateAliases: true,
}),
// eslint-disable-next-line sf-plugin/id-flag-suggestions
'record-id': Flags.salesforceId({
length: 'both',
char: 'i',
Expand Down Expand Up @@ -70,10 +69,10 @@ export default class Get extends SfCommand<Record> {
? flags['target-org'].getConnection(flags['api-version']).tooling
: flags['target-org'].getConnection(flags['api-version']);
try {
const sObjectId = flags['record-id'] ?? ((await query(conn, flags.sobject, flags.where as string)).Id as string);
const sObjectId = (flags['record-id'] ?? (await query(conn, flags.sobject, flags.where as string)).Id) as string;
const result = await conn.sobject(flags.sobject).retrieve(sObjectId);
if (!this.jsonEnabled()) {
logNestedObject(new Ux({ jsonEnabled: this.jsonEnabled() }), result as never);
logNestedObject(new Ux({ jsonEnabled: this.jsonEnabled() }), result);
}
this.spinner.stop();
return toAnyJson(result) as Record;
Expand Down
2 changes: 1 addition & 1 deletion src/commands/data/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ const recursivelyFindColumns = (data: JsonArray): Field[] => {
}
columns.push(field);
} else {
columns.push({ fieldType: FieldType.field, name } as Field);
columns.push({ fieldType: FieldType.field, name });
}
}
return columns;
Expand Down
3 changes: 1 addition & 2 deletions src/commands/data/update/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export default class Update extends SfCommand<SaveResult> {
aliases: ['sobjecttype'],
deprecateAliases: true,
}),
// eslint-disable-next-line sf-plugin/id-flag-suggestions
'record-id': Flags.salesforceId({
char: 'i',
length: 'both',
Expand Down Expand Up @@ -86,7 +85,7 @@ export default class Update extends SfCommand<SaveResult> {
? flags['target-org'].getConnection(flags['api-version']).tooling
: flags['target-org'].getConnection(flags['api-version']);
// oclif isn't smart of enough to know that if record-id is not set, then where is set
const sObjectId = flags['record-id'] ?? ((await query(conn, flags.sobject, flags.where as string)).Id as string);
const sObjectId = (flags['record-id'] ?? (await query(conn, flags.sobject, flags.where as string)).Id) as string;
try {
const updateObject = { ...stringToDictionary(flags.values), Id: sObjectId };
const result = await conn
Expand Down
4 changes: 2 additions & 2 deletions src/commands/force/data/bulk/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import fs from 'node:fs';
import { ReadStream } from 'node:fs';

import { Connection, Messages } from '@salesforce/core';
import { Connection, Messages, SfError } from '@salesforce/core';
import { Flags, SfCommand, Ux } from '@salesforce/sf-plugins-core';
import { orgFlags } from '../../../../flags.js';
import { Batcher, BatcherReturnType } from '../../../../batcher.js';
Expand Down Expand Up @@ -79,7 +79,7 @@ export default class Delete extends SfCommand<BatcherReturnType> {
this.spinner.stop();
} catch (e) {
this.spinner.stop('error');
reject(e);
reject(SfError.wrap(e));
}
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/commands/force/data/bulk/upsert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
import fs from 'node:fs';

import { Messages } from '@salesforce/core';
import { Messages, SfError } from '@salesforce/core';
import { Flags, SfCommand, Ux } from '@salesforce/sf-plugins-core';
import { orgFlags } from '../../../../flags.js';
import { Batcher, BatcherReturnType } from '../../../../batcher.js';
Expand Down Expand Up @@ -85,15 +85,15 @@ export default class Upsert extends SfCommand<BatcherReturnType> {
// eslint-disable-next-line @typescript-eslint/no-misused-promises,no-async-promise-executor
return new Promise(async (resolve, reject) => {
job.on('error', (err): void => {
reject(err);
reject(SfError.wrap(err));
});

try {
resolve(await batcher.createAndExecuteBatches(job, csvStream, sobject, flags.wait?.minutes));
this.spinner.stop();
} catch (e) {
this.spinner.stop('error');
reject(e);
reject(SfError.wrap(e));
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/reporters/query/humanReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ function prepData(
const row: Record<string, unknown> = {};
fields.forEach((field) => {
if (field in record) {
row[field] = (record[field] as string) ?? '';
row[field] = (record[field]) ?? '';
} else {
// if not, try to find it query
row[field] = (get(record, field) as string) ?? '';
row[field] = (get(record, field)) ?? '';
}
});
return row;
Expand Down
28 changes: 0 additions & 28 deletions test/.eslintrc.cjs

This file was deleted.

3 changes: 3 additions & 0 deletions test/api/data/tree/export.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ describe('replaceParentReferences', () => {
});

it('no changes when there is not parent Id field on the record', () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { AccountId, ...caseWithNoParent } = caseRecord;
const result = fnToTest(caseWithNoParent);
expect(result).to.deep.equal(caseWithNoParent);
Expand Down Expand Up @@ -437,6 +438,7 @@ describe('removeChildren', () => {
expect(result).to.not.have.property('Cases');
expect(result).to.not.have.property('Contacts');

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { Cases, Contacts, ...originalForComparison } = record;
expect(result).to.deep.equal(originalForComparison);
});
Expand All @@ -447,6 +449,7 @@ describe('removeChildren', () => {
const result = removeChildren(record);
expect(result).to.not.have.property('Bars');

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { Bars, Cases, Contacts, ...originalForComparison } = record;
expect(result).to.deep.equal(originalForComparison);
});
Expand Down
2 changes: 1 addition & 1 deletion test/api/data/tree/exportApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/ban-ts-comment */

import fs from 'node:fs';
Expand Down
5 changes: 2 additions & 3 deletions test/commands/data/delete/record.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { ensureJsonMap, ensureString, AnyJson } from '@salesforce/ts-types';
import { expect } from 'chai';
import { Config } from '@oclif/core/config';

import type { SaveResult } from '@jsforce/jsforce-node';
import Delete from '../../../../src/commands/data/delete/record.js';

const sObjectId = '0011100001zhhyUAAQ';
Expand Down Expand Up @@ -70,7 +69,7 @@ describe('data:delete:record', () => {
['--target-org', 'test@org.com', '--sobject', 'Account', '--record-id', sObjectId, '--json'],
config
);
const result = (await cmd.run()) as unknown as SaveResult;
const result = await cmd.run();
expect(result?.id).to.equal('0011100001zhhyUAAQ');
});

Expand All @@ -93,7 +92,7 @@ describe('data:delete:record', () => {
);
try {
await shouldThrow(cmd.run());
} catch (e) {
} catch {
// expected an error
}
});
Expand Down
2 changes: 1 addition & 1 deletion test/commands/data/query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ describe('Execute a SOQL statement', (): void => {
// @ts-expect-error stubbing for testing
soqlQuerySpy = $$.SANDBOX.stub(DataSoqlQueryCommand.prototype, 'runSoqlQuery')
// aggregate query types are wrong in jsforce
.resolves(soqlQueryExemplars.queryWithAggregates.soqlQueryResult as unknown as SoqlQueryResult);
.resolves(soqlQueryExemplars.queryWithAggregates.soqlQueryResult);
});
afterEach(() => {
$$.SANDBOX.restore();
Expand Down
3 changes: 2 additions & 1 deletion test/commands/data/query/query.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ describe('data:query command', () => {

// the Metadata object parsed correctly
// @ts-expect-error typescript doesn't know the shape of the Metadata object
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
const metadataObject = result?.records[0].Metadata;
expect(metadataObject).to.have.property('disableProtocolSecurity');
expect(metadataObject).to.have.property('isActive');
Expand All @@ -301,6 +301,7 @@ describe('data:query command', () => {
await fs.promises.readFile(path.join(testSession.project.dir, 'accounts.json'), 'utf8')
) as DataQueryResult;

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { outputFile, ...result } = queryResult?.result as DataQueryResult;

expect(file).to.deep.equal(result);
Expand Down
Loading
Loading