@@ -191,7 +191,53 @@ tester.run('no-ref-as-operand', rule, {
191
191
model.value = value;
192
192
}
193
193
</script>
194
+ ` ,
195
+ `
196
+ <script setup>
197
+ const emit = defineEmits(['test'])
198
+ const [model, mod] = defineModel();
199
+
200
+ function update() {
201
+ emit('test', model.value)
202
+ }
203
+ </script>
204
+ ` ,
194
205
`
206
+ <script>
207
+ import { ref, defineComponent } from 'vue'
208
+
209
+ export default defineComponent({
210
+ emits: ['incremented'],
211
+ setup(_, ctx) {
212
+ const counter = ref(0)
213
+
214
+ ctx.emit('incremented', counter.value)
215
+
216
+ return {
217
+ counter
218
+ }
219
+ }
220
+ })
221
+ </script>
222
+ ` ,
223
+ `
224
+ <script>
225
+ import { ref, defineComponent } from 'vue'
226
+
227
+ export default defineComponent({
228
+ emits: ['incremented'],
229
+ setup(_, { emit }) {
230
+ const counter = ref(0)
231
+
232
+ emit('incremented', counter.value)
233
+
234
+ return {
235
+ counter
236
+ }
237
+ }
238
+ })
239
+ </script>
240
+ ` ,
195
241
] ,
196
242
invalid : [
197
243
{
@@ -823,6 +869,130 @@ tester.run('no-ref-as-operand', rule, {
823
869
}
824
870
]
825
871
} ,
872
+ {
873
+ code : `
874
+ <script setup>
875
+ import { ref } from 'vue'
876
+ const emits = defineEmits(['test'])
877
+ const count = ref(0)
878
+
879
+ function update() {
880
+ emits('test', count)
881
+ }
882
+ </script>
883
+ ` ,
884
+ output : `
885
+ <script setup>
886
+ import { ref } from 'vue'
887
+ const emits = defineEmits(['test'])
888
+ const count = ref(0)
889
+
890
+ function update() {
891
+ emits('test', count.value)
892
+ }
893
+ </script>
894
+ ` ,
895
+ errors : [
896
+ {
897
+ message :
898
+ 'Must use `.value` to read or write the value wrapped by `ref()`.' ,
899
+ line : 8 ,
900
+ endLine : 8 ,
901
+ } ,
902
+ ]
903
+ } ,
904
+ {
905
+ code : `
906
+ <script>
907
+ import { ref, defineComponent } from 'vue'
908
+
909
+ export default defineComponent({
910
+ emits: ['incremented'],
911
+ setup(_, ctx) {
912
+ const counter = ref(0)
913
+
914
+ ctx.emit('incremented', counter)
915
+
916
+ return {
917
+ counter
918
+ }
919
+ }
920
+ })
921
+ </script>
922
+ ` ,
923
+ output :`
924
+ <script>
925
+ import { ref, defineComponent } from 'vue'
926
+
927
+ export default defineComponent({
928
+ emits: ['incremented'],
929
+ setup(_, ctx) {
930
+ const counter = ref(0)
931
+
932
+ ctx.emit('incremented', counter.value)
933
+
934
+ return {
935
+ counter
936
+ }
937
+ }
938
+ })
939
+ </script>
940
+ ` ,
941
+ errors : [
942
+ {
943
+ message :
944
+ 'Must use `.value` to read or write the value wrapped by `ref()`.' ,
945
+ line : 10 ,
946
+ endLine : 10 ,
947
+ } ,
948
+ ]
949
+ } ,
950
+ {
951
+ code : `
952
+ <script>
953
+ import { ref, defineComponent } from 'vue'
954
+
955
+ export default defineComponent({
956
+ emits: ['incremented'],
957
+ setup(_, { emit }) {
958
+ const counter = ref(0)
959
+
960
+ emit('incremented', counter)
961
+
962
+ return {
963
+ counter
964
+ }
965
+ }
966
+ })
967
+ </script>
968
+ ` ,
969
+ output :`
970
+ <script>
971
+ import { ref, defineComponent } from 'vue'
972
+
973
+ export default defineComponent({
974
+ emits: ['incremented'],
975
+ setup(_, { emit }) {
976
+ const counter = ref(0)
977
+
978
+ emit('incremented', counter.value)
979
+
980
+ return {
981
+ counter
982
+ }
983
+ }
984
+ })
985
+ </script>
986
+ ` ,
987
+ errors : [
988
+ {
989
+ message :
990
+ 'Must use `.value` to read or write the value wrapped by `ref()`.' ,
991
+ line : 10 ,
992
+ endLine : 10 ,
993
+ } ,
994
+ ]
995
+ } ,
826
996
// Auto-import
827
997
{
828
998
code : `
0 commit comments