The Strict flag in Flow sets up files for stricter adherence to rules. The user can choose the rules that need to be followed and the files that they apply to.
@flow strict
should be added to the files that are to be checked for Strict rules.
The rules to be adopted by these pages should be written in the .flowconfig
files. A [strict]
section will be created in these files. This section will then be filled with the Lint Rules needed to be checked for by Flow. Lint Rules are rules defined in Flow that can be checked for when included in .flowconfig
files. The following code block shows an example of a .flowconfig
file.
[strict]
nonstrict-import
unclear-type
unsafe-getters-setters
untyped-import
untyped-type-import
The rules in this example are some of the rules that are recommended for use in Flow Strict files.
nonstrict-import
shows an error for imports that are not Flow Strict themselves.unclear-type
shows an error when using Object
, Function
, or any
in a type annotation.unsafe-getters-setters
shows an error when getters or setters are used as they can be unsafe.untyped-import
shows an error when an untyped module is being imported.untyped-type-import
shows an error when a type is being imported from an untyped module.