Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix errors for XO v0.59.3 #157

Merged
merged 6 commits into from
Oct 6, 2024
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: 1 addition & 0 deletions .xo-config
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"unicorn/no-array-callback-reference": "off",
"unicorn/prefer-module": 0,
"unicorn/no-process-exit": 0,
"unicorn/prevent-abbreviations": "off",
"node/prefer-global/process": 0,
"n/prefer-global/process": 0,
"n/file-extension-in-import": 0,
Expand Down
15,645 changes: 7,973 additions & 7,672 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"url": "git@github.com:rkotze/git-mob.git"
},
"engines": {
"node": ">=14"
"node": ">=16"
},
"keywords": [
"cli",
Expand Down Expand Up @@ -55,7 +55,7 @@
}
],
"devDependencies": {
"eslint-plugin-jest": "^27.6.0",
"xo": "^0.54.1"
"eslint-plugin-jest": "^28.8.3",
"xo": "^0.59.3"
}
}
4 changes: 2 additions & 2 deletions packages/git-mob-core/src/git-mob-api/fetch/http-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ async function httpFetch(
url: string,
options: https.RequestOptions
): Promise<BasicResponse> {
return new Promise((fulfil, reject) => {
return new Promise((resolve, reject) => {
const httpRequest = https
.request(url, options, response => {
let chunkedData = '';
Expand All @@ -19,7 +19,7 @@ async function httpFetch(
});

response.on('end', () => {
fulfil({
resolve({
statusCode: response.statusCode,
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
data: JSON.parse(chunkedData),
Expand Down
36 changes: 14 additions & 22 deletions packages/git-mob-core/src/git-mob-api/git-message/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readFile, writeFile } from 'node:fs';
import { readFile, writeFile } from 'node:fs/promises';
import { EOL } from 'node:os';
import { type Author } from '../author';

Expand All @@ -7,32 +7,24 @@ function fileExists(error: NodeJS.ErrnoException) {
}

async function append(messagePath: string, newAuthors: string): Promise<void> {
return new Promise((resolve, reject) => {
readFile(messagePath, 'utf8', (error, data) => {
if (error && fileExists(error)) reject(error);
const data = await read(messagePath);

let result = newAuthors;
if (data) {
result = data.replace(/(\r\n|\r|\n){1,2}Co-authored-by.*/g, '') + newAuthors;
}
let result = newAuthors;
if (data) {
result = data.replaceAll(/(\r\n|\r|\n){1,2}Co-authored-by.*/g, '') + newAuthors;
}

writeFile(messagePath, result, error => {
if (error) reject(error);

resolve();
});
});
});
await writeFile(messagePath, result);
}

async function read(messagePath: string) {
return new Promise((resolve, reject) => {
readFile(messagePath, 'utf8', (error, data) => {
if (error && fileExists(error)) reject(error);

resolve(data);
});
});
try {
return await readFile(messagePath, { encoding: 'utf8' });
} catch (error: unknown) {
if (error && fileExists(error as Error)) {
throw error as Error;
}
}
}

function formatCoAuthorList(coAuthorList: Author[]): string {
Expand Down
6 changes: 4 additions & 2 deletions packages/git-mob-core/tsconfig.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

/* Language and Environment */
"target": "es2017" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
"lib": [
"ES2021"
] /* Specify a set of bundled library declaration files that describe the target runtime environment. */,
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
Expand All @@ -27,7 +29,7 @@
/* Modules */
"module": "NodeNext" /* Specify what module code is generated. */,
// "rootDir": "src" /* Specify the root folder within your source files. */,
// "moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */,
// "moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */,
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
"rootDirs": [
Expand Down
4 changes: 3 additions & 1 deletion packages/git-mob-core/tsconfig.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

/* Language and Environment */
"target": "es2017" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
"lib": [
"ES2021"
] /* Specify a set of bundled library declaration files that describe the target runtime environment. */,
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
Expand Down
9 changes: 5 additions & 4 deletions packages/git-mob/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@
],
"dependencies": {
"common-tags": "^1.8.2",
"git-mob-core": "^0.9.0",
"minimist": "^1.2.8"
"git-mob-core": "^0.9.3",
"minimist": "^1.2.8",
"update-notifier": "^7.3.1"
},
"devDependencies": {
"@ava/typescript": "^5.0.0",
"@types/common-tags": "^1.8.4",
"@types/minimist": "^1.2.5",
"@types/node": "^22.7.4",
"@types/sinon": "^17.0.3",
"ava": "^6.1.3",
Expand All @@ -77,8 +79,7 @@
"rimraf": "^6.0.1",
"sinon": "^19.0.2",
"tempy": "^3.1.0",
"typescript": "^5.6.2",
"update-notifier": "^7.3.1"
"typescript": "^5.6.2"
},
"ava": {
"files": [
Expand Down
4 changes: 2 additions & 2 deletions packages/git-mob/src/git-add-coauthor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ await execute(argv)
.then(() => {
process.exit(0);
})
.catch((error: Error) => {
console.error(red(error.message));
.catch((error: unknown) => {
console.error(red((error as Error).message));
process.exit(1);
});
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

/* Language and Environment */
"target": "es2017" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
"lib": [
"ES2021"
] /* Specify a set of bundled library declaration files that describe the target runtime environment. */,
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
Expand Down
Loading