@@ -5,7 +5,8 @@ contributors:
5
5
- manucorporat
6
6
- gioboa
7
7
- maiieul
8
- updated_at : ' 2023-11-22T07:02:07Z'
8
+ - wmertens
9
+ updated_at : ' 2025-03-18T00:00:00Z'
9
10
created_at : ' 2023-05-20T00:04:28Z'
10
11
---
11
12
@@ -15,6 +16,7 @@ created_at: '2023-05-20T00:04:28Z'
15
16
[ // ] : < > ( to update run: pnpm eslint.update )
16
17
[ // ] : < > ( after changing the rule metadata on )
17
18
[ // ] : < > ( packages/eslint-plugin-qwik/index.ts )
19
+ [ // ] : < > ( and update the frontmatter if needed )
18
20
[ // ] : < > ( -------------------------------------- )
19
21
20
22
import ' ./styles.css' ;
@@ -323,7 +325,33 @@ import './styles.css';
323
325
</span >
324
326
<span
325
327
class = { {
326
- ' icon' : true ,
328
+ ' icon' : false ,
329
+ ' icon icon-inactive' : true ,
330
+ }}
331
+ >
332
+ 🔔
333
+ </span >
334
+ </div >
335
+ </a >
336
+
337
+
338
+ <a href = " #serializer-signal-usage" class = " p-4 flex panel" >
339
+ <div class = " flex-1" >
340
+ <code >serializer-signal-usage</code >
341
+ <span class = " rule-description" >Ensure signals used in update() are also used in deserialize()</span >
342
+ </div >
343
+ <div class = " flex gap-2 items-center" >
344
+ <span
345
+ class = { {
346
+ ' icon' : false ,
347
+ ' icon icon-inactive' : false ,
348
+ }}
349
+ >
350
+ ✅
351
+ </span >
352
+ <span
353
+ class = { {
354
+ ' icon' : false ,
327
355
' icon icon-inactive' : false ,
328
356
}}
329
357
>
@@ -972,7 +1000,7 @@ export const ColorList = component$(() => {
972
1000
<div class = " code-wrapper" >
973
1001
<span class = " badge good" >✓</span >
974
1002
```tsx { 4 ,12 } /serverGreeter/#a
975
- import { $ , component$ } from '@qwik.dev/core';
1003
+ import { component$ } from '@qwik.dev/core';
976
1004
import { server$ } from '@qwik.dev/router';
977
1005
978
1006
const serverGreeter = server$((firstName: string, lastName: string) => {
@@ -982,10 +1010,10 @@ const serverGreeter = server$((firstName: string, lastName: string) => {
982
1010
983
1011
export default component$(() => (
984
1012
<button
985
- onClick$ = { $ ( async () => {
1013
+ onClick$ = { async () => {
986
1014
const greeting = await serverGreeter (' John' , ' Doe' );
987
1015
alert (greeting );
988
- }) }
1016
+ }}
989
1017
>
990
1018
greet
991
1019
</button >
@@ -1086,5 +1114,61 @@ import Image from '~/media/image.png';
1086
1114
1087
1115
</div >
1088
1116
1117
+
1118
+ <div class = " rule-wrapper" >
1119
+ <h3 id = " serializer-signal-usage" >serializer-signal-usage</h3 >
1120
+ <span >Ensure signals used in update() are also used in deserialize()</span >
1121
+
1122
+ <h4 >serializerSignalMismatch</h4 >
1123
+ <p >Examples of <b >correct</b > code for this rule:</p >
1124
+ <div class = " code-wrapper" >
1125
+ <span class = " badge good" >✓</span >
1126
+ ```tsx /countSignal/#a
1127
+ import { useSignal , useSerializer$ } from '@qwik.dev/core';
1128
+ import MyClass from './my-class';
1129
+
1130
+ export default component$(() => {
1131
+ const countSignal = useSignal (0 );
1132
+
1133
+ useSerializer$ (() => ({
1134
+ deserialize : () => new MyClass (countSignal .value ),
1135
+ update : (myClass ) => {
1136
+ myClass .count = countSignal .value ;
1137
+ return myClass ;
1138
+ }
1139
+ }));
1140
+
1141
+ return <div >{ myClass .count } </div >;
1142
+ } );
1143
+ ```
1144
+ </div >
1145
+ <p >Examples of <b >incorrect</b > code for this rule:</p >
1146
+ <div class = " code-wrapper" >
1147
+ <span class = " badge bad" >✕</span >
1148
+ ```tsx /countSignal/#a
1149
+ import { useSignal , useSerializer$ } from '@qwik.dev/core';
1150
+ import MyClass from './my-class';
1151
+
1152
+ export default component$(() => {
1153
+ const countSignal = useSignal (0 );
1154
+
1155
+ useSerializer$ (() => ({
1156
+ deserialize : (count ) => new MyClass (count ),
1157
+ initial: 2 ,
1158
+ update : (myClass ) => {
1159
+ myClass .count = countSignal .value ;
1160
+ return myClass ;
1161
+ }
1162
+ }));
1163
+
1164
+ return <div >{ myClass .count } </div >;
1165
+ } );
1166
+ ```
1167
+ <p class = " code-description" >The countSignal is used in update() but not in deserialize()</p >
1168
+ </div >
1169
+ <div class = " edit-examples-wrapper" ><a href = " https://github.com/QwikDev/qwik/edit/main/packages/eslint-plugin-qwik/src/serializerSignalUsage.ts" target = " _blank" class = " edit-btn" >Edit examples</a ></div >
1170
+
1171
+ </div >
1172
+
1089
1173
</div >
1090
1174
</div >
0 commit comments