Skip to content

Commit

Permalink
style: cs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
prisis committed Sep 20, 2024
1 parent d01352a commit 2b0cb4f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/packem/__tests__/intigration/typescript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { join } from "@visulima/path";
import { temporaryDirectory } from "tempy";
import { afterEach, beforeEach, describe, expect, it } from "vitest";

import { createPackageJson, createPackemConfig, createTsConfig, execPackemSync, installPackage } from "../helpers";
import getRegexMatches from "../../src/utils/get-regex-matches";
import { createPackageJson, createPackemConfig, createTsConfig, execPackemSync, installPackage } from "../helpers";

describe("packem typescript", () => {
let temporaryDirectoryPath: string;
Expand Down
14 changes: 10 additions & 4 deletions packages/packem/src/rollup/plugins/isolated-declarations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,13 @@ export const isolatedDeclarationsPlugin = (
if ((declaration === true || declaration === "compatible") && outputOptions.format === "cjs") {
this.emitFile({
fileName: entryFileNames.replace("[name]", relative(outBase, filename)).replace(".cts", ".ts"),
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands,regexp/no-misleading-capturing-group,regexp/no-super-linear-backtracking
source: source.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g, (_, group1, group2, group3) => group1 + quote + (group3 || group2) + ".d.ts" + quote + ";"),

source: source.replaceAll(
// eslint-disable-next-line regexp/no-misleading-capturing-group,regexp/no-super-linear-backtracking
/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
(_, group1, group2, group3) => group1 + quote + (group3 || group2) + ".d.ts" + quote + ";",
),
type: "asset",
});
}
Expand All @@ -199,8 +204,9 @@ export const isolatedDeclarationsPlugin = (
source: source.replaceAll(
// eslint-disable-next-line regexp/no-misleading-capturing-group,regexp/no-super-linear-backtracking
/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
(_, group1, group2, group3) => group1 + quote + (group3 || group2) + (outputOptions.format === "cjs" ? ".d.cts" : ".d.mts") + quote + ";",
(_, group1, group2, group3) =>
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
group1 + quote + (group3 || group2) + (outputOptions.format === "cjs" ? ".d.cts" : ".d.mts") + quote + ";",
),
type: "asset",
});
Expand Down

0 comments on commit 2b0cb4f

Please sign in to comment.