Skip to content
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
9 changes: 5 additions & 4 deletions migration/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { RuleTester } from "@typescript-eslint/rule-tester";
import migration from "./index.ts";
import parser from "@typescript-eslint/parser";
import manifest from "./package.json" with { type: "json" };

Expand All @@ -11,10 +10,12 @@ const tester = new RuleTester({
languageOptions: { parser },
});

const ruleName = `v${manifest.version.split(".")[0]}`;
const theRule = migration.rules[ruleName as keyof typeof migration.rules];
describe("Migration", async () => {
vi.stubEnv("TSDOWN_VERSION", manifest.version);
const { default: migration } = await import("./index.ts");
const ruleName = `v${manifest.version.split(".")[0]}`;
const theRule = migration.rules[ruleName as keyof typeof migration.rules];

describe("Migration", () => {
test("should consist of one rule being the major version of the package", () => {
expect(migration.rules).toHaveProperty(ruleName);
expect(migration).toMatchSnapshot();
Expand Down
7 changes: 5 additions & 2 deletions migration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ const listen = <
{},
);

const v25 = ESLintUtils.RuleCreator.withoutDocs({
// eslint-disable-next-line no-restricted-syntax -- substituted by TSDOWN and vitest
const ruleName = `v${process.env.TSDOWN_VERSION!.split(".")[0]}`;

const theRule = ESLintUtils.RuleCreator.withoutDocs({
meta: {
type: "problem",
fixable: "code",
Expand Down Expand Up @@ -90,5 +93,5 @@ const v25 = ESLintUtils.RuleCreator.withoutDocs({
});

export default {
rules: { v25 },
rules: { [ruleName]: theRule } as Record<`v${number}`, typeof theRule>,
} satisfies TSESLint.Linter.Plugin;
4 changes: 4 additions & 0 deletions migration/tsdown.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { defineConfig } from "tsdown";
import manifest from "./package.json" with { type: "json" };

export default defineConfig({
entry: "index.ts",
minify: true,
skipNodeModulesBundle: true,
attw: { profile: "esmOnly", level: "error" },
define: {
"process.env.TSDOWN_VERSION": `"${manifest.version}"`, // used by ruleName
},
});