[Flow] add eslint-plugin-flowtype - require-valid-file-annotation
It would be great to use this eslint rule to ensure that we don't mistakenly leave out // @flow headers.
Here are this list of files that are missing the header. Lets add the header and the minimal types needed to satisfy flow. It is okay to add a lot of loose types like any, Object, etc...
Example
here is an example patch that could be a PR
diff --git a/src/utils/ui.js b/src/utils/ui.js
index efc8b03..599989d 100644
--- a/src/utils/ui.js
+++ b/src/utils/ui.js
@@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
+// @flow
+
/* Checks to see if the root element is available and
* if the element is visible. We check the width of the element
* because it is more reliable than either checking a focus state or
@@ -14,7 +16,7 @@ export function isVisible() {
/* Gets the line numbers width in the code editor
*/
-export function getLineNumberWidth(editor) {
+export function getLineNumberWidth(editor: Object) {
const gutters = editor.display.gutters;
const lineNumbers = gutters.querySelector(".CodeMirror-linenumbers");
return lineNumbers && lineNumbers.clientWidth;
Todo List
- [ ] src/actions
- [ ] ast/setInScopeLines.js
- [ ] breakpoints/addBreakpoint.js
- [ ] breakpoints/remapLocations.js
- [ ] event-listeners.js
- [ ] source-tree.js
- [ ] utils/middleware/log.js
- [ ] utils/middleware/timing.js
- [ ] src/components
- [ ] SecondaryPanes/Breakpoints/BreakpointsContextMenu.js
- [ ] SecondaryPanes/Frames/types.js
- [ ] src/reducers
- [ ] /async-requests.js
- [ ] src/reducers/event-listeners.js
- [ ] src/reducers/index.js
- [ ] src/reducers/quick-open.js
- [x] src/reducers/types.js
- [ ] src/selectors/
- [ ] breakpointAtLocation.js
- [ ] getCallStackFrames.js
- [ ] isSelectedFrameVisible.js
- [x] visibleBreakpoints.js
- [ ] src/utils
- [x] DevToolsUtils.js
- [x] bootstrap.js
- [x] clipboard.js
- [x] dbg.js
- [ ] editor/source-editor.js (started here #5897)
- [x] function.js
- [x] indentation.js
- [ ] location.js
- [ ] project-search.js
- [ ] result-list.js
- [ ] source-maps.js
- [ ] source-queue.js
- [x] sources-tree/index.js
- [ ] sources-tree/sortTree.js
- [x] task.js
- [ ] timings.js
- [x] ui.js
- [ ] worker.js
- [ ] src/global-types.js
Also, even if this was intentional, the eslint rule makes it explicit when you don't want to use flow in a file.
I noticed that several files are missing the header and I think they may have been that way because of some naive prop-types -> Flow conversions.
yeah - we should definitely fix them!
/claim I am in @emmet0r 's class and my team ( @johnsonwe and @mohamedabo )would like to work on this issue.
thanks! we might need to disable this for some files while we fix them, but not a big deal. when we do we can file issues to fix them!
@jasonLaster @gregtatum Hello. My team has a few questions regarding this issue. What exactly do we need to do to implement the flow header?? Do we just add // @flow as said in the documentation for the flow headers? Also we have noticed that many files are missing this header. How do we identify which files that need the flow header? (edited)
yes, lets add them and then get yarn flow passing
Awesome! However we are still confused about which files that need this header if not all of JavaScript files.
every JS file in src
excluding spec.js and files in src/test/mochitest
Hello @jasonLaster , my team have added the flow header to every JS file in src except spec.js files in src/test/mochitest. However, when I ran the command yarn run flow it gave me a list of errors showed in the following screen shots

So basically my question is that what is our next step? Thanks in advance.
@mohamedabo can you share the files that you added // @flow to. We have a bug for reducers/types.js
Hi @jasonLaster. We already posted the commits. This is a list of the files that we have edited in our local repository https://github.com/johnsonwe/debugger.html/commit/a8c5abe199cdc5aaf6b5321233899d36b65196c8. If you need an additional list please let me know and I would be happy to provide it to you.
Great @mohamedabo I just copied the files you touched into a todo list which is now in the description. Feel free to fix one file at a time and add a PR!
/claim I can claim the src/utils directory to start
Thanks for claiming the issue! :wave:
Here are some links for getting setup, contributing, and developing. We're always happy to answer questions in slack! If you become busy, feel free to /unclaim it.
:fox_face: Debugger team!
@mohamedabo, @johnsonwe, and I will tackle the src/components directory.
@jasonLaster : @darkwing Told us that BreakpointsDropdown.js has been deleted. So, could you take that off the list? Thank you.
Since the semester is getting to close, we are going to unclaim the issue. What we basically did was push a PR that was accepted and another PR that its file was deleted. Anyway, as stated above, the best course of action for anyone who wants to work on this project in the future is to add //@flow headers on top of these files and add flow types to the variables. /unclaim
/claim I'll get to work on this tonight. I am an Outreachy candidate. This seems like a good first issue.
Thanks for claiming the issue! :wave:
!!! Please check your email and confirm the invitation
Here are some links for getting setup, contributing, and developing. We're always happy to answer questions in slack! If you become busy, feel free to /unclaim it.
:fox_face: Debugger team!