Manually fix places the codemod doesnt hit

Summary:
Generating this diff was difficult. We _will_ fix the issues with jscodeshift, but i don't want to block the syntax change on that.

To get this diff, I first codemodded all of xplat to use exact-by-default. Then i turned on implicit-inexact-object:error enforcement to get a list of errors showing places that violated the lint. With that, I used this to generate a list of `sed` commands to add `...`:

```
flow --json | jq '.errors | .[] | .message | .[] | .loc | {source, "line": .end."line", "column": .end."column"} | "\(.column),\(.line),\(.source)"' | sort -n -r | sed 's/"//g' | while read -r line; do echo $line; awk -F',' "{ print \"sed -i '\"\$2\"s/./...&/\"\$1\"' \" \$3 }"; done
```

Then I ran prettier, reverted generated files, and manually fixed up suppressions that got messed up.

Changelog: [Internal]

Reviewed By: gkz

Differential Revision: D18516431

fbshipit-source-id: 6cf940dce411fb179e7ebaff764bd5113a07989f
This commit is contained in:
Jordan Brown 2019-11-19 13:36:06 -08:00 коммит произвёл Facebook Github Bot
Родитель 8ac9b32779
Коммит 48cb80892d
5 изменённых файлов: 57 добавлений и 23 удалений

Просмотреть файл

@ -13,7 +13,11 @@
const FlatList = require('../FlatList');
const React = require('react');
function renderMyListItem(info: {item: {title: string}, index: number}) {
function renderMyListItem(info: {
item: {title: string, ...},
index: number,
...
}) {
return <span />;
}
@ -93,7 +97,7 @@ module.exports = {
/>,
// EverythingIsFine
<FlatList
renderItem={(info: {item: {title: string}}) => <span />}
renderItem={(info: {item: {title: string, ...}, ...}) => <span />}
data={data}
/>,
];

Просмотреть файл

@ -13,13 +13,20 @@
const React = require('react');
const SectionList = require('../SectionList');
function renderMyListItem(info: {item: {title: string}, index: number}) {
function renderMyListItem(info: {
item: {title: string, ...},
index: number,
...
}) {
return <span />;
}
const renderMyHeader = ({section}: {section: {fooNumber: number} & Object}) => (
<span />
);
const renderMyHeader = ({
section,
}: {
section: {fooNumber: number, ...} & Object,
...
}) => <span />;
module.exports = {
testGoodDataWithGoodItem(): React.Node {
@ -52,7 +59,7 @@ module.exports = {
return [
// $FlowExpectedError - title should be inside `item`
<SectionList
renderItem={(info: {title: string}) => <span />}
renderItem={(info: {title: string, ...}) => <span />}
sections={sections}
/>,
<SectionList
@ -62,7 +69,7 @@ module.exports = {
/>,
// EverythingIsFine
<SectionList
renderItem={(info: {item: {title: string}}) => <span />}
renderItem={(info: {item: {title: string, ...}, ...}) => <span />}
sections={sections}
/>,
];

Просмотреть файл

@ -34,7 +34,7 @@ const MyHostComponent = (('Host': any): HostComponent<mixed>);
}}
/>;
declare var NativeComponent: _InternalReactNativeComponentClass<{}>;
declare var NativeComponent: _InternalReactNativeComponentClass<{...}>;
class MyNativeComponent extends NativeComponent {}
<MyNativeComponent

2
flow-typed/npm/prop-types_v15.x.x.js поставляемый
Просмотреть файл

@ -38,7 +38,7 @@ declare module 'prop-types' {
declare var shape: React$PropType$Shape;
declare function checkPropTypes<V>(
propTypes: {[_: $Keys<V>]: $npm$propTypes$ReactPropsCheckType},
propTypes: {[_: $Keys<V>]: $npm$propTypes$ReactPropsCheckType, ...},
values: V,
location: string,
componentName: string,

Просмотреть файл

@ -36,7 +36,8 @@ type JestMockFn<TArguments: $ReadOnlyArray<mixed>, TReturn> = {|
* An array that contains all the object results that have been
* returned by this mock function call
*/
results: Array<{isThrow: boolean, value: TReturn}>,
results: Array<{isThrow: boolean, value: TReturn, ...}>,
...
},
/**
* Resets all information stored in the mockFn.mock.calls and
@ -116,6 +117,7 @@ type JestAsymmetricEqualityType = {
* A custom Jasmine equality tester
*/
asymmetricMatch(value: mixed): boolean,
...
};
type JestCallsType = {
@ -126,6 +128,7 @@ type JestCallsType = {
first(): mixed,
mostRecent(): mixed,
reset(): void,
...
};
type JestClockType = {
@ -133,11 +136,13 @@ type JestClockType = {
mockDate(date: Date): void,
tick(milliseconds?: number): void,
uninstall(): void,
...
};
type JestMatcherResult = {
message?: string | (() => string),
pass: boolean,
...
};
type JestMatcher = (
@ -156,6 +161,7 @@ type JestPromiseType = {
* matcher can be chained. If the promise is rejected the assertion fails.
*/
resolves: JestExpectType,
...
};
/**
@ -178,6 +184,7 @@ type JestStyledComponentsMatcherOptions = {
media?: string,
modifier?: string,
supports?: string,
...
};
type JestStyledComponentsMatchersType = {
@ -186,6 +193,7 @@ type JestStyledComponentsMatchersType = {
value: JestStyledComponentsMatcherValue,
options?: JestStyledComponentsMatcherOptions,
): void,
...
};
/**
@ -214,6 +222,7 @@ type EnzymeMatchersType = {
toHaveValue(value: any): void,
toMatchElement(element: React$Element<any>): void,
toMatchSelector(selector: string): void,
...
};
// DOM testing library extensions https://github.com/kentcdodds/dom-testing-library#custom-jest-matchers
@ -221,6 +230,7 @@ type DomTestingLibraryType = {
toBeInTheDOM(): void,
toHaveTextContent(content: string): void,
toHaveAttribute(name: string, expectedValue?: string): void,
...
};
// Jest JQuery Matchers: https://github.com/unindented/custom-jquery-matchers
@ -235,7 +245,7 @@ type JestJQueryMatchersType = {
toHaveText(text: string | RegExp): void,
toHaveData(key: string, val?: any): void,
toHaveValue(val: any): void,
toHaveCss(css: {[key: string]: any}): void,
toHaveCss(css: {[key: string]: any, ...}): void,
toBeChecked(): void,
toBeDisabled(): void,
toBeEmpty(): void,
@ -247,6 +257,7 @@ type JestJQueryMatchersType = {
toBeMatchedBy(sel: string): void,
toHaveDescendant(sel: string): void,
toHaveDescendantWithText(sel: string, text: string | RegExp): void,
...
};
// Jest Extended Matchers: https://github.com/jest-community/jest-extended
@ -547,6 +558,7 @@ type JestExtendedMatchersType = {
* @param {Array.<String>} substring
*/
toIncludeMultiple(substring: Array<string>): void,
...
};
interface JestExpectType {
@ -715,7 +727,7 @@ interface JestExpectType {
* This ensures that an Object matches the most recent snapshot.
*/
toMatchSnapshot(
propertyMatchers?: {[key: string]: JestAsymmetricEqualityType},
propertyMatchers?: {[key: string]: JestAsymmetricEqualityType, ...},
name?: string,
): void;
/**
@ -725,7 +737,7 @@ interface JestExpectType {
toMatchInlineSnapshot(snapshot?: string): void;
toMatchInlineSnapshot(
propertyMatchers?: {[key: string]: JestAsymmetricEqualityType},
propertyMatchers?: {[key: string]: JestAsymmetricEqualityType, ...},
snapshot?: string,
): void;
/**
@ -907,10 +919,12 @@ type JestObjectType = {
* Note: The default timeout interval is 5 seconds if this method is not called.
*/
setTimeout(timeout: number): JestObjectType,
...
};
type JestSpyType = {
calls: JestCallsType,
...
};
/** Runs this function after every test inside this context */
@ -962,6 +976,7 @@ declare var describe: {
name: JestTestName,
fn?: (...args: TArguments) => ?Promise<mixed>,
) => void,
...
};
/** An individual test unit */
@ -1007,6 +1022,7 @@ declare var it: {
name: JestTestName,
fn?: (...args: TArguments) => ?Promise<mixed>,
) => void,
...
},
/**
* Skip running this test
@ -1032,6 +1048,7 @@ declare var it: {
fn?: (done: () => void) => ?Promise<mixed>,
timeout?: number,
): void,
...
};
declare function fit(
name: JestTestName,
@ -1050,11 +1067,12 @@ declare var xit: typeof it;
declare var xtest: typeof it;
type JestPrettyFormatColors = {
comment: {close: string, open: string},
content: {close: string, open: string},
prop: {close: string, open: string},
tag: {close: string, open: string},
value: {close: string, open: string},
comment: {close: string, open: string, ...},
content: {close: string, open: string, ...},
prop: {close: string, open: string, ...},
tag: {close: string, open: string, ...},
value: {close: string, open: string, ...},
...
};
type JestPrettyFormatIndent = string => string;
@ -1089,6 +1107,7 @@ type JestPrettyFormatPlugin = {
colors: JestPrettyFormatColors,
) => string,
test: any => boolean,
...
};
type JestPrettyFormatPlugins = Array<JestPrettyFormatPlugin>;
@ -1107,7 +1126,7 @@ declare var expect: {
JestExtendedMatchersType,
/** Add additional Jasmine matchers to Jest's roster */
extend(matchers: {[name: string]: JestMatcher}): void,
extend(matchers: {[name: string]: JestMatcher, ...}): void,
/** Add a module that formats application-specific data structures. */
addSnapshotSerializer(pluginModule: JestPrettyFormatPlugin): void,
assertions(expectedAssertions: number): void,
@ -1121,10 +1140,12 @@ declare var expect: {
stringMatching(value: string | RegExp): string,
not: {
arrayContaining: (value: $ReadOnlyArray<mixed>) => Array<mixed>,
objectContaining: (value: {}) => Object,
objectContaining: (value: {...}) => Object,
stringContaining: (value: string) => string,
stringMatching: (value: string | RegExp) => string,
...
},
...
};
// TODO handle return type
@ -1143,6 +1164,7 @@ type JasmineReporter = {
specStarted?: (result: mixed) => void,
specDone?: (result: mixed) => void,
suiteDone?: (result: mixed) => void,
...
};
/**
@ -1159,8 +1181,9 @@ declare var jasmine: {
createSpyObj(
baseName: string,
methodNames: Array<string>,
): {[methodName: string]: JestSpyType},
getEnv(): {addReporter: (jasmineReporter: JasmineReporter) => void},
): {[methodName: string]: JestSpyType, ...},
getEnv(): {addReporter: (jasmineReporter: JasmineReporter) => void, ...},
objectContaining(value: Object): Object,
stringMatching(value: string): string,
...
};