From 9ec4199a19fdac739f8e8fe8df5df18aa65e0f03 Mon Sep 17 00:00:00 2001 From: zaggy Date: Mon, 12 Jun 2017 20:07:45 +1100 Subject: [PATCH 1/5] Fix flow issues throughout the codebase --- package.json | 2 +- src/actions/sources.js | 2 +- src/actions/tests/__snapshots__/ast.js.snap | 15 +++++++++++++++ .../__snapshots__/pending-breakpoints.js.snap | 17 +++++++++++++++++ src/actions/types.js | 2 +- src/client/firefox/types.js | 2 +- src/components/Editor/Preview.js | 2 +- src/components/Editor/index.js | 2 +- src/components/shared/Autocomplete.js | 6 +++--- src/components/shared/ManagedTree.js | 6 +++--- src/components/shared/ResultList.js | 2 +- src/reducers/ast.js | 3 ++- yarn.lock | 6 +++--- 13 files changed, 50 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 55185d670d..cb1e367736 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "eslint-config-prettier": "^2.1.0", "eslint-plugin-prettier": "^2.0.1", "expect.js": "^0.3.1", - "flow-bin": "^0.46", + "flow-bin": "^0.47", "fuzzaldrin-plus": "^0.4.1", "glob": "^7.0.3", "jest-junit-reporter": "^1.0.1", diff --git a/src/actions/sources.js b/src/actions/sources.js index aa5b60a8b6..398d0bd577 100644 --- a/src/actions/sources.js +++ b/src/actions/sources.js @@ -439,7 +439,7 @@ export function getTextForSources(actors: any[]) { } /* Called if fetching a source failed because of an error. */ - function onError([aSource, aError]) { + function onError(aSource: any, aError: any) { pending.delete(aSource.actor); maybeFinish(); } diff --git a/src/actions/tests/__snapshots__/ast.js.snap b/src/actions/tests/__snapshots__/ast.js.snap index 19346f5386..6b637b209f 100644 --- a/src/actions/tests/__snapshots__/ast.js.snap +++ b/src/actions/tests/__snapshots__/ast.js.snap @@ -15,6 +15,21 @@ Array [ ] `; +exports[`ast getOutOfScopeLocations simple 2`] = ` +Array [ + Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, +] +`; + exports[`ast setSelection simple 1`] = ` Object { "expression": "this.bazz", diff --git a/src/actions/tests/__snapshots__/pending-breakpoints.js.snap b/src/actions/tests/__snapshots__/pending-breakpoints.js.snap index 4ae28aed59..129a2d3daf 100644 --- a/src/actions/tests/__snapshots__/pending-breakpoints.js.snap +++ b/src/actions/tests/__snapshots__/pending-breakpoints.js.snap @@ -124,3 +124,20 @@ Object { }, } `; + +exports[`when adding breakpoints adding and deleting breakpoints add a corresponding pendingBreakpoint for each addition 3`] = ` +Object { + "condition": null, + "disabled": false, + "generatedLocation": Object { + "line": 5, + "sourceId": "foo2", + "sourceUrl": "http://localhost:8000/examples/foo2", + }, + "location": Object { + "column": undefined, + "line": 5, + "sourceUrl": "http://localhost:8000/examples/foo2", + }, +} +`; diff --git a/src/actions/types.js b/src/actions/types.js index 2800019499..e19a493765 100644 --- a/src/actions/types.js +++ b/src/actions/types.js @@ -30,7 +30,7 @@ import type { SymbolDeclaration, AstLocation } from "../utils/parser"; * @typedef {Object} ThunkArgs */ export type ThunkArgs = { - dispatch: () => Promise, + dispatch: (action: any) => Promise, getState: () => State, client: any, sourceMaps: any diff --git a/src/client/firefox/types.js b/src/client/firefox/types.js index 4f307b5787..6e4870f376 100644 --- a/src/client/firefox/types.js +++ b/src/client/firefox/types.js @@ -338,7 +338,7 @@ export type ThreadClient = { interrupt: () => Promise<*>, eventListeners: () => Promise<*>, getFrames: (number, number) => FramesResponse, - getEnvironment: () => Promise<*>, + getEnvironment: (frame: any) => Promise<*>, addListener: (string, Function) => void, getSources: () => Promise, reconfigure: ({ observeAsmJS: boolean }) => Promise<*>, diff --git a/src/components/Editor/Preview.js b/src/components/Editor/Preview.js index 660120f5e7..bbebdaf242 100644 --- a/src/components/Editor/Preview.js +++ b/src/components/Editor/Preview.js @@ -148,7 +148,7 @@ class Preview extends Component { return dom.div( {}, this.renderObjectPreview(expression, root), - this.renderAddToExpressionBar(expression, value) + this.renderAddToExpressionBar(expression) ); } diff --git a/src/components/Editor/index.js b/src/components/Editor/index.js index b5e922e60a..acc076e5fb 100644 --- a/src/components/Editor/index.js +++ b/src/components/Editor/index.js @@ -435,7 +435,7 @@ class Editor extends PureComponent { } if (this.isCbPanelOpen()) { - return this.closeConditionalPanel(line); + return this.closeConditionalPanel(); } if (gutter !== "CodeMirror-foldgutter") { diff --git a/src/components/shared/Autocomplete.js b/src/components/shared/Autocomplete.js index 2dc896c409..587f3a1eb8 100644 --- a/src/components/shared/Autocomplete.js +++ b/src/components/shared/Autocomplete.js @@ -21,10 +21,10 @@ type State = { }; type Props = { - selectItem: () => any, - onSelectedItem: () => any, + selectItem: (event: any, item: Object) => any, + onSelectedItem: (selectedItem: Object) => any, items: Array, - close: () => any, + close: (value: any) => any, inputValue: string, placeholder: string, size: string diff --git a/src/components/shared/ManagedTree.js b/src/components/shared/ManagedTree.js index 9a67652052..f991bd3355 100644 --- a/src/components/shared/ManagedTree.js +++ b/src/components/shared/ManagedTree.js @@ -21,9 +21,9 @@ type Props = { highlightItems?: Array, itemHeight: number, listItems?: Array, - onFocus?: () => any, - onExpand?: () => any, - onCollapse?: () => any, + onFocus?: (item: any) => any, + onExpand?: (item: any) => any, + onCollapse?: (item: any) => any, renderItem: any }; diff --git a/src/components/shared/ResultList.js b/src/components/shared/ResultList.js index 5d3a97feae..7b9c6705c4 100644 --- a/src/components/shared/ResultList.js +++ b/src/components/shared/ResultList.js @@ -14,7 +14,7 @@ type ResultListItem = { type Props = { items: Array, selected: number, - selectItem: () => any, + selectItem: (event: any, item: any, index: any) => any, size: string }; diff --git a/src/reducers/ast.js b/src/reducers/ast.js index 5702bf1c08..43ebb9e1a8 100644 --- a/src/reducers/ast.js +++ b/src/reducers/ast.js @@ -19,7 +19,8 @@ export type SymbolsMap = Map; export type ASTState = { symbols: SymbolsMap, - outOfScopeLocations: ?Array + outOfScopeLocations: ?Array, + selection: any }; export function initialState() { diff --git a/yarn.lock b/yarn.lock index 646851cabb..e8f5a64b9c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3274,9 +3274,9 @@ flatten@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782" -flow-bin@^0.46: - version "0.46.0" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.46.0.tgz#06ad7fe19dddb1042264438064a2a32fee12b872" +flow-bin@^0.47: + version "0.47.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.47.0.tgz#a2a08ab3e0d1f1cb57d17e27b30b118b62fda367" fn-name@^2.0.1: version "2.0.1" From 47d06feb58608fd11a1aa8f27e56339d82294ee7 Mon Sep 17 00:00:00 2001 From: zaggy Date: Mon, 12 Jun 2017 20:17:33 +1100 Subject: [PATCH 2/5] fix linting errors --- src/actions/sources.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/actions/sources.js b/src/actions/sources.js index 398d0bd577..af0d33ff92 100644 --- a/src/actions/sources.js +++ b/src/actions/sources.js @@ -439,8 +439,8 @@ export function getTextForSources(actors: any[]) { } /* Called if fetching a source failed because of an error. */ - function onError(aSource: any, aError: any) { - pending.delete(aSource.actor); + function onError(source: Object, error: any) { + pending.delete(source.actor); maybeFinish(); } From d6fa68db9cb6dbdda9fd276b93e6af8f9ec173c1 Mon Sep 17 00:00:00 2001 From: zaggy Date: Mon, 12 Jun 2017 21:16:54 +1100 Subject: [PATCH 3/5] updated jest snapshots --- src/actions/tests/__snapshots__/ast.js.snap | 15 --------------- .../__snapshots__/pending-breakpoints.js.snap | 17 ----------------- 2 files changed, 32 deletions(-) diff --git a/src/actions/tests/__snapshots__/ast.js.snap b/src/actions/tests/__snapshots__/ast.js.snap index 6b637b209f..19346f5386 100644 --- a/src/actions/tests/__snapshots__/ast.js.snap +++ b/src/actions/tests/__snapshots__/ast.js.snap @@ -15,21 +15,6 @@ Array [ ] `; -exports[`ast getOutOfScopeLocations simple 2`] = ` -Array [ - Object { - "end": Object { - "column": 21, - "line": 1, - }, - "start": Object { - "column": 13, - "line": 1, - }, - }, -] -`; - exports[`ast setSelection simple 1`] = ` Object { "expression": "this.bazz", diff --git a/src/actions/tests/__snapshots__/pending-breakpoints.js.snap b/src/actions/tests/__snapshots__/pending-breakpoints.js.snap index 129a2d3daf..4ae28aed59 100644 --- a/src/actions/tests/__snapshots__/pending-breakpoints.js.snap +++ b/src/actions/tests/__snapshots__/pending-breakpoints.js.snap @@ -124,20 +124,3 @@ Object { }, } `; - -exports[`when adding breakpoints adding and deleting breakpoints add a corresponding pendingBreakpoint for each addition 3`] = ` -Object { - "condition": null, - "disabled": false, - "generatedLocation": Object { - "line": 5, - "sourceId": "foo2", - "sourceUrl": "http://localhost:8000/examples/foo2", - }, - "location": Object { - "column": undefined, - "line": 5, - "sourceUrl": "http://localhost:8000/examples/foo2", - }, -} -`; From 6bba1c48187c08c3a4f223d3c80b9ac0504d682b Mon Sep 17 00:00:00 2001 From: Jason Laster Date: Mon, 12 Jun 2017 09:53:30 -0400 Subject: [PATCH 4/5] bump lp --- package.json | 2 +- yarn.lock | 26 +++++++------------------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index cb1e367736..85a52c1393 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "babylon": "^6.15.0", "codemirror": "^5.1.0", "devtools-components": "^0.0.1", - "devtools-launchpad": "0.0.84", + "devtools-launchpad": "0.0.85", "devtools-reps": "^0.7.0", "devtools-source-editor": "0.0.5", "devtools-source-map": "0.6.0", diff --git a/yarn.lock b/yarn.lock index e8f5a64b9c..3313049341 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1130,18 +1130,12 @@ babel-plugin-transform-regenerator@^6.24.1, babel-plugin-transform-regenerator@^ dependencies: regenerator-transform "0.9.11" -babel-plugin-transform-runtime@6.15.0: +babel-plugin-transform-runtime@6.15.0, babel-plugin-transform-runtime@^6.7.5: version "6.15.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-runtime/-/babel-plugin-transform-runtime-6.15.0.tgz#3d75b4d949ad81af157570273846fb59aeb0d57c" dependencies: babel-runtime "^6.9.0" -babel-plugin-transform-runtime@^6.7.5: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-runtime/-/babel-plugin-transform-runtime-6.23.0.tgz#88490d446502ea9b8e7efb0fe09ec4d99479b1ee" - dependencies: - babel-runtime "^6.22.0" - babel-plugin-transform-strict-mode@^6.24.1: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz#d5faf7aa578a65bbe591cf5edae04a0c67020758" @@ -2368,9 +2362,9 @@ devtools-connection@^0.0.5: version "0.0.5" resolved "https://registry.yarnpkg.com/devtools-connection/-/devtools-connection-0.0.5.tgz#5684508ccbeb45643510b536a62c9952afdbaf0c" -devtools-launchpad@0.0.84: - version "0.0.84" - resolved "https://registry.yarnpkg.com/devtools-launchpad/-/devtools-launchpad-0.0.84.tgz#05c6bb1f93e1195b85be0728dba5adb75926df15" +devtools-launchpad@0.0.85: + version "0.0.85" + resolved "https://registry.yarnpkg.com/devtools-launchpad/-/devtools-launchpad-0.0.85.tgz#4bed590f091123dec5850661f63545743a190a43" dependencies: amd-loader "0.0.5" autoprefixer "^6.7.6" @@ -3801,11 +3795,11 @@ husky@^0.13.2: is-ci "^1.0.9" normalize-path "^1.0.0" -iconv-lite@0.4.13: +iconv-lite@0.4.13, iconv-lite@~0.4.13: version "0.4.13" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.13.tgz#1f88aba4ab0b1508e8312acc39345f36e992e2f2" -iconv-lite@0.4.15, iconv-lite@~0.4.13: +iconv-lite@0.4.15: version "0.4.15" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.15.tgz#fe265a218ac6a57cfe854927e9d04c19825eddeb" @@ -7877,18 +7871,12 @@ strip-json-comments@^2.0.0, strip-json-comments@^2.0.1, strip-json-comments@~2.0 version "2.0.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" -style-loader@0.13.1: +style-loader@0.13.1, style-loader@^0.13.1: version "0.13.1" resolved "https://registry.yarnpkg.com/style-loader/-/style-loader-0.13.1.tgz#468280efbc0473023cd3a6cd56e33b5a1d7fc3a9" dependencies: loader-utils "^0.2.7" -style-loader@^0.13.1: - version "0.13.2" - resolved "https://registry.yarnpkg.com/style-loader/-/style-loader-0.13.2.tgz#74533384cf698c7104c7951150b49717adc2f3bb" - dependencies: - loader-utils "^1.0.2" - style-search@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/style-search/-/style-search-0.1.0.tgz#7958c793e47e32e07d2b5cafe5c0bf8e12e77902" From ca2914ac8d0ceac91170ef4a5553b7ff60e3de87 Mon Sep 17 00:00:00 2001 From: Jason Laster Date: Mon, 12 Jun 2017 10:04:06 -0400 Subject: [PATCH 5/5] add some types --- src/client/firefox/types.js | 3 ++- src/components/shared/Autocomplete.js | 2 +- src/components/shared/ResultList.js | 6 +++++- src/reducers/ast.js | 12 +++++++++++- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/client/firefox/types.js b/src/client/firefox/types.js index 6e4870f376..b6f6d0e671 100644 --- a/src/client/firefox/types.js +++ b/src/client/firefox/types.js @@ -11,6 +11,7 @@ import type { Script, Source, Pause, + Frame, SourceId } from "../types"; @@ -338,7 +339,7 @@ export type ThreadClient = { interrupt: () => Promise<*>, eventListeners: () => Promise<*>, getFrames: (number, number) => FramesResponse, - getEnvironment: (frame: any) => Promise<*>, + getEnvironment: (frame: Frame) => Promise<*>, addListener: (string, Function) => void, getSources: () => Promise, reconfigure: ({ observeAsmJS: boolean }) => Promise<*>, diff --git a/src/components/shared/Autocomplete.js b/src/components/shared/Autocomplete.js index 587f3a1eb8..f3d015deb5 100644 --- a/src/components/shared/Autocomplete.js +++ b/src/components/shared/Autocomplete.js @@ -21,7 +21,7 @@ type State = { }; type Props = { - selectItem: (event: any, item: Object) => any, + selectItem: (event: SyntheticKeyboardEvent, item: Object) => any, onSelectedItem: (selectedItem: Object) => any, items: Array, close: (value: any) => any, diff --git a/src/components/shared/ResultList.js b/src/components/shared/ResultList.js index 7b9c6705c4..1abe6b99a9 100644 --- a/src/components/shared/ResultList.js +++ b/src/components/shared/ResultList.js @@ -14,7 +14,11 @@ type ResultListItem = { type Props = { items: Array, selected: number, - selectItem: (event: any, item: any, index: any) => any, + selectItem: ( + event: SyntheticKeyboardEvent, + item: ResultListItem, + index: number + ) => any, size: string }; diff --git a/src/reducers/ast.js b/src/reducers/ast.js index 43ebb9e1a8..3ea5db7acf 100644 --- a/src/reducers/ast.js +++ b/src/reducers/ast.js @@ -17,10 +17,20 @@ import type { Record } from "../utils/makeRecord"; export type SymbolsMap = Map; +export type Selection = + | {| updating: true |} + | null + | {| + updating: false, + expression: string, + location: AstLocation, + result: Object + |}; + export type ASTState = { symbols: SymbolsMap, outOfScopeLocations: ?Array, - selection: any + selection: Selection }; export function initialState() {