|
36 | 36 | * [`object-type-delimiter`](#eslint-plugin-flowtype-rules-object-type-delimiter) |
37 | 37 | * [`require-compound-type-alias`](#eslint-plugin-flowtype-rules-require-compound-type-alias) |
38 | 38 | * [`require-exact-type`](#eslint-plugin-flowtype-rules-require-exact-type) |
| 39 | + * [`require-indexer-name`](#eslint-plugin-flowtype-rules-require-indexer-name) |
39 | 40 | * [`require-inexact-type`](#eslint-plugin-flowtype-rules-require-inexact-type) |
40 | 41 | * [`require-parameter-type`](#eslint-plugin-flowtype-rules-require-parameter-type) |
41 | 42 | * [`require-readonly-react-props`](#eslint-plugin-flowtype-rules-require-readonly-react-props) |
@@ -2367,12 +2368,59 @@ type foo = number; |
2367 | 2368 |
|
2368 | 2369 |
|
2369 | 2370 |
|
| 2371 | +<a name="eslint-plugin-flowtype-rules-require-indexer-name"></a> |
| 2372 | +### <code>require-indexer-name</code> |
| 2373 | +
|
| 2374 | +_The `--fix` option on the command line automatically fixes problems reported by this rule._ |
| 2375 | +
|
| 2376 | +This rule validates Flow object indexer name. |
| 2377 | +
|
| 2378 | +<a name="eslint-plugin-flowtype-rules-require-indexer-name-options-4"></a> |
| 2379 | +#### Options |
| 2380 | +
|
| 2381 | +The rule has a string option: |
| 2382 | +
|
| 2383 | +* `"never"` (default): Never report files that are missing an indexer key name. |
| 2384 | +* `"always"`: Always report files that are missing an indexer key name. |
| 2385 | +
|
| 2386 | +```js |
| 2387 | +{ |
| 2388 | + "rules": { |
| 2389 | + "flowtype/require-indexer-name": [ |
| 2390 | + 2, |
| 2391 | + "always" |
| 2392 | + ] |
| 2393 | + } |
| 2394 | +} |
| 2395 | +``` |
| 2396 | +
|
| 2397 | +The following patterns are considered problems: |
| 2398 | +
|
| 2399 | +```js |
| 2400 | +type foo = { [string]: number }; |
| 2401 | +// Message: All indexers must be declared with key name. |
| 2402 | +``` |
| 2403 | +
|
| 2404 | +The following patterns are not considered problems: |
| 2405 | +
|
| 2406 | +```js |
| 2407 | +type foo = { [key: string]: number }; |
| 2408 | + |
| 2409 | +// Options: ["never"] |
| 2410 | +type foo = { [key: string]: number }; |
| 2411 | + |
| 2412 | +// Options: ["never"] |
| 2413 | +type foo = { [string]: number }; |
| 2414 | +``` |
| 2415 | +
|
| 2416 | +
|
| 2417 | +
|
2370 | 2418 | <a name="eslint-plugin-flowtype-rules-require-inexact-type"></a> |
2371 | 2419 | ### <code>require-inexact-type</code> |
2372 | 2420 |
|
2373 | 2421 | This rule enforces explicit inexact object types. |
2374 | 2422 |
|
2375 | | -<a name="eslint-plugin-flowtype-rules-require-inexact-type-options-4"></a> |
| 2423 | +<a name="eslint-plugin-flowtype-rules-require-inexact-type-options-5"></a> |
2376 | 2424 | #### Options |
2377 | 2425 |
|
2378 | 2426 | The rule has one string option: |
@@ -2481,7 +2529,7 @@ type foo = number; |
2481 | 2529 |
|
2482 | 2530 | Requires that all function parameters have type annotations. |
2483 | 2531 |
|
2484 | | -<a name="eslint-plugin-flowtype-rules-require-parameter-type-options-5"></a> |
| 2532 | +<a name="eslint-plugin-flowtype-rules-require-parameter-type-options-6"></a> |
2485 | 2533 | #### Options |
2486 | 2534 |
|
2487 | 2535 | You can skip all arrow functions by providing the `excludeArrowFunctions` option with `true`. |
@@ -2806,7 +2854,7 @@ function Foo(props: {||}) { return <p /> } |
2806 | 2854 |
|
2807 | 2855 | Requires that functions have return type annotation. |
2808 | 2856 |
|
2809 | | -<a name="eslint-plugin-flowtype-rules-require-return-type-options-6"></a> |
| 2857 | +<a name="eslint-plugin-flowtype-rules-require-return-type-options-7"></a> |
2810 | 2858 | #### Options |
2811 | 2859 |
|
2812 | 2860 | You can skip all arrow functions by providing the `excludeArrowFunctions` option with `true`. |
@@ -3160,7 +3208,7 @@ async function * foo(): AsyncIterable<number> { yield 2; } |
3160 | 3208 |
|
3161 | 3209 | Requires all type declarations to be at the top of the file, after any import declarations. |
3162 | 3210 |
|
3163 | | -<a name="eslint-plugin-flowtype-rules-require-types-at-top-options-7"></a> |
| 3211 | +<a name="eslint-plugin-flowtype-rules-require-types-at-top-options-8"></a> |
3164 | 3212 | #### Options |
3165 | 3213 |
|
3166 | 3214 | The rule has a string option: |
@@ -3237,7 +3285,7 @@ This rule validates Flow file annotations. |
3237 | 3285 |
|
3238 | 3286 | This rule can optionally report missing or missed placed annotations, common typos (e.g. `// @floww`), and enforce a consistant annotation style. |
3239 | 3287 |
|
3240 | | -<a name="eslint-plugin-flowtype-rules-require-valid-file-annotation-options-8"></a> |
| 3288 | +<a name="eslint-plugin-flowtype-rules-require-valid-file-annotation-options-9"></a> |
3241 | 3289 | #### Options |
3242 | 3290 |
|
3243 | 3291 | The rule has a string option: |
|
3409 | 3457 |
|
3410 | 3458 | Requires that all variable declarators have type annotations. |
3411 | 3459 |
|
3412 | | -<a name="eslint-plugin-flowtype-rules-require-variable-type-options-9"></a> |
| 3460 | +<a name="eslint-plugin-flowtype-rules-require-variable-type-options-10"></a> |
3413 | 3461 | #### Options |
3414 | 3462 |
|
3415 | 3463 | You can exclude variables that match a certain regex by using `excludeVariableMatch`. |
@@ -3561,7 +3609,7 @@ Enforces sorting of Object annotations. |
3561 | 3609 |
|
3562 | 3610 | This rule mirrors ESlint's [sort-keys](http://eslint.org/docs/rules/sort-keys) rule. |
3563 | 3611 |
|
3564 | | -<a name="eslint-plugin-flowtype-rules-sort-keys-options-10"></a> |
| 3612 | +<a name="eslint-plugin-flowtype-rules-sort-keys-options-11"></a> |
3565 | 3613 | #### Options |
3566 | 3614 |
|
3567 | 3615 | The first option specifies sort order. |
@@ -3786,7 +3834,7 @@ _The `--fix` option on the command line automatically fixes problems reported by |
3786 | 3834 |
|
3787 | 3835 | Enforces consistent spacing after the type annotation colon. |
3788 | 3836 |
|
3789 | | -<a name="eslint-plugin-flowtype-rules-space-after-type-colon-options-11"></a> |
| 3837 | +<a name="eslint-plugin-flowtype-rules-space-after-type-colon-options-12"></a> |
3790 | 3838 | #### Options |
3791 | 3839 |
|
3792 | 3840 | This rule has a string argument. |
@@ -5155,7 +5203,7 @@ type foo = {test: number}; type bar = {...$Exact<foo>} |
5155 | 5203 |
|
5156 | 5204 | Enforces a consistent naming pattern for type aliases. |
5157 | 5205 |
|
5158 | | -<a name="eslint-plugin-flowtype-rules-type-id-match-options-12"></a> |
| 5206 | +<a name="eslint-plugin-flowtype-rules-type-id-match-options-13"></a> |
5159 | 5207 | #### Options |
5160 | 5208 |
|
5161 | 5209 | This rule needs a text RegExp to operate with Its signature is as follows: |
@@ -5213,7 +5261,7 @@ import {type T, type U, type V} from '...'; |
5213 | 5261 | import type {T, U, V} from '...'; |
5214 | 5262 | ``` |
5215 | 5263 |
|
5216 | | -<a name="eslint-plugin-flowtype-rules-type-import-style-options-13"></a> |
| 5264 | +<a name="eslint-plugin-flowtype-rules-type-import-style-options-14"></a> |
5217 | 5265 | #### Options |
5218 | 5266 |
|
5219 | 5267 | The rule has a string option: |
|
0 commit comments