@prettier/plugin-oxc 0.0.1 → 0.0.2

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 (3) hide show
  1. package/README.md +5 -0
  2. package/index.mjs +30 -7
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # @prettier/plugin-oxc
2
2
 
3
+ [![Npm Version](https://img.shields.io/npm/v/@prettier/plugin-oxc.svg?style=flat-square)](https://www.npmjs.com/package/@prettier/plugin-oxc)
4
+ [![MIT License](https://img.shields.io/npm/l/@prettier/plugin-oxc.svg?style=flat-square)](https://github.com/prettier/prettier/blob/main/license)
5
+
3
6
  > Prettier [Oxc](https://oxc.rs/) plugin.
4
7
 
5
8
  ## Install
@@ -17,6 +20,8 @@ plugins:
17
20
  - "@prettier/plugin-oxc"
18
21
  ```
19
22
 
23
+ **Requires prettier >= 3.6**
24
+
20
25
  Or config explicitly
21
26
 
22
27
  ```yaml
package/index.mjs CHANGED
@@ -6803,12 +6803,7 @@ function maybeWrapJsxElementInParens(path, elem, options2) {
6803
6803
  if (NO_WRAP_PARENTS.has(parent.type)) {
6804
6804
  return elem;
6805
6805
  }
6806
- const shouldBreak = path.match(
6807
- void 0,
6808
- (node) => node.type === "ArrowFunctionExpression",
6809
- isCallExpression,
6810
- (node) => node.type === "JSXExpressionContainer"
6811
- );
6806
+ const shouldBreak = shouldBreakJsxElement(path);
6812
6807
  const needsParens2 = needs_parens_default(path, options2);
6813
6808
  return group(
6814
6809
  [
@@ -6820,6 +6815,26 @@ function maybeWrapJsxElementInParens(path, elem, options2) {
6820
6815
  { shouldBreak }
6821
6816
  );
6822
6817
  }
6818
+ function shouldBreakJsxElement(path) {
6819
+ return path.match(
6820
+ void 0,
6821
+ (node) => node.type === "ArrowFunctionExpression",
6822
+ isCallExpression
6823
+ ) && // Babel
6824
+ (path.match(
6825
+ void 0,
6826
+ void 0,
6827
+ void 0,
6828
+ (node) => node.type === "JSXExpressionContainer"
6829
+ ) || // Estree
6830
+ path.match(
6831
+ void 0,
6832
+ void 0,
6833
+ void 0,
6834
+ (node) => node.type === "ChainExpression",
6835
+ (node) => node.type === "JSXExpressionContainer"
6836
+ ));
6837
+ }
6823
6838
  function printJsxAttribute(path, options2, print3) {
6824
6839
  const { node } = path;
6825
6840
  const parts = [];
@@ -7473,6 +7488,10 @@ function printCallArguments(path, options2, print3) {
7473
7488
  !options2.parser.startsWith("__ng_") && // Dynamic imports cannot have trailing commas
7474
7489
  node.type !== "ImportExpression" && node.type !== "TSImportType" && shouldPrintComma(options2, "all") ? "," : ""
7475
7490
  );
7491
+ if (node.type === "TSImportType" && args.length === 1 && (args[0].type === "TSLiteralType" && isStringLiteral(args[0].literal) || // TODO: Remove this when update Babel to v8
7492
+ isStringLiteral(args[0])) && !hasComment(args[0])) {
7493
+ return group(["(", ...printedArguments, ifBreak(maybeTrailingComma), ")"]);
7494
+ }
7476
7495
  function allArgsBrokenOut() {
7477
7496
  return group(
7478
7497
  ["(", indent([line, ...printedArguments]), maybeTrailingComma, line, ")"],
@@ -10363,7 +10382,11 @@ function printObject(path, options2, print3) {
10363
10382
  propsAndLoc,
10364
10383
  -1
10365
10384
  )) == null ? void 0 : _a.node;
10366
- const canHaveTrailingSeparator = !(node.inexact || node.hasUnknownMembers || lastElem && (lastElem.type === "RestElement" || (lastElem.type === "TSPropertySignature" || lastElem.type === "TSCallSignatureDeclaration" || lastElem.type === "TSMethodSignature" || lastElem.type === "TSConstructSignatureDeclaration" || lastElem.type === "TSIndexSignature") && hasComment(lastElem, CommentCheckFlags.PrettierIgnore)));
10385
+ const canHaveTrailingSeparator = !(node.inexact || node.hasUnknownMembers || lastElem && (lastElem.type === "RestElement" || (lastElem.type === "TSPropertySignature" || lastElem.type === "TSCallSignatureDeclaration" || lastElem.type === "TSMethodSignature" || lastElem.type === "TSConstructSignatureDeclaration" || lastElem.type === "TSIndexSignature") && hasComment(lastElem, CommentCheckFlags.PrettierIgnore)) || // https://github.com/microsoft/TypeScript/issues/61916
10386
+ path.match(
10387
+ void 0,
10388
+ (node2, key2) => node2.type === "TSImportType" && key2 === "options"
10389
+ ));
10367
10390
  let content;
10368
10391
  if (props.length === 0) {
10369
10392
  if (!hasComment(node, CommentCheckFlags.Dangling)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prettier/plugin-oxc",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Prettier Oxc plugin.",
5
5
  "exports": {
6
6
  ".": {