@ripple-ts/prettier-plugin 0.2.170 → 0.2.172
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/package.json +2 -2
- package/src/index.js +31 -10
- package/src/index.test.js +27 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ripple-ts/prettier-plugin",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.172",
|
|
4
4
|
"description": "Ripple plugin for Prettier",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"prettier": "^3.6.2",
|
|
28
|
-
"ripple": "0.2.
|
|
28
|
+
"ripple": "0.2.172"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {},
|
|
31
31
|
"files": [
|
package/src/index.js
CHANGED
|
@@ -2044,7 +2044,6 @@ function printRippleNode(node, path, options, print, args) {
|
|
|
2044
2044
|
}
|
|
2045
2045
|
|
|
2046
2046
|
function printImportDeclaration(node, path, options, print) {
|
|
2047
|
-
// Use Prettier's doc builders for proper cursor tracking
|
|
2048
2047
|
const parts = ['import'];
|
|
2049
2048
|
|
|
2050
2049
|
// Handle type imports
|
|
@@ -2073,25 +2072,47 @@ function printImportDeclaration(node, path, options, print) {
|
|
|
2073
2072
|
}
|
|
2074
2073
|
});
|
|
2075
2074
|
|
|
2076
|
-
// Build import clause
|
|
2077
|
-
const
|
|
2075
|
+
// Build import clause with proper grouping and line breaking
|
|
2076
|
+
const importClauseParts = [];
|
|
2077
|
+
|
|
2078
2078
|
if (defaultImports.length > 0) {
|
|
2079
|
-
|
|
2079
|
+
importClauseParts.push(defaultImports.join(', '));
|
|
2080
2080
|
}
|
|
2081
2081
|
if (namespaceImports.length > 0) {
|
|
2082
|
-
|
|
2082
|
+
importClauseParts.push(namespaceImports.join(', '));
|
|
2083
2083
|
}
|
|
2084
2084
|
if (namedImports.length > 0) {
|
|
2085
|
-
|
|
2085
|
+
// Use Prettier's group and conditionalGroup for named imports to handle line breaking
|
|
2086
|
+
const namedImportsDocs = namedImports.map((name) => name);
|
|
2087
|
+
const namedImportsGroup = group(
|
|
2088
|
+
concat([
|
|
2089
|
+
'{',
|
|
2090
|
+
indent(
|
|
2091
|
+
concat([
|
|
2092
|
+
options.bracketSpacing ? line : softline,
|
|
2093
|
+
join(concat([',', line]), namedImportsDocs),
|
|
2094
|
+
]),
|
|
2095
|
+
),
|
|
2096
|
+
ifBreak(shouldPrintComma(options) ? ',' : ''),
|
|
2097
|
+
options.bracketSpacing ? line : softline,
|
|
2098
|
+
'}',
|
|
2099
|
+
]),
|
|
2100
|
+
);
|
|
2101
|
+
importClauseParts.push(namedImportsGroup);
|
|
2086
2102
|
}
|
|
2087
2103
|
|
|
2088
|
-
parts.push(' '
|
|
2104
|
+
parts.push(' ');
|
|
2105
|
+
if (importClauseParts.length === 1 && typeof importClauseParts[0] === 'object') {
|
|
2106
|
+
parts.push(importClauseParts[0]);
|
|
2107
|
+
} else {
|
|
2108
|
+
parts.push(join(', ', importClauseParts));
|
|
2109
|
+
}
|
|
2110
|
+
parts.push(' from');
|
|
2089
2111
|
}
|
|
2090
2112
|
|
|
2091
|
-
parts.push(' '
|
|
2113
|
+
parts.push(' ', formatStringLiteral(node.source.value, options), semi(options));
|
|
2092
2114
|
|
|
2093
|
-
|
|
2094
|
-
return parts;
|
|
2115
|
+
return concat(parts);
|
|
2095
2116
|
}
|
|
2096
2117
|
|
|
2097
2118
|
function printExportNamedDeclaration(node, path, options, print) {
|
package/src/index.test.js
CHANGED
|
@@ -663,6 +663,33 @@ import { Something, type Props, track } from 'ripple';`;
|
|
|
663
663
|
expect(result).toBeWithNewline(expected);
|
|
664
664
|
});
|
|
665
665
|
|
|
666
|
+
it('should format long import statements correctly', async () => {
|
|
667
|
+
const input = `import { flushSync, track, effect, bindValue, bindChecked, bindGroup, bindClientWidth, bindClientHeight, bindOffsetWidth, bindOffsetHeight, bindContentRect, bindContentBoxSize, bindBorderBoxSize, bindDevicePixelContentBoxSize, bindInnerHTML, bindInnerText, bindTextContent, bindNode } from 'ripple';`;
|
|
668
|
+
const expected = `import {
|
|
669
|
+
flushSync,
|
|
670
|
+
track,
|
|
671
|
+
effect,
|
|
672
|
+
bindValue,
|
|
673
|
+
bindChecked,
|
|
674
|
+
bindGroup,
|
|
675
|
+
bindClientWidth,
|
|
676
|
+
bindClientHeight,
|
|
677
|
+
bindOffsetWidth,
|
|
678
|
+
bindOffsetHeight,
|
|
679
|
+
bindContentRect,
|
|
680
|
+
bindContentBoxSize,
|
|
681
|
+
bindBorderBoxSize,
|
|
682
|
+
bindDevicePixelContentBoxSize,
|
|
683
|
+
bindInnerHTML,
|
|
684
|
+
bindInnerText,
|
|
685
|
+
bindTextContent,
|
|
686
|
+
bindNode,
|
|
687
|
+
} from 'ripple';`;
|
|
688
|
+
|
|
689
|
+
const result = await format(input, { singleQuote: true, printWidth: 80 });
|
|
690
|
+
expect(result).toBeWithNewline(expected);
|
|
691
|
+
});
|
|
692
|
+
|
|
666
693
|
it('should preserve @ symbol in JSX attributes and shorthand syntax', async () => {
|
|
667
694
|
const input = `component App() {
|
|
668
695
|
const count = track(0);
|