@openrewrite/rewrite 8.69.0-20251207-184829 → 8.69.0-20251207-220615

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.
Files changed (53) hide show
  1. package/dist/cli/cli-utils.d.ts.map +1 -1
  2. package/dist/cli/cli-utils.js +3 -2
  3. package/dist/cli/cli-utils.js.map +1 -1
  4. package/dist/cli/rewrite.js +2 -1
  5. package/dist/cli/rewrite.js.map +1 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +3 -2
  8. package/dist/index.js.map +1 -1
  9. package/dist/javascript/parser.d.ts.map +1 -1
  10. package/dist/javascript/parser.js +48 -8
  11. package/dist/javascript/parser.js.map +1 -1
  12. package/dist/javascript/recipes/auto-format.d.ts +24 -0
  13. package/dist/javascript/recipes/auto-format.d.ts.map +1 -0
  14. package/dist/javascript/recipes/auto-format.js +58 -0
  15. package/dist/javascript/recipes/auto-format.js.map +1 -0
  16. package/dist/javascript/recipes/change-import.d.ts +51 -0
  17. package/dist/javascript/recipes/change-import.d.ts.map +1 -0
  18. package/dist/javascript/recipes/change-import.js +658 -0
  19. package/dist/javascript/recipes/change-import.js.map +1 -0
  20. package/dist/javascript/recipes/index.d.ts +3 -0
  21. package/dist/javascript/recipes/index.d.ts.map +1 -1
  22. package/dist/javascript/recipes/index.js +3 -0
  23. package/dist/javascript/recipes/index.js.map +1 -1
  24. package/dist/javascript/recipes/order-imports.d.ts +10 -0
  25. package/dist/javascript/recipes/order-imports.d.ts.map +1 -0
  26. package/dist/javascript/recipes/order-imports.js +240 -0
  27. package/dist/javascript/recipes/order-imports.js.map +1 -0
  28. package/dist/javascript/style.js +2 -2
  29. package/dist/javascript/style.js.map +1 -1
  30. package/dist/json/parser.js +78 -30
  31. package/dist/json/parser.js.map +1 -1
  32. package/dist/version.txt +1 -1
  33. package/package.json +1 -1
  34. package/src/cli/cli-utils.ts +3 -2
  35. package/src/cli/rewrite.ts +2 -1
  36. package/src/index.ts +3 -2
  37. package/src/javascript/parser.ts +49 -8
  38. package/src/javascript/recipes/auto-format.ts +44 -0
  39. package/src/javascript/recipes/change-import.ts +700 -0
  40. package/src/javascript/recipes/index.ts +3 -0
  41. package/src/javascript/recipes/order-imports.ts +242 -0
  42. package/src/javascript/style.ts +2 -2
  43. package/src/json/parser.ts +69 -24
  44. package/dist/recipe/index.d.ts +0 -2
  45. package/dist/recipe/index.d.ts.map +0 -1
  46. package/dist/recipe/index.js +0 -21
  47. package/dist/recipe/index.js.map +0 -1
  48. package/dist/recipe/order-imports.d.ts +0 -10
  49. package/dist/recipe/order-imports.d.ts.map +0 -1
  50. package/dist/recipe/order-imports.js +0 -213
  51. package/dist/recipe/order-imports.js.map +0 -1
  52. package/src/recipe/index.ts +0 -17
  53. package/src/recipe/order-imports.ts +0 -195
@@ -0,0 +1,24 @@
1
+ import { Recipe } from "../../recipe";
2
+ import { TreeVisitor } from "../../visitor";
3
+ import { ExecutionContext } from "../../execution";
4
+ /**
5
+ * Formats JavaScript/TypeScript code using a comprehensive set of formatting rules.
6
+ *
7
+ * This recipe applies the following formatting:
8
+ * - Normalizes whitespace
9
+ * - Ensures minimum viable spacing
10
+ * - Applies blank line rules
11
+ * - Applies wrapping and braces rules
12
+ * - Applies spacing rules
13
+ * - Applies tabs and indentation rules
14
+ *
15
+ * The formatting rules are determined by the style settings attached to the source file,
16
+ * or defaults to IntelliJ IDEA style if no custom style is specified.
17
+ */
18
+ export declare class AutoFormat extends Recipe {
19
+ readonly name = "org.openrewrite.javascript.format.auto-format";
20
+ readonly displayName = "Auto-format JavaScript/TypeScript code";
21
+ readonly description = "Format JavaScript and TypeScript code using a comprehensive set of formatting rules based on the project's style settings.";
22
+ editor(): Promise<TreeVisitor<any, ExecutionContext>>;
23
+ }
24
+ //# sourceMappingURL=auto-format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-format.d.ts","sourceRoot":"","sources":["../../../src/javascript/recipes/auto-format.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AACpC,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,gBAAgB,EAAC,MAAM,iBAAiB,CAAC;AAGjD;;;;;;;;;;;;;GAaG;AACH,qBAAa,UAAW,SAAQ,MAAM;IAClC,QAAQ,CAAC,IAAI,mDAAmD;IAChE,QAAQ,CAAC,WAAW,4CAA4C;IAChE,QAAQ,CAAC,WAAW,gIAAgI;IAE9I,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAG9D"}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2025 the original author or authors.
4
+ * <p>
5
+ * Licensed under the Moderne Source Available License (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ * <p>
9
+ * https://docs.moderne.io/licensing/moderne-source-available-license
10
+ * <p>
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.AutoFormat = void 0;
28
+ const recipe_1 = require("../../recipe");
29
+ const format_1 = require("../format");
30
+ /**
31
+ * Formats JavaScript/TypeScript code using a comprehensive set of formatting rules.
32
+ *
33
+ * This recipe applies the following formatting:
34
+ * - Normalizes whitespace
35
+ * - Ensures minimum viable spacing
36
+ * - Applies blank line rules
37
+ * - Applies wrapping and braces rules
38
+ * - Applies spacing rules
39
+ * - Applies tabs and indentation rules
40
+ *
41
+ * The formatting rules are determined by the style settings attached to the source file,
42
+ * or defaults to IntelliJ IDEA style if no custom style is specified.
43
+ */
44
+ class AutoFormat extends recipe_1.Recipe {
45
+ constructor() {
46
+ super(...arguments);
47
+ this.name = "org.openrewrite.javascript.format.auto-format";
48
+ this.displayName = "Auto-format JavaScript/TypeScript code";
49
+ this.description = "Format JavaScript and TypeScript code using a comprehensive set of formatting rules based on the project's style settings.";
50
+ }
51
+ editor() {
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ return new format_1.AutoformatVisitor();
54
+ });
55
+ }
56
+ }
57
+ exports.AutoFormat = AutoFormat;
58
+ //# sourceMappingURL=auto-format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-format.js","sourceRoot":"","sources":["../../../src/javascript/recipes/auto-format.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;AAEH,yCAAoC;AAGpC,sCAA4C;AAE5C;;;;;;;;;;;;;GAaG;AACH,MAAa,UAAW,SAAQ,eAAM;IAAtC;;QACa,SAAI,GAAG,+CAA+C,CAAC;QACvD,gBAAW,GAAG,wCAAwC,CAAC;QACvD,gBAAW,GAAG,4HAA4H,CAAC;IAKxJ,CAAC;IAHS,MAAM;;YACR,OAAO,IAAI,0BAAiB,EAAE,CAAC;QACnC,CAAC;KAAA;CACJ;AARD,gCAQC"}
@@ -0,0 +1,51 @@
1
+ import { Recipe } from "../../recipe";
2
+ import { TreeVisitor } from "../../visitor";
3
+ import { ExecutionContext } from "../../execution";
4
+ /**
5
+ * Changes an import from one module to another, updating all type attributions.
6
+ *
7
+ * This recipe is useful for:
8
+ * - Library migrations (e.g., moving `act` from `react-dom/test-utils` to `react`)
9
+ * - Module restructuring (e.g., split packages)
10
+ * - Renaming exported members
11
+ *
12
+ * @example
13
+ * // Migrate act import from react-dom/test-utils to react
14
+ * const recipe = new ChangeImport({
15
+ * oldModule: "react-dom/test-utils",
16
+ * oldMember: "act",
17
+ * newModule: "react"
18
+ * });
19
+ * // Before: import { act } from 'react-dom/test-utils';
20
+ * // After: import { act } from 'react';
21
+ *
22
+ * @example
23
+ * // Change a named import to a different name
24
+ * const recipe = new ChangeImport({
25
+ * oldModule: "lodash",
26
+ * oldMember: "extend",
27
+ * newModule: "lodash",
28
+ * newMember: "assign"
29
+ * });
30
+ * // Before: import { extend } from 'lodash';
31
+ * // After: import { assign } from 'lodash';
32
+ */
33
+ export declare class ChangeImport extends Recipe {
34
+ readonly name = "org.openrewrite.javascript.change-import";
35
+ readonly displayName = "Change import";
36
+ readonly description = "Changes an import from one module/member to another, updating all type attributions.";
37
+ oldModule: string;
38
+ oldMember: string;
39
+ newModule: string;
40
+ newMember?: string;
41
+ newAlias?: string;
42
+ constructor(options?: {
43
+ oldModule?: string;
44
+ oldMember?: string;
45
+ newModule?: string;
46
+ newMember?: string;
47
+ newAlias?: string;
48
+ });
49
+ editor(): Promise<TreeVisitor<any, ExecutionContext>>;
50
+ }
51
+ //# sourceMappingURL=change-import.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"change-import.d.ts","sourceRoot":"","sources":["../../../src/javascript/recipes/change-import.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAS,MAAM,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,gBAAgB,EAAC,MAAM,iBAAiB,CAAC;AAMjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,YAAa,SAAQ,MAAM;IACpC,QAAQ,CAAC,IAAI,8CAA8C;IAC3D,QAAQ,CAAC,WAAW,mBAAmB;IACvC,QAAQ,CAAC,WAAW,0FAA0F;IAO9G,SAAS,EAAG,MAAM,CAAC;IAOnB,SAAS,EAAG,MAAM,CAAC;IAOnB,SAAS,EAAG,MAAM,CAAC;IAQnB,SAAS,CAAC,EAAE,MAAM,CAAC;IAOnB,QAAQ,CAAC,EAAE,MAAM,CAAC;gBAEN,OAAO,CAAC,EAAE;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACrB;IAIK,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAmlB9D"}