Add eslint-plugin-flowtype

This commit is contained in:
Nicolas Gallagher
2020-05-06 18:08:55 -07:00
parent ff6109ec1c
commit cecacbc3ac
11 changed files with 62 additions and 43 deletions

View File

@@ -17,41 +17,23 @@
"sourceType": "module"
},
"extends": [
"plugin:flowtype/recommended",
"prettier",
"prettier/react"
],
"plugins": [
"flowtype",
"promise",
"react",
"react-hooks"
],
"env": {
"browser": true,
"es6": true,
"node": true
},
"globals": {
"document": false,
"navigator": false,
"window": false,
// Flow global types,
"$Diff": false,
"$ElementType": false,
"$Enum": false,
"$PropertyType": false,
"$ReadOnly": false,
"$ReadOnlyArray": false,
"CSSStyleSheet": false,
"HTMLElement": false,
"HTMLInputElement": false,
"ReactClass": false,
"ReactComponent": false,
"ReactElement": false,
"ReactPropsChainableTypeChecker": false,
"ReactPropsCheckType": false,
"ReactPropTypes": false,
"ResizeObserver": false,
"SyntheticEvent": false,
"TimeoutID": false,
},
"rules": {
"camelcase": 0,
@@ -141,6 +123,10 @@
"valid-typeof": 2,
"yoda": [2, "never"],
// flow
"flowtype/generic-spacing": 0,
"flowtype/space-after-type-colon": 0,
// promise
"promise/param-names": 2,

View File

@@ -43,6 +43,7 @@
"del-cli": "^3.0.0",
"eslint": "^6.5.1",
"eslint-config-prettier": "^6.4.0",
"eslint-plugin-flowtype": "^4.7.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.16.0",
"eslint-plugin-react-hooks": "^2.3.0",

View File

@@ -1,3 +1,5 @@
/* @noflow */
import Text from './Text';
import { StyleSheet, View } from 'react-native';
import React, { Fragment } from 'react';

View File

@@ -1,3 +1,5 @@
/* @noflow */
import { type Component } from 'react';
import packageJson from '../package.json';

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule MultiColumnExample
* @noflow
*/
'use strict';

View File

@@ -3,6 +3,8 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @noflow
*/
'use strict';

View File

@@ -3,6 +3,8 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @noflow
*/
'use strict';

View File

@@ -1,3 +1,7 @@
/**
* @noflow
*/
import React from 'react';
import { styles } from '../helpers';
import { Text, TextInput, View } from 'react-native';

View File

@@ -8,8 +8,7 @@
* @flow
*/
import type { ViewProps } from '../View';
import type { ResizeMode, Source, Style } from './types';
import type { ImageProps } from './types';
import createElement from '../createElement';
import css from '../StyleSheet/css';
@@ -22,21 +21,7 @@ import TextAncestorContext from '../Text/TextAncestorContext';
import View from '../View';
import React, { forwardRef, useContext, useEffect, useRef, useState } from 'react';
export type ImageProps = {
...ViewProps,
blurRadius?: number,
defaultSource?: Source,
draggable?: boolean,
onError?: (e: any) => void,
onLayout?: (e: any) => void,
onLoad?: (e: any) => void,
onLoadEnd?: (e: any) => void,
onLoadStart?: (e: any) => void,
onProgress?: (e: any) => void,
resizeMode?: ResizeMode,
source: Source,
style?: Style
};
export type { ImageProps };
const ERRORED = 'ERRORED';
const LOADED = 'LOADED';
@@ -108,7 +93,7 @@ function resolveAssetDimensions(source) {
if (typeof source === 'number') {
const { height, width } = getAssetByID(source);
return { height, width };
} else if (source != null && typeof source === 'object') {
} else if (source != null && !Array.isArray(source) && typeof source === 'object') {
const { height, width } = source;
return { height, width };
}

View File

@@ -1,4 +1,16 @@
import type { ColorValue } from '../../types';
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import type { ColorValue, GenericStyleProp } from '../../types';
import type { ViewProps } from '../View/types';
import type {
AnimationStyles,
BorderStyles,
@@ -69,7 +81,7 @@ export type ResizeMode = 'center' | 'contain' | 'cover' | 'none' | 'repeat' | 's
export type Source = number | string | SourceObject | Array<SourceObject>;
export type Style = {
export type ImageStyle = {
...AnimationStyles,
...BorderStyles,
...InteractionStyles,
@@ -83,3 +95,19 @@ export type Style = {
resizeMode?: ResizeMode,
tintColor?: ColorValue
};
export type ImageProps = {
...ViewProps,
blurRadius?: number,
defaultSource?: Source,
draggable?: boolean,
onError?: (e: any) => void,
onLayout?: (e: any) => void,
onLoad?: (e: any) => void,
onLoadEnd?: (e: any) => void,
onLoadStart?: (e: any) => void,
onProgress?: (e: any) => void,
resizeMode?: ResizeMode,
source: Source,
style?: GenericStyleProp<ImageStyle>
};

View File

@@ -6875,6 +6875,13 @@ eslint-config-prettier@^6.4.0:
dependencies:
get-stdin "^6.0.0"
eslint-plugin-flowtype@^4.7.0:
version "4.7.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-4.7.0.tgz#903a6ea3eb5cbf4c7ba7fa73cc43fc39ab7e4a70"
integrity sha512-M+hxhSCk5QBEValO5/UqrS4UunT+MgplIJK5wA1sCtXjzBcZkpTGRwxmLHhGpbHcrmQecgt6ZL/KDdXWqGB7VA==
dependencies:
lodash "^4.17.15"
eslint-plugin-promise@^4.2.1:
version "4.2.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-4.2.1.tgz#845fd8b2260ad8f82564c1222fce44ad71d9418a"