19
19
* [ ` delimiter-dangle ` ] ( #eslint-plugin-flowtype-rules-delimiter-dangle )
20
20
* [ ` generic-spacing ` ] ( #eslint-plugin-flowtype-rules-generic-spacing )
21
21
* [ ` no-dupe-keys ` ] ( #eslint-plugin-flowtype-rules-no-dupe-keys )
22
+ * [ ` no-flow-fix-me-comments ` ] ( #eslint-plugin-flowtype-rules-no-flow-fix-me-comments )
22
23
* [ ` no-mutable-array ` ] ( #eslint-plugin-flowtype-rules-no-mutable-array )
23
24
* [ ` no-primitive-constructor-types ` ] ( #eslint-plugin-flowtype-rules-no-primitive-constructor-types )
24
25
* [ ` no-types-missing-file-annotation ` ] ( #eslint-plugin-flowtype-rules-no-types-missing-file-annotation )
25
26
* [ ` no-unused-expressions ` ] ( #eslint-plugin-flowtype-rules-no-unused-expressions )
26
27
* [ ` no-weak-types ` ] ( #eslint-plugin-flowtype-rules-no-weak-types )
27
28
* [ ` object-type-delimiter ` ] ( #eslint-plugin-flowtype-rules-object-type-delimiter )
29
+ * [ ` require-exact-type ` ] ( #eslint-plugin-flowtype-rules-require-exact-type )
28
30
* [ ` require-parameter-type ` ] ( #eslint-plugin-flowtype-rules-require-parameter-type )
29
31
* [ ` require-return-type ` ] ( #eslint-plugin-flowtype-rules-require-return-type )
30
32
* [ ` require-valid-file-annotation ` ] ( #eslint-plugin-flowtype-rules-require-valid-file-annotation )
@@ -252,6 +254,9 @@ var a: AType<BType>
252
254
type A = AType
253
255
// Additional rules: {"no-undef":2}
254
256
257
+ declare type A = number
258
+ // Additional rules: {"no-undef":2}
259
+
255
260
opaque type A = AType
256
261
// Additional rules: {"no-undef":2}
257
262
@@ -285,6 +290,9 @@ class C implements AType {}
285
290
interface AType {}
286
291
// Additional rules: {"no-undef":2}
287
292
293
+ declare interface A {}
294
+ // Additional rules: {"no-undef":2}
295
+
288
296
({ a: ({b () {}}: AType) })
289
297
// Additional rules: {"no-undef":2}
290
298
@@ -309,6 +317,9 @@ var a: AType<BType>
309
317
type A = AType
310
318
// Additional rules: {"no-undef":2,"no-use-before-define":[2,"nofunc"]}
311
319
320
+ declare type A = number
321
+ // Additional rules: {"no-undef":2,"no-use-before-define":[2,"nofunc"]}
322
+
312
323
opaque type A = AType
313
324
// Additional rules: {"no-undef":2,"no-use-before-define":[2,"nofunc"]}
314
325
@@ -342,6 +353,9 @@ class C implements AType {}
342
353
interface AType {}
343
354
// Additional rules: {"no-undef":2,"no-use-before-define":[2,"nofunc"]}
344
355
356
+ declare interface A {}
357
+ // Additional rules: {"no-undef":2,"no-use-before-define":[2,"nofunc"]}
358
+
345
359
({ a: ({b () {}}: AType) })
346
360
// Additional rules: {"no-undef":2,"no-use-before-define":[2,"nofunc"]}
347
361
@@ -968,6 +982,31 @@ var a = 1; var b = 1; type f = { get(key: a): string, get(key: b): string }
968
982
969
983
970
984
985
+ <a name =" eslint-plugin-flowtype-rules-no-flow-fix-me-comments " ></a >
986
+ ### <code >no-flow-fix-me-comments</code >
987
+
988
+ Disallows ` $FlowFixMe ` comment suppressions.
989
+
990
+ This is especially useful as a warning to ensure instances of ` $FlowFixMe ` in your codebase get fixed over time.
991
+
992
+ <a name =" eslint-plugin-flowtype-rules-no-flow-fix-me-comments-options " ></a >
993
+ #### Options
994
+
995
+ This rule takes an optional RegExp that comments a text RegExp that makes the supression valid.
996
+
997
+ ``` js
998
+ {
999
+ " rules" : {
1000
+ " flowtype/no-flow-fix-me-comments" : [
1001
+ 1 ,
1002
+ " TODO\s +[0-9]+"
1003
+ ]
1004
+ }
1005
+ }
1006
+ ```
1007
+
1008
+ <!-- assertions no-flow-fix-me-comments -->
1009
+
971
1010
<a name =" eslint-plugin-flowtype-rules-no-mutable-array " ></a >
972
1011
### <code >no-mutable-array</code >
973
1012
@@ -1500,6 +1539,95 @@ type Foo = { a: Foo, b: Bar }
1500
1539
1501
1540
1502
1541
1542
+ <a name="eslint-plugin-flowtype-rules-require-exact-type"></a>
1543
+ ### <code>require-exact-type</code>
1544
+
1545
+ This rule enforces [exact object types](https://flow.org/en/docs/types/objects/#toc-exact-object-types).
1546
+
1547
+ <a name="eslint-plugin-flowtype-rules-require-exact-type-options"></a>
1548
+ #### Options
1549
+
1550
+ The rule has one string option:
1551
+
1552
+ * ` " always" ` (default): Report all object type definitions that aren't exact.
1553
+ * ` " never" ` : Report all object type definitions that are exact.
1554
+
1555
+ ` ` ` js
1556
+ {
1557
+ " rules" : {
1558
+ " flowtype/require-exact-type" : [
1559
+ 2 ,
1560
+ " always"
1561
+ ]
1562
+ }
1563
+ }
1564
+
1565
+ {
1566
+ " rules" : {
1567
+ " flowtype/require-exact-type" : [
1568
+ 2 ,
1569
+ " never"
1570
+ ]
1571
+ }
1572
+ }
1573
+ ` ` `
1574
+
1575
+ The following patterns are considered problems:
1576
+
1577
+ ` ` ` js
1578
+ type foo = {};
1579
+ // Message: Type identifier 'foo' must be exact.
1580
+
1581
+ type foo = { bar: string };
1582
+ // Message: Type identifier 'foo' must be exact.
1583
+
1584
+ // Options: ["always"]
1585
+ type foo = {};
1586
+ // Message: Type identifier 'foo' must be exact.
1587
+
1588
+ // Options: ["always"]
1589
+ type foo = { bar: string };
1590
+ // Message: Type identifier 'foo' must be exact.
1591
+
1592
+ // Options: ["never"]
1593
+ type foo = {| | };
1594
+ // Message: Type identifier 'foo' must not be exact.
1595
+
1596
+ // Options: ["never"]
1597
+ type foo = {| bar: string | };
1598
+ // Message: Type identifier 'foo' must not be exact.
1599
+ ` ` `
1600
+
1601
+ The following patterns are not considered problems:
1602
+
1603
+ ` ` ` js
1604
+ type foo = {| | };
1605
+
1606
+ type foo = {| bar: string | };
1607
+
1608
+ type foo = number;
1609
+
1610
+ // Options: ["always"]
1611
+ type foo = {| | };
1612
+
1613
+ // Options: ["always"]
1614
+ type foo = {| bar: string | };
1615
+
1616
+ // Options: ["always"]
1617
+ type foo = number;
1618
+
1619
+ // Options: ["never"]
1620
+ type foo = { };
1621
+
1622
+ // Options: ["never"]
1623
+ type foo = { bar: string };
1624
+
1625
+ // Options: ["never"]
1626
+ type foo = number;
1627
+ ` ` `
1628
+
1629
+
1630
+
1503
1631
<a name="eslint-plugin-flowtype-rules-require-parameter-type"></a>
1504
1632
### <code>require-parameter-type</code>
1505
1633
@@ -1789,6 +1917,19 @@ async () => {}
1789
1917
async function x () {}
1790
1918
// Message: Missing return type annotation.
1791
1919
1920
+ // Options: ["always",{"annotateUndefined":"always"}]
1921
+ class Test { constructor () { } }
1922
+ // Message: Must annotate undefined return type.
1923
+
1924
+ class Test { foo () { return 42 ; } }
1925
+ // Message: Missing return type annotation.
1926
+
1927
+ class Test { foo = () => { return 42 ; } }
1928
+ // Message: Missing return type annotation.
1929
+
1930
+ class Test { foo = () => 42 ; }
1931
+ // Message: Missing return type annotation.
1932
+
1792
1933
// Options: ["always"]
1793
1934
async () => { return ; }
1794
1935
// Message: Missing return type annotation.
@@ -1869,6 +2010,24 @@ async function doThing(): Promise<void> {}
1869
2010
// Options: ["always",{"annotateUndefined":"always"}]
1870
2011
function * doThing (): Generator<number, void, void> { yield 2 ; }
1871
2012
2013
+ // Options: ["always",{"annotateUndefined":"always","excludeMatching":["constructor"]}]
2014
+ class Test { constructor () { } }
2015
+
2016
+ class Test { constructor () { } }
2017
+
2018
+ // Options: ["always",{"excludeMatching":["foo"]}]
2019
+ class Test { foo () { return 42 ; } }
2020
+
2021
+ // Options: ["always",{"excludeMatching":["foo"]}]
2022
+ class Test { foo = () => { return 42 ; } }
2023
+
2024
+ // Options: ["always",{"excludeMatching":["foo"]}]
2025
+ class Test { foo = () => 42 ; }
2026
+
2027
+ class Test { foo = (): number => { return 42 ; } }
2028
+
2029
+ class Test { foo = (): number => 42 ; }
2030
+
1872
2031
async (foo): Promise < number> => { return 3 ; }
1873
2032
1874
2033
// Options: ["always",{"excludeArrowFunctions":true}]
0 commit comments