Skip to content

Commit 408249c

Browse files
author
Sebastian Silbermann
committed
fixup! fixup! feat: Add deprecated-react-fragment transform
1 parent d9db616 commit 408249c

31 files changed

Lines changed: 153 additions & 150 deletions

bin/__tests__/types-react-codemod.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe("types-react-codemod", () => {
77
const exec = promisify(childProcess.exec);
88
const typesReactCodemodBin = path.join(
99
__dirname,
10-
"../types-react-codemod.cjs"
10+
"../types-react-codemod.cjs",
1111
);
1212
function execTypesReactCodemod(args) {
1313
return exec(`${typesReactCodemodBin} ${args}`, {});

bin/types-react-codemod.cjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ async function main() {
4747
// Ignoring `build`: https://www.digitalocean.com/community/tools/glob?comments=true&glob=%2A%2A%2F%7Bnode_modules%2Cbuild%7D%2F%2A%2A&matches=false&tests=package%2Fnode_modules%2Ftest.js&tests=package%2Fbuild%2Ftest.js&tests=package%2Ftest.js
4848
.example(
4949
'$0 preset-18 ./ --ignore-pattern "**/{node_modules,build}/**"',
50-
"Ignores `node_modules` and `build` folders"
50+
"Ignores `node_modules` and `build` folders",
5151
)
5252
.demandOption(["codemod", "paths"])
5353
);
@@ -57,7 +57,7 @@ async function main() {
5757

5858
// TODO: npx instead?
5959
const jscodeshiftExecutable = require.resolve(
60-
"jscodeshift/bin/jscodeshift.js"
60+
"jscodeshift/bin/jscodeshift.js",
6161
);
6262

6363
/**
@@ -120,7 +120,7 @@ async function main() {
120120
const command = `node ${jscodeshiftExecutable} ${args.join(" ")}`;
121121
console.info(`executing "${command}"`);
122122
childProcess.execSync(command, { stdio: "inherit" });
123-
}
123+
},
124124
)
125125
.version()
126126
.strict(true)

transforms/__tests__/context-any.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ describe("transform context-any", () => {
1515
expect(
1616
applyTransform(`
1717
class A extends React.Component {}
18-
`)
18+
`),
1919
).toMatchInlineSnapshot(`"class A extends React.Component {}"`);
2020
});
2121

2222
test("empty pure component", () => {
2323
expect(
2424
applyTransform(`
2525
class A extends React.PureComponent {}
26-
`)
26+
`),
2727
).toMatchInlineSnapshot(`"class A extends React.PureComponent {}"`);
2828
});
2929

@@ -36,7 +36,7 @@ describe("transform context-any", () => {
3636
return this.context.value;
3737
}
3838
}
39-
`)
39+
`),
4040
).toMatchInlineSnapshot(`
4141
"class A extends React.Component {
4242
context: any
@@ -55,7 +55,7 @@ describe("transform context-any", () => {
5555
return this.context.value;
5656
}
5757
}
58-
`)
58+
`),
5959
).toMatchInlineSnapshot(`
6060
"class A extends PureComponent {
6161
context: any;
@@ -74,7 +74,7 @@ describe("transform context-any", () => {
7474
return this.context.value;
7575
}
7676
}
77-
`)
77+
`),
7878
).toMatchInlineSnapshot(`
7979
"class A extends React.Component {
8080
context: any;
@@ -94,7 +94,7 @@ describe("transform context-any", () => {
9494
return this.context.value;
9595
}
9696
}
97-
`)
97+
`),
9898
).toMatchInlineSnapshot(`
9999
"class A extends React.Component {}
100100
class B extends A {
@@ -113,7 +113,7 @@ describe("transform context-any", () => {
113113
return this.context.value;
114114
}
115115
}
116-
`)
116+
`),
117117
).toMatchInlineSnapshot(`
118118
"class Component {
119119
render() {

transforms/__tests__/deprecated-react-child.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function applyTransform(source, options = {}) {
1010
{
1111
path: "test.d.ts",
1212
source: dedent(source),
13-
}
13+
},
1414
);
1515
}
1616

@@ -22,7 +22,7 @@ describe("transform deprecated-react-child", () => {
2222
interface Props {
2323
children?: ReactNode;
2424
}
25-
`)
25+
`),
2626
).toMatchInlineSnapshot(`
2727
"import * as React from 'react';
2828
interface Props {
@@ -38,7 +38,7 @@ describe("transform deprecated-react-child", () => {
3838
interface Props {
3939
children?: ReactChild;
4040
}
41-
`)
41+
`),
4242
).toMatchInlineSnapshot(`
4343
"import { ReactChild } from 'react';
4444
interface Props {
@@ -54,7 +54,7 @@ describe("transform deprecated-react-child", () => {
5454
interface Props {
5555
children?: MyReactChild;
5656
}
57-
`)
57+
`),
5858
).toMatchInlineSnapshot(`
5959
"import { ReactChild as MyReactChild } from 'react';
6060
interface Props {
@@ -70,7 +70,7 @@ describe("transform deprecated-react-child", () => {
7070
interface Props {
7171
children?: React.ReactChild;
7272
}
73-
`)
73+
`),
7474
).toMatchInlineSnapshot(`
7575
"import * as React from 'react';
7676
interface Props {

transforms/__tests__/deprecated-react-fragment.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function applyTransform(source, options = {}) {
1010
{
1111
path: "test.d.ts",
1212
source: dedent(source),
13-
}
13+
},
1414
);
1515
}
1616

@@ -22,7 +22,7 @@ describe("transform deprecated-react-node-array", () => {
2222
interface Props {
2323
children?: ReactNode;
2424
}
25-
`)
25+
`),
2626
).toMatchInlineSnapshot(`
2727
"import * as React from 'react';
2828
interface Props {
@@ -38,7 +38,7 @@ describe("transform deprecated-react-node-array", () => {
3838
interface Props {
3939
children?: ReactFragment;
4040
}
41-
`)
41+
`),
4242
).toMatchInlineSnapshot(`
4343
"import { ReactNode } from 'react';
4444
interface Props {
@@ -54,7 +54,7 @@ describe("transform deprecated-react-node-array", () => {
5454
interface Props {
5555
children?: ReactFragment;
5656
}
57-
`)
57+
`),
5858
).toMatchInlineSnapshot(`
5959
"import { ReactNode } from 'react';
6060
interface Props {
@@ -70,7 +70,7 @@ describe("transform deprecated-react-node-array", () => {
7070
interface Props {
7171
children?: MyReactFragment;
7272
}
73-
`)
73+
`),
7474
).toMatchInlineSnapshot(`
7575
"import { ReactFragment as MyReactFragment } from 'react';
7676
interface Props {
@@ -86,7 +86,7 @@ describe("transform deprecated-react-node-array", () => {
8686
interface Props {
8787
children?: React.ReactFragment;
8888
}
89-
`)
89+
`),
9090
).toMatchInlineSnapshot(`
9191
"import * as React from 'react';
9292
interface Props {

transforms/__tests__/deprecated-react-node-array.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function applyTransform(source, options = {}) {
1010
{
1111
path: "test.d.ts",
1212
source: dedent(source),
13-
}
13+
},
1414
);
1515
}
1616

@@ -22,7 +22,7 @@ describe("transform deprecated-react-node-array", () => {
2222
interface Props {
2323
children?: ReactNode;
2424
}
25-
`)
25+
`),
2626
).toMatchInlineSnapshot(`
2727
"import * as React from 'react';
2828
interface Props {
@@ -38,7 +38,7 @@ describe("transform deprecated-react-node-array", () => {
3838
interface Props {
3939
children?: ReactNodeArray;
4040
}
41-
`)
41+
`),
4242
).toMatchInlineSnapshot(`
4343
"import { ReactNode } from 'react';
4444
interface Props {
@@ -54,7 +54,7 @@ describe("transform deprecated-react-node-array", () => {
5454
interface Props {
5555
children?: ReactNodeArray;
5656
}
57-
`)
57+
`),
5858
).toMatchInlineSnapshot(`
5959
"import { ReactNode } from 'react';
6060
interface Props {
@@ -70,7 +70,7 @@ describe("transform deprecated-react-node-array", () => {
7070
interface Props {
7171
children?: MyReactNodeArray;
7272
}
73-
`)
73+
`),
7474
).toMatchInlineSnapshot(`
7575
"import { ReactNodeArray as MyReactNodeArray } from 'react';
7676
interface Props {
@@ -86,7 +86,7 @@ describe("transform deprecated-react-node-array", () => {
8686
interface Props {
8787
children?: React.ReactNodeArray;
8888
}
89-
`)
89+
`),
9090
).toMatchInlineSnapshot(`
9191
"import * as React from 'react';
9292
interface Props {

transforms/__tests__/deprecated-react-text.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function applyTransform(source, options = {}) {
1010
{
1111
path: "test.d.ts",
1212
source: dedent(source),
13-
}
13+
},
1414
);
1515
}
1616

@@ -22,7 +22,7 @@ describe("transform deprecated-react-text", () => {
2222
interface Props {
2323
children?: ReactNode;
2424
}
25-
`)
25+
`),
2626
).toMatchInlineSnapshot(`
2727
"import * as React from 'react';
2828
interface Props {
@@ -38,7 +38,7 @@ describe("transform deprecated-react-text", () => {
3838
interface Props {
3939
children?: ReactText;
4040
}
41-
`)
41+
`),
4242
).toMatchInlineSnapshot(`
4343
"import { ReactText } from 'react';
4444
interface Props {
@@ -54,7 +54,7 @@ describe("transform deprecated-react-text", () => {
5454
interface Props {
5555
children?: MyReactText;
5656
}
57-
`)
57+
`),
5858
).toMatchInlineSnapshot(`
5959
"import { ReactText as MyReactText } from 'react';
6060
interface Props {
@@ -70,7 +70,7 @@ describe("transform deprecated-react-text", () => {
7070
interface Props {
7171
children?: React.ReactText;
7272
}
73-
`)
73+
`),
7474
).toMatchInlineSnapshot(`
7575
"import * as React from 'react';
7676
interface Props {

transforms/__tests__/deprecated-react-type.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function applyTransform(source, options = {}) {
1010
{
1111
path: "test.d.ts",
1212
source: dedent(source),
13-
}
13+
},
1414
);
1515
}
1616

@@ -20,7 +20,7 @@ describe("transform deprecated-react-type", () => {
2020
applyTransform(`
2121
import { ElementType } from 'react';
2222
ElementType;
23-
`)
23+
`),
2424
).toMatchInlineSnapshot(`
2525
"import { ElementType } from 'react';
2626
ElementType;"
@@ -32,7 +32,7 @@ describe("transform deprecated-react-type", () => {
3232
applyTransform(`
3333
import { ReactType } from 'react';
3434
ReactType;
35-
`)
35+
`),
3636
).toMatchInlineSnapshot(`
3737
"import { ElementType } from 'react';
3838
ElementType;"
@@ -44,7 +44,7 @@ describe("transform deprecated-react-type", () => {
4444
applyTransform(`
4545
import { ReactType as MyReactType } from 'react';
4646
MyReactType;
47-
`)
47+
`),
4848
).toMatchInlineSnapshot(`
4949
"import { ElementType as MyReactType } from 'react';
5050
MyReactType;"
@@ -56,7 +56,7 @@ describe("transform deprecated-react-type", () => {
5656
applyTransform(`
5757
import * as React from 'react';
5858
React.ReactType;
59-
`)
59+
`),
6060
).toMatchInlineSnapshot(`
6161
"import * as React from 'react';
6262
React.ElementType;"
@@ -68,7 +68,7 @@ describe("transform deprecated-react-type", () => {
6868
applyTransform(`
6969
import * as Preact from 'preact';
7070
Preact.ReactType;
71-
`)
71+
`),
7272
).toMatchInlineSnapshot(`
7373
"import * as Preact from 'preact';
7474
Preact.ElementType;"

0 commit comments

Comments
 (0)