|
36 | 36 | * [`no-weak-types`](#eslint-plugin-flowtype-rules-no-weak-types)
|
37 | 37 | * [`object-type-curly-spacing`](#eslint-plugin-flowtype-rules-object-type-curly-spacing)
|
38 | 38 | * [`object-type-delimiter`](#eslint-plugin-flowtype-rules-object-type-delimiter)
|
| 39 | + * [`quotes`](#eslint-plugin-flowtype-rules-quotes) |
39 | 40 | * [`require-compound-type-alias`](#eslint-plugin-flowtype-rules-require-compound-type-alias)
|
40 | 41 | * [`require-exact-type`](#eslint-plugin-flowtype-rules-require-exact-type)
|
41 | 42 | * [`require-indexer-name`](#eslint-plugin-flowtype-rules-require-indexer-name)
|
@@ -2836,12 +2837,79 @@ type Foo = { a: Foo, b: Bar }
|
2836 | 2837 |
|
2837 | 2838 |
|
2838 | 2839 |
|
| 2840 | +<a name="eslint-plugin-flowtype-rules-quotes"></a> |
| 2841 | +### <code>quotes</code> |
| 2842 | +
|
| 2843 | +Enforces single quotes or double quotes around string literals. |
| 2844 | +
|
| 2845 | +<a name="eslint-plugin-flowtype-rules-quotes-options-3"></a> |
| 2846 | +#### Options |
| 2847 | +
|
| 2848 | +The rule has string options of: |
| 2849 | +
|
| 2850 | +* `"double"` (default) requires double quotes around string literals. |
| 2851 | +* `"single"` requires single quotes around string literals. |
| 2852 | +
|
| 2853 | +The following patterns are considered problems: |
| 2854 | +
|
| 2855 | +```js |
| 2856 | +type T = 'hi' |
| 2857 | +// Message: String literals must use double quote. |
| 2858 | + |
| 2859 | +// Options: ["double"] |
| 2860 | +type T = { test: 'hello' | 'test' } |
| 2861 | +// Message: String literals must use double quote. |
| 2862 | +// Message: String literals must use double quote. |
| 2863 | + |
| 2864 | +// Options: ["double"] |
| 2865 | +type T = { test: "hello" | 'test', t: 'hello' } |
| 2866 | +// Message: String literals must use double quote. |
| 2867 | +// Message: String literals must use double quote. |
| 2868 | + |
| 2869 | +// Options: ["single"] |
| 2870 | +type T = "hi" |
| 2871 | +// Message: String literals must use single quote. |
| 2872 | + |
| 2873 | +// Options: ["single"] |
| 2874 | +type T = { test: "hello" | "test" } |
| 2875 | +// Message: String literals must use single quote. |
| 2876 | +// Message: String literals must use single quote. |
| 2877 | + |
| 2878 | +// Options: ["single"] |
| 2879 | +type T = { test: "hello" | 'test', t: 'hello' } |
| 2880 | +// Message: String literals must use single quote. |
| 2881 | +``` |
| 2882 | +
|
| 2883 | +The following patterns are not considered problems: |
| 2884 | +
|
| 2885 | +```js |
| 2886 | +// Options: ["double"] |
| 2887 | +type T = "hi" |
| 2888 | + |
| 2889 | +// Options: ["double"] |
| 2890 | +type T = { test: "hello" | "test" } |
| 2891 | + |
| 2892 | +// Options: ["double"] |
| 2893 | +type T = { test: "hello" | "test", t: "hello" } |
| 2894 | + |
| 2895 | +// Options: ["single"] |
| 2896 | +type FooType = 'hi' |
| 2897 | + |
| 2898 | +// Options: ["single"] |
| 2899 | +type T = { test: 'hello' | 'test' } |
| 2900 | + |
| 2901 | +// Options: ["single"] |
| 2902 | +type T = { test: 'hello' | 'test', t: 'hello' } |
| 2903 | +``` |
| 2904 | +
|
| 2905 | +
|
| 2906 | +
|
2839 | 2907 | <a name="eslint-plugin-flowtype-rules-require-compound-type-alias"></a>
|
2840 | 2908 | ### <code>require-compound-type-alias</code>
|
2841 | 2909 |
|
2842 | 2910 | Requires to make a type alias for all [union](https://flow.org/en/docs/types/unions/) and [intersection](https://flow.org/en/docs/types/intersections/) types. If these are used in "raw" forms it might be tempting to just copy & paste them around the code. However, this brings sort of a source code pollution and unnecessary changes on several parts when these compound types need to be changed.
|
2843 | 2911 |
|
2844 |
| -<a name="eslint-plugin-flowtype-rules-require-compound-type-alias-options-3"></a> |
| 2912 | +<a name="eslint-plugin-flowtype-rules-require-compound-type-alias-options-4"></a> |
2845 | 2913 | #### Options
|
2846 | 2914 |
|
2847 | 2915 | The rule has two options:
|
@@ -2935,7 +3003,7 @@ _The `--fix` option on the command line automatically fixes problems reported by
|
2935 | 3003 |
|
2936 | 3004 | This rule enforces [exact object types](https://flow.org/en/docs/types/objects/#toc-exact-object-types).
|
2937 | 3005 |
|
2938 |
| -<a name="eslint-plugin-flowtype-rules-require-exact-type-options-4"></a> |
| 3006 | +<a name="eslint-plugin-flowtype-rules-require-exact-type-options-5"></a> |
2939 | 3007 | #### Options
|
2940 | 3008 |
|
2941 | 3009 | The rule has one string option:
|
@@ -3088,7 +3156,7 @@ _The `--fix` option on the command line automatically fixes problems reported by
|
3088 | 3156 |
|
3089 | 3157 | This rule validates Flow object indexer name.
|
3090 | 3158 |
|
3091 |
| -<a name="eslint-plugin-flowtype-rules-require-indexer-name-options-5"></a> |
| 3159 | +<a name="eslint-plugin-flowtype-rules-require-indexer-name-options-6"></a> |
3092 | 3160 | #### Options
|
3093 | 3161 |
|
3094 | 3162 | The rule has a string option:
|
@@ -3133,7 +3201,7 @@ type foo = { [string]: number };
|
3133 | 3201 |
|
3134 | 3202 | This rule enforces explicit inexact object types.
|
3135 | 3203 |
|
3136 |
| -<a name="eslint-plugin-flowtype-rules-require-inexact-type-options-6"></a> |
| 3204 | +<a name="eslint-plugin-flowtype-rules-require-inexact-type-options-7"></a> |
3137 | 3205 | #### Options
|
3138 | 3206 |
|
3139 | 3207 | The rule has one string option:
|
@@ -3242,7 +3310,7 @@ type foo = number;
|
3242 | 3310 |
|
3243 | 3311 | Requires that all function parameters have type annotations.
|
3244 | 3312 |
|
3245 |
| -<a name="eslint-plugin-flowtype-rules-require-parameter-type-options-7"></a> |
| 3313 | +<a name="eslint-plugin-flowtype-rules-require-parameter-type-options-8"></a> |
3246 | 3314 | #### Options
|
3247 | 3315 |
|
3248 | 3316 | You can skip all arrow functions by providing the `excludeArrowFunctions` option with `true`.
|
@@ -3602,7 +3670,7 @@ function Foo(props: {}) { return <p /> }
|
3602 | 3670 |
|
3603 | 3671 | Requires that functions have return type annotation.
|
3604 | 3672 |
|
3605 |
| -<a name="eslint-plugin-flowtype-rules-require-return-type-options-8"></a> |
| 3673 | +<a name="eslint-plugin-flowtype-rules-require-return-type-options-9"></a> |
3606 | 3674 | #### Options
|
3607 | 3675 |
|
3608 | 3676 | You can skip all arrow functions by providing the `excludeArrowFunctions` option with `true`.
|
@@ -3964,7 +4032,7 @@ async function * foo(): AsyncIterable<number> { yield 2; }
|
3964 | 4032 |
|
3965 | 4033 | Requires all type declarations to be at the top of the file, after any import declarations.
|
3966 | 4034 |
|
3967 |
| -<a name="eslint-plugin-flowtype-rules-require-types-at-top-options-9"></a> |
| 4035 | +<a name="eslint-plugin-flowtype-rules-require-types-at-top-options-10"></a> |
3968 | 4036 | #### Options
|
3969 | 4037 |
|
3970 | 4038 | The rule has a string option:
|
@@ -4041,7 +4109,7 @@ This rule validates Flow file annotations.
|
4041 | 4109 |
|
4042 | 4110 | This rule can optionally report missing or missed placed annotations, common typos (e.g. `// @floww`), and enforce a consistent annotation style.
|
4043 | 4111 |
|
4044 |
| -<a name="eslint-plugin-flowtype-rules-require-valid-file-annotation-options-10"></a> |
| 4112 | +<a name="eslint-plugin-flowtype-rules-require-valid-file-annotation-options-11"></a> |
4045 | 4113 | #### Options
|
4046 | 4114 |
|
4047 | 4115 | The rule has a string option:
|
|
4234 | 4302 |
|
4235 | 4303 | Requires that all variable declarators have type annotations.
|
4236 | 4304 |
|
4237 |
| -<a name="eslint-plugin-flowtype-rules-require-variable-type-options-11"></a> |
| 4305 | +<a name="eslint-plugin-flowtype-rules-require-variable-type-options-12"></a> |
4238 | 4306 | #### Options
|
4239 | 4307 |
|
4240 | 4308 | You can exclude variables that match a certain regex by using `excludeVariableMatch`.
|
@@ -4401,7 +4469,7 @@ _The `--fix` option on the command line automatically fixes problems reported by
|
4401 | 4469 |
|
4402 | 4470 | Enforces natural, case-insensitive sorting of Object annotations.
|
4403 | 4471 |
|
4404 |
| -<a name="eslint-plugin-flowtype-rules-sort-keys-options-12"></a> |
| 4472 | +<a name="eslint-plugin-flowtype-rules-sort-keys-options-13"></a> |
4405 | 4473 | #### Options
|
4406 | 4474 |
|
4407 | 4475 | The first option specifies sort order.
|
@@ -4753,7 +4821,7 @@ _The `--fix` option on the command line automatically fixes problems reported by
|
4753 | 4821 |
|
4754 | 4822 | Enforces consistent spacing after the type annotation colon.
|
4755 | 4823 |
|
4756 |
| -<a name="eslint-plugin-flowtype-rules-space-after-type-colon-options-13"></a> |
| 4824 | +<a name="eslint-plugin-flowtype-rules-space-after-type-colon-options-14"></a> |
4757 | 4825 | #### Options
|
4758 | 4826 |
|
4759 | 4827 | This rule has a string argument.
|
@@ -6122,7 +6190,7 @@ type foo = {test: number}; type bar = {...$Exact<foo>}
|
6122 | 6190 |
|
6123 | 6191 | Enforces a consistent naming pattern for type aliases.
|
6124 | 6192 |
|
6125 |
| -<a name="eslint-plugin-flowtype-rules-type-id-match-options-14"></a> |
| 6193 | +<a name="eslint-plugin-flowtype-rules-type-id-match-options-15"></a> |
6126 | 6194 | #### Options
|
6127 | 6195 |
|
6128 | 6196 | This rule requires a text RegExp:
|
@@ -6183,7 +6251,7 @@ import {type T, type U, type V} from '...';
|
6183 | 6251 | import type {T, U, V} from '...';
|
6184 | 6252 | ```
|
6185 | 6253 |
|
6186 |
| -<a name="eslint-plugin-flowtype-rules-type-import-style-options-15"></a> |
| 6254 | +<a name="eslint-plugin-flowtype-rules-type-import-style-options-16"></a> |
6187 | 6255 | #### Options
|
6188 | 6256 |
|
6189 | 6257 | The rule has a string option:
|
|
0 commit comments