Skip to content

Commit b77e2f1

Browse files
author
Anna Bocharova
committed
Adjusting migration and compat test.
1 parent d4049cc commit b77e2f1

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

compat-test/migration.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ import { describe, test, expect } from "vitest";
44
describe("Migration", () => {
55
test("should fix the import", async () => {
66
const fixed = await readFile("./sample.ts", "utf-8");
7-
expect(fixed).toBe(`const route = {\n"get /": someEndpoint,\n}\n`);
7+
expect(fixed).toBe(`const route = {\nget: someEndpoint,\n}\n`);
88
});
99
});

migration/index.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe("Migration", async () => {
3434
{
3535
name: "basic DependsOnMethod",
3636
code: `const routing = new DependsOnMethod({ get: someEndpoint });`,
37-
output: `const routing = {\n"get /": someEndpoint,\n};`,
37+
output: `const routing = {\nget: someEndpoint,\n};`,
3838
errors: [
3939
{
4040
messageId: "change",
@@ -49,7 +49,7 @@ describe("Migration", async () => {
4949
{
5050
name: "DependsOnMethod with literals",
5151
code: `const routing = new DependsOnMethod({ "get": someEndpoint });`,
52-
output: `const routing = {\n"get /": someEndpoint,\n};`,
52+
output: `const routing = {\nget: someEndpoint,\n};`,
5353
errors: [
5454
{
5555
messageId: "change",
@@ -64,7 +64,7 @@ describe("Migration", async () => {
6464
{
6565
name: "deprecated DependsOnMethod",
6666
code: `const routing = new DependsOnMethod({ get: someEndpoint }).deprecated();`,
67-
output: `const routing = {\n"get /": someEndpoint.deprecated(),\n};`,
67+
output: `const routing = {\nget: someEndpoint.deprecated(),\n};`,
6868
errors: [
6969
{
7070
messageId: "change",
@@ -79,7 +79,7 @@ describe("Migration", async () => {
7979
{
8080
name: "DependsOnMethod with nesting",
8181
code: `const routing = new DependsOnMethod({ get: someEndpoint }).nest({ some: otherEndpoint });`,
82-
output: `const routing = {\n"get /": someEndpoint,\n"some": otherEndpoint,\n};`,
82+
output: `const routing = {\nget: someEndpoint,\nsome: otherEndpoint,\n};`,
8383
errors: [
8484
{
8585
messageId: "change",
@@ -93,8 +93,8 @@ describe("Migration", async () => {
9393
},
9494
{
9595
name: "DependsOnMethod both deprecated and with nesting",
96-
code: `const routing = new DependsOnMethod({ get: someEndpoint }).deprecated().nest({ some: otherEndpoint });`,
97-
output: `const routing = {\n"get /": someEndpoint.deprecated(),\n"some": otherEndpoint,\n};`,
96+
code: `const routing = new DependsOnMethod({ get: someEndpoint }).deprecated().nest({ "get some": otherEndpoint });`,
97+
output: `const routing = {\nget: someEndpoint.deprecated(),\n"get some": otherEndpoint,\n};`,
9898
errors: [
9999
{
100100
messageId: "change",

migration/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ const theRule = ESLintUtils.RuleCreator.withoutDocs({
110110
(feat?: "deprecated" | "nest") =>
111111
(prop: TSESTree.ObjectLiteralElement) =>
112112
isNamedProp(prop)
113-
? `"${getPropName(prop)}${feat === "nest" ? "" : " /"}": ${ctx.sourceCode.getText(prop.value)}${feat === "deprecated" ? ".deprecated()" : ""},`
113+
? `${feat === "nest" ? ctx.sourceCode.getText(prop.key) : getPropName(prop)}: ${ctx.sourceCode.getText(prop.value)}${feat === "deprecated" ? ".deprecated()" : ""},`
114114
: `${ctx.sourceCode.getText(prop)}, /** @todo migrate manually */`;
115115
const nextProps = argument.properties
116116
.map(makeMapper(isDeprecated ? "deprecated" : undefined))

0 commit comments

Comments
 (0)