@@ -8,16 +8,21 @@ 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 : { ecmaVersion : 2015 , sourceType : 'module' , parser : '@typescript-eslint/parser ' }
21
26
} )
22
27
23
28
ruleTester . run ( 'force-types-on-object-props' , rule , {
@@ -54,35 +59,31 @@ ruleTester.run('force-types-on-object-props', rule, {
54
59
code : template ( 'type: Object as any' ) ,
55
60
errors : [
56
61
{
57
- message :
58
- 'Object props should be typed like this: "type: Object as Prop<T>"'
62
+ message : 'Object props has to contains type.'
59
63
}
60
64
]
61
65
} ,
62
66
{
63
67
code : template ( 'type: Object as {}' ) ,
64
68
errors : [
65
69
{
66
- message :
67
- 'Object props should be typed like this: "type: Object as Prop<T>"'
70
+ message : 'Object props has to contains type.'
68
71
}
69
72
]
70
73
} ,
71
74
{
72
75
code : template ( 'type: Object as unknown' ) ,
73
76
errors : [
74
77
{
75
- message :
76
- 'Object props should be typed like this: "type: Object as Prop<T>"'
78
+ message : 'Object props has to contains type.'
77
79
}
78
80
]
79
81
} ,
80
82
{
81
83
code : template ( 'type: Object as string' ) ,
82
84
errors : [
83
85
{
84
- message :
85
- 'Object props should be typed like this: "type: Object as Prop<T>"'
86
+ message : 'Object props has to contains type.'
86
87
}
87
88
]
88
89
}
0 commit comments