From 8457ebba8bc58ef8804346422bd644e4e2f8fb51 Mon Sep 17 00:00:00 2001 From: Daniel Sainati Date: Fri, 10 Jul 2020 14:14:50 -0700 Subject: [PATCH] add codes to suppressions in www Summary: This updates `www` suppressions to use error codes. This diff was generated by running ``` ~/fbsource/fbcode/flow/tool update-suppressions ~/www --bin ~/fbsource/fbcode/flow/facebook/flowd hg status -n --rev master | xargs -P 20 -n 1000 prettier --write --require-pragma hg status -n --rev master | xargs grep -P -l '@(partially-)?generated' | xargs hg revert -r master hg status -n --rev master | xargs grep -P -l 'lightSyntaxTransform' | xargs hg revert -r master flow --json | jq -r '.errors[] | .message[] | .loc.source' | sort -u | xargs hg revert -r master arc rebuild hg st -n | xargs -n 500 hg commit -m "[Flow][Codemod] add codes to suppressions in www" ``` on top of D22399626 bypass-lint allow_many_files drop-conflicts Reviewed By: pieterv Differential Revision: D22462377 fbshipit-source-id: 5c1d51e5b000a734c770d7a3e6b70fdf209cf154 --- .../base/__tests__/DraftEditor.react-test.js | 2 +- .../__tests__/DraftEditorTextNode-test.js | 32 ++++++++++--------- .../DraftEditorCompostionHandler-test.js | 23 ++++++++----- .../edit/__tests__/editOnBlur-test.js | 4 +-- .../edit/__tests__/editOnInput-test.js | 6 ++-- .../convertFromHTMLToContentBlocks-test.js | 6 ++-- 6 files changed, 41 insertions(+), 32 deletions(-) diff --git a/src/component/base/__tests__/DraftEditor.react-test.js b/src/component/base/__tests__/DraftEditor.react-test.js index 2d4488106c..7e8ea842f6 100644 --- a/src/component/base/__tests__/DraftEditor.react-test.js +++ b/src/component/base/__tests__/DraftEditor.react-test.js @@ -17,7 +17,7 @@ const DraftEditor = require('DraftEditor.react'); const EditorState = require('EditorState'); const React = require('React'); -// $FlowFixMe +// $FlowFixMe[cannot-resolve-module] const ReactShallowRenderer = require('react-test-renderer/shallow'); let shallow; diff --git a/src/component/contents/__tests__/DraftEditorTextNode-test.js b/src/component/contents/__tests__/DraftEditorTextNode-test.js index 44296010e6..7da32c33e2 100644 --- a/src/component/contents/__tests__/DraftEditorTextNode-test.js +++ b/src/component/contents/__tests__/DraftEditorTextNode-test.js @@ -34,21 +34,21 @@ const renderIntoContainer = element => { }; const initializeAsIE = () => { - /* $FlowFixMe(>=0.99.0 site=www) This comment suppresses an error found when - * Flow v0.47 was deployed. To see the error delete this comment and run - * Flow. */ + /* $FlowFixMe[prop-missing] (>=0.99.0 site=www) This comment suppresses an + * error found when Flow v0.47 was deployed. To see the error delete this + * comment and run Flow. */ UserAgent.isBrowser.mockImplementation(() => true); }; const initializeAsNonIE = () => { - /* $FlowFixMe(>=0.99.0 site=www) This comment suppresses an error found when - * Flow v0.47 was deployed. To see the error delete this comment and run - * Flow. */ + /* $FlowFixMe[prop-missing] (>=0.99.0 site=www) This comment suppresses an + * error found when Flow v0.47 was deployed. To see the error delete this + * comment and run Flow. */ UserAgent.isBrowser.mockImplementation(() => false); }; const expectPopulatedSpan = (stub, testString) => { - // $FlowExpectedError node could be null + // $FlowExpectedError[incompatible-type] node could be null const node: Element = ReactDOM.findDOMNode(stub); expect(node.tagName).toBe('SPAN'); expect(node.childNodes.length).toBe(1); @@ -60,7 +60,8 @@ test('must initialize correctly with an empty string, non-IE', function() { const stub = renderIntoContainer( {''}, ); - // $FlowExpectedError we know node is an Element + // $FlowExpectedError[incompatible-use] we know node is an Element + // $FlowExpectedError[prop-missing] we know node is an Element expect(ReactDOM.findDOMNode(stub).tagName).toBe('BR'); }); @@ -149,13 +150,13 @@ test('must skip updates if text already matches DOM, non-IE', function() { renderIntoContainer({TEST_A}); - // $FlowExpectedError property render is missing in HTMLDivElement + // $FlowExpectedError[prop-missing] property render is missing in HTMLDivElement expect(stub.render.mock.calls.length).toBe(0); // Sanity check that updating is performed when appropriate. renderIntoContainer({TEST_B}); - // $FlowExpectedError property render is missing in HTMLDivElement + // $FlowExpectedError[prop-missing] property render is missing in HTMLDivElement expect(stub.render.mock.calls.length).toBe(1); }); @@ -169,13 +170,13 @@ test('must skip updates if text already matches DOM, IE', function() { renderIntoContainer({TEST_A}); - // $FlowExpectedError property render is missing in HTMLDivElement + // $FlowExpectedError[prop-missing] property render is missing in HTMLDivElement expect(stub.render.mock.calls.length).toBe(0); // Sanity check that updating is performed when appropriate. renderIntoContainer({TEST_B}); - // $FlowExpectedError property render is missing in HTMLDivElement + // $FlowExpectedError[prop-missing] property render is missing in HTMLDivElement expect(stub.render.mock.calls.length).toBe(1); }); @@ -187,7 +188,8 @@ test('must update from non-empty to empty, non-IE', function() { renderIntoContainer({''}); - // $FlowExpectedError we know node is an Element + // $FlowExpectedError[incompatible-use] we know node is an Element + // $FlowExpectedError[prop-missing] we know node is an Element expect(ReactDOM.findDOMNode(stub).tagName).toBe('BR'); }); @@ -217,11 +219,11 @@ test('must force unchanged text back into the DOM', function() { {TEST_A}, ); - // $FlowExpectedError we know node is not null + // $FlowExpectedError[incompatible-use] we know node is not null ReactDOM.findDOMNode(stub).textContent = TEST_B; renderIntoContainer({TEST_A}); - // $FlowExpectedError we know node is not null + // $FlowExpectedError[incompatible-use] we know node is not null expect(ReactDOM.findDOMNode(stub).textContent).toBe(TEST_A); }); diff --git a/src/component/handlers/composition/__tests__/DraftEditorCompostionHandler-test.js b/src/component/handlers/composition/__tests__/DraftEditorCompostionHandler-test.js index fcdc0fcc4b..abba7b3557 100644 --- a/src/component/handlers/composition/__tests__/DraftEditorCompostionHandler-test.js +++ b/src/component/handlers/composition/__tests__/DraftEditorCompostionHandler-test.js @@ -103,11 +103,12 @@ beforeEach(() => { test('isInCompositionMode is properly updated on composition events', () => { // `inCompositionMode` is updated inside editOnCompositionStart, // which is why we can't just call compositionHandler.onCompositionStart. - // $FlowExpectedError + // $FlowExpectedError[incompatible-call] editOnCompositionStart(editor, {}); expect(editor.setMode).toHaveBeenLastCalledWith('composite'); expect(editor._latestEditorState.isInCompositionMode()).toBe(true); - // $FlowExpectedError + // $FlowExpectedError[incompatible-use] + // $FlowExpectedError[incompatible-call] compositionHandler.onCompositionEnd(editor); jest.runAllTimers(); expect(editor._latestEditorState.isInCompositionMode()).toBe(false); @@ -121,9 +122,11 @@ test('Can handle a single mutation', () => { require('DOMObserver').prototype.stopAndFlushMutations.mockReturnValue( mutations, ); - // $FlowExpectedError + // $FlowExpectedError[incompatible-use] + // $FlowExpectedError[incompatible-call] compositionHandler.onCompositionStart(editor); - // $FlowExpectedError + // $FlowExpectedError[incompatible-use] + // $FlowExpectedError[incompatible-call] compositionHandler.onCompositionEnd(editor); jest.runAllTimers(); @@ -144,9 +147,11 @@ test('Can handle mutations in multiple blocks', () => { require('DOMObserver').prototype.stopAndFlushMutations.mockReturnValue( mutations, ); - // $FlowExpectedError + // $FlowExpectedError[incompatible-use] + // $FlowExpectedError[incompatible-call] compositionHandler.onCompositionStart(editor); - // $FlowExpectedError + // $FlowExpectedError[incompatible-use] + // $FlowExpectedError[incompatible-call] compositionHandler.onCompositionEnd(editor); jest.runAllTimers(); @@ -172,9 +177,11 @@ test('Can handle mutations in the same block in multiple leaf nodes', () => { require('DOMObserver').prototype.stopAndFlushMutations.mockReturnValue( mutations, ); - // $FlowExpectedError + // $FlowExpectedError[incompatible-use] + // $FlowExpectedError[incompatible-call] compositionHandler.onCompositionStart(editor); - // $FlowExpectedError + // $FlowExpectedError[incompatible-use] + // $FlowExpectedError[incompatible-call] compositionHandler.onCompositionEnd(editor); jest.runAllTimers(); diff --git a/src/component/handlers/edit/__tests__/editOnBlur-test.js b/src/component/handlers/edit/__tests__/editOnBlur-test.js index b0100c43f9..e77705c26a 100644 --- a/src/component/handlers/edit/__tests__/editOnBlur-test.js +++ b/src/component/handlers/edit/__tests__/editOnBlur-test.js @@ -67,7 +67,7 @@ test('editor removes selection on blur (default behaviour)', () => { editor: editorNode, }; - // $FlowExpectedError + // $FlowExpectedError[incompatible-call] onBlur(editor, getBlurEvent(editorNode)); expect(globalSelection.removeAllRanges).toHaveBeenCalledTimes(1); @@ -97,7 +97,7 @@ test('editor preserves selection on blur', () => { editor: editorNode, }; - // $FlowExpectedError + // $FlowExpectedError[incompatible-call] onBlur(editor, getBlurEvent(editorNode)); expect(globalSelection.removeAllRanges).toHaveBeenCalledTimes(0); diff --git a/src/component/handlers/edit/__tests__/editOnInput-test.js b/src/component/handlers/edit/__tests__/editOnInput-test.js index 266ad8e7b9..5e3611a553 100644 --- a/src/component/handlers/edit/__tests__/editOnInput-test.js +++ b/src/component/handlers/edit/__tests__/editOnInput-test.js @@ -62,7 +62,7 @@ test('restoreEditorDOM and keyCommandPlainBackspace are NOT called when the `inp currentTarget: editorNode, }; - // $FlowExpectedError + // $FlowExpectedError[incompatible-call] onInput(editor, inputEvent); expect(require('keyCommandPlainBackspace')).toHaveBeenCalledTimes(0); @@ -94,10 +94,10 @@ test('restoreEditorDOM and keyCommandPlainBackspace are called when backspace is currentTarget: editorNode, }; - // $FlowExpectedError + // $FlowExpectedError[incompatible-call] onInput(editor, inputEvent); - // $FlowExpectedError + // $FlowExpectedError[prop-missing] const newEditorState = require('keyCommandPlainBackspace').mock.results[0] .value; expect(require('keyCommandPlainBackspace')).toHaveBeenCalledWith( diff --git a/src/model/encoding/__tests__/convertFromHTMLToContentBlocks-test.js b/src/model/encoding/__tests__/convertFromHTMLToContentBlocks-test.js index f321fdf32b..a1c3af36d3 100644 --- a/src/model/encoding/__tests__/convertFromHTMLToContentBlocks-test.js +++ b/src/model/encoding/__tests__/convertFromHTMLToContentBlocks-test.js @@ -76,9 +76,9 @@ beforeEach(() => { }); const convertFromHTML = (html_string, config) => { - /* $FlowFixMe(>=0.122.0 site=www) This comment suppresses an error found when - * Flow v0.122.0 was deployed. To see the error, delete this comment and run - * Flow. */ + /* $FlowFixMe[cannot-spread-inexact] (>=0.122.0 site=www) This comment + * suppresses an error found when Flow v0.122.0 was deployed. To see the + * error, delete this comment and run Flow. */ const options = { ...DEFAULT_CONFIG, ...config,