Fix linting and add new lint rules

This commit is contained in:
Dolan Miu
2022-09-19 20:48:50 +01:00
parent e90d97b813
commit 5950055cca
13 changed files with 78 additions and 46 deletions

View File

@ -25,7 +25,7 @@ describe("Compiler", () => {
});
describe("#compile()", () => {
it("should pack all the content", async function () {
it("should pack all the content", function () {
this.timeout(99999999);
const file = new File({
sections: [],
@ -53,7 +53,7 @@ describe("Compiler", () => {
expect(fileNames).to.include("_rels/.rels");
});
it("should pack all additional headers and footers", async function () {
it("should pack all additional headers and footers", function () {
const file = new File({
sections: [
{

View File

@ -54,7 +54,7 @@ describe("Packer", () => {
assert.isTrue(buffer.byteLength > 0);
});
it("should handle exception if it throws any", async () => {
it("should handle exception if it throws any", () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const compiler = stub((Packer as any).compiler, "compile");
@ -139,7 +139,7 @@ describe("Packer", () => {
const stream = await Packer.toStream(file);
return new Promise((resolve, reject) => {
stream.on("error", () => {
reject();
reject(new Error());
});
stream.on("end", () => {
@ -148,7 +148,7 @@ describe("Packer", () => {
});
});
it("should handle exception if it throws any", async () => {
it("should handle exception if it throws any", () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const compiler = stub((Packer as any).compiler, "compile").callsFake(() => ({
// tslint:disable-next-line: no-empty
@ -160,9 +160,11 @@ describe("Packer", () => {
}));
compiler.throwsException();
return Packer.toStream(file).catch((error) => {
try {
Packer.toStream(file);
} catch (error) {
assert.isDefined(error);
});
}
});
afterEach(() => {

View File

@ -58,7 +58,7 @@ export class Packer {
return zipData;
}
public static async toStream(file: File, prettify?: boolean | PrettifyType): Promise<Stream> {
public static toStream(file: File, prettify?: boolean | PrettifyType): Stream {
const zip = this.compiler.compile(file, prettify);
const zipData = zip.generateNodeStream({
type: "nodebuffer",