@@ -8,16 +8,25 @@ const RuleTester = require('eslint').RuleTester
8
8
const rule = require ( '../../../lib/rules/force-types-on-object-props' )
9
9
10
10
const template = ( prop ) => `
11
- <template></template >
12
- <script>
11
+ <script lang="ts" >
12
+ import { Prop } from 'vue/types/options';
13
13
export default {
14
+ props: {
15
+ prop: {
16
+ ${ prop }
17
+ }
18
+ }
14
19
}
15
20
</script>
16
21
`
17
22
18
23
const ruleTester = new RuleTester ( {
19
24
parser : require . resolve ( 'vue-eslint-parser' ) ,
20
- parserOptions : { ecmaVersion : 2015 , sourceType : 'module' }
25
+ parserOptions : {
26
+ ecmaVersion : 2015 ,
27
+ sourceType : 'module' ,
28
+ parser : '@typescript-eslint/parser'
29
+ }
21
30
} )
22
31
23
32
ruleTester . run ( 'force-types-on-object-props' , rule , {
@@ -54,35 +63,31 @@ ruleTester.run('force-types-on-object-props', rule, {
54
63
code : template ( 'type: Object as any' ) ,
55
64
errors : [
56
65
{
57
- message :
58
- 'Object props should be typed like this: "type: Object as Prop<T>"'
66
+ message : 'Object props has to contains type.'
59
67
}
60
68
]
61
69
} ,
62
70
{
63
71
code : template ( 'type: Object as {}' ) ,
64
72
errors : [
65
73
{
66
- message :
67
- 'Object props should be typed like this: "type: Object as Prop<T>"'
74
+ message : 'Object props has to contains type.'
68
75
}
69
76
]
70
77
} ,
71
78
{
72
79
code : template ( 'type: Object as unknown' ) ,
73
80
errors : [
74
81
{
75
- message :
76
- 'Object props should be typed like this: "type: Object as Prop<T>"'
82
+ message : 'Object props has to contains type.'
77
83
}
78
84
]
79
85
} ,
80
86
{
81
87
code : template ( 'type: Object as string' ) ,
82
88
errors : [
83
89
{
84
- message :
85
- 'Object props should be typed like this: "type: Object as Prop<T>"'
90
+ message : 'Object props has to contains type.'
86
91
}
87
92
]
88
93
}
0 commit comments