Skip to content

Commit c82f5a8

Browse files
committed
release: 0.0.1-1
1 parent c55c68c commit c82f5a8

7 files changed

Lines changed: 174 additions & 86 deletions

File tree

.npmignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
src/test/
1+
src/__snapshots__/
2+
src/index.test.ts
23
.editorconfig
34
.gitignore
45
manualRun.ts
56
yarn.lock
67
*.log
8+
/jest.config.js
9+
/index.d.ts
10+
/cjs/
11+
!/cjs/src/index.js

index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
declare module "@babel/plugin-syntax-typescript";
2+
declare module "babel-plugin-tester";
3+
declare module "@babel/helper-plugin-utils";

manualRun.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@ const check = `
1010
const options = {
1111
module: {
1212
from: "one",
13-
to: "two"
13+
to: "two",
1414
},
1515
specifiers: {
16-
One: "default"
17-
}
16+
One: "default",
17+
},
1818
} as Config;
1919

20-
const result = transform(check, {
21-
plugins: [["./src/index.ts", options]]
22-
}).code;
20+
const result =
21+
transform(check, {
22+
plugins: [["./src/index.ts", options]],
23+
})?.code ?? "";
2324

2425
console.log(
2526
format(result, { semi: false, singleQuote: true, parser: "babel" })

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "import-move-codemod",
3-
"version": "0.0.1-0",
3+
"version": "0.0.1-1",
44
"description": "This babel plugin should be used as codemod for bulk import refactorings a.k.a module move refactorings",
55
"repository": "https://github.com/RIP21/import-move-codemod",
66
"license": "MIT",
77
"author": "https://github.com/RIP21/",
8-
"main": "src/index.ts",
8+
"main": "cjs/src/index.js",
99
"keywords": [
1010
"babel-plugin",
1111
"babel-codemod",
@@ -31,7 +31,8 @@
3131
"scripts": {
3232
"test": "jest",
3333
"start": "ts-node manualRun.ts",
34-
"release": "np"
34+
"tsc": "tsc",
35+
"release": "tsc && np"
3536
},
3637
"dependencies": {
3738
"@babel/core": "^7.10.5",

src/index.test.ts

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ pluginTester({
77
pluginName: "import-rename-codemod",
88
plugin: transform,
99
snapshot: true,
10-
formatResult: output =>
10+
formatResult: (output: any) =>
1111
format(output, {
1212
semi: true,
1313
singleQuote: true,
14-
parser: "babel"
14+
parser: "babel",
1515
}),
1616
tests: [
1717
{
@@ -23,10 +23,10 @@ pluginTester({
2323
pluginOptions: {
2424
module: {
2525
from: "one",
26-
to: "two"
26+
to: "two",
2727
},
28-
specifiers: ["One"]
29-
} as Config
28+
specifiers: ["One"],
29+
} as Config,
3030
},
3131
{
3232
title:
@@ -37,10 +37,10 @@ pluginTester({
3737
pluginOptions: {
3838
module: {
3939
from: "one",
40-
to: "two"
40+
to: "two",
4141
},
42-
specifiers: ["Two"]
43-
} as Config
42+
specifiers: ["Two"],
43+
} as Config,
4444
},
4545
{
4646
title:
@@ -51,10 +51,10 @@ pluginTester({
5151
pluginOptions: {
5252
module: {
5353
from: "one",
54-
to: "two"
54+
to: "two",
5555
},
56-
specifiers: ["One", "Two"]
57-
} as Config
56+
specifiers: ["One", "Two"],
57+
} as Config,
5858
},
5959
{
6060
title:
@@ -65,10 +65,10 @@ pluginTester({
6565
pluginOptions: {
6666
module: {
6767
from: "one",
68-
to: "two"
68+
to: "two",
6969
},
70-
specifiers: ["One", "Two"]
71-
} as Config
70+
specifiers: ["One", "Two"],
71+
} as Config,
7272
},
7373
{
7474
title: "When named to named and imports should be renamed",
@@ -78,13 +78,13 @@ pluginTester({
7878
pluginOptions: {
7979
module: {
8080
from: "one",
81-
to: "two"
81+
to: "two",
8282
},
8383
specifiers: {
8484
One: "OneR",
85-
Two: "TwoR"
86-
}
87-
} as Config
85+
Two: "TwoR",
86+
},
87+
} as Config,
8888
},
8989
{
9090
title:
@@ -95,13 +95,13 @@ pluginTester({
9595
pluginOptions: {
9696
module: {
9797
from: "one",
98-
to: "two"
98+
to: "two",
9999
},
100100
specifiers: {
101101
One: "OneR",
102-
Two: "TwoR"
103-
}
104-
} as Config
102+
Two: "TwoR",
103+
},
104+
} as Config,
105105
},
106106
{
107107
title: "When named to default should change import",
@@ -111,12 +111,12 @@ pluginTester({
111111
pluginOptions: {
112112
module: {
113113
from: "one",
114-
to: "two"
114+
to: "two",
115115
},
116116
specifiers: {
117-
One: "default"
118-
}
119-
} as Config
117+
One: "default",
118+
},
119+
} as Config,
120120
},
121121
{
122122
title: "When wildcard should move all imports",
@@ -126,10 +126,10 @@ pluginTester({
126126
pluginOptions: {
127127
module: {
128128
from: "one",
129-
to: "two"
129+
to: "two",
130130
},
131-
specifiers: ["*"]
132-
} as Config
131+
specifiers: ["*"],
132+
} as Config,
133133
},
134134
{
135135
title: "Should move only default import",
@@ -139,10 +139,10 @@ pluginTester({
139139
pluginOptions: {
140140
module: {
141141
from: "one",
142-
to: "two"
142+
to: "two",
143143
},
144-
specifiers: ["default"]
145-
} as Config
144+
specifiers: ["default"],
145+
} as Config,
146146
},
147147
{
148148
title: "Should move default import and named imports",
@@ -152,10 +152,10 @@ pluginTester({
152152
pluginOptions: {
153153
module: {
154154
from: "one",
155-
to: "two"
155+
to: "two",
156156
},
157-
specifiers: ["default", "One", "Two"]
158-
} as Config
157+
specifiers: ["default", "One", "Two"],
158+
} as Config,
159159
},
160160
{
161161
title: "Should move default to named",
@@ -165,10 +165,10 @@ pluginTester({
165165
pluginOptions: {
166166
module: {
167167
from: "one",
168-
to: "two"
168+
to: "two",
169169
},
170-
specifiers: { default: "One" }
171-
} as Config
170+
specifiers: { default: "One" },
171+
} as Config,
172172
},
173173
{
174174
title: "Should move default to named while keeping others that are left",
@@ -178,10 +178,10 @@ pluginTester({
178178
pluginOptions: {
179179
module: {
180180
from: "one",
181-
to: "two"
181+
to: "two",
182182
},
183-
specifiers: { default: "One" }
184-
} as Config
183+
specifiers: { default: "One" },
184+
} as Config,
185185
},
186186
{
187187
title: "Should move default to named and move others along",
@@ -191,10 +191,10 @@ pluginTester({
191191
pluginOptions: {
192192
module: {
193193
from: "one",
194-
to: "two"
194+
to: "two",
195195
},
196-
specifiers: { default: "One", Two: "Two" }
197-
} as Config
196+
specifiers: { default: "One", Two: "Two" },
197+
} as Config,
198198
},
199199
{
200200
title: "Should move default to default",
@@ -204,10 +204,10 @@ pluginTester({
204204
pluginOptions: {
205205
module: {
206206
from: "one",
207-
to: "two"
207+
to: "two",
208208
},
209-
specifiers: ["default"]
210-
} as Config
209+
specifiers: ["default"],
210+
} as Config,
211211
},
212212
{
213213
title:
@@ -218,12 +218,12 @@ pluginTester({
218218
pluginOptions: {
219219
module: {
220220
from: "one",
221-
to: "two"
221+
to: "two",
222222
},
223-
specifiers: { One: "default", Two: "default" }
223+
specifiers: { One: "default", Two: "default" },
224224
} as Config,
225225
error:
226-
"It's impossible to make two named imports into two defaults! You should only have one 'default' value in your specifiers mapping"
226+
"It's impossible to make two named imports into two defaults! You should only have one 'default' value in your specifiers mapping",
227227
},
228228
{
229229
title: "Should fail when provided with wrong config shape",
@@ -233,12 +233,12 @@ pluginTester({
233233
pluginOptions: {
234234
module: {
235235
from: "one",
236-
to: "two"
236+
to: "two",
237237
},
238-
specifiers: "Wrong"
238+
specifiers: "Wrong",
239239
},
240240
error:
241-
"Wrong specifiers format provided! It should be non-empty object or array."
242-
}
243-
]
241+
"Wrong specifiers format provided! It should be non-empty object or array.",
242+
},
243+
],
244244
});

0 commit comments

Comments
 (0)