Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
steveukx committed Aug 5, 2023
1 parent 59d9c5f commit bf62036
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 19 deletions.
5 changes: 4 additions & 1 deletion simple-git/src/lib/errors/git-construct-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import { SimpleGitOptions } from '../types';
* passed to the constructor.
*/
export class GitConstructError extends GitError {
constructor(public readonly config: SimpleGitOptions, message: string) {
constructor(
public readonly config: SimpleGitOptions,
message: string
) {
super(undefined, message);
}
}
5 changes: 4 additions & 1 deletion simple-git/src/lib/errors/git-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ import type { SimpleGitTask } from '../types';
```
*/
export class GitError extends Error {
constructor(public task?: SimpleGitTask<any>, message?: string) {
constructor(
public task?: SimpleGitTask<any>,
message?: string
) {
super(message);
Object.setPrototypeOf(this, new.target.prototype);
}
Expand Down
11 changes: 7 additions & 4 deletions simple-git/src/lib/parsers/parse-list-log-summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ export const SPLITTER = ' ò ';
const defaultFieldNames = ['hash', 'date', 'message', 'refs', 'author_name', 'author_email'];

function lineBuilder(tokens: string[], fields: string[]): any {
return fields.reduce((line, field, index) => {
line[field] = tokens[index] || '';
return line;
}, Object.create({ diff: null }) as any);
return fields.reduce(
(line, field, index) => {
line[field] = tokens[index] || '';
return line;
},
Object.create({ diff: null }) as any
);
}

export function createListLogSummaryParser<T = any>(
Expand Down
6 changes: 5 additions & 1 deletion simple-git/src/lib/responses/FileStatusSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ export const fromPathRegex = /^(.+) -> (.+)$/;
export class FileStatusSummary implements FileStatusResult {
public readonly from: string | undefined;

constructor(public path: string, public index: string, public working_dir: string) {
constructor(
public path: string,
public index: string,
public working_dir: string
) {
if ('R' === index + working_dir) {
const detail = fromPathRegex.exec(path) || [null, path, path];
this.from = detail[1] || '';
Expand Down
5 changes: 4 additions & 1 deletion simple-git/src/lib/responses/TagList.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { TagResult } from '../../../typings';

export class TagList implements TagResult {
constructor(public readonly all: string[], public readonly latest: string | undefined) {}
constructor(
public readonly all: string[],
public readonly latest: string | undefined
) {}
}

export const parseTagList = function (data: string, customSort = false) {
Expand Down
5 changes: 4 additions & 1 deletion simple-git/src/lib/utils/git-output-streams.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { TaskResponseFormat } from '../types';

export class GitOutputStreams<T extends TaskResponseFormat = Buffer> {
constructor(public readonly stdOut: T, public readonly stdErr: T) {}
constructor(
public readonly stdOut: T,
public readonly stdErr: T
) {}

asStrings(): GitOutputStreams<string> {
return new GitOutputStreams(this.stdOut.toString('utf8'), this.stdErr.toString('utf8'));
Expand Down
12 changes: 6 additions & 6 deletions simple-git/test/unit/__fixtures__/responses/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ function change(count: number, sign: '-' | '+') {
function line(insertions: SmallNumber, deletions: SmallNumber, fileName: string) {
return `
${fileName} | ${insertions + deletions} ${''.padEnd(insertions, '+')}${''.padEnd(
deletions,
'-'
)}`;
deletions,
'-'
)}`;
}

export function diffSummarySingleFile(
Expand Down Expand Up @@ -48,9 +48,9 @@ export function diffSummaryMultiFile(

stdOut += `
${files.length} file${files.length === 1 ? '' : 's'} changed ${change(add, '+')}${change(
del,
'-'
)}
del,
'-'
)}
`;
return createFixture(stdOut, '');
}
11 changes: 7 additions & 4 deletions simple-git/test/unit/promises.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,13 @@ describe('promises', () => {
const resolveMockCallCount = (c: jest.Mock) => c.mock.calls.length;

function byName<T>(resolver: (c: jest.Mock) => T) {
return callbacks.reduce((all, callback) => {
all[callback.getMockName()] = resolver(callback);
return all;
}, {} as { [key: string]: T });
return callbacks.reduce(
(all, callback) => {
all[callback.getMockName()] = resolver(callback);
return all;
},
{} as { [key: string]: T }
);
}

return {
Expand Down

0 comments on commit bf62036

Please sign in to comment.