Skip to content

Commit

Permalink
Eslint config: enable Flow indexed access by default
Browse files Browse the repository at this point in the history
This commit partially reverts #2662

Flow config option `indexed_access` was removed in https://github.com/facebook/flow/releases/tag/v0.164.0 (indexed access is enabled by default in Flow) so this commit only enabled the Eslint rule and fixes related issues in our codebase.

See: https://flow.org/en/docs/types/indexed-access/
  • Loading branch information
mrtnzlml authored and kodiakhq[bot] committed Dec 17, 2021
1 parent d2ad9c6 commit 729591a
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/eslint-config-adeira/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Unreleased

- We internally switched from [`eslint-plugin-flowtype`](https://github.com/gajus/eslint-plugin-flowtype/tree/449cb99f1b6d3bbbb66f5be55f497667f5b2cb31) to [`eslint-plugin-ft-flow`](https://github.com/flow-typed/eslint-plugin-ft-flow/tree/820e631ce491cdf45821744d4e29f348cf776392) which contains the same set of rules but it's more up to date. We are going to enable additional rules later. There is a possible minor breaking change (with very simple fix) when suppressing the rules manually, for example:
- New rule enabled: `fb-flow/use-indexed-access-type` (warnings or errors in strict mode), for more information visit: https://flow.org/en/docs/types/indexed-access/.
- We internally switched from [`eslint-plugin-flowtype`](https://github.com/gajus/eslint-plugin-flowtype/tree/449cb99f1b6d3bbbb66f5be55f497667f5b2cb31) to [`eslint-plugin-ft-flow`](https://github.com/flow-typed/eslint-plugin-ft-flow/tree/820e631ce491cdf45821744d4e29f348cf776392) which contains the same set of rules but should be more up to date and maintained. We are going to enable additional rules later. There is a possible minor breaking change (with very simple fix) when suppressing the rules manually, for example:

```diff
- /* eslint-disable flowtype/require-valid-file-annotation */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Object {
"fb-flow/no-flow-enums-object-mapping": 1,
"fb-flow/use-exact-by-default-object-type": 1,
"fb-flow/use-flow-enums": 1,
"fb-flow/use-indexed-access-type": 0,
"fb-flow/use-indexed-access-type": 1,
"flowtype/boolean-style": "off",
"flowtype/delimiter-dangle": "off",
"flowtype/generic-spacing": "off",
Expand Down Expand Up @@ -1179,11 +1179,13 @@ Snapshot Diff:
- "fb-flow/no-flow-enums-object-mapping": 1,
- "fb-flow/use-exact-by-default-object-type": 1,
- "fb-flow/use-flow-enums": 1,
- "fb-flow/use-indexed-access-type": 1,
+ "fb-flow/flow-enums-default-if-possible": 2,
+ "fb-flow/no-flow-enums-object-mapping": 2,
+ "fb-flow/use-exact-by-default-object-type": 2,
+ "fb-flow/use-flow-enums": 2,
"fb-flow/use-indexed-access-type": 0,
+ "fb-flow/use-indexed-access-type": 2,
"flowtype/boolean-style": "off",
@@ --- --- @@
"ft-flow/no-dupe-keys": 2,
- "ft-flow/no-duplicate-type-union-intersection-members": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ Object {
"fb-flow/no-flow-enums-object-mapping": 1,
"fb-flow/use-exact-by-default-object-type": 1,
"fb-flow/use-flow-enums": 1,
"fb-flow/use-indexed-access-type": 0,
"fb-flow/use-indexed-access-type": 1,
"ft-flow/array-style-complex-type": 0,
"ft-flow/array-style-simple-type": 0,
"ft-flow/arrow-parens": 0,
Expand Down
2 changes: 1 addition & 1 deletion src/eslint-config-adeira/src/presets/flowtype.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ module.exports = ({
'fb-flow/no-flow-enums-object-mapping': NEXT_VERSION_ERROR,
'fb-flow/use-exact-by-default-object-type': NEXT_VERSION_ERROR, // we are using `exact_by_default=true`
'fb-flow/use-flow-enums': NEXT_VERSION_ERROR,
'fb-flow/use-indexed-access-type': OFF, // TODO (revert https://github.com/adeira/universe/pull/2662)
'fb-flow/use-indexed-access-type': NEXT_VERSION_ERROR,
},
} /*: EslintConfig */);
2 changes: 1 addition & 1 deletion src/relay/src/getDataFromRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Operation = {
export default function getDataFromRequest(
{ query, variables }: Operation,
environment: Environment,
): $PropertyType<Snapshot, 'data'> {
): Snapshot['data'] {
const request = getRequest(query);
const operation = createOperationDescriptor(request, variables);

Expand Down
2 changes: 1 addition & 1 deletion src/relay/src/useLazyLoadQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ export default function useLazyLoadQuery<TQuery: OperationType>(
networkCacheConfig?: CacheConfig,
UNSTABLE_renderPolicy?: RenderPolicy,
},
): $ElementType<TQuery, 'response'> {
): TQuery['response'] {
return _useLazyLoadQuery(gqlQuery, variables ?? {}, options);
}
11 changes: 4 additions & 7 deletions src/relay/src/useMutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,13 @@ export type MutationParameters = {
type HookMutationConfig<T: MutationParameters> = {
// This config is essentially `MutationConfig` type except there are some small differences
// to make the hook interface more friendly. Feel free to expand it as needed.
+onCompleted: (
response: $ElementType<T, 'response'>,
errors: ?$ReadOnlyArray<PayloadError>,
) => void,
+variables?: $ElementType<T, 'variables'>,
+onCompleted: (response: T['response'], errors: ?$ReadOnlyArray<PayloadError>) => void,
+variables?: T['variables'],
+onError?: (error: Error) => void,
+onUnsubscribe?: ?() => void,
+optimisticResponse?: $ElementType<T, 'rawResponse'>,
+optimisticResponse?: T['rawResponse'],
+optimisticUpdater?: (store: RecordSourceSelectorProxy) => void,
+updater?: ?(store: RecordSourceSelectorProxy, data: $ElementType<T, 'response'>) => void,
+updater?: ?(store: RecordSourceSelectorProxy, data: T['response']) => void,
+configs?: Array<DeclarativeMutationConfig>,
+uploadables?: UploadableMap,
};
Expand Down

0 comments on commit 729591a

Please sign in to comment.