@prettier/plugin-oxc 0.1.1 → 0.1.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.
package/index.mjs CHANGED
@@ -2246,15 +2246,22 @@ function getPreferredQuote(text, preferredQuoteOrPreferSingleQuote) {
2246
2246
  var get_preferred_quote_default = getPreferredQuote;
2247
2247
 
2248
2248
  // src/utils/make-string.js
2249
- var REGEX = /\\?(?<quote>["'])/gu;
2249
+ var REGEX = /\\(["'\\])|(["'])/gu;
2250
2250
  function makeString(rawText, enclosingQuote) {
2251
- return enclosingQuote + method_replace_all_default(
2251
+ const otherQuote = enclosingQuote === '"' ? "'" : '"';
2252
+ const raw = method_replace_all_default(
2252
2253
  /* OPTIONAL_OBJECT: false */
2253
2254
  0,
2254
2255
  rawText,
2255
2256
  REGEX,
2256
- (_, quote) => (quote === enclosingQuote ? "\\" : "") + quote
2257
- ) + enclosingQuote;
2257
+ (match, escaped, unescaped) => {
2258
+ if (escaped) {
2259
+ return escaped === otherQuote ? otherQuote : match;
2260
+ }
2261
+ return unescaped === enclosingQuote ? "\\" + unescaped : unescaped;
2262
+ }
2263
+ );
2264
+ return enclosingQuote + raw + enclosingQuote;
2258
2265
  }
2259
2266
  var make_string_default = makeString;
2260
2267
 
@@ -8767,6 +8774,7 @@ function printClassBody(path, options2, print3) {
8767
8774
  const isFlowTypeAnnotation = node.type === "ObjectTypeAnnotation";
8768
8775
  const isObjectType2 = !isClassBody(path);
8769
8776
  const separator = isObjectType2 ? line : hardline;
8777
+ const hasDanglingComments = hasComment(node, CommentCheckFlags.Dangling);
8770
8778
  const [openingBrace, closingBrace] = isFlowTypeAnnotation && node.exact ? ["{|", "|}"] : "{}";
8771
8779
  let firstMember;
8772
8780
  iterateClassMembers(path, ({
@@ -8802,7 +8810,7 @@ function printClassBody(path, options2, print3) {
8802
8810
  }
8803
8811
  }
8804
8812
  });
8805
- if (hasComment(node, CommentCheckFlags.Dangling)) {
8813
+ if (hasDanglingComments) {
8806
8814
  parts.push(printDanglingComments(path, options2));
8807
8815
  }
8808
8816
  if (node.type === "ObjectTypeAnnotation" && node.inexact) {
@@ -8821,7 +8829,7 @@ function printClassBody(path, options2, print3) {
8821
8829
  parts.push(printed);
8822
8830
  }
8823
8831
  if (isObjectType2) {
8824
- const shouldBreak = options2.objectWrap === "preserve" && firstMember && has_newline_in_range_default(options2.originalText, locStart(node), locStart(firstMember));
8832
+ const shouldBreak = hasDanglingComments || options2.objectWrap === "preserve" && firstMember && has_newline_in_range_default(options2.originalText, locStart(node), locStart(firstMember));
8825
8833
  let content;
8826
8834
  if (parts.length === 0) {
8827
8835
  content = openingBrace + closingBrace;
@@ -10670,21 +10678,7 @@ function printTernaryOld(path, options2, print3) {
10670
10678
  parent.type !== node.type || parent[alternateNodePropertyName] === node || isParentTest ? part : options2.useTabs ? dedent(indent(part)) : align(Math.max(0, options2.tabWidth - 2), part)
10671
10679
  );
10672
10680
  }
10673
- const shouldBreak = [
10674
- consequentNodePropertyName,
10675
- alternateNodePropertyName,
10676
- ...testNodePropertyNames
10677
- ].some(
10678
- (property) => hasComment(
10679
- node[property],
10680
- (comment) => is_block_comment_default(comment) && has_newline_in_range_default(
10681
- options2.originalText,
10682
- locStart(comment),
10683
- locEnd(comment)
10684
- )
10685
- )
10686
- );
10687
- const maybeGroup = (doc) => parent === firstNonConditionalParent ? group(doc, { shouldBreak }) : shouldBreak ? [doc, breakParent] : doc;
10681
+ const maybeGroup = (doc) => parent === firstNonConditionalParent ? group(doc) : doc;
10688
10682
  const breakClosingParen = !jsxMode && (isMemberExpression(parent) || parent.type === "NGPipeExpression" && parent.left === node) && !parent.computed;
10689
10683
  const shouldExtraIndent = shouldExtraIndentForConditionalExpression(path);
10690
10684
  const result = maybeGroup([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prettier/plugin-oxc",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Prettier Oxc plugin.",
5
5
  "exports": {
6
6
  ".": {