From a2e11e1800c0f24ee6df6127bd7b78f62e3d8226 Mon Sep 17 00:00:00 2001 From: Samuel Reed Date: Thu, 26 Sep 2019 20:24:43 -0400 Subject: [PATCH] refactor(declarations): rename [declarations] to [silence] This name has not gone over well: https://github.com/facebook/flow/issues/6631#issuecomment-411285015 and is confusing in multiple places, such as: https://github.com/facebook/flow/blob/master/website/en/docs/declarations/index.md and https://github.com/facebook/flow/blob/dd93de0a3796897fe07cca8a3bdc621c992a9880/tests/lib_interfaces/.flowconfig#L5-L6 It is difficult to grep for, difficult to distinguish versus type declarations, and is widely used interchangeably with "interfaces". For these reasons and many more, it is best to rename this option now that it is usable. --- src/commands/commandUtils.ml | 24 ++++++++--------- src/commands/config/flowConfig.ml | 26 +++++++++---------- src/commands/config/flowConfig.mli | 6 ++--- src/commands/initCommand.ml | 4 +-- src/commands/lsCommand.ml | 4 +-- src/common/files.ml | 10 +++---- src/common/files.mli | 8 +++--- .../inference/__tests__/types_js_test.ml | 2 +- src/typing/errors/error_suppressions.ml | 8 +++--- .../.flowconfig | 2 +- .../A.js | 0 .../B.js | 0 .../C.js | 0 .../D.js | 0 .../config_silence.exp} | 0 .../lib.js | 0 .../.flowconfig | 2 +- .../A.js | 2 +- .../B.js | 0 .../config_silence_react.exp} | 0 .../node_modules/react-d3/str2str.js | 0 .../node_modules/react-native/str2str.js | 0 .../node_modules/react/index.js | 0 .../node_modules/react/package.json | 0 tests/flowconfig_ignore/.flowconfig | 2 +- tests/json_exit/json_exit.exp | 4 +-- website/_data/guides.yml | 2 +- website/en/docs/config/index.md | 2 +- .../config/{declarations.md => silence.md} | 20 +++++++------- website/en/docs/config/untyped.md | 2 +- 30 files changed, 65 insertions(+), 65 deletions(-) rename tests/{config_declarations => config_silence}/.flowconfig (92%) rename tests/{config_declarations => config_silence}/A.js (100%) rename tests/{config_declarations => config_silence}/B.js (100%) rename tests/{config_declarations => config_silence}/C.js (100%) rename tests/{config_declarations => config_silence}/D.js (100%) rename tests/{config_declarations/config_declarations.exp => config_silence/config_silence.exp} (100%) rename tests/{config_declarations => config_silence}/lib.js (100%) rename tests/{config_declarations_react => config_silence_react}/.flowconfig (93%) rename tests/{config_declarations_react => config_silence_react}/A.js (86%) rename tests/{config_declarations_react => config_silence_react}/B.js (100%) rename tests/{config_declarations_react/config_declarations_react.exp => config_silence_react/config_silence_react.exp} (100%) rename tests/{config_declarations_react => config_silence_react}/node_modules/react-d3/str2str.js (100%) rename tests/{config_declarations_react => config_silence_react}/node_modules/react-native/str2str.js (100%) rename tests/{config_declarations_react => config_silence_react}/node_modules/react/index.js (100%) rename tests/{config_declarations_react => config_silence_react}/node_modules/react/package.json (100%) rename website/en/docs/config/{declarations.md => silence.md} (73%) diff --git a/src/commands/commandUtils.ml b/src/commands/commandUtils.ml index fdf7325e0ce..b153883cbb2 100644 --- a/src/commands/commandUtils.ml +++ b/src/commands/commandUtils.ml @@ -529,7 +529,7 @@ let assert_version flowconfig = type flowconfig_params = { ignores: string list; untyped: string list; - declarations: string list; + silence: string list; includes: string list; libs: string list; (* We store raw_lint_severities as a string list instead of as a LintSettings.t so we @@ -543,14 +543,14 @@ let list_of_string_arg = function | Some arg_str -> Str.split (Str.regexp ",") arg_str let collect_flowconfig_flags - main ignores_str untyped_str declarations_str includes_str lib_str lints_str = + main ignores_str untyped_str silence_str includes_str lib_str lints_str = let ignores = list_of_string_arg ignores_str in let untyped = list_of_string_arg untyped_str in - let declarations = list_of_string_arg declarations_str in + let silence = list_of_string_arg silence_str in let includes = list_of_string_arg includes_str in let libs = list_of_string_arg lib_str in let raw_lint_severities = list_of_string_arg lints_str in - main { ignores; includes; libs; raw_lint_severities; untyped; declarations } + main { ignores; includes; libs; raw_lint_severities; untyped; silence } let remove_exclusion pattern = if String_utils.string_starts_with pattern "!" then @@ -635,14 +635,14 @@ let file_options = | [] -> config_libs | _ -> config_libs @ Core_list.map ~f:(Files.make_path_absolute root) extras in - fun ~root ~no_flowlib ~temp_dir ~includes ~ignores ~libs ~untyped ~declarations flowconfig -> + fun ~root ~no_flowlib ~temp_dir ~includes ~ignores ~libs ~untyped ~silence flowconfig -> let default_lib_dir = let no_flowlib = no_flowlib || FlowConfig.no_flowlib flowconfig in Some (default_lib_dir ~no_flowlib temp_dir) in let ignores = ignores_of_arg root (FlowConfig.ignores flowconfig) ignores in let untyped = ignores_of_arg root (FlowConfig.untyped flowconfig) untyped in - let declarations = ignores_of_arg root (FlowConfig.declarations flowconfig) declarations in + let silence = ignores_of_arg root (FlowConfig.silence flowconfig) silence in let lib_paths = lib_paths ~root flowconfig libs in let includes = includes @@ -653,7 +653,7 @@ let file_options = Files.default_lib_dir; ignores; untyped; - declarations; + silence; includes; lib_paths; module_file_exts = FlowConfig.module_file_exts flowconfig; @@ -681,9 +681,9 @@ let declaration_flag prev = CommandSpec.ArgSpec.( prev |> flag - "--declaration" + "--silence" (optional string) - ~doc:"Specify one or more patterns, comma separated, for files to treat as declarations") + ~doc:"Specify one or more patterns, comma separated, for files to silence errors for") let include_flag prev = CommandSpec.ArgSpec.( @@ -949,7 +949,7 @@ let options_flags = no_arg ~doc:"Typecheck with weak inference, assuming dynamic types by default" |> flag "--traces" (optional int) ~doc:"Outline an error path up to a specified level" - |> flag "--no-flowlib" no_arg ~doc:"Do not include embedded declarations" + |> flag "--no-flowlib" no_arg ~doc:"Do not include embedded silence" |> flag "--munge-underscore-members" no_arg @@ -1148,7 +1148,7 @@ let make_options ~flowconfig_name ~flowconfig ~lazy_mode ~root (options_flags : Options_flags.( let file_options = let no_flowlib = options_flags.no_flowlib in - let { includes; ignores; libs; raw_lint_severities = _; untyped; declarations } = + let { includes; ignores; libs; raw_lint_severities = _; untyped; silence } = options_flags.flowconfig_flags in file_options @@ -1159,7 +1159,7 @@ let make_options ~flowconfig_name ~flowconfig ~lazy_mode ~root (options_flags : ~ignores ~libs ~untyped - ~declarations + ~silence flowconfig in let lint_severities = diff --git a/src/commands/config/flowConfig.ml b/src/commands/config/flowConfig.ml index f693acf681c..f6e9ba126f9 100644 --- a/src/commands/config/flowConfig.ml +++ b/src/commands/config/flowConfig.ml @@ -600,8 +600,8 @@ type config = { ignores: string list; (* files that should be treated as untyped *) untyped: string list; - (* files that should be treated as declarations *) - declarations: string list; + (* files that should be treated as silent *) + silence: string list; (* non-root include paths *) includes: string list; (* library paths. no wildcards *) @@ -627,7 +627,7 @@ end = struct let untyped o = Core_list.iter ~f:(fprintf o "%s\n") - let declarations o = Core_list.iter ~f:(fprintf o "%s\n") + let silence o = Core_list.iter ~f:(fprintf o "%s\n") let includes o = Core_list.iter ~f:(fprintf o "%s\n") @@ -680,7 +680,7 @@ end = struct ignores o config.ignores; fprintf o "\n"; section_if_nonempty o "untyped" untyped config.untyped; - section_if_nonempty o "declarations" declarations config.declarations; + section_if_nonempty o "silence" silence config.silence; section_header o "include"; includes o config.includes; fprintf o "\n"; @@ -702,7 +702,7 @@ let empty_config = rollouts = SMap.empty; ignores = []; untyped = []; - declarations = []; + silence = []; includes = []; libs = []; lint_severities = LintSettings.empty_severities; @@ -765,8 +765,8 @@ let parse_untyped lines config = Ok ({ config with untyped }, []) let parse_declarations lines config = - let declarations = trim_lines lines in - Ok ({ config with declarations }, []) + let silence = trim_lines lines in + Ok ({ config with silence }, []) let parse_options lines config : (config * warning list, error) result = Opts.parse config.options lines @@ -910,7 +910,7 @@ let parse_section config ((section_ln, section), lines) : (config * warning list | ("ignore", _) -> parse_ignores lines config | ("libs", _) -> parse_libs lines config | ("lints", _) -> parse_lints lines config - | ("declarations", _) -> parse_declarations lines config + | ("silence", _) -> parse_declarations lines config | ("strict", _) -> parse_strict lines config | ("options", _) -> parse_options lines config | ("untyped", _) -> parse_untyped lines config @@ -983,7 +983,7 @@ let is_not_comment = (* Line starts with ; *) Str.regexp_string "\240\159\146\169"; (* Line starts with poop emoji *) - + ] in fun (_, line) -> @@ -1013,7 +1013,7 @@ let get_empty_config () = in { empty_config with lint_severities } -let init ~ignores ~untyped ~declarations ~includes ~libs ~options ~lints = +let init ~ignores ~untyped ~silence ~includes ~libs ~options ~lints = let ( >>= ) (acc : (config * warning list, error) result) (fn : config -> (config * warning list, error) result) = @@ -1024,7 +1024,7 @@ let init ~ignores ~untyped ~declarations ~includes ~libs ~options ~lints = in let ignores_lines = Core_list.map ~f:(fun s -> (1, s)) ignores in let untyped_lines = Core_list.map ~f:(fun s -> (1, s)) untyped in - let declarations_lines = Core_list.map ~f:(fun s -> (1, s)) declarations in + let declarations_lines = Core_list.map ~f:(fun s -> (1, s)) silence in let includes_lines = Core_list.map ~f:(fun s -> (1, s)) includes in let options_lines = Core_list.map ~f:(fun s -> (1, s)) options in let lib_lines = Core_list.map ~f:(fun s -> (1, s)) libs in @@ -1073,8 +1073,8 @@ let ignores config = config.ignores (* files that should be treated as untyped *) let untyped config = config.untyped -(* files that should be treated as declarations *) -let declarations config = config.declarations +(* files that should be treated as silenct *) +let silence config = config.silence (* non-root include paths *) let includes config = config.includes diff --git a/src/commands/config/flowConfig.mli b/src/commands/config/flowConfig.mli index 547077d4096..5de54b4f6b5 100644 --- a/src/commands/config/flowConfig.mli +++ b/src/commands/config/flowConfig.mli @@ -20,7 +20,7 @@ val empty_config : config val init : ignores:string list -> untyped:string list -> - declarations:string list -> + silence:string list -> includes:string list -> libs:string list -> options:string list -> @@ -37,8 +37,8 @@ val ignores : config -> string list (* files that should be treated as untyped *) val untyped : config -> string list -(* files that should be treated as declarations *) -val declarations : config -> string list +(* files that should be treated as silence *) +val silence : config -> string list (* non-root include paths *) val includes : config -> string list diff --git a/src/commands/initCommand.ml b/src/commands/initCommand.ml index 2fd9d0e8a3d..ee8e57d71eb 100644 --- a/src/commands/initCommand.ml +++ b/src/commands/initCommand.ml @@ -53,7 +53,7 @@ let main base_flags flowconfig_flags options root () = in let ignores = flowconfig_flags.CommandUtils.ignores in let untyped = flowconfig_flags.CommandUtils.untyped in - let declarations = flowconfig_flags.CommandUtils.declarations in + let silence = flowconfig_flags.CommandUtils.silence in let includes = flowconfig_flags.CommandUtils.includes in let libs = flowconfig_flags.CommandUtils.libs in let lints = flowconfig_flags.CommandUtils.raw_lint_severities in @@ -62,7 +62,7 @@ let main base_flags flowconfig_flags options root () = let msg = Utils_js.spf "Error: \"%s\" already exists!\n%!" file in FlowExitStatus.(exit ~msg Invalid_flowconfig) ); - let config = FlowConfig.init ~ignores ~untyped ~declarations ~includes ~libs ~options ~lints in + let config = FlowConfig.init ~ignores ~untyped ~silence ~includes ~libs ~options ~lints in let config = match config with | Ok (config, []) -> config diff --git a/src/commands/lsCommand.ml b/src/commands/lsCommand.ml index a2326adbdda..895b9882d2e 100644 --- a/src/commands/lsCommand.ml +++ b/src/commands/lsCommand.ml @@ -121,7 +121,7 @@ let make_options ~flowconfig_name ~root ~ignore_flag ~include_flag ~untyped_flag let includes = CommandUtils.list_of_string_arg include_flag in let ignores = CommandUtils.list_of_string_arg ignore_flag in let untyped = CommandUtils.list_of_string_arg untyped_flag in - let declarations = CommandUtils.list_of_string_arg declaration_flag in + let silence = CommandUtils.list_of_string_arg declaration_flag in let libs = [] in CommandUtils.file_options flowconfig @@ -132,7 +132,7 @@ let make_options ~flowconfig_name ~root ~ignore_flag ~include_flag ~untyped_flag ~includes ~libs ~untyped - ~declarations + ~silence (* The problem with Files.wanted is that it says yes to everything except ignored files and libs. * So implicitly ignored files (like files in another directory) pass the Files.wanted check *) diff --git a/src/common/files.ml b/src/common/files.ml index ef5816bd7f2..1b41850c23f 100644 --- a/src/common/files.ml +++ b/src/common/files.ml @@ -11,7 +11,7 @@ type options = { default_lib_dir: Path.t option; ignores: (string * Str.regexp) list; untyped: (string * Str.regexp) list; - declarations: (string * Str.regexp) list; + silence: (string * Str.regexp) list; includes: Path_matcher.t; lib_paths: Path.t list; module_file_exts: SSet.t; @@ -25,7 +25,7 @@ let ignores options = options.ignores let untyped options = options.untyped -let declarations options = options.declarations +let silence options = options.silence let includes options = options.includes @@ -377,12 +377,12 @@ let is_untyped (options : options) path = let path = Sys_utils.normalize_filename_dir_sep path in is_matching path options.untyped -(* true if a file path matches a [declarations] entry in config *) -let is_declaration (options : options) path = +(* true if a file path matches a [silence] entry in config *) +let is_silenced (options : options) path = (* On Windows, the path may use \ instead of /, but let's standardize the * ignore regex to use / *) let path = Sys_utils.normalize_filename_dir_sep path in - is_matching path options.declarations + is_matching path options.silence (* true if a file path matches an [include] path in config *) let is_included options f = Path_matcher.matches options.includes f diff --git a/src/common/files.mli b/src/common/files.mli index b38ac8ee0fa..02b5d6c325c 100644 --- a/src/common/files.mli +++ b/src/common/files.mli @@ -11,7 +11,7 @@ type options = { default_lib_dir: Path.t option; ignores: (string * Str.regexp) list; untyped: (string * Str.regexp) list; - declarations: (string * Str.regexp) list; + silence: (string * Str.regexp) list; includes: Path_matcher.t; lib_paths: Path.t list; module_file_exts: SSet.t; @@ -25,7 +25,7 @@ val ignores : options -> (string * Str.regexp) list val untyped : options -> (string * Str.regexp) list -val declarations : options -> (string * Str.regexp) list +val silence : options -> (string * Str.regexp) list val includes : options -> Path_matcher.t @@ -57,8 +57,8 @@ val is_ignored : options -> string -> bool (* true if a file path matches an [untyped] entry in config *) val is_untyped : options -> string -> bool -(* true if a file path matches a [declarations] entry in config *) -val is_declaration : options -> string -> bool +(* true if a file path matches a [silence] entry in config *) +val is_silenced : options -> string -> bool (* true if a file path matches an [include] path in config *) val is_included : options -> string -> bool diff --git a/src/services/inference/__tests__/types_js_test.ml b/src/services/inference/__tests__/types_js_test.ml index 40e2148811d..c6ffb0a57be 100644 --- a/src/services/inference/__tests__/types_js_test.ml +++ b/src/services/inference/__tests__/types_js_test.ml @@ -23,7 +23,7 @@ let dummy_flowconfig_params = { CommandUtils.ignores = []; untyped = []; - declarations = []; + silence = []; includes = []; libs = []; raw_lint_severities = []; diff --git a/src/typing/errors/error_suppressions.ml b/src/typing/errors/error_suppressions.ml index 589482577f6..5902b18aca1 100644 --- a/src/typing/errors/error_suppressions.ml +++ b/src/typing/errors/error_suppressions.ml @@ -167,10 +167,10 @@ let in_node_modules ~root ~file_options loc = | None -> false | Some (file, options) -> Files.is_within_node_modules ~root ~options (File_key.to_string file) -let in_declarations ~file_options loc = +let in_silence ~file_options loc = match Option.both (Loc.source loc) file_options with | None -> false - | Some (file, options) -> Files.is_declaration options (File_key.to_string file) + | Some (file, options) -> Files.is_silenced options (File_key.to_string file) let check ~root ~file_options (err : Loc.t Errors.printable_error) (suppressions : t) (unused : t) = @@ -181,11 +181,11 @@ let check ~root ~file_options (err : Loc.t Errors.printable_error) (suppressions * without a source. *) |> List.filter (fun loc -> Option.is_some (Loc.source loc)) in - (* Ignore lint errors from node modules, and all errors from declarations directories. *) + (* Ignore lint errors from node modules, and all errors from [silence] directories. *) let ignore = match Errors.kind_of_printable_error err with | Errors.LintError _ -> in_node_modules ~root ~file_options (Errors.loc_of_printable_error err) - | _ -> in_declarations ~file_options (Errors.loc_of_printable_error err) + | _ -> in_silence ~file_options (Errors.loc_of_printable_error err) in if ignore then None diff --git a/tests/config_declarations/.flowconfig b/tests/config_silence/.flowconfig similarity index 92% rename from tests/config_declarations/.flowconfig rename to tests/config_silence/.flowconfig index 99c24d2787f..7c4809631f5 100644 --- a/tests/config_declarations/.flowconfig +++ b/tests/config_silence/.flowconfig @@ -5,7 +5,7 @@ [libs] lib.js -[declarations] +[silence] .*/B.js .*/C.js diff --git a/tests/config_declarations/A.js b/tests/config_silence/A.js similarity index 100% rename from tests/config_declarations/A.js rename to tests/config_silence/A.js diff --git a/tests/config_declarations/B.js b/tests/config_silence/B.js similarity index 100% rename from tests/config_declarations/B.js rename to tests/config_silence/B.js diff --git a/tests/config_declarations/C.js b/tests/config_silence/C.js similarity index 100% rename from tests/config_declarations/C.js rename to tests/config_silence/C.js diff --git a/tests/config_declarations/D.js b/tests/config_silence/D.js similarity index 100% rename from tests/config_declarations/D.js rename to tests/config_silence/D.js diff --git a/tests/config_declarations/config_declarations.exp b/tests/config_silence/config_silence.exp similarity index 100% rename from tests/config_declarations/config_declarations.exp rename to tests/config_silence/config_silence.exp diff --git a/tests/config_declarations/lib.js b/tests/config_silence/lib.js similarity index 100% rename from tests/config_declarations/lib.js rename to tests/config_silence/lib.js diff --git a/tests/config_declarations_react/.flowconfig b/tests/config_silence_react/.flowconfig similarity index 93% rename from tests/config_declarations_react/.flowconfig rename to tests/config_silence_react/.flowconfig index 98afa5a468c..5f7b6ec1ab5 100644 --- a/tests/config_declarations_react/.flowconfig +++ b/tests/config_silence_react/.flowconfig @@ -4,7 +4,7 @@ [libs] -[declarations] +[silence] /node_modules/react-native/.* [options] diff --git a/tests/config_declarations_react/A.js b/tests/config_silence_react/A.js similarity index 86% rename from tests/config_declarations_react/A.js rename to tests/config_silence_react/A.js index 338271d584a..333218e104e 100644 --- a/tests/config_declarations_react/A.js +++ b/tests/config_silence_react/A.js @@ -1,4 +1,4 @@ -// Due to [declarations], this won't error +// Due to [silence], this won't error const str2str = require('react-native/str2str') // But this identical one will diff --git a/tests/config_declarations_react/B.js b/tests/config_silence_react/B.js similarity index 100% rename from tests/config_declarations_react/B.js rename to tests/config_silence_react/B.js diff --git a/tests/config_declarations_react/config_declarations_react.exp b/tests/config_silence_react/config_silence_react.exp similarity index 100% rename from tests/config_declarations_react/config_declarations_react.exp rename to tests/config_silence_react/config_silence_react.exp diff --git a/tests/config_declarations_react/node_modules/react-d3/str2str.js b/tests/config_silence_react/node_modules/react-d3/str2str.js similarity index 100% rename from tests/config_declarations_react/node_modules/react-d3/str2str.js rename to tests/config_silence_react/node_modules/react-d3/str2str.js diff --git a/tests/config_declarations_react/node_modules/react-native/str2str.js b/tests/config_silence_react/node_modules/react-native/str2str.js similarity index 100% rename from tests/config_declarations_react/node_modules/react-native/str2str.js rename to tests/config_silence_react/node_modules/react-native/str2str.js diff --git a/tests/config_declarations_react/node_modules/react/index.js b/tests/config_silence_react/node_modules/react/index.js similarity index 100% rename from tests/config_declarations_react/node_modules/react/index.js rename to tests/config_silence_react/node_modules/react/index.js diff --git a/tests/config_declarations_react/node_modules/react/package.json b/tests/config_silence_react/node_modules/react/package.json similarity index 100% rename from tests/config_declarations_react/node_modules/react/package.json rename to tests/config_silence_react/node_modules/react/package.json diff --git a/tests/flowconfig_ignore/.flowconfig b/tests/flowconfig_ignore/.flowconfig index a0c7186edc8..b293302c8f0 100644 --- a/tests/flowconfig_ignore/.flowconfig +++ b/tests/flowconfig_ignore/.flowconfig @@ -1,4 +1,4 @@ -[declarations] +[silence] .*/my_declarations/.* !.*/my_declarations/typecheck/.* !.*/my_declarations/actually_typecheck\.js diff --git a/tests/json_exit/json_exit.exp b/tests/json_exit/json_exit.exp index 46524b163f0..67d29398f41 100644 --- a/tests/json_exit/json_exit.exp +++ b/tests/json_exit/json_exit.exp @@ -7,12 +7,12 @@ "msg":"Could not find file or directory pants; canceling search for .flowconfig.\nSee \"flow init --help\" for more info" } } -{"flowVersion":"","exit":{"code":64,"reason":"Commandline_usage_error","msg":"flow: --pants unknown option\nUsage: flow check [OPTION]... [ROOT]\n\nDoes a full Flow check and prints the results.\n\nFlow will search upward for a .flowconfig file, beginning at ROOT.\nROOT is assumed to be the current directory if unspecified.\n\n --abstract-locations [EXPERIMENTAL] Use abstract locations to improve recheck times. Has no effect unless types-first is also enabled\n --all Typecheck all files, not just @flow\n --color Display terminal output in color. never, always, auto (default: auto)\n --debug Print debug info during typecheck\n --declaration Specify one or more patterns, comma separated, for files to treat as declarations\n --flowconfig-name Set the name of the flow configuration file. (default: .flowconfig)\n --from Specify who is calling this CLI command (used by logging)\n --help This list of options\n --ignore Specify one or more ignore patterns, comma separated\n --ignore-version Ignore the version constraint in .flowconfig\n --include Specify one or more include patterns, comma separated\n --include-suppressed Ignore any `suppress_comment` lines in .flowconfig\n --include-warnings Include warnings in the error output (warnings are excluded by default)\n --json Output results in JSON format\n --json-version The version of the JSON format (defaults to 1)\n --lib Specify one or more lib files/directories, comma separated\n --lints Specify one or more lint rules, comma separated\n --max-warnings Warnings above this number will cause a nonzero exit code (implies --include-warnings)\n --max-workers Maximum number of workers to create (capped by number of cores)\n --merge-timeout The maximum time in seconds to attempt to typecheck a file or cycle of files. 0 means no timeout (default: 100)\n --message-width Sets the width of messages but not code snippets (defaults to the smaller of 120 or the terminal width)\n --munge-underscore-members Treat any class member name with a leading underscore as private\n --no-cgroup Don't automatically run this command in a cgroup (if cgroups are available)\n --no-flowlib Do not include embedded declarations\n --no-saved-state Do not load from a saved state even if one is available\n --one-line Escapes newlines so that each error prints on one line\n --pretty Pretty-print JSON output (implies --json)\n --profile Output profiling information\n --quiet Suppress output about server startup\n --saved-state-fetcher Which saved state fetcher Flow should use (none, local) (default: none)\n --saved-state-force-recheck Force a lazy server to recheck the changes since the saved state was generated\n --saved-state-no-fallback If saved state fails to load, exit (normally fallback is to initialize from scratch)\n --sharedmemory-dep-table-pow The exponent for the size of the shared memory dependency table. The default is 17, implying a size of 2^17 bytes\n --sharedmemory-dirs Directory in which to store shared memory heap (default: /dev/shm/)\n --sharedmemory-hash-table-pow The exponent for the size of the shared memory hash table. The default is 19, implying a size of 2^19 bytes\n --sharedmemory-log-level The logging level for shared memory statistics. 0=none, 1=some\n --sharedmemory-minimum-available Flow will only use a filesystem for shared memory if it has at least these many bytes available (default: 536870912 - which is 512MB)\n --show-all-branches Print all branch errors (the default is to print the most relevant branches)\n --show-all-errors Print all errors (the default is to truncate after 50 errors)\n --strip-root Print paths without the root\n --temp-dir Directory in which to store temp files (default: FLOW_TEMP_DIR, or /tmp/flow/)\n --traces Outline an error path up to a specified level\n --types-first [EXPERIMENTAL] types-first architecture\n --unicode Display terminal output with unicode decoration. never, always, auto (default: auto)\n --untyped Specify one or more patterns, comma separated, for files to treat as untyped\n --verbose Print verbose info during typecheck\n --verbose-depth Recursively print types up to specified depth (default 1, implies --verbose)\n --verbose-flowlib Print verbose info while initializing the flowlib\n --verbose-indent Indent verbose info during typecheck (implies --verbose)\n --wait-for-recheck If true, always wait for rechecks to finish before serving commands (default: false)\n --weak Typecheck with weak inference, assuming dynamic types by default"}} +{"flowVersion":"","exit":{"code":64,"reason":"Commandline_usage_error","msg":"flow: --pants unknown option\nUsage: flow check [OPTION]... [ROOT]\n\nDoes a full Flow check and prints the results.\n\nFlow will search upward for a .flowconfig file, beginning at ROOT.\nROOT is assumed to be the current directory if unspecified.\n\n --abstract-locations [EXPERIMENTAL] Use abstract locations to improve recheck times. Has no effect unless types-first is also enabled\n --all Typecheck all files, not just @flow\n --color Display terminal output in color. never, always, auto (default: auto)\n --debug Print debug info during typecheck\n --flowconfig-name Set the name of the flow configuration file. (default: .flowconfig)\n --from Specify who is calling this CLI command (used by logging)\n --help This list of options\n --ignore Specify one or more ignore patterns, comma separated\n --ignore-version Ignore the version constraint in .flowconfig\n --include Specify one or more include patterns, comma separated\n --include-suppressed Ignore any `suppress_comment` lines in .flowconfig\n --include-warnings Include warnings in the error output (warnings are excluded by default)\n --json Output results in JSON format\n --json-version The version of the JSON format (defaults to 1)\n --lib Specify one or more lib files/directories, comma separated\n --lints Specify one or more lint rules, comma separated\n --max-warnings Warnings above this number will cause a nonzero exit code (implies --include-warnings)\n --max-workers Maximum number of workers to create (capped by number of cores)\n --merge-timeout The maximum time in seconds to attempt to typecheck a file or cycle of files. 0 means no timeout (default: 100)\n --message-width Sets the width of messages but not code snippets (defaults to the smaller of 120 or the terminal width)\n --munge-underscore-members Treat any class member name with a leading underscore as private\n --no-cgroup Don't automatically run this command in a cgroup (if cgroups are available)\n --no-flowlib Do not include embedded silence\n --no-saved-state Do not load from a saved state even if one is available\n --one-line Escapes newlines so that each error prints on one line\n --pretty Pretty-print JSON output (implies --json)\n --profile Output profiling information\n --quiet Suppress output about server startup\n --saved-state-fetcher Which saved state fetcher Flow should use (none, local) (default: none)\n --saved-state-force-recheck Force a lazy server to recheck the changes since the saved state was generated\n --saved-state-no-fallback If saved state fails to load, exit (normally fallback is to initialize from scratch)\n --sharedmemory-dep-table-pow The exponent for the size of the shared memory dependency table. The default is 17, implying a size of 2^17 bytes\n --sharedmemory-dirs Directory in which to store shared memory heap (default: /dev/shm/)\n --sharedmemory-hash-table-pow The exponent for the size of the shared memory hash table. The default is 19, implying a size of 2^19 bytes\n --sharedmemory-log-level The logging level for shared memory statistics. 0=none, 1=some\n --sharedmemory-minimum-available Flow will only use a filesystem for shared memory if it has at least these many bytes available (default: 536870912 - which is 512MB)\n --show-all-branches Print all branch errors (the default is to print the most relevant branches)\n --show-all-errors Print all errors (the default is to truncate after 50 errors)\n --silence Specify one or more patterns, comma separated, for files to silence errors for\n --strip-root Print paths without the root\n --temp-dir Directory in which to store temp files (default: FLOW_TEMP_DIR, or /tmp/flow/)\n --traces Outline an error path up to a specified level\n --types-first [EXPERIMENTAL] types-first architecture\n --unicode Display terminal output with unicode decoration. never, always, auto (default: auto)\n --untyped Specify one or more patterns, comma separated, for files to treat as untyped\n --verbose Print verbose info during typecheck\n --verbose-depth Recursively print types up to specified depth (default 1, implies --verbose)\n --verbose-flowlib Print verbose info while initializing the flowlib\n --verbose-indent Indent verbose info during typecheck (implies --verbose)\n --wait-for-recheck If true, always wait for rechecks to finish before serving commands (default: false)\n --weak Typecheck with weak inference, assuming dynamic types by default"}} { "flowVersion":"", "exit":{ "code":64, "reason":"Commandline_usage_error", - "msg":"flow: --pants unknown option\nUsage: flow check [OPTION]... [ROOT]\n\nDoes a full Flow check and prints the results.\n\nFlow will search upward for a .flowconfig file, beginning at ROOT.\nROOT is assumed to be the current directory if unspecified.\n\n --abstract-locations [EXPERIMENTAL] Use abstract locations to improve recheck times. Has no effect unless types-first is also enabled\n --all Typecheck all files, not just @flow\n --color Display terminal output in color. never, always, auto (default: auto)\n --debug Print debug info during typecheck\n --declaration Specify one or more patterns, comma separated, for files to treat as declarations\n --flowconfig-name Set the name of the flow configuration file. (default: .flowconfig)\n --from Specify who is calling this CLI command (used by logging)\n --help This list of options\n --ignore Specify one or more ignore patterns, comma separated\n --ignore-version Ignore the version constraint in .flowconfig\n --include Specify one or more include patterns, comma separated\n --include-suppressed Ignore any `suppress_comment` lines in .flowconfig\n --include-warnings Include warnings in the error output (warnings are excluded by default)\n --json Output results in JSON format\n --json-version The version of the JSON format (defaults to 1)\n --lib Specify one or more lib files/directories, comma separated\n --lints Specify one or more lint rules, comma separated\n --max-warnings Warnings above this number will cause a nonzero exit code (implies --include-warnings)\n --max-workers Maximum number of workers to create (capped by number of cores)\n --merge-timeout The maximum time in seconds to attempt to typecheck a file or cycle of files. 0 means no timeout (default: 100)\n --message-width Sets the width of messages but not code snippets (defaults to the smaller of 120 or the terminal width)\n --munge-underscore-members Treat any class member name with a leading underscore as private\n --no-cgroup Don't automatically run this command in a cgroup (if cgroups are available)\n --no-flowlib Do not include embedded declarations\n --no-saved-state Do not load from a saved state even if one is available\n --one-line Escapes newlines so that each error prints on one line\n --pretty Pretty-print JSON output (implies --json)\n --profile Output profiling information\n --quiet Suppress output about server startup\n --saved-state-fetcher Which saved state fetcher Flow should use (none, local) (default: none)\n --saved-state-force-recheck Force a lazy server to recheck the changes since the saved state was generated\n --saved-state-no-fallback If saved state fails to load, exit (normally fallback is to initialize from scratch)\n --sharedmemory-dep-table-pow The exponent for the size of the shared memory dependency table. The default is 17, implying a size of 2^17 bytes\n --sharedmemory-dirs Directory in which to store shared memory heap (default: /dev/shm/)\n --sharedmemory-hash-table-pow The exponent for the size of the shared memory hash table. The default is 19, implying a size of 2^19 bytes\n --sharedmemory-log-level The logging level for shared memory statistics. 0=none, 1=some\n --sharedmemory-minimum-available Flow will only use a filesystem for shared memory if it has at least these many bytes available (default: 536870912 - which is 512MB)\n --show-all-branches Print all branch errors (the default is to print the most relevant branches)\n --show-all-errors Print all errors (the default is to truncate after 50 errors)\n --strip-root Print paths without the root\n --temp-dir Directory in which to store temp files (default: FLOW_TEMP_DIR, or /tmp/flow/)\n --traces Outline an error path up to a specified level\n --types-first [EXPERIMENTAL] types-first architecture\n --unicode Display terminal output with unicode decoration. never, always, auto (default: auto)\n --untyped Specify one or more patterns, comma separated, for files to treat as untyped\n --verbose Print verbose info during typecheck\n --verbose-depth Recursively print types up to specified depth (default 1, implies --verbose)\n --verbose-flowlib Print verbose info while initializing the flowlib\n --verbose-indent Indent verbose info during typecheck (implies --verbose)\n --wait-for-recheck If true, always wait for rechecks to finish before serving commands (default: false)\n --weak Typecheck with weak inference, assuming dynamic types by default" + "msg":"flow: --pants unknown option\nUsage: flow check [OPTION]... [ROOT]\n\nDoes a full Flow check and prints the results.\n\nFlow will search upward for a .flowconfig file, beginning at ROOT.\nROOT is assumed to be the current directory if unspecified.\n\n --abstract-locations [EXPERIMENTAL] Use abstract locations to improve recheck times. Has no effect unless types-first is also enabled\n --all Typecheck all files, not just @flow\n --color Display terminal output in color. never, always, auto (default: auto)\n --debug Print debug info during typecheck\n --flowconfig-name Set the name of the flow configuration file. (default: .flowconfig)\n --from Specify who is calling this CLI command (used by logging)\n --help This list of options\n --ignore Specify one or more ignore patterns, comma separated\n --ignore-version Ignore the version constraint in .flowconfig\n --include Specify one or more include patterns, comma separated\n --include-suppressed Ignore any `suppress_comment` lines in .flowconfig\n --include-warnings Include warnings in the error output (warnings are excluded by default)\n --json Output results in JSON format\n --json-version The version of the JSON format (defaults to 1)\n --lib Specify one or more lib files/directories, comma separated\n --lints Specify one or more lint rules, comma separated\n --max-warnings Warnings above this number will cause a nonzero exit code (implies --include-warnings)\n --max-workers Maximum number of workers to create (capped by number of cores)\n --merge-timeout The maximum time in seconds to attempt to typecheck a file or cycle of files. 0 means no timeout (default: 100)\n --message-width Sets the width of messages but not code snippets (defaults to the smaller of 120 or the terminal width)\n --munge-underscore-members Treat any class member name with a leading underscore as private\n --no-cgroup Don't automatically run this command in a cgroup (if cgroups are available)\n --no-flowlib Do not include embedded silence\n --no-saved-state Do not load from a saved state even if one is available\n --one-line Escapes newlines so that each error prints on one line\n --pretty Pretty-print JSON output (implies --json)\n --profile Output profiling information\n --quiet Suppress output about server startup\n --saved-state-fetcher Which saved state fetcher Flow should use (none, local) (default: none)\n --saved-state-force-recheck Force a lazy server to recheck the changes since the saved state was generated\n --saved-state-no-fallback If saved state fails to load, exit (normally fallback is to initialize from scratch)\n --sharedmemory-dep-table-pow The exponent for the size of the shared memory dependency table. The default is 17, implying a size of 2^17 bytes\n --sharedmemory-dirs Directory in which to store shared memory heap (default: /dev/shm/)\n --sharedmemory-hash-table-pow The exponent for the size of the shared memory hash table. The default is 19, implying a size of 2^19 bytes\n --sharedmemory-log-level The logging level for shared memory statistics. 0=none, 1=some\n --sharedmemory-minimum-available Flow will only use a filesystem for shared memory if it has at least these many bytes available (default: 536870912 - which is 512MB)\n --show-all-branches Print all branch errors (the default is to print the most relevant branches)\n --show-all-errors Print all errors (the default is to truncate after 50 errors)\n --silence Specify one or more patterns, comma separated, for files to silence errors for\n --strip-root Print paths without the root\n --temp-dir Directory in which to store temp files (default: FLOW_TEMP_DIR, or /tmp/flow/)\n --traces Outline an error path up to a specified level\n --types-first [EXPERIMENTAL] types-first architecture\n --unicode Display terminal output with unicode decoration. never, always, auto (default: auto)\n --untyped Specify one or more patterns, comma separated, for files to treat as untyped\n --verbose Print verbose info during typecheck\n --verbose-depth Recursively print types up to specified depth (default 1, implies --verbose)\n --verbose-flowlib Print verbose info while initializing the flowlib\n --verbose-indent Indent verbose info during typecheck (implies --verbose)\n --wait-for-recheck If true, always wait for rechecks to finish before serving commands (default: false)\n --weak Typecheck with weak inference, assuming dynamic types by default" } } diff --git a/website/_data/guides.yml b/website/_data/guides.yml index 13e12bf18be..925f9ebdb92 100644 --- a/website/_data/guides.yml +++ b/website/_data/guides.yml @@ -89,13 +89,13 @@ - id: config pages: - path: "/docs/config/" - - path: "/docs/config/declarations/" - path: "/docs/config/include/" - path: "/docs/config/ignore/" - path: "/docs/config/untyped/" - path: "/docs/config/libs/" - path: "/docs/config/lints/" - path: "/docs/config/options/" + - path: "/docs/config/silence/" - path: "/docs/config/version/" - id: libdefs diff --git a/website/en/docs/config/index.md b/website/en/docs/config/index.md index a476a538f19..174890e5e13 100644 --- a/website/en/docs/config/index.md +++ b/website/en/docs/config/index.md @@ -15,7 +15,7 @@ this. The `.flowconfig` consists of 7 sections: -* [`[declarations]`](declarations) +* [`[silence]`](silence) * [`[include]`](include) * [`[ignore]`](ignore) * [`[untyped]`](untyped) diff --git a/website/en/docs/config/declarations.md b/website/en/docs/config/silence.md similarity index 73% rename from website/en/docs/config/declarations.md rename to website/en/docs/config/silence.md index c7c84f3d80d..0be80ee2483 100644 --- a/website/en/docs/config/declarations.md +++ b/website/en/docs/config/silence.md @@ -7,14 +7,14 @@ definitions only compatible with a certain version of Flow. In those cases it may be useful to use type information from the third-party libraries without typechecking their contents. -### `[declarations]` +### `[silence]` -The `[declarations]` section in a `.flowconfig` file tells Flow to parse files -matching the specified regular expressions in _declaration mode_. In declaration +The `[silence]` section in a `.flowconfig` file tells Flow to parse files +matching the specified regular expressions in _silence mode_. In silence mode the code is not typechecked. However, the signatures of functions, classes, etc are extracted and used by the typechecker when checking other code. -Conceptually one can think of declaration mode as if Flow still typechecks the +Conceptually one can think of silence mode as if Flow still typechecks the files but acts as if there is a comment that matches [`suppress_comment`](options#toc-suppress-comment-regex") on every line. @@ -22,22 +22,22 @@ See also `[untyped]`(untyped) for not typechecking files, and instead using `any Things to keep in mind: -1. Declaration mode should only be used for existing third-party code. You +1. Silence mode should only be used for existing third-party code. You should never use this for code under your control. 2. These are [OCaml regular expressions](http://caml.inria.fr/pub/docs/manual-ocaml/libref/Str.html#TYPEregexp). 3. These regular expressions match against absolute paths. They probably should start with `.*` -An example `[declarations]` section might look like: +An example `[silence]` section might look like: ``` -[declarations] +[silence] .*/third_party/.* .*/src/\(foo\|bar\)/.* .*\.decl\.js ``` -This `[declarations]` section will parse in declaration mode: +This `[silence]` section will parse in silent mode: 1. Any file or directory under a directory named `third_party` 2. Any file or directory under `.*/src/foo` or under `.*/src/bar` @@ -51,11 +51,11 @@ writing regular expressions that are relative rather than absolute. For example, you can write: ``` -[declarations] +[silence] /third_party/.* ``` -Which would parse in declaration mode any file or directory under the directory +Which would parse in silence mode any file or directory under the directory named `third_party/` within the project root. However, unlike the previous example's `.*/third_party/.*`, it would NOT parse files or directories under directories named `third_party/`, like `src/third_party/`. diff --git a/website/en/docs/config/untyped.md b/website/en/docs/config/untyped.md index 5f3ecf1f8c6..44d336d88d1 100644 --- a/website/en/docs/config/untyped.md +++ b/website/en/docs/config/untyped.md @@ -13,7 +13,7 @@ matching the specified regular expressions and instead throw away types and trea This is different from the `[ignore]` config section that causes matching files to be ignored by the module resolver, which inherently makes them un-typechecked, and also unresolvable by `import` or `require`. When ignored `[libs]` must then be specified for each `import` using `flow-typed`, which may not always be desired. -It is also different from the `[declarations]` section. This also does not typecheck the file contents, but `[declarations]` does extract and use the signatures of functions, classes, etc, when checking other code. +It is also different from the `[silence]` section. This also does not typecheck the file contents, but `[silence]` does extract and use the signatures of functions, classes, etc, when checking other code. `[untyped]` instead causes a file to be ignored by the typechecker as if it had `noflow` in it, resolve modules as `any` typ, but allow them to NOT be ignored by the module resolver. Any matching file is skipped by Flow (not even parsed, like other `noflow` files!), but can still be `require()`'d.