@ripple-ts/prettier-plugin 0.2.211 → 0.2.213

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/README.md CHANGED
@@ -1,4 +1,7 @@
1
1
  # @ripple-ts/prettier-plugin
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/%40ripple-ts%2Fprettier-plugin?logo=npm)](https://www.npmjs.com/package/@ripple-ts/prettier-plugin)
4
+ [![npm downloads](https://img.shields.io/npm/dm/%40ripple-ts%2Fprettier-plugin?logo=npm&label=downloads)](https://www.npmjs.com/package/@ripple-ts/prettier-plugin)
5
+
3
6
  A Prettier plugin for formatting [Ripple](https://github.com/Ripple-TS/ripple)
4
7
  `.ripple` files.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ripple-ts/prettier-plugin",
3
- "version": "0.2.211",
3
+ "version": "0.2.213",
4
4
  "description": "Ripple plugin for Prettier",
5
5
  "type": "module",
6
6
  "module": "src/index.js",
@@ -27,7 +27,7 @@
27
27
  "@types/estree": "^1.0.8",
28
28
  "@types/estree-jsx": "^1.0.5",
29
29
  "prettier": "^3.6.2",
30
- "ripple": "0.2.211"
30
+ "ripple": "0.2.213"
31
31
  },
32
32
  "dependencies": {},
33
33
  "files": [
package/src/index.js CHANGED
@@ -1596,6 +1596,18 @@ function printRippleNode(node, path, options, print, args) {
1596
1596
  break;
1597
1597
  }
1598
1598
 
1599
+ case 'StyleSheet': {
1600
+ // StyleSheet nodes inside <style> elements. When CSS is empty/whitespace-only,
1601
+ // return empty string so the element collapses to <style></style>.
1602
+ // Non-empty stylesheets are normally handled by embed() using textToDoc with the CSS parser.
1603
+ if (!node.source || !node.source.trim()) {
1604
+ nodeContent = '';
1605
+ } else {
1606
+ nodeContent = node.source.trim();
1607
+ }
1608
+ break;
1609
+ }
1610
+
1599
1611
  case 'ServerIdentifier': {
1600
1612
  nodeContent = '#server';
1601
1613
  break;
package/src/index.test.js CHANGED
@@ -1236,6 +1236,21 @@ const [obj1, obj2] = arrayOfObjects;`;
1236
1236
  expect(result).toBeWithNewline(expected);
1237
1237
  });
1238
1238
 
1239
+ it('should not mangle empty stylesheet tags <style></style>', async () => {
1240
+ const input = `component App() {
1241
+ <style>
1242
+
1243
+ </style>
1244
+ }`;
1245
+
1246
+ const expected = `component App() {
1247
+ <style></style>
1248
+ }`;
1249
+
1250
+ const result = await format(input, { singleQuote: true, printWidth: 100 });
1251
+ expect(result).toBeWithNewline(expected);
1252
+ });
1253
+
1239
1254
  it('should keep TrackedMap short syntax intact', async () => {
1240
1255
  const expected = `const map = new #Map([['key1', 'value1'], ['key2', 'value2']]);
1241
1256
  const set = new #Set([1, 2, 3]);`;
@@ -1891,6 +1906,201 @@ files = [...(files ?? []), ...dt.files];`;
1891
1906
  const result = await format(expected, { singleQuote: true, printWidth: 100 });
1892
1907
  expect(result).toBeWithNewline(expected);
1893
1908
  });
1909
+
1910
+ it('should not remove comments when stylesheet contains some sort of combination of selectors', async () => {
1911
+ const expected = `component Editor() {
1912
+ <div class="editor-mockup">
1913
+ <div class="editor-header">
1914
+ <div class="editor-dots">
1915
+ // <div class="editor-dot red" />
1916
+ // <div class="editor-dot yellow" />
1917
+ <div class="editor-dot green" />
1918
+ </div>
1919
+ <div class="editor-tab">{'Examples.ripple'}</div>
1920
+ </div>
1921
+ <div class="editor-content">
1922
+ <pre class="editor-code">
1923
+ <span class="editor-loader">{'Loading...'}</span>
1924
+ </pre>
1925
+ </div>
1926
+ </div>
1927
+
1928
+ <style>
1929
+ @keyframes editorSlideIn {
1930
+ 0% {
1931
+ opacity: 0;
1932
+ transform: translateY(30px);
1933
+ }
1934
+ 100% {
1935
+ opacity: 1;
1936
+ transform: translateY(0);
1937
+ }
1938
+ }
1939
+ .editor-mockup {
1940
+ max-width: 700px;
1941
+ margin: 1rem auto;
1942
+ background: rgba(30, 30, 35, 0.98);
1943
+ border-radius: 12px;
1944
+ border: 1px solid rgba(255, 255, 255, 0.1);
1945
+ overflow: hidden;
1946
+ box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
1947
+ text-align: left;
1948
+ opacity: 1;
1949
+ transform: translateY(30px);
1950
+ animation: editorSlideIn 1s ease-out 0.5s forwards;
1951
+ }
1952
+
1953
+ .editor-header {
1954
+ background: rgba(20, 20, 25, 0.9);
1955
+ padding: 0.75rem 1rem 0;
1956
+ border-bottom: 1px solid rgba(255, 255, 255, 0.1);
1957
+ display: flex;
1958
+ align-items: flex-start;
1959
+ gap: 1rem;
1960
+ }
1961
+
1962
+ .editor-dots {
1963
+ display: flex;
1964
+ gap: 0.5rem;
1965
+ align-self: center;
1966
+ margin-top: -7px;
1967
+ }
1968
+
1969
+ .editor-dot {
1970
+ width: 12px;
1971
+ height: 12px;
1972
+ border-radius: 50%;
1973
+ }
1974
+
1975
+ .editor-dot.red {
1976
+ background: #ff5f57;
1977
+ }
1978
+ .editor-dot.yellow {
1979
+ background: #ffbd2e;
1980
+ }
1981
+ .editor-dot.green {
1982
+ background: #28ca42;
1983
+ }
1984
+
1985
+ .editor-loader {
1986
+ display: 'flex';
1987
+ align-items: center;
1988
+ justify-content: center;
1989
+ }
1990
+
1991
+ .editor-tab {
1992
+ background: rgba(25, 25, 30, 0.95);
1993
+ padding: 0.5rem 1rem;
1994
+ border-radius: 6px 6px 0 0;
1995
+ color: rgba(255, 255, 255, 0.9);
1996
+ font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
1997
+ font-size: 0.75rem;
1998
+ border: 1px solid rgba(255, 255, 255, 0.1);
1999
+ border-bottom: none;
2000
+ margin-bottom: -1px;
2001
+ align-self: flex-end;
2002
+ }
2003
+
2004
+ .editor-content {
2005
+ background: rgba(25, 25, 30, 0.95);
2006
+ padding: 0;
2007
+ font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
2008
+ font-size: 0.8rem;
2009
+ line-height: 1.5;
2010
+ color: #e1e4e8;
2011
+ overflow-x: auto;
2012
+ text-align: left;
2013
+ height: 800px;
2014
+ }
2015
+
2016
+ .editor-code {
2017
+ margin: 0;
2018
+ padding: 1.5rem;
2019
+ background: none;
2020
+ color: inherit;
2021
+ font: inherit;
2022
+ white-space: pre;
2023
+ overflow-x: auto;
2024
+ }
2025
+
2026
+ :global(.editor-line) {
2027
+ display: block;
2028
+ }
2029
+
2030
+ :global(.line-number) {
2031
+ color: rgba(255, 255, 255, 0.3);
2032
+ display: inline-block;
2033
+ width: 1rem;
2034
+ text-align: right;
2035
+ margin-right: 0.75rem;
2036
+ user-select: none;
2037
+ }
2038
+
2039
+ :global(.keyword) {
2040
+ color: #569cd6;
2041
+ }
2042
+ :global(.export-keyword) {
2043
+ color: #c586c0;
2044
+ }
2045
+ :global(.string) {
2046
+ color: #ce9178;
2047
+ }
2048
+ :global(.component) {
2049
+ color: #4ec9b0;
2050
+ }
2051
+ :global(.function) {
2052
+ color: #dcdcaa;
2053
+ }
2054
+ :global(.property) {
2055
+ color: #9cdcfe;
2056
+ }
2057
+ :global(.css-selector) {
2058
+ color: #d7ba7d;
2059
+ }
2060
+ :global(.control-keyword) {
2061
+ color: #c586c0;
2062
+ }
2063
+ :global(.block-brace) {
2064
+ color: #c586c0;
2065
+ }
2066
+ :global(.tag) {
2067
+ color: #569cd6;
2068
+ }
2069
+ :global(.attribute) {
2070
+ color: #92c5f8;
2071
+ }
2072
+ :global(.value) {
2073
+ color: #b5cea8;
2074
+ }
2075
+ :global(.comment) {
2076
+ color: #6a9955;
2077
+ font-style: italic;
2078
+ }
2079
+ :global(.brace) {
2080
+ color: #ffd700;
2081
+ }
2082
+ :global(.css-brace) {
2083
+ color: #d4d4d4;
2084
+ }
2085
+ :global(.template-brace) {
2086
+ color: #ffd700;
2087
+ }
2088
+ :global(.ripple-syntax) {
2089
+ color: #4fc1ff;
2090
+ }
2091
+ :global(.bracket) {
2092
+ color: #808080;
2093
+ }
2094
+ :global(.reactive-var) {
2095
+ color: #9cdcfe;
2096
+ font-weight: bold;
2097
+ }
2098
+ </style>
2099
+ }`;
2100
+
2101
+ const result = await format(expected, { singleQuote: true, printWidth: 100 });
2102
+ expect(result).toBeWithNewline(expected);
2103
+ });
1894
2104
  });
1895
2105
 
1896
2106
  describe('edge cases', () => {