Skip to content

Commit ab62a49

Browse files
goodmindgajus
authored andcommitted
feat: add require-inexact-type rule (#408)
* feat: add require-inexact-type rule * docs: generate docs
1 parent 712d840 commit ab62a49

File tree

8 files changed

+503
-15
lines changed

8 files changed

+503
-15
lines changed

.README/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ When `true`, only checks files with a [`@flow` annotation](http://flowtype.org/d
173173
{"gitdown": "include", "file": "./rules/object-type-delimiter.md"}
174174
{"gitdown": "include", "file": "./rules/require-compound-type-alias.md"}
175175
{"gitdown": "include", "file": "./rules/require-exact-type.md"}
176+
{"gitdown": "include", "file": "./rules/require-inexact-type.md"}
176177
{"gitdown": "include", "file": "./rules/require-parameter-type.md"}
178+
{"gitdown": "include", "file": "./rules/require-readonly-react-props.md"}
177179
{"gitdown": "include", "file": "./rules/require-return-type.md"}
178180
{"gitdown": "include", "file": "./rules/require-types-at-top.md"}
179181
{"gitdown": "include", "file": "./rules/require-valid-file-annotation.md"}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
### `require-inexact-type`
2+
3+
This rule enforces explicit inexact object types.
4+
5+
#### Options
6+
7+
The rule has one string option:
8+
9+
- `"always"` (default): Report all object type definitions that aren't explicit inexact, but ignore exact objects.
10+
- `"never"`: Report all object type definitions that are explicit inexact.
11+
12+
```js
13+
{
14+
"rules": {
15+
"flowtype/require-inexact-type": [
16+
2,
17+
"always"
18+
]
19+
}
20+
}
21+
22+
{
23+
"rules": {
24+
"flowtype/require-inexact-type": [
25+
2,
26+
"never"
27+
]
28+
}
29+
}
30+
```
31+
32+
<!-- assertions requireInexactType -->

.README/rules/require-readonly-react-props.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This rule validates that React props are marked as $ReadOnly. React props are immutable and modifying them could lead to unexpected results. Marking prop shapes as $ReadOnly avoids these issues.
44

5-
The rule tries its best to work with both class and functional components. For class components, it does a fuzzy check for one of "Component", "PureComponent", "React.Component" and "React.PureComponent". It doesn't actually infer that those identifiers resolve to a proper `React.Component` object.
5+
The rule tries its best to work with both class and functional components. For class components, it does a fuzzy check for one of "Component", "PureComponent", "React.Component" and "React.PureComponent". It doesn't actually infer that those identifiers resolve to a proper `React.Component` object.
66

77
For example, this will NOT be checked:
88

@@ -79,4 +79,4 @@ class Bar extends React.Component<Props> { }
7979
```
8080

8181

82-
<!-- assertions requireReadOnlyReactProps -->
82+
<!-- assertions requireReadonlyReactProps -->

0 commit comments

Comments
 (0)