@ripple-ts/prettier-plugin 0.3.7 → 0.3.8

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 (2) hide show
  1. package/package.json +2 -2
  2. package/src/index.test.js +42 -42
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ripple-ts/prettier-plugin",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "description": "Ripple plugin for Prettier",
5
5
  "type": "module",
6
6
  "module": "src/index.js",
@@ -26,7 +26,7 @@
26
26
  "devDependencies": {
27
27
  "@types/node": "^24.3.0",
28
28
  "prettier": "^3.8.1",
29
- "ripple": "0.3.7"
29
+ "ripple": "0.3.8"
30
30
  },
31
31
  "dependencies": {},
32
32
  "files": [
package/src/index.test.js CHANGED
@@ -291,10 +291,10 @@ export default component App() {
291
291
  expect(result).toBeWithNewline(expected);
292
292
  });
293
293
 
294
- it('should format a component with an object reactive property notation props.@children', async () => {
294
+ it('should format a component with a dynamic component using props member access', async () => {
295
295
  const expected = `component Card(props) {
296
296
  <div class="card">
297
- <props.@children />
297
+ <@props.children />
298
298
  </div>
299
299
  }`;
300
300
 
@@ -652,26 +652,26 @@ import { Something, type Props, track } from 'ripple';`;
652
652
  expect(result).toBeWithNewline(expected);
653
653
  });
654
654
 
655
- it('should handle @ prefix', async () => {
655
+ it('should handle tracked variable with lazy destructuring', async () => {
656
656
  const input = `export default component App() {
657
657
  <div>
658
- let count = track(0);
659
- @count = 2;
660
- console.log(@count);
658
+ let &[count] = track(0);
659
+ count = 2;
661
660
  console.log(count);
662
- if (@count > 1) {
663
- <button onClick={() => @count++}>{@count}</button>
661
+ console.log(count);
662
+ if (count > 1) {
663
+ <button onClick={() => count++}>{count}</button>
664
664
  }
665
665
  </div>
666
666
  }`;
667
667
  const expected = `export default component App() {
668
668
  <div>
669
- let count = track(0);
670
- @count = 2;
671
- console.log(@count);
669
+ let &[count] = track(0);
670
+ count = 2;
671
+ console.log(count);
672
672
  console.log(count);
673
- if (@count > 1) {
674
- <button onClick={() => @count++}>{@count}</button>
673
+ if (count > 1) {
674
+ <button onClick={() => count++}>{count}</button>
675
675
  }
676
676
  </div>
677
677
  }`;
@@ -706,19 +706,19 @@ import { Something, type Props, track } from 'ripple';`;
706
706
  expect(result).toBeWithNewline(expected);
707
707
  });
708
708
 
709
- it('should preserve @ symbol in JSX attributes and shorthand syntax', async () => {
709
+ it('should format JSX attributes with tracked values', async () => {
710
710
  const input = `component App() {
711
- const count = track(0);
711
+ const &[count] = track(0);
712
712
 
713
- <Counter count={@count} />
714
- <Counter {@count} />
713
+ <Counter count={count} />
714
+ <Counter {count} />
715
715
  }`;
716
716
 
717
717
  const expected = `component App() {
718
- const count = track(0);
718
+ const &[count] = track(0);
719
719
 
720
- <Counter {@count} />
721
- <Counter {@count} />
720
+ <Counter {count} />
721
+ <Counter {count} />
722
722
  }`;
723
723
 
724
724
  const result = await format(input, { singleQuote: true });
@@ -963,7 +963,7 @@ export component Test({ a, b }: Props) {}`;
963
963
 
964
964
  it('should not strip @ from dynamic self-closing components', async () => {
965
965
  const expected = `component App() {
966
- <@ripple_object.@tracked_basic />
966
+ <@ripple_object.tracked_basic />
967
967
  }`;
968
968
 
969
969
  const result = await format(expected, { singleQuote: true, printWidth: 100 });
@@ -1733,7 +1733,7 @@ const program =
1733
1733
  });
1734
1734
 
1735
1735
  it('should keep parents in math subtraction and multiplication', async () => {
1736
- const expected = `let offset = track(() => (@page - 1) * @limit);`;
1736
+ const expected = `let offset = track(() => (page - 1) * limit);`;
1737
1737
 
1738
1738
  const result = await format(expected, { singleQuote: true, printWidth: 100 });
1739
1739
  expect(result).toBeWithNewline(expected);
@@ -2292,18 +2292,18 @@ component Child({ something }) {
2292
2292
 
2293
2293
  it('should correctly handle call expressions', async () => {
2294
2294
  const input = `export component App() {
2295
- const context = track(globalContext.get().theme);
2295
+ const &[context] = track(globalContext.get().theme);
2296
2296
  <div>
2297
2297
  <TypedComponent />
2298
- {@context}
2298
+ {context}
2299
2299
  </div>
2300
2300
  }`;
2301
2301
 
2302
2302
  const expected = `export component App() {
2303
- const context = track(globalContext.get().theme);
2303
+ const &[context] = track(globalContext.get().theme);
2304
2304
  <div>
2305
2305
  <TypedComponent />
2306
- {@context}
2306
+ {context}
2307
2307
  </div>
2308
2308
  }`;
2309
2309
 
@@ -2725,13 +2725,13 @@ function test() {
2725
2725
  const expected = `component App() {
2726
2726
  <button
2727
2727
  onClick={() => {
2728
- @hasError = false;
2728
+ hasError = false;
2729
2729
  try {
2730
- @hasError = false;
2730
+ hasError = false;
2731
2731
  // @ts-ignore
2732
2732
  obj['nonexistent']();
2733
2733
  } catch {
2734
- // @hasError = true;
2734
+ // hasError = true;
2735
2735
  }
2736
2736
  }}
2737
2737
  >
@@ -4377,7 +4377,7 @@ component Polygon() {
4377
4377
  // <div id="third-top-block">{"Top Scope - Show is true"}</div>
4378
4378
  // }
4379
4379
 
4380
- <button onClick={() => (@b = !@b)}>{"Toggle b"}</button>
4380
+ <button onClick={() => (b = !b)}>{"Toggle b"}</button>
4381
4381
  }`;
4382
4382
 
4383
4383
  const result = await format(expected, { printWidth: 100 });
@@ -4400,7 +4400,7 @@ component Polygon() {
4400
4400
  // <div>{"Top Scope - Show is true"}</div>
4401
4401
  // }
4402
4402
 
4403
- <button onClick={() => (@b = !@b)}>{"Toggle b"}</button>
4403
+ <button onClick={() => (b = !b)}>{"Toggle b"}</button>
4404
4404
  }`;
4405
4405
 
4406
4406
  const result = await format(expected, { printWidth: 100 });
@@ -4828,25 +4828,25 @@ component Polygon() {
4828
4828
  expect(result).toBeWithNewline(expected);
4829
4829
  });
4830
4830
 
4831
- it('should preserve @ symbol in JSX attributes inside <tsx:react>', async () => {
4831
+ it('should format JSX attributes inside <tsx:react>', async () => {
4832
4832
  const input = `component App() {
4833
- const count = track(0);
4833
+ const &[count] = track(0);
4834
4834
 
4835
4835
  <div>
4836
4836
  <h1>{'Hello, from Ripple!'}</h1>
4837
4837
  <tsx:react>
4838
- <Counter count={@count} />
4838
+ <Counter count={count} />
4839
4839
  </tsx:react>
4840
4840
  </div>
4841
4841
  }`;
4842
4842
 
4843
4843
  const expected = `component App() {
4844
- const count = track(0);
4844
+ const &[count] = track(0);
4845
4845
 
4846
4846
  <div>
4847
4847
  <h1>{'Hello, from Ripple!'}</h1>
4848
4848
  <tsx:react>
4849
- <Counter count={@count} />
4849
+ <Counter count={count} />
4850
4850
  </tsx:react>
4851
4851
  </div>
4852
4852
  }`;
@@ -4898,7 +4898,7 @@ component App() {
4898
4898
  <tsx:react>
4899
4899
  Hello world
4900
4900
  <DemoContext.Provider value={"Hello from Context!"}>
4901
- <Child count={@count} />
4901
+ <Child count={count} />
4902
4902
  </DemoContext.Provider>
4903
4903
  </tsx:react>
4904
4904
  }`;
@@ -4906,7 +4906,7 @@ component App() {
4906
4906
  <tsx:react>
4907
4907
  Hello world
4908
4908
  <DemoContext.Provider value={"Hello from Context!"}>
4909
- <Child count={@count} />
4909
+ <Child count={count} />
4910
4910
  </DemoContext.Provider>
4911
4911
  </tsx:react>
4912
4912
  }`;
@@ -4963,7 +4963,7 @@ component App() {
4963
4963
  const input = `component Test() {
4964
4964
  <button
4965
4965
  onClick={() => {
4966
- if (@status === 'a') @status = 'b'; else if (@status === 'b') @status = 'c'; else @status =
4966
+ if (status === 'a') status = 'b'; else if (status === 'b') status = 'c'; else status =
4967
4967
  'a';
4968
4968
  }}
4969
4969
  >
@@ -4973,9 +4973,9 @@ if (@status === 'a') @status = 'b'; else if (@status === 'b') @status = 'c'; els
4973
4973
  const expected = `component Test() {
4974
4974
  <button
4975
4975
  onClick={() => {
4976
- if (@status === 'a') @status = 'b';
4977
- else if (@status === 'b') @status = 'c';
4978
- else @status = 'a';
4976
+ if (status === 'a') status = 'b';
4977
+ else if (status === 'b') status = 'c';
4978
+ else status = 'a';
4979
4979
  }}
4980
4980
  >
4981
4981
  {'Click'}