@@ -40,6 +40,9 @@ function message(macro) {
40
40
const defineExposeNotTheLast =
41
41
'`defineExpose` should be the last statement in `<script setup>`.'
42
42
43
+ const putExposeAtBottom =
44
+ 'Put `defineExpose` as the last statement in `<script setup>`.'
45
+
43
46
tester . run ( 'define-macros-order' , rule , {
44
47
valid : [
45
48
{
@@ -678,58 +681,52 @@ tester.run('define-macros-order', rule, {
678
681
filename : 'test.vue' ,
679
682
code : `
680
683
<script setup>
681
- defineProps({
682
- test: Boolean
683
- })
684
-
685
- /** expose */
686
- defineExpose({
687
- foo: 'bar'
688
- })
689
-
690
- /** console start */
691
- console.log('test')
692
- /** console end */
693
- </script>
694
- ` ,
695
- output : `
696
- <script setup>
697
- defineProps({
698
- test: Boolean
699
- })
700
-
701
- /** console start */
702
- console.log('test')
703
- /** console end */
704
-
705
- /** expose */
706
- defineExpose({
707
- foo: 'bar'
708
- })
684
+ /** emits */
685
+ defineEmits(['update:foo'])
686
+ /** expose */
687
+ defineExpose({})
688
+ /** slots */
689
+ const slots = defineSlots()
709
690
</script>
710
691
` ,
692
+ output : null ,
711
693
options : optionsExposeLast ,
712
694
errors : [
713
695
{
714
696
message : defineExposeNotTheLast ,
715
- line : 8
697
+ line : 6 ,
698
+ suggestions : [
699
+ {
700
+ desc : putExposeAtBottom ,
701
+ output : `
702
+ <script setup>
703
+ /** emits */
704
+ defineEmits(['update:foo'])
705
+ /** slots */
706
+ const slots = defineSlots()
707
+ /** expose */
708
+ defineExpose({})
709
+ </script>
710
+ `
711
+ }
712
+ ]
716
713
}
717
714
]
718
715
} ,
719
716
{
720
717
filename : 'test.vue' ,
721
718
code : `
722
719
<script setup>
723
- /** slots */
724
- const slots = defineSlots()
725
- /** options */
726
- defineOptions({})
727
720
/** emits */
728
721
defineEmits(['update:foo'])
729
722
/** expose */
730
723
defineExpose({})
724
+ /** options */
725
+ defineOptions({})
731
726
/** props */
732
727
const props = defineProps(['foo'])
728
+ /** slots */
729
+ const slots = defineSlots()
733
730
</script>
734
731
` ,
735
732
output : `
@@ -738,28 +735,47 @@ tester.run('define-macros-order', rule, {
738
735
defineOptions({})
739
736
/** emits */
740
737
defineEmits(['update:foo'])
738
+ /** expose */
739
+ defineExpose({})
741
740
/** props */
742
741
const props = defineProps(['foo'])
743
742
/** slots */
744
743
const slots = defineSlots()
745
- /** expose */
746
- defineExpose({})
747
744
</script>
748
745
` ,
749
746
options : [
750
747
{
751
- order : [ 'defineOptions' , 'defineEmits' , 'defineProps' , 'defineSlots' ] ,
748
+ order : [ 'defineOptions' , 'defineEmits' , 'defineProps' ] ,
752
749
defineExposeLast : true
753
750
}
754
751
] ,
755
752
errors : [
756
753
{
757
- message : message ( 'defineOptions' ) ,
758
- line : 6
754
+ message : defineExposeNotTheLast ,
755
+ line : 6 ,
756
+ suggestions : [
757
+ {
758
+ desc : putExposeAtBottom ,
759
+ output : `
760
+ <script setup>
761
+ /** emits */
762
+ defineEmits(['update:foo'])
763
+ /** options */
764
+ defineOptions({})
765
+ /** props */
766
+ const props = defineProps(['foo'])
767
+ /** slots */
768
+ const slots = defineSlots()
769
+ /** expose */
770
+ defineExpose({})
771
+ </script>
772
+ `
773
+ }
774
+ ]
759
775
} ,
760
776
{
761
- message : defineExposeNotTheLast ,
762
- line : 10
777
+ message : message ( 'defineOptions' ) ,
778
+ line : 8
763
779
}
764
780
]
765
781
}
0 commit comments