@openrewrite/recipes-react 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/migration/change-component-prop-value.d.ts.map +1 -1
- package/dist/migration/change-component-prop-value.js +2 -2
- package/dist/migration/change-component-prop-value.js.map +1 -1
- package/dist/react-native/view-prop-types.d.ts.map +1 -1
- package/dist/react-native/view-prop-types.js +2 -2
- package/dist/react-native/view-prop-types.js.map +1 -1
- package/dist/react16/error-boundaries.d.ts.map +1 -1
- package/dist/react16/error-boundaries.js +2 -2
- package/dist/react16/error-boundaries.js.map +1 -1
- package/dist/react16/find-dom-node.d.ts.map +1 -1
- package/dist/react16/find-dom-node.js +2 -2
- package/dist/react16/find-dom-node.js.map +1 -1
- package/dist/react16/react-dom-factories.d.ts.map +1 -1
- package/dist/react16/react-dom-factories.js +2 -2
- package/dist/react16/react-dom-factories.js.map +1 -1
- package/dist/react16/react-prop-types.d.ts.map +1 -1
- package/dist/react16/react-prop-types.js +2 -2
- package/dist/react16/react-prop-types.js.map +1 -1
- package/dist/react16/react-to-react-dom.d.ts.map +1 -1
- package/dist/react16/react-to-react-dom.js +2 -2
- package/dist/react16/react-to-react-dom.js.map +1 -1
- package/dist/react16/replace-create-factory.d.ts.map +1 -1
- package/dist/react16/replace-create-factory.js +2 -2
- package/dist/react16/replace-create-factory.js.map +1 -1
- package/dist/react17/remove-event-persist.d.ts.map +1 -1
- package/dist/react17/remove-event-persist.js +2 -2
- package/dist/react17/remove-event-persist.js.map +1 -1
- package/dist/react17/rename-unsafe-lifecycles.d.ts.map +1 -1
- package/dist/react17/rename-unsafe-lifecycles.js +2 -2
- package/dist/react17/rename-unsafe-lifecycles.js.map +1 -1
- package/dist/react17/update-react-imports.d.ts.map +1 -1
- package/dist/react17/update-react-imports.js +2 -2
- package/dist/react17/update-react-imports.js.map +1 -1
- package/dist/react18/remove-unstable-batched-updates.d.ts.map +1 -1
- package/dist/react18/remove-unstable-batched-updates.js +2 -2
- package/dist/react18/remove-unstable-batched-updates.js.map +1 -1
- package/dist/react18/replace-reactdom-render.d.ts.map +1 -1
- package/dist/react18/replace-reactdom-render.js +2 -2
- package/dist/react18/replace-reactdom-render.js.map +1 -1
- package/dist/react18/replace-render-callback.d.ts.map +1 -1
- package/dist/react18/replace-render-callback.js +2 -2
- package/dist/react18/replace-render-callback.js.map +1 -1
- package/dist/react18/replace-unmount-component-at-node.d.ts.map +1 -1
- package/dist/react18/replace-unmount-component-at-node.js +2 -2
- package/dist/react18/replace-unmount-component-at-node.js.map +1 -1
- package/dist/react19/deprecated-react-types.d.ts.map +1 -1
- package/dist/react19/deprecated-react-types.js +2 -2
- package/dist/react19/deprecated-react-types.js.map +1 -1
- package/dist/react19/find-context-consumer.d.ts.map +1 -1
- package/dist/react19/find-context-consumer.js +2 -2
- package/dist/react19/find-context-consumer.js.map +1 -1
- package/dist/react19/find-deprecated-reactdom-apis.d.ts.map +1 -1
- package/dist/react19/find-deprecated-reactdom-apis.js +2 -2
- package/dist/react19/find-deprecated-reactdom-apis.js.map +1 -1
- package/dist/react19/find-element-ref.d.ts.map +1 -1
- package/dist/react19/find-element-ref.js +2 -2
- package/dist/react19/find-element-ref.js.map +1 -1
- package/dist/react19/find-legacy-context-api.d.ts.map +1 -1
- package/dist/react19/find-legacy-context-api.js +2 -2
- package/dist/react19/find-legacy-context-api.js.map +1 -1
- package/dist/react19/no-implicit-ref-callback-return.d.ts.map +1 -1
- package/dist/react19/no-implicit-ref-callback-return.js +2 -2
- package/dist/react19/no-implicit-ref-callback-return.js.map +1 -1
- package/dist/react19/remove-context-provider.d.ts.map +1 -1
- package/dist/react19/remove-context-provider.js +2 -2
- package/dist/react19/remove-context-provider.js.map +1 -1
- package/dist/react19/remove-forward-ref.d.ts.map +1 -1
- package/dist/react19/remove-forward-ref.js +2 -2
- package/dist/react19/remove-forward-ref.js.map +1 -1
- package/dist/react19/remove-prop-types.d.ts.map +1 -1
- package/dist/react19/remove-prop-types.js +2 -2
- package/dist/react19/remove-prop-types.js.map +1 -1
- package/dist/react19/remove-react-fc.d.ts.map +1 -1
- package/dist/react19/remove-react-fc.js +2 -2
- package/dist/react19/remove-react-fc.js.map +1 -1
- package/dist/react19/replace-act-import.d.ts.map +1 -1
- package/dist/react19/replace-act-import.js +1 -1
- package/dist/react19/replace-act-import.js.map +1 -1
- package/dist/react19/replace-default-props.d.ts.map +1 -1
- package/dist/react19/replace-default-props.js +2 -2
- package/dist/react19/replace-default-props.js.map +1 -1
- package/dist/react19/replace-react-shallow-renderer.d.ts.map +1 -1
- package/dist/react19/replace-react-shallow-renderer.js +2 -2
- package/dist/react19/replace-react-shallow-renderer.js.map +1 -1
- package/dist/react19/replace-reactdom-hydrate.d.ts.map +1 -1
- package/dist/react19/replace-reactdom-hydrate.js +2 -2
- package/dist/react19/replace-reactdom-hydrate.js.map +1 -1
- package/dist/react19/replace-string-ref.d.ts.map +1 -1
- package/dist/react19/replace-string-ref.js +2 -2
- package/dist/react19/replace-string-ref.js.map +1 -1
- package/dist/react19/replace-use-form-state.d.ts.map +1 -1
- package/dist/react19/replace-use-form-state.js +2 -2
- package/dist/react19/replace-use-form-state.js.map +1 -1
- package/dist/react19/scoped-jsx-namespace.d.ts.map +1 -1
- package/dist/react19/scoped-jsx-namespace.js +2 -2
- package/dist/react19/scoped-jsx-namespace.js.map +1 -1
- package/dist/react19/use-context-hook.d.ts.map +1 -1
- package/dist/react19/use-context-hook.js +2 -2
- package/dist/react19/use-context-hook.js.map +1 -1
- package/dist/react19/use-ref-required-initial.d.ts.map +1 -1
- package/dist/react19/use-ref-required-initial.js +2 -2
- package/dist/react19/use-ref-required-initial.js.map +1 -1
- package/dist/refactoring/class-to-functional.d.ts.map +1 -1
- package/dist/refactoring/class-to-functional.js +2 -2
- package/dist/refactoring/class-to-functional.js.map +1 -1
- package/dist/refactoring/create-class-to-es6.d.ts.map +1 -1
- package/dist/refactoring/create-class-to-es6.js +164 -32
- package/dist/refactoring/create-class-to-es6.js.map +1 -1
- package/dist/refactoring/create-element-to-jsx.d.ts.map +1 -1
- package/dist/refactoring/create-element-to-jsx.js +2 -2
- package/dist/refactoring/create-element-to-jsx.js.map +1 -1
- package/dist/refactoring/manual-bind-to-arrow.d.ts.map +1 -1
- package/dist/refactoring/manual-bind-to-arrow.js +2 -2
- package/dist/refactoring/manual-bind-to-arrow.js.map +1 -1
- package/dist/refactoring/pure-render-mixin.d.ts.map +1 -1
- package/dist/refactoring/pure-render-mixin.js +22 -16
- package/dist/refactoring/pure-render-mixin.js.map +1 -1
- package/dist/refactoring/sort-comp.d.ts.map +1 -1
- package/dist/refactoring/sort-comp.js +2 -2
- package/dist/refactoring/sort-comp.js.map +1 -1
- package/dist/search/find-hook-usage.d.ts.map +1 -1
- package/dist/search/find-hook-usage.js +2 -2
- package/dist/search/find-hook-usage.js.map +1 -1
- package/dist/search/find-prop-usage.d.ts.map +1 -1
- package/dist/search/find-prop-usage.js +2 -2
- package/dist/search/find-prop-usage.js.map +1 -1
- package/dist/search/find-react-component.d.ts.map +1 -1
- package/dist/search/find-react-component.js +2 -2
- package/dist/search/find-react-component.js.map +1 -1
- package/dist/search/find-server-rendering-usage.d.ts.map +1 -1
- package/dist/search/find-server-rendering-usage.js +2 -2
- package/dist/search/find-server-rendering-usage.js.map +1 -1
- package/dist/simplify-object-pattern-property.d.ts.map +1 -1
- package/dist/simplify-object-pattern-property.js +2 -2
- package/dist/simplify-object-pattern-property.js.map +1 -1
- package/dist/simplify-react-imports.d.ts.map +1 -1
- package/dist/simplify-react-imports.js +2 -2
- package/dist/simplify-react-imports.js.map +1 -1
- package/package.json +2 -2
- package/src/migration/change-component-prop-value.ts +4 -4
- package/src/react-native/view-prop-types.ts +4 -4
- package/src/react16/error-boundaries.ts +4 -4
- package/src/react16/find-dom-node.ts +5 -4
- package/src/react16/react-dom-factories.ts +5 -4
- package/src/react16/react-prop-types.ts +4 -5
- package/src/react16/react-to-react-dom.ts +4 -6
- package/src/react16/replace-create-factory.ts +4 -12
- package/src/react17/remove-event-persist.ts +4 -4
- package/src/react17/rename-unsafe-lifecycles.ts +4 -4
- package/src/react17/update-react-imports.ts +4 -4
- package/src/react18/remove-unstable-batched-updates.ts +4 -4
- package/src/react18/replace-reactdom-render.ts +5 -4
- package/src/react18/replace-render-callback.ts +4 -4
- package/src/react18/replace-unmount-component-at-node.ts +5 -4
- package/src/react19/deprecated-react-types.ts +4 -4
- package/src/react19/find-context-consumer.ts +4 -4
- package/src/react19/find-deprecated-reactdom-apis.ts +4 -4
- package/src/react19/find-element-ref.ts +4 -4
- package/src/react19/find-legacy-context-api.ts +4 -4
- package/src/react19/no-implicit-ref-callback-return.ts +4 -4
- package/src/react19/remove-context-provider.ts +5 -4
- package/src/react19/remove-forward-ref.ts +7 -4
- package/src/react19/remove-prop-types.ts +4 -4
- package/src/react19/remove-react-fc.ts +5 -4
- package/src/react19/replace-act-import.ts +3 -3
- package/src/react19/replace-default-props.ts +4 -4
- package/src/react19/replace-react-shallow-renderer.ts +4 -4
- package/src/react19/replace-reactdom-hydrate.ts +5 -4
- package/src/react19/replace-string-ref.ts +4 -4
- package/src/react19/replace-use-form-state.ts +5 -4
- package/src/react19/scoped-jsx-namespace.ts +4 -4
- package/src/react19/use-context-hook.ts +7 -4
- package/src/react19/use-ref-required-initial.ts +4 -4
- package/src/refactoring/class-to-functional.ts +4 -4
- package/src/refactoring/create-class-to-es6.ts +222 -37
- package/src/refactoring/create-element-to-jsx.ts +4 -4
- package/src/refactoring/manual-bind-to-arrow.ts +4 -4
- package/src/refactoring/pure-render-mixin.ts +30 -22
- package/src/refactoring/sort-comp.ts +4 -4
- package/src/search/find-hook-usage.ts +4 -4
- package/src/search/find-prop-usage.ts +4 -4
- package/src/search/find-react-component.ts +4 -4
- package/src/search/find-server-rendering-usage.ts +4 -4
- package/src/simplify-object-pattern-property.ts +4 -4
- package/src/simplify-react-imports.ts +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simplify-object-pattern-property.js","sourceRoot":"","sources":["../src/simplify-object-pattern-property.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"simplify-object-pattern-property.js","sourceRoot":"","sources":["../src/simplify-object-pattern-property.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAuF;AACvF,gEAA2F;AAC3F,oDAA4C;AAC5C,uCAAgC;AAUhC,MAAa,6BAA8B,SAAQ,gBAAM;IAAzD;;QACa,SAAI,GAAG,qEAAqE,CAAC;QAC7E,gBAAW,GAAW,oCAAoC,CAAC;QAC3D,gBAAW,GAAW,qIAAqI,CAAC;IA0DzK,CAAC;IAxDS,MAAM;;YACR,OAAO,IAAA,eAAK,EAAC,IAAA,aAAG,EAAC,IAAA,gCAAmB,GAAE,CAAC,EAAE,IAAI,KAAM,SAAQ,8BAAmC;gBAC1E,yBAAyB,CAAC,OAAgC,EAAE,CAAmB;;;;;wBAE3F,MAAM,OAAO,GAAG,MAAM,OAAM,yBAAyB,YAAC,OAAO,EAAE,CAAC,CAA4B,CAAC;wBAG7F,MAAM,kBAAkB,GAAG,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;4BAC7D,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;4BAG9B,IAAI,OAAO,CAAC,IAAI,KAAK,eAAE,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;gCAC1C,MAAM,OAAO,GAAG,OAA4B,CAAC;gCAG7C,IAAI,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,KAAK,QAAC,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;oCAClF,MAAM,QAAQ,GAAI,OAAO,CAAC,YAAY,CAAC,OAAwB,CAAC,UAAU,CAAC;oCAG3E,IAAI,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,QAAC,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;wCAC1D,MAAM,cAAc,GAAI,OAAO,CAAC,IAAqB,CAAC,UAAU,CAAC;wCAGjE,IAAI,QAAQ,KAAK,cAAc,EAAE,CAAC;4CAG9B,OAAO,gCACA,KAAK,KACR,OAAO,kCACA,OAAO,KACV,YAAY,EAAE,SAAS,EACvB,IAAI,kCACG,OAAO,CAAC,IAAI,KACf,MAAM,EAAE,OAAO,CAAC,YAAa,CAAC,OAAO,CAAC,MAAM,SAGnB,CAAC;wCAC1C,CAAC;oCACL,CAAC;gCACL,CAAC;4BACL,CAAC;4BAED,OAAO,KAAK,CAAC;wBACjB,CAAC,CAAC,CAAC;wBAEH,IAAI,kBAAkB,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;4BACrF,OAAO,OAAO,CAAC;wBACnB,CAAC;wBAGD,OAAO,IAAA,iBAAM,EAAC,OAAO,EAAE,KAAK,CAAC,EAAE;4BAC3B,KAAK,CAAC,QAAQ,CAAC,QAAQ,GAAG,kBAAkB,CAAC;wBACjD,CAAC,CAAC,CAAC;oBACP,CAAC;iBAAA;aACJ,EAAE,CAAC,CAAC;QACT,CAAC;KAAA;CACJ;AA7DD,sEA6DC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simplify-react-imports.d.ts","sourceRoot":"","sources":["../src/simplify-react-imports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,MAAM,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"simplify-react-imports.d.ts","sourceRoot":"","sources":["../src/simplify-react-imports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAa,MAAM,sBAAsB,CAAC;AA+FvF,qBAAa,oBAAqB,SAAQ,MAAM;IAC5C,QAAQ,CAAC,IAAI,kDAAkD;IAC/D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAA4C;IACxE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAA+G;IAErI,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CA4I9D"}
|
|
@@ -75,7 +75,7 @@ class SimplifyReactImports extends rewrite_1.Recipe {
|
|
|
75
75
|
}
|
|
76
76
|
editor() {
|
|
77
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
return new class extends javascript_1.JavaScriptVisitor {
|
|
78
|
+
return (0, rewrite_1.check)((0, rewrite_1.not)((0, javascript_1.isVendoredOrBundled)()), new class extends javascript_1.JavaScriptVisitor {
|
|
79
79
|
constructor() {
|
|
80
80
|
super(...arguments);
|
|
81
81
|
this.usedExports = new Set();
|
|
@@ -191,7 +191,7 @@ class SimplifyReactImports extends rewrite_1.Recipe {
|
|
|
191
191
|
return identifier;
|
|
192
192
|
});
|
|
193
193
|
}
|
|
194
|
-
}();
|
|
194
|
+
}());
|
|
195
195
|
});
|
|
196
196
|
}
|
|
197
197
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simplify-react-imports.js","sourceRoot":"","sources":["../src/simplify-react-imports.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"simplify-react-imports.js","sourceRoot":"","sources":["../src/simplify-react-imports.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAuF;AACvF,gEAAuG;AACvG,oDAA4C;AAC5C,gEAAmD;AAMnD,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IAE1B,UAAU;IACV,WAAW;IACX,YAAY;IACZ,YAAY;IACZ,aAAa;IACb,SAAS;IACT,QAAQ;IACR,qBAAqB;IACrB,iBAAiB;IACjB,eAAe;IACf,kBAAkB;IAClB,eAAe;IACf,OAAO;IACP,sBAAsB;IACtB,oBAAoB;IAEpB,gBAAgB;I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T,CAAC;KAAA;CACJ;AAjJD,oDAiJC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openrewrite/recipes-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"license": "Moderne Source Available License",
|
|
5
5
|
"description": "OpenRewrite recipes for React.",
|
|
6
6
|
"homepage": "https://github.com/openrewrite/rewrite",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"ci:test": "NODE_OPTIONS=--max-old-space-size=6144 vitest run"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@openrewrite/rewrite": "^8.
|
|
27
|
+
"@openrewrite/rewrite": "^8.97.1",
|
|
28
28
|
"mutative": "^1.1.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {ExecutionContext, Option, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
2
|
-
import {JavaScriptVisitor, JS, JSX} from "@openrewrite/rewrite/javascript";
|
|
1
|
+
import {ExecutionContext, Option, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
+
import {JavaScriptVisitor, JS, JSX, isVendoredOrBundled} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {J, isIdentifier} from "@openrewrite/rewrite/java";
|
|
4
4
|
import {create} from "mutative";
|
|
5
5
|
|
|
@@ -134,7 +134,7 @@ export class ChangeComponentPropValue extends Recipe {
|
|
|
134
134
|
matcher = (value: string) => value === oldValue ? newValue : null;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
137
|
+
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
138
138
|
// FIXME: This manual import tracking should be removed once type attribution preserves
|
|
139
139
|
// module/package origin information. Currently, JSX element types show as generic
|
|
140
140
|
// function types (𝑓) without preserving where they were imported from. Ideally, we
|
|
@@ -263,6 +263,6 @@ export class ChangeComponentPropValue extends Recipe {
|
|
|
263
263
|
|
|
264
264
|
return null;
|
|
265
265
|
}
|
|
266
|
-
}();
|
|
266
|
+
}());
|
|
267
267
|
}
|
|
268
268
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
2
|
-
import {JavaScriptVisitor, maybeAddImport, maybeRemoveImport} from "@openrewrite/rewrite/javascript";
|
|
1
|
+
import {ExecutionContext, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
+
import {JavaScriptVisitor, maybeAddImport, maybeRemoveImport, isVendoredOrBundled} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {J} from "@openrewrite/rewrite/java";
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -28,7 +28,7 @@ export class ViewPropTypes extends Recipe {
|
|
|
28
28
|
readonly description: string = "Migrates deprecated `View.propTypes` references to `ViewPropTypes` from `deprecated-react-native-prop-types`.";
|
|
29
29
|
|
|
30
30
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
31
|
-
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
31
|
+
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
32
32
|
private transformed = false;
|
|
33
33
|
|
|
34
34
|
override async visitJsCompilationUnit(cu: any, ctx: ExecutionContext): Promise<J | undefined> {
|
|
@@ -58,6 +58,6 @@ export class ViewPropTypes extends Recipe {
|
|
|
58
58
|
prefix: fa.prefix
|
|
59
59
|
} as J.Identifier;
|
|
60
60
|
}
|
|
61
|
-
}();
|
|
61
|
+
}());
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
2
|
-
import {JavaScriptVisitor} from "@openrewrite/rewrite/javascript";
|
|
1
|
+
import {ExecutionContext, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
+
import {JavaScriptVisitor, isVendoredOrBundled} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {J} from "@openrewrite/rewrite/java";
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -30,7 +30,7 @@ export class ErrorBoundaries extends Recipe {
|
|
|
30
30
|
readonly description: string = "Renames the unstable error boundary method to the official `componentDidCatch` API introduced in React 16.";
|
|
31
31
|
|
|
32
32
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
33
|
-
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
33
|
+
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
34
34
|
override async visitIdentifier(ident: J.Identifier, ctx: ExecutionContext): Promise<J | undefined> {
|
|
35
35
|
let id = await super.visitIdentifier(ident, ctx) as J.Identifier;
|
|
36
36
|
|
|
@@ -43,6 +43,6 @@ export class ErrorBoundaries extends Recipe {
|
|
|
43
43
|
|
|
44
44
|
return id;
|
|
45
45
|
}
|
|
46
|
-
}();
|
|
46
|
+
}());
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
1
|
+
import {ExecutionContext, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
2
|
import {
|
|
3
3
|
capture,
|
|
4
4
|
JavaScriptVisitor,
|
|
5
5
|
pattern,
|
|
6
6
|
rewrite,
|
|
7
|
-
template
|
|
7
|
+
template,
|
|
8
|
+
isVendoredOrBundled
|
|
8
9
|
} from "@openrewrite/rewrite/javascript";
|
|
9
10
|
import {Expression, J} from "@openrewrite/rewrite/java";
|
|
10
11
|
|
|
@@ -41,7 +42,7 @@ export class FindDomNode extends Recipe {
|
|
|
41
42
|
after: template`React.findDOMNode(${target})`
|
|
42
43
|
}));
|
|
43
44
|
|
|
44
|
-
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
45
|
+
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
45
46
|
override async visitMethodInvocation(method: J.MethodInvocation, p: ExecutionContext): Promise<J | undefined> {
|
|
46
47
|
let m = await super.visitMethodInvocation(method, p) as J.MethodInvocation;
|
|
47
48
|
|
|
@@ -52,6 +53,6 @@ export class FindDomNode extends Recipe {
|
|
|
52
53
|
|
|
53
54
|
return m;
|
|
54
55
|
}
|
|
55
|
-
}();
|
|
56
|
+
}());
|
|
56
57
|
}
|
|
57
58
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {emptyMarkers, ExecutionContext, randomId, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
1
|
+
import {emptyMarkers, ExecutionContext, randomId, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
2
|
import {
|
|
3
3
|
capture,
|
|
4
4
|
JavaScriptVisitor,
|
|
5
5
|
pattern,
|
|
6
6
|
rewrite,
|
|
7
|
-
template
|
|
7
|
+
template,
|
|
8
|
+
isVendoredOrBundled
|
|
8
9
|
} from "@openrewrite/rewrite/javascript";
|
|
9
10
|
import {emptySpace, J, rightPadded, singleSpace, Type} from "@openrewrite/rewrite/java";
|
|
10
11
|
|
|
@@ -31,7 +32,7 @@ export class ReactDomFactories extends Recipe {
|
|
|
31
32
|
readonly description: string = "Converts deprecated `React.DOM.xxx()` factory calls to `React.createElement('xxx', ...)`.";
|
|
32
33
|
|
|
33
34
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
34
|
-
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
35
|
+
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
35
36
|
override async visitMethodInvocation(method: J.MethodInvocation, p: ExecutionContext): Promise<J | undefined> {
|
|
36
37
|
let m = await super.visitMethodInvocation(method, p) as J.MethodInvocation;
|
|
37
38
|
|
|
@@ -98,6 +99,6 @@ export class ReactDomFactories extends Recipe {
|
|
|
98
99
|
}
|
|
99
100
|
} as any as J.MethodInvocation;
|
|
100
101
|
}
|
|
101
|
-
}();
|
|
102
|
+
}());
|
|
102
103
|
}
|
|
103
104
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
2
|
-
import {JavaScriptVisitor, maybeAddImport, maybeRemoveImport} from "@openrewrite/rewrite/javascript";
|
|
1
|
+
import {ExecutionContext, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
+
import {JavaScriptVisitor, maybeAddImport, maybeRemoveImport, isVendoredOrBundled} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {J} from "@openrewrite/rewrite/java";
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -32,13 +32,12 @@ export class ReactPropTypes extends Recipe {
|
|
|
32
32
|
readonly description: string = "Extracts PropTypes usage from the React namespace to the separate `prop-types` package introduced in React 15.5.";
|
|
33
33
|
|
|
34
34
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
35
|
-
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
35
|
+
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
36
36
|
private transformed = false;
|
|
37
37
|
|
|
38
38
|
override async visitFieldAccess(fieldAccess: J.FieldAccess, ctx: ExecutionContext): Promise<J | undefined> {
|
|
39
39
|
let fa = await super.visitFieldAccess(fieldAccess, ctx) as J.FieldAccess;
|
|
40
40
|
|
|
41
|
-
// Match React.PropTypes
|
|
42
41
|
if (fa.target.kind !== J.Kind.Identifier) {
|
|
43
42
|
return fa;
|
|
44
43
|
}
|
|
@@ -71,6 +70,6 @@ export class ReactPropTypes extends Recipe {
|
|
|
71
70
|
}
|
|
72
71
|
return result;
|
|
73
72
|
}
|
|
74
|
-
}();
|
|
73
|
+
}());
|
|
75
74
|
}
|
|
76
75
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
2
|
-
import {JavaScriptVisitor, maybeAddImport} from "@openrewrite/rewrite/javascript";
|
|
1
|
+
import {ExecutionContext, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
+
import {JavaScriptVisitor, maybeAddImport, isVendoredOrBundled} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {J} from "@openrewrite/rewrite/java";
|
|
4
|
-
import {JS} from "@openrewrite/rewrite/javascript";
|
|
5
4
|
|
|
6
5
|
const SERVER_METHODS = new Set(['renderToString', 'renderToStaticMarkup']);
|
|
7
6
|
|
|
@@ -39,7 +38,7 @@ export class ReactToReactDom extends Recipe {
|
|
|
39
38
|
readonly description: string = "Moves DOM-specific methods like `React.render()` and `React.findDOMNode()` to `ReactDOM` from the `react-dom` package.";
|
|
40
39
|
|
|
41
40
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
42
|
-
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
41
|
+
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
43
42
|
private destination(methodName: string): string | undefined {
|
|
44
43
|
return SERVER_METHODS.has(methodName)
|
|
45
44
|
? maybeAddImport(this, {module: 'react-dom/server', member: '*', preferredName: 'ReactDOMServer', onlyIfReferenced: false})
|
|
@@ -62,7 +61,6 @@ export class ReactToReactDom extends Recipe {
|
|
|
62
61
|
const replacement = this.destination(methodName);
|
|
63
62
|
if (!replacement) return fa;
|
|
64
63
|
|
|
65
|
-
// Replace React with ReactDOM
|
|
66
64
|
return {
|
|
67
65
|
...fa,
|
|
68
66
|
target: {
|
|
@@ -96,6 +94,6 @@ export class ReactToReactDom extends Recipe {
|
|
|
96
94
|
}
|
|
97
95
|
} as any as J.MethodInvocation;
|
|
98
96
|
}
|
|
99
|
-
}();
|
|
97
|
+
}());
|
|
100
98
|
}
|
|
101
99
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
2
|
-
import {JavaScriptVisitor, JS} from "@openrewrite/rewrite/javascript";
|
|
1
|
+
import {ExecutionContext, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
+
import {JavaScriptVisitor, JS, isVendoredOrBundled} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {J, singleSpace} from "@openrewrite/rewrite/java";
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -26,7 +26,7 @@ export class ReplaceCreateFactory extends Recipe {
|
|
|
26
26
|
readonly description: string = "Replaces `React.createFactory(type)(props, children)` with `React.createElement(type, props, children)`. React.createFactory was deprecated in React 15.6 and removed in React 16.";
|
|
27
27
|
|
|
28
28
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
29
|
-
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
29
|
+
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
30
30
|
override async visitFunctionCall(functionCall: JS.FunctionCall, p: ExecutionContext): Promise<J | undefined> {
|
|
31
31
|
let fc = await super.visitFunctionCall(functionCall, p) as JS.FunctionCall;
|
|
32
32
|
|
|
@@ -34,24 +34,18 @@ export class ReplaceCreateFactory extends Recipe {
|
|
|
34
34
|
if (!fc.function) return fc;
|
|
35
35
|
const callee = (fc.function as any).element ?? fc.function;
|
|
36
36
|
|
|
37
|
-
// Check if the callee is a MethodInvocation (React.createFactory(...))
|
|
38
37
|
if (callee.kind !== J.Kind.MethodInvocation) return fc;
|
|
39
38
|
const innerCall = callee as J.MethodInvocation;
|
|
40
39
|
|
|
41
|
-
// Check if inner call is createFactory
|
|
42
40
|
if (innerCall.name.simpleName !== 'createFactory') return fc;
|
|
43
41
|
|
|
44
|
-
// Require a select (React.createFactory, not bare createFactory)
|
|
45
42
|
if (!innerCall.select) return fc;
|
|
46
43
|
|
|
47
|
-
// Get the type argument from createFactory(type)
|
|
48
44
|
const innerArgs = innerCall.arguments?.elements;
|
|
49
45
|
if (!innerArgs || innerArgs.length !== 1) return fc;
|
|
50
46
|
|
|
51
47
|
const typeArg = innerArgs[0];
|
|
52
48
|
|
|
53
|
-
// Build new argument list: prepend typeArg to outer args
|
|
54
|
-
// Filter out J.Empty placeholders from outer args
|
|
55
49
|
const outerArgs = fc.arguments.elements.filter((el: any) => {
|
|
56
50
|
const element = el.element ?? el;
|
|
57
51
|
return element.kind !== J.Kind.Empty;
|
|
@@ -75,8 +69,6 @@ export class ReplaceCreateFactory extends Recipe {
|
|
|
75
69
|
? [typeArg, ...newOuterArgs]
|
|
76
70
|
: [typeArg];
|
|
77
71
|
|
|
78
|
-
// Build a MethodInvocation: React.createElement(type, props, children)
|
|
79
|
-
// Preserve the prefix from the outer FunctionCall node
|
|
80
72
|
return {
|
|
81
73
|
...innerCall,
|
|
82
74
|
prefix: (fc as any).prefix,
|
|
@@ -91,6 +83,6 @@ export class ReplaceCreateFactory extends Recipe {
|
|
|
91
83
|
}
|
|
92
84
|
} as any as J.MethodInvocation;
|
|
93
85
|
}
|
|
94
|
-
}();
|
|
86
|
+
}());
|
|
95
87
|
}
|
|
96
88
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
2
|
-
import {JavaScriptVisitor, JS} from "@openrewrite/rewrite/javascript";
|
|
1
|
+
import {ExecutionContext, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
+
import {JavaScriptVisitor, JS, isVendoredOrBundled} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {J} from "@openrewrite/rewrite/java";
|
|
4
4
|
import {create} from "mutative";
|
|
5
5
|
|
|
@@ -32,7 +32,7 @@ export class RemoveEventPersist extends Recipe {
|
|
|
32
32
|
readonly description: string = "Removes `event.persist()` calls. React 17 removed event pooling, making persist() unnecessary.";
|
|
33
33
|
|
|
34
34
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
35
|
-
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
35
|
+
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
36
36
|
override async visitJsCompilationUnit(cu: JS.CompilationUnit, ctx: ExecutionContext): Promise<J | undefined> {
|
|
37
37
|
let result = await super.visitJsCompilationUnit(cu, ctx) as JS.CompilationUnit;
|
|
38
38
|
|
|
@@ -116,6 +116,6 @@ export class RemoveEventPersist extends Recipe {
|
|
|
116
116
|
|
|
117
117
|
return true;
|
|
118
118
|
}
|
|
119
|
-
}();
|
|
119
|
+
}());
|
|
120
120
|
}
|
|
121
121
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
2
|
-
import {JavaScriptVisitor} from "@openrewrite/rewrite/javascript";
|
|
1
|
+
import {ExecutionContext, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
+
import {JavaScriptVisitor, isVendoredOrBundled} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {J} from "@openrewrite/rewrite/java";
|
|
4
4
|
|
|
5
5
|
const UNSAFE_LIFECYCLE_MAP = new Map<string, string>([
|
|
@@ -40,7 +40,7 @@ export class RenameUnsafeLifecycles extends Recipe {
|
|
|
40
40
|
readonly description: string = "Renames `componentWillMount`, `componentWillReceiveProps`, and `componentWillUpdate` to their UNSAFE_ prefixed versions.";
|
|
41
41
|
|
|
42
42
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
43
|
-
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
43
|
+
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
44
44
|
override async visitIdentifier(ident: J.Identifier, ctx: ExecutionContext): Promise<J | undefined> {
|
|
45
45
|
let id = await super.visitIdentifier(ident, ctx) as J.Identifier;
|
|
46
46
|
|
|
@@ -54,6 +54,6 @@ export class RenameUnsafeLifecycles extends Recipe {
|
|
|
54
54
|
|
|
55
55
|
return id;
|
|
56
56
|
}
|
|
57
|
-
}();
|
|
57
|
+
}());
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {ExecutionContext, Option, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
2
|
-
import {JavaScriptVisitor, JS, JSX, maybeRemoveImport} from "@openrewrite/rewrite/javascript";
|
|
1
|
+
import {ExecutionContext, Option, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
+
import {JavaScriptVisitor, JS, JSX, maybeRemoveImport, isVendoredOrBundled} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {J} from "@openrewrite/rewrite/java";
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -48,7 +48,7 @@ export class UpdateReactImports extends Recipe {
|
|
|
48
48
|
|
|
49
49
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
50
50
|
const automaticJsxRuntime = this.automaticJsxRuntime === true;
|
|
51
|
-
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
51
|
+
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
52
52
|
private containsJsx = false;
|
|
53
53
|
|
|
54
54
|
override async visitJsCompilationUnit(cu: JS.CompilationUnit, ctx: ExecutionContext): Promise<J | undefined> {
|
|
@@ -65,6 +65,6 @@ export class UpdateReactImports extends Recipe {
|
|
|
65
65
|
this.containsJsx = true;
|
|
66
66
|
return super.visitJsxTag(tag, ctx);
|
|
67
67
|
}
|
|
68
|
-
}();
|
|
68
|
+
}());
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
2
|
-
import {JavaScriptVisitor, JS, maybeRemoveImport} from "@openrewrite/rewrite/javascript";
|
|
1
|
+
import {ExecutionContext, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
+
import {JavaScriptVisitor, JS, maybeRemoveImport, isVendoredOrBundled} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {isIdentifier, J} from "@openrewrite/rewrite/java";
|
|
4
4
|
import {create} from "mutative";
|
|
5
5
|
|
|
@@ -34,7 +34,7 @@ export class RemoveUnstableBatchedUpdates extends Recipe {
|
|
|
34
34
|
readonly description = "Removes `unstable_batchedUpdates` wrappers from `react-dom`. React 18 automatically batches all state updates, making this function unnecessary.";
|
|
35
35
|
|
|
36
36
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
37
|
-
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
37
|
+
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
38
38
|
private changed = false;
|
|
39
39
|
|
|
40
40
|
override async visitJsCompilationUnit(cu: JS.CompilationUnit, ctx: ExecutionContext): Promise<J | undefined> {
|
|
@@ -187,6 +187,6 @@ export class RemoveUnstableBatchedUpdates extends Recipe {
|
|
|
187
187
|
|
|
188
188
|
return false;
|
|
189
189
|
}
|
|
190
|
-
}();
|
|
190
|
+
}());
|
|
191
191
|
}
|
|
192
192
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
1
|
+
import {ExecutionContext, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
2
|
import {
|
|
3
3
|
capture,
|
|
4
4
|
JavaScriptVisitor,
|
|
5
5
|
maybeRemoveImport,
|
|
6
6
|
pattern,
|
|
7
7
|
rewrite,
|
|
8
|
-
template
|
|
8
|
+
template,
|
|
9
|
+
isVendoredOrBundled
|
|
9
10
|
} from "@openrewrite/rewrite/javascript";
|
|
10
11
|
import {Expression, J} from "@openrewrite/rewrite/java";
|
|
11
12
|
|
|
@@ -52,7 +53,7 @@ export class ReplaceReactDomRender extends Recipe {
|
|
|
52
53
|
})
|
|
53
54
|
}));
|
|
54
55
|
|
|
55
|
-
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
56
|
+
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
56
57
|
override async visitMethodInvocation(method: J.MethodInvocation, p: ExecutionContext): Promise<J | undefined> {
|
|
57
58
|
let m = await super.visitMethodInvocation(method, p) as J.MethodInvocation;
|
|
58
59
|
|
|
@@ -64,6 +65,6 @@ export class ReplaceReactDomRender extends Recipe {
|
|
|
64
65
|
|
|
65
66
|
return m;
|
|
66
67
|
}
|
|
67
|
-
}();
|
|
68
|
+
}());
|
|
68
69
|
}
|
|
69
70
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
2
|
-
import {JavaScriptVisitor} from "@openrewrite/rewrite/javascript";
|
|
1
|
+
import {ExecutionContext, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
+
import {JavaScriptVisitor, isVendoredOrBundled} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {isIdentifier, J} from "@openrewrite/rewrite/java";
|
|
4
4
|
import {create} from "mutative";
|
|
5
5
|
|
|
@@ -30,7 +30,7 @@ export class ReplaceRenderCallback extends Recipe {
|
|
|
30
30
|
readonly description: string = "Removes the third callback argument from `ReactDOM.render(element, container, callback)` calls. Callbacks are not supported in React 18's `createRoot` API.";
|
|
31
31
|
|
|
32
32
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
33
|
-
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
33
|
+
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
34
34
|
override async visitMethodInvocation(method: J.MethodInvocation, p: ExecutionContext): Promise<J | undefined> {
|
|
35
35
|
let m = await super.visitMethodInvocation(method, p) as J.MethodInvocation;
|
|
36
36
|
|
|
@@ -61,6 +61,6 @@ export class ReplaceRenderCallback extends Recipe {
|
|
|
61
61
|
};
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
-
}();
|
|
64
|
+
}());
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
1
|
+
import {ExecutionContext, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
2
|
import {
|
|
3
3
|
capture,
|
|
4
4
|
JavaScriptVisitor,
|
|
5
5
|
maybeRemoveImport,
|
|
6
6
|
pattern,
|
|
7
7
|
rewrite,
|
|
8
|
-
template
|
|
8
|
+
template,
|
|
9
|
+
isVendoredOrBundled
|
|
9
10
|
} from "@openrewrite/rewrite/javascript";
|
|
10
11
|
import {Expression, J} from "@openrewrite/rewrite/java";
|
|
11
12
|
|
|
@@ -50,7 +51,7 @@ export class ReplaceUnmountComponentAtNode extends Recipe {
|
|
|
50
51
|
})
|
|
51
52
|
}));
|
|
52
53
|
|
|
53
|
-
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
54
|
+
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
54
55
|
override async visitMethodInvocation(method: J.MethodInvocation, p: ExecutionContext): Promise<J | undefined> {
|
|
55
56
|
let m = await super.visitMethodInvocation(method, p) as J.MethodInvocation;
|
|
56
57
|
|
|
@@ -62,6 +63,6 @@ export class ReplaceUnmountComponentAtNode extends Recipe {
|
|
|
62
63
|
|
|
63
64
|
return m;
|
|
64
65
|
}
|
|
65
|
-
}();
|
|
66
|
+
}());
|
|
66
67
|
}
|
|
67
68
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
2
|
-
import {JavaScriptVisitor, JS} from "@openrewrite/rewrite/javascript";
|
|
1
|
+
import {ExecutionContext, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
+
import {JavaScriptVisitor, JS, isVendoredOrBundled} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {isIdentifier, J} from "@openrewrite/rewrite/java";
|
|
4
4
|
import {create} from "mutative";
|
|
5
5
|
|
|
@@ -27,7 +27,7 @@ export class DeprecatedReactTypes extends Recipe {
|
|
|
27
27
|
readonly description: string = "Replaces deprecated React TypeScript types (`SFC`, `StatelessComponent`, `VFC`, `VoidFunctionComponent`) with their modern equivalents.";
|
|
28
28
|
|
|
29
29
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
30
|
-
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
30
|
+
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
31
31
|
private deprecatedNames = new Set<string>();
|
|
32
32
|
|
|
33
33
|
override async visitJsCompilationUnit(cu: JS.CompilationUnit, ctx: ExecutionContext): Promise<J | undefined> {
|
|
@@ -116,6 +116,6 @@ export class DeprecatedReactTypes extends Recipe {
|
|
|
116
116
|
}
|
|
117
117
|
return undefined;
|
|
118
118
|
}
|
|
119
|
-
}();
|
|
119
|
+
}());
|
|
120
120
|
}
|
|
121
121
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {Column, DataTable, ExecutionContext, foundSearchResult, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
2
|
-
import {JavaScriptVisitor, JS, JSX} from "@openrewrite/rewrite/javascript";
|
|
1
|
+
import {Column, DataTable, ExecutionContext, foundSearchResult, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
+
import {JavaScriptVisitor, JS, JSX, isVendoredOrBundled} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {isIdentifier, J} from "@openrewrite/rewrite/java";
|
|
4
4
|
|
|
5
5
|
class ContextConsumerRow {
|
|
@@ -54,7 +54,7 @@ export class FindContextConsumer extends Recipe {
|
|
|
54
54
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
55
55
|
const dataTable = this.dataTable;
|
|
56
56
|
|
|
57
|
-
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
57
|
+
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
58
58
|
private filePath = "";
|
|
59
59
|
private componentStack: string[] = [];
|
|
60
60
|
|
|
@@ -122,6 +122,6 @@ export class FindContextConsumer extends Recipe {
|
|
|
122
122
|
|
|
123
123
|
return foundSearchResult(t, `Deprecated: ${contextName}.Consumer — use the use() hook instead`);
|
|
124
124
|
}
|
|
125
|
-
}();
|
|
125
|
+
}());
|
|
126
126
|
}
|
|
127
127
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {Column, DataTable, ExecutionContext, foundSearchResult, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
2
|
-
import {JavaScriptVisitor, JS} from "@openrewrite/rewrite/javascript";
|
|
1
|
+
import {Column, DataTable, ExecutionContext, foundSearchResult, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
+
import {JavaScriptVisitor, JS, isVendoredOrBundled} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {isIdentifier, J} from "@openrewrite/rewrite/java";
|
|
4
4
|
|
|
5
5
|
class DeprecatedReactDomRow {
|
|
@@ -50,7 +50,7 @@ export class FindDeprecatedReactDomAPIs extends Recipe {
|
|
|
50
50
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
51
51
|
const dataTable = this.dataTable;
|
|
52
52
|
|
|
53
|
-
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
53
|
+
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
54
54
|
private filePath = "";
|
|
55
55
|
private importedDeprecatedApis = new Set<string>();
|
|
56
56
|
|
|
@@ -122,6 +122,6 @@ export class FindDeprecatedReactDomAPIs extends Recipe {
|
|
|
122
122
|
|
|
123
123
|
return m;
|
|
124
124
|
}
|
|
125
|
-
}();
|
|
125
|
+
}());
|
|
126
126
|
}
|
|
127
127
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {Column, DataTable, ExecutionContext, foundSearchResult, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
2
|
-
import {JavaScriptVisitor, JS} from "@openrewrite/rewrite/javascript";
|
|
1
|
+
import {Column, DataTable, ExecutionContext, foundSearchResult, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
+
import {JavaScriptVisitor, JS, isVendoredOrBundled} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {isIdentifier, J} from "@openrewrite/rewrite/java";
|
|
4
4
|
|
|
5
5
|
class ElementRefRow {
|
|
@@ -43,7 +43,7 @@ export class FindElementRef extends Recipe {
|
|
|
43
43
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
44
44
|
const dataTable = this.dataTable;
|
|
45
45
|
|
|
46
|
-
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
46
|
+
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
47
47
|
private filePath = "";
|
|
48
48
|
|
|
49
49
|
override async visitJsCompilationUnit(cu: JS.CompilationUnit, ctx: ExecutionContext): Promise<J | undefined> {
|
|
@@ -81,6 +81,6 @@ export class FindElementRef extends Recipe {
|
|
|
81
81
|
|
|
82
82
|
return foundSearchResult(fa, "element.ref is deprecated, use element.props.ref");
|
|
83
83
|
}
|
|
84
|
-
}();
|
|
84
|
+
}());
|
|
85
85
|
}
|
|
86
86
|
}
|