Skip to content

Commit 9264f63

Browse files
Apply suggestions from code review
Co-authored-by: Flo Edelmann <[email protected]>
1 parent 96eb868 commit 9264f63

File tree

2 files changed

+10
-50
lines changed

2 files changed

+10
-50
lines changed

docs/rules/force-types-on-object-props.md

+7-47
Original file line numberDiff line numberDiff line change
@@ -13,60 +13,20 @@ description: enforce user to add type declaration to object props
1313

1414
## :book: Rule Details
1515

16-
Prevent missing type declaration of not primitive objects in a TypeScript projects.
17-
18-
Bad:
19-
20-
<eslint-code-block :rules="{'vue/force-types-on-object-props': ['error']}">
21-
22-
```js
23-
export default {
24-
props: {
25-
prop: {
26-
type: Object,
27-
},
28-
},
29-
}
30-
```
31-
32-
</eslint-code-block>
33-
34-
<eslint-code-block :rules="{'vue/force-types-on-object-props': ['error']}">
35-
36-
```ts
37-
export default {
38-
props: {
39-
prop: {
40-
type: Array
41-
}
42-
}
43-
}
44-
```
45-
46-
</eslint-code-block>
47-
48-
Good:
16+
Prevent missing type declarations for non-primitive object props in TypeScript projects.
4917

5018
<eslint-code-block :rules="{'vue/force-types-on-object-props': ['error']}">
5119

5220
```ts
5321
export default {
5422
props: {
5523
prop: {
24+
// ✗ BAD
25+
type: Object,
26+
type: Array,
27+
28+
// ✓ GOOD
5629
type: Object as Props<Anything>,
57-
}
58-
}
59-
}
60-
```
61-
62-
</eslint-code-block>
63-
64-
<eslint-code-block :rules="{'vue/force-types-on-object-props': ['error']}">
65-
66-
```ts
67-
export default {
68-
props: {
69-
prop: {
7030
type: String, // or any other primitive type
7131
}
7232
}
@@ -81,7 +41,7 @@ Nothing.
8141

8242
## :mute: When Not To Use It
8343

84-
When you're not using TypeScript in the project****.
44+
When you're not using TypeScript in the project.
8545

8646
## :books: Further Reading
8747

lib/rules/force-types-on-object-props.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ module.exports = {
3737
meta: {
3838
type: 'suggestion',
3939
docs: {
40-
description: 'enforce user to add type declaration to object props',
41-
categories: ['base'],
40+
description: 'enforce adding type declarations to object props',
41+
categories: ['suggestion'],
4242
recommended: false,
4343
url: 'https://eslint.vuejs.org/rules/force-types-on-object-props.html'
4444
},
@@ -108,7 +108,7 @@ module.exports = {
108108
) {
109109
context.report({
110110
node: prop,
111-
message: 'Object props has to contains type.'
111+
message: 'Expected type annotation on object prop.'
112112
})
113113
}
114114
}

0 commit comments

Comments
 (0)