debugger icon indicating copy to clipboard operation
debugger copied to clipboard

[Flow] add eslint-plugin-flowtype - require-valid-file-annotation

Open gregtatum opened this issue 8 years ago • 29 comments

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

gregtatum avatar Jan 16 '18 22:01 gregtatum

Also, even if this was intentional, the eslint rule makes it explicit when you don't want to use flow in a file.

gregtatum avatar Jan 16 '18 22:01 gregtatum

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.

wldcordeiro avatar Jan 16 '18 22:01 wldcordeiro

yeah - we should definitely fix them!

jasonLaster avatar Jan 16 '18 22:01 jasonLaster

/claim I am in @emmet0r 's class and my team ( @johnsonwe and @mohamedabo )would like to work on this issue.

CameronPilgrim avatar Mar 22 '18 18:03 CameronPilgrim

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 avatar Mar 22 '18 18:03 jasonLaster

@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)

mohamedabo avatar Mar 29 '18 17:03 mohamedabo

yes, lets add them and then get yarn flow passing

jasonLaster avatar Mar 29 '18 17:03 jasonLaster

Awesome! However we are still confused about which files that need this header if not all of JavaScript files.

mohamedabo avatar Mar 29 '18 17:03 mohamedabo

every JS file in src excluding spec.js and files in src/test/mochitest

jasonLaster avatar Mar 29 '18 18:03 jasonLaster

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
screenshot from 2018-04-03 13-48-27 screenshot from 2018-04-03 13-53-08

So basically my question is that what is our next step? Thanks in advance.

mohamedabo avatar Apr 03 '18 17:04 mohamedabo

@mohamedabo can you share the files that you added // @flow to. We have a bug for reducers/types.js

jasonLaster avatar Apr 03 '18 17:04 jasonLaster

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.

mohamedabo avatar Apr 05 '18 17:04 mohamedabo

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!

jasonLaster avatar Apr 05 '18 17:04 jasonLaster

/claim I can claim the src/utils directory to start

atwalg2 avatar Apr 06 '18 06:04 atwalg2

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!

claim avatar Apr 06 '18 06:04 claim

@mohamedabo, @johnsonwe, and I will tackle the src/components directory.

CameronPilgrim avatar Apr 12 '18 17:04 CameronPilgrim

@jasonLaster : @darkwing Told us that BreakpointsDropdown.js has been deleted. So, could you take that off the list? Thank you.

mohamedabo avatar Apr 19 '18 18:04 mohamedabo

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

mohamedabo avatar Apr 24 '18 17:04 mohamedabo

/claim I'll get to work on this tonight. I am an Outreachy candidate. This seems like a good first issue.

ghost avatar Sep 23 '18 20:09 ghost

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!

claim avatar Sep 23 '18 20:09 claim