Skip to content

Commit

Permalink
refactor: use imports with js file extensions
Browse files Browse the repository at this point in the history
for better compatibility with TypeScript < 5.0
  • Loading branch information
schoero committed Nov 17, 2023
1 parent cbe419a commit 1c77d52
Show file tree
Hide file tree
Showing 28 changed files with 77 additions and 80 deletions.
4 changes: 2 additions & 2 deletions src/bundle/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable simple-import-sort/exports */
export * as pdf from "swissqrbill:pdf:index";
export * as svg from "swissqrbill:svg:index";
export * as pdf from "swissqrbill:pdf";
export * as svg from "swissqrbill:svg";
export * as types from "swissqrbill:types";
export * as utils from "swissqrbill:utils";
export * as errors from "swissqrbill:errors";
6 changes: 3 additions & 3 deletions src/pdf/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from "./swissqrbill";
export * from "./swissqrcode";
export * from "./table";
export * from "./swissqrbill.js";
export * from "./swissqrcode.js";
export * from "./table.js";
7 changes: 3 additions & 4 deletions src/pdf/swissqrbill.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { describe, expect, it } from "vitest";

import { minimalRequired } from "swissqrbill:tests:data/valid-data";
import { TestDocument } from "swissqrbill:tests:utils/pdf";
import { SwissQRBill } from "swissqrbill:pdf";
import { minimalRequired } from "swissqrbill:tests:data/valid-data.js";
import { TestDocument } from "swissqrbill:tests:utils/pdf.js";
import { mm2pt } from "swissqrbill:utils";

import { SwissQRBill } from "./swissqrbill";


describe("qr-bill", async () => {

Expand Down
8 changes: 4 additions & 4 deletions src/pdf/swissqrbill.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SwissQRCode } from "swissqrbill:pdf:swissqrcode";
import { cleanData } from "swissqrbill:shared:cleaner";
import { translations } from "swissqrbill:shared:translations";
import { validateData } from "swissqrbill:shared:validator";
import { SwissQRCode } from "swissqrbill:pdf";
import { cleanData } from "swissqrbill:shared:cleaner.js";
import { translations } from "swissqrbill:shared:translations.js";
import { validateData } from "swissqrbill:shared:validator.js";
import { formatAmount, formatIBAN, formatReference, getReferenceType, mm2pt, pt2mm } from "swissqrbill:utils";

import type { ValidationError } from "swissqrbill:errors";
Expand Down
8 changes: 4 additions & 4 deletions src/pdf/swissqrcode.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { describe, expect, it, test } from "vitest";

import { SwissQRCode } from "swissqrbill:pdf:swissqrcode";
import { mm2pt } from "swissqrbill:shared:utils";
import { minimalRequiredWithAlternativeScheme1and2 } from "swissqrbill:tests:data/valid-data";
import { TestDocument } from "swissqrbill:tests:utils/pdf";
import { SwissQRCode } from "swissqrbill:pdf";
import { minimalRequiredWithAlternativeScheme1and2 } from "swissqrbill:tests:data/valid-data.js";
import { TestDocument } from "swissqrbill:tests:utils/pdf.js";
import { mm2pt } from "swissqrbill:utils";


describe("swissqrcode", () => {
Expand Down
12 changes: 6 additions & 6 deletions src/pdf/swissqrcode.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ValidationError } from "swissqrbill:errors";
import { cleanData } from "swissqrbill:shared:cleaner";
import { renderQRCode, renderSwissCross } from "swissqrbill:shared:qr-code";
import { mm2pt } from "swissqrbill:shared:utils";
import { validateData } from "swissqrbill:shared:validator";
import { cleanData } from "swissqrbill:shared:cleaner.js";
import { renderQRCode, renderSwissCross } from "swissqrbill:shared:qr-code.js";
import { validateData } from "swissqrbill:shared:validator.js";
import { mm2pt } from "swissqrbill:utils";

import type { Data } from "swissqrbill:shared:types";
import type { ValidationError } from "swissqrbill:errors";
import type { Data } from "swissqrbill:types";


export class SwissQRCode {
Expand Down
6 changes: 3 additions & 3 deletions src/pdf/table.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";

import { Table } from "swissqrbill:pdf:table";
import { Table } from "swissqrbill:pdf";
import {
alignmentOverrides,
alignmentVariants,
Expand All @@ -16,8 +16,8 @@ import {
singleCell,
textColorOverrides,
tupleShorthand
} from "swissqrbill:tests:data/table";
import { TestDocument } from "swissqrbill:tests:utils/pdf";
} from "swissqrbill:tests:data/table.js";
import { TestDocument } from "swissqrbill:tests:utils/pdf.js";


describe("table", async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/shared/cleaner.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";

import { cleanData } from "swissqrbill:shared:cleaner";
import { cleanData } from "swissqrbill:shared:cleaner.js";

import type { Data } from "swissqrbill:types";

Expand Down
2 changes: 1 addition & 1 deletion src/shared/cleaner.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Creditor, Data, Debtor } from "./types";
import type { Creditor, Data, Debtor } from "swissqrbill:types";


export function cleanData(data: Data): Data {
Expand Down
6 changes: 3 additions & 3 deletions src/shared/qr-code.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, test } from "vitest";

import { } from "swissqrbill:shared:cleaner";
import { generateQRData } from "swissqrbill:shared:qr-code";
import { } from "swissqrbill:shared:cleaner.js";
import { generateQRData } from "swissqrbill:shared:qr-code.js";
import {
creditorWithBuildingNumber,
creditorWithBuildingNumberString,
Expand All @@ -22,7 +22,7 @@ import {
minimalRequiredWithEuro,
minimalRequiredWithMaxedOutMessage,
minimalRequiredWithMessage
} from "swissqrbill:tests:data/valid-data";
} from "swissqrbill:tests:data/valid-data.js";


describe("generateQRData", () => {
Expand Down
9 changes: 4 additions & 5 deletions src/shared/qr-code.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { cleanData } from "swissqrbill:shared:cleaner";
import { validateData } from "swissqrbill:shared:validator";
import { cleanData } from "swissqrbill:shared:cleaner.js";
import { qrcodegen } from "swissqrbill:shared:qr-code-generator.js";
import { validateData } from "swissqrbill:shared:validator.js";
import { getReferenceType, mm2pt } from "swissqrbill:utils";

import { qrcodegen } from "./qr-code-generator";

import type { Data } from "./types";
import type { Data } from "swissqrbill:shared:types.js";


export function generateQRData(data: Data): string {
Expand Down
6 changes: 3 additions & 3 deletions src/shared/translations.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { describe, expect, test } from "vitest";

import { minimalRequired } from "swissqrbill:tests:data/valid-data";
import { pdf } from "swissqrbill:tests:utils/pdf";
import { svg } from "swissqrbill:tests:utils/svg";
import { minimalRequired } from "swissqrbill:tests:data/valid-data.js";
import { pdf } from "swissqrbill:tests:utils/pdf.js";
import { svg } from "swissqrbill:tests:utils/svg.js";


describe("translations", async () => {
Expand Down
8 changes: 4 additions & 4 deletions src/shared/validator.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { describe, expect, it } from "vitest";

import { resolveMessageParams, ValidationErrors } from "swissqrbill:errors";
import { cleanData } from "swissqrbill:shared:cleaner";
import { validateData } from "swissqrbill:shared:validator";
import { cleanData } from "swissqrbill:shared:cleaner.js";
import { validateData } from "swissqrbill:shared:validator.js";
import {
additionalInformationInvalidType,
additionalInformationTooLong,
Expand Down Expand Up @@ -70,7 +70,7 @@ import {
referenceTypeInvalid,
regularIBANAndQRReference,
regularIBANAndReferenceTooLong
} from "swissqrbill:tests:data/invalid-data";
} from "swissqrbill:tests:data/invalid-data.js";
import {
creditorWithBuildingNumber,
creditorWithBuildingNumberString,
Expand All @@ -93,7 +93,7 @@ import {
minimalRequiredWithEuro,
minimalRequiredWithMaxedOutMessage,
minimalRequiredWithMessage
} from "swissqrbill:tests:data/valid-data";
} from "swissqrbill:tests:data/valid-data.js";


describe("validator", async () => {
Expand Down
5 changes: 2 additions & 3 deletions src/shared/validator.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { ValidationError, ValidationErrors } from "swissqrbill:errors";
import { isIBANValid, isQRIBAN, isQRReference, isQRReferenceValid } from "swissqrbill:utils";

import { isIBANValid, isQRIBAN, isQRReference, isQRReferenceValid } from "./utils";

import type { Data } from "./types";
import type { Data } from "swissqrbill:types";


/**
Expand Down
4 changes: 2 additions & 2 deletions src/svg/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "./swissqrbill";
export * from "./swissqrcode";
export * from "./swissqrbill.js";
export * from "./swissqrcode.js";
11 changes: 6 additions & 5 deletions src/svg/swissqrbill.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { calc, SVG } from "svg-engine";

import { cleanData } from "swissqrbill:shared:cleaner";
import { translations } from "swissqrbill:shared:translations";
import { validateData } from "swissqrbill:shared:validator";
import { calculateTextWidth } from "swissqrbill:svg:character-width";
import { SwissQRCode } from "swissqrbill:svg:swissqrcode";
import { cleanData } from "swissqrbill:shared:cleaner.js";
import { translations } from "swissqrbill:shared:translations.js";
import { validateData } from "swissqrbill:shared:validator.js";
import { SwissQRCode } from "swissqrbill:svg";
import { formatAmount, formatIBAN, formatReference, getReferenceType, mm2px } from "swissqrbill:utils";

import { calculateTextWidth } from "./character-width.js";

import type { Creditor, Data, Debtor, FontName, Language, SVGOptions } from "swissqrbill:types";

/**
Expand Down
8 changes: 4 additions & 4 deletions src/svg/swissqrcode.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { describe, expect, test } from "vitest";

import { mm2pt } from "swissqrbill:shared:utils";
import { SwissQRCode } from "swissqrbill:svg:index";
import { minimalRequiredWithAlternativeScheme1and2 } from "swissqrbill:tests:data/valid-data";
import { TestDocument } from "swissqrbill:tests:utils/svg";
import { SwissQRCode } from "swissqrbill:svg";
import { minimalRequiredWithAlternativeScheme1and2 } from "swissqrbill:tests:data/valid-data.js";
import { TestDocument } from "swissqrbill:tests:utils/svg.js";
import { mm2pt } from "swissqrbill:utils";


describe("swissqrcode", () => {
Expand Down
4 changes: 2 additions & 2 deletions src/svg/swissqrcode.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { SVG } from "svg-engine";

import { renderQRCode, renderSwissCross } from "swissqrbill:shared:qr-code";
import { renderQRCode, renderSwissCross } from "swissqrbill:shared:qr-code.js";

import type { ValidationError } from "swissqrbill:errors";
import type { Data } from "swissqrbill:shared:types";
import type { Data } from "swissqrbill:types";


export class SwissQRCode {
Expand Down
2 changes: 1 addition & 1 deletion tests/data/invalid-data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { creditorWithQRIBAN, minimalRequired, minimalRequiredWithDebtor } from "swissqrbill:tests:data/valid-data";
import { creditorWithQRIBAN, minimalRequired, minimalRequiredWithDebtor } from "swissqrbill:tests:data/valid-data.js";

import type { Data } from "swissqrbill:types";

Expand Down
2 changes: 1 addition & 1 deletion tests/data/table.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PDFTable } from "swissqrbill:pdf:table";
import type { PDFTable } from "swissqrbill:pdf";


export const tupleShorthand: PDFTable = {
Expand Down
2 changes: 1 addition & 1 deletion tests/data/valid-data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fillUntil } from "swissqrbill:tests:utils/fill";
import { fillUntil } from "swissqrbill:tests:utils/fill.js";

import type { Creditor, Data, Debtor } from "swissqrbill:types";

Expand Down
6 changes: 3 additions & 3 deletions tests/integration/data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import {
minimalRequiredWithEuro,
minimalRequiredWithMaxedOutMessage,
minimalRequiredWithMessage
} from "swissqrbill:tests:data/valid-data";
import { pdf } from "swissqrbill:tests:utils/pdf";
import { svg } from "swissqrbill:tests:utils/svg";
} from "swissqrbill:tests:data/valid-data.js";
import { pdf } from "swissqrbill:tests:utils/pdf.js";
import { svg } from "swissqrbill:tests:utils/svg.js";


describe("data", async () => {
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/options.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { describe, expect, test } from "vitest";

import { minimalRequired } from "swissqrbill:tests:data/valid-data";
import { pdf } from "swissqrbill:tests:utils/pdf";
import { svg } from "swissqrbill:tests:utils/svg";
import { minimalRequired } from "swissqrbill:tests:data/valid-data.js";
import { pdf } from "swissqrbill:tests:utils/pdf.js";
import { svg } from "swissqrbill:tests:utils/svg.js";


describe("options", async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/buffer.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";

import { splitBuffer } from "swissqrbill:tests:utils/buffer";
import { splitBuffer } from "swissqrbill:tests:utils/buffer.js";


describe("buffer", () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/fill.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";

import { fillUntil } from "./fill";
import { fillUntil } from "swissqrbill:tests:utils/fill.js";


describe("fill", () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/utils/pdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { buffer } from "node:stream/consumers";

import PDFDocument from "pdfkit";

import { SwissQRBill } from "swissqrbill:pdf:swissqrbill";
import { splitBuffer } from "swissqrbill:tests:utils/buffer";
import { SwissQRBill } from "swissqrbill:pdf";
import { splitBuffer } from "swissqrbill:tests:utils/buffer.js";

import type { Data, PDFOptions } from "swissqrbill:types";

Expand Down
2 changes: 1 addition & 1 deletion tests/utils/svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { dirname, join } from "node:path";

import SVG from "svg-engine";

import { SwissQRBill } from "swissqrbill:svg:index";
import { SwissQRBill } from "swissqrbill:svg";

import type { Data, SVGOptions } from "swissqrbill:types";

Expand Down
13 changes: 6 additions & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
"noImplicitAny": false,
"outDir": "lib",
"paths": {
"swissqrbill:bundle:*": ["src/bundle/*"],
"swissqrbill:errors": ["src/shared/errors"],
"swissqrbill:node_modules:*": ["node_modules/*"],
"swissqrbill:pdf:*": ["src/pdf/*"],
"swissqrbill:bundle": ["src/bundle/index.js"],
"swissqrbill:errors": ["src/shared/errors.js"],
"swissqrbill:pdf": ["src/pdf/index.js"],
"swissqrbill:shared:*": ["src/shared/*"],
"swissqrbill:svg:*": ["src/svg/*"],
"swissqrbill:svg": ["src/svg/index.js"],
"swissqrbill:tests:*": ["tests/*"],
"swissqrbill:types": ["src/shared/types"],
"swissqrbill:utils": ["src/shared/utils"]
"swissqrbill:types": ["src/shared/types.js"],
"swissqrbill:utils": ["src/shared/utils.js"]
},
"rootDir": ".",
"skipLibCheck": true
Expand Down

0 comments on commit 1c77d52

Please sign in to comment.