mirror of
https://github.com/status-im/react-native.git
synced 2025-02-20 13:18:07 +00:00
Fix linting issues (#22062)
Summary: Fixes lots of ESLint warnings. Many of them where in PR #20877 by janicduplessis which requested to split the linting fixes from configuration and package changes. I solved only the issues that I was most certain about but I would love to get hands on all of them with a little bit of input. Pull Request resolved: https://github.com/facebook/react-native/pull/22062 Differential Revision: D12889447 Pulled By: TheSavior fbshipit-source-id: 35f7a08104a5b859c860afdde4af2b32c0685c50
This commit is contained in:
parent
136dfc8312
commit
ae8ec39397
@ -38,7 +38,7 @@ const test_opts = {
|
||||
PATH: argv.path || './ReactAndroid/src/androidTest/java/com/facebook/react/tests',
|
||||
RETRIES: parseInt(argv.retries || 2, 10),
|
||||
|
||||
TEST_TIMEOUT: parseInt(argv['test-timeout'] || 1000 * 60 * 10),
|
||||
TEST_TIMEOUT: parseInt(argv['test-timeout'] || 1000 * 60 * 10, 10),
|
||||
|
||||
OFFSET: argv.offset,
|
||||
COUNT: argv.count,
|
||||
@ -68,7 +68,6 @@ testClasses = testClasses.map((clazz) => {
|
||||
|
||||
// only process subset of the tests at corresponding offset and count if args provided
|
||||
if (test_opts.COUNT != null && test_opts.OFFSET != null) {
|
||||
const testCount = testClasses.length;
|
||||
const start = test_opts.COUNT * test_opts.OFFSET;
|
||||
const end = start + test_opts.COUNT;
|
||||
|
||||
|
@ -82,7 +82,7 @@ module.exports = function bezier(
|
||||
mX2: number,
|
||||
mY2: number,
|
||||
) {
|
||||
if (!(0 <= mX1 && mX1 <= 1 && 0 <= mX2 && mX2 <= 1)) {
|
||||
if (!(mX1 >= 0 && mX1 <= 1 && mX2 >= 0 && mX2 <= 1)) {
|
||||
throw new Error('bezier x values must be in [0, 1] range');
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
'use strict';
|
||||
|
||||
const AnimatedInterpolation = require('./AnimatedInterpolation');
|
||||
const AnimatedNode = require('./AnimatedNode');
|
||||
const AnimatedWithChildren = require('./AnimatedWithChildren');
|
||||
const InteractionManager = require('InteractionManager');
|
||||
const NativeAnimatedHelper = require('../NativeAnimatedHelper');
|
||||
|
@ -150,7 +150,7 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
|
||||
children,
|
||||
contentContainerStyle,
|
||||
enabled,
|
||||
keyboardVerticalOffset, // eslint-disable-line no-unused-vars
|
||||
keyboardVerticalOffset,
|
||||
style,
|
||||
...props
|
||||
} = this.props;
|
||||
|
@ -247,7 +247,7 @@ const TouchableOpacity = ((createReactClass({
|
||||
|
||||
_getChildStyleOpacityWithDefault: function() {
|
||||
const childStyle = flattenStyle(this.props.style) || {};
|
||||
return childStyle.opacity == undefined ? 1 : childStyle.opacity;
|
||||
return childStyle.opacity == null ? 1 : childStyle.opacity;
|
||||
},
|
||||
|
||||
render: function() {
|
||||
|
@ -17,7 +17,6 @@ const Linking = require('Linking');
|
||||
const PropTypes = require('prop-types');
|
||||
const React = require('React');
|
||||
const ReactNative = require('ReactNative');
|
||||
const ScrollView = require('ScrollView');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const Text = require('Text');
|
||||
const UIManager = require('UIManager');
|
||||
|
@ -92,12 +92,11 @@ export type Props = {
|
||||
name: string,
|
||||
children: React.Node,
|
||||
};
|
||||
type DefaultProps = {
|
||||
name: string,
|
||||
};
|
||||
|
||||
type State = {
|
||||
doIncrementalRender: boolean,
|
||||
};
|
||||
|
||||
class Incremental extends React.Component<Props, State> {
|
||||
props: Props;
|
||||
state: State;
|
||||
|
@ -12,7 +12,6 @@
|
||||
import type {Props as FlatListProps} from 'FlatList';
|
||||
import type {renderItemType} from 'VirtualizedList';
|
||||
|
||||
const PropTypes = require('prop-types');
|
||||
const React = require('React');
|
||||
const SwipeableRow = require('SwipeableRow');
|
||||
const FlatList = require('FlatList');
|
||||
|
@ -17,7 +17,7 @@ const ImageViewNativeComponent = require('ImageViewNativeComponent');
|
||||
const NativeModules = require('NativeModules');
|
||||
const PropTypes = require('prop-types');
|
||||
const React = require('React');
|
||||
const ReactNative = require('ReactNative');
|
||||
const ReactNative = require('ReactNative'); // eslint-disable-line no-unused-vars
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const TextAncestor = require('TextAncestor');
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
const DeprecatedImagePropType = require('DeprecatedImagePropType');
|
||||
const NativeModules = require('NativeModules');
|
||||
const React = require('React');
|
||||
const ReactNative = require('ReactNative');
|
||||
const ReactNative = require('ReactNative'); // eslint-disable-line no-unused-vars
|
||||
const StyleSheet = require('StyleSheet');
|
||||
|
||||
const flattenStyle = require('flattenStyle');
|
||||
|
@ -643,7 +643,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
static getDerivedStateFromProps(newProps: Props, prevState: State) {
|
||||
const {data, extraData, getItemCount, maxToRenderPerBatch} = newProps;
|
||||
const {data, getItemCount, maxToRenderPerBatch} = newProps;
|
||||
// first and last could be stale (e.g. if a new, shorter items props is passed in), so we make
|
||||
// sure we're rendering a reasonable range here.
|
||||
return {
|
||||
|
@ -20,7 +20,6 @@ const PropTypes = require('prop-types');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const View = require('View');
|
||||
|
||||
const deprecatedPropType = require('deprecatedPropType');
|
||||
const requireNativeComponent = require('requireNativeComponent');
|
||||
|
||||
const RCTModalHostView = requireNativeComponent('RCTModalHostView');
|
||||
|
@ -147,7 +147,9 @@ if (Platform.OS === 'ios') {
|
||||
// we also tell Prepack that it has only partial knowledge of the UIManager,
|
||||
// so that any accesses to unknown properties along the global code will fail
|
||||
// when Prepack encounters them.
|
||||
if (global.__makePartial) global.__makePartial(UIManager);
|
||||
if (global.__makePartial) {
|
||||
global.__makePartial(UIManager);
|
||||
}
|
||||
}
|
||||
|
||||
if (__DEV__) {
|
||||
|
@ -10,8 +10,6 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const invariant = require('fbjs/lib/invariant');
|
||||
|
||||
import type React from 'React';
|
||||
|
||||
type Args = $ReadOnly<{|
|
||||
|
@ -44,6 +44,8 @@
|
||||
* @polyfill
|
||||
*/
|
||||
|
||||
/* eslint-disable no-func-assign, no-shadow, no-proto, no-void, no-undef-init */
|
||||
|
||||
'use strict';
|
||||
|
||||
var babelHelpers = (global.babelHelpers = {});
|
||||
|
@ -9,7 +9,7 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
/* eslint-disable no-shadow, eqeqeq, curly, no-unused-vars, no-void */
|
||||
/* eslint-disable no-shadow, eqeqeq, curly, no-unused-vars, no-void, no-control-regex */
|
||||
|
||||
/**
|
||||
* This pipes all of our console logging functions to native logging so that
|
||||
|
@ -9,8 +9,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const __fbBatchedBridge = {
|
||||
// eslint-disable-line no-unused-vars
|
||||
flushedQueue: function() {
|
||||
return null;
|
||||
},
|
||||
|
@ -10,7 +10,7 @@
|
||||
describe('Sanity', () => {
|
||||
beforeEach(async () => {
|
||||
await device.reloadReactNative();
|
||||
await element(by.label(`<Button> Simple React Native button component.`)).tap();
|
||||
await element(by.label('<Button> Simple React Native button component.')).tap();
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
@ -30,7 +30,7 @@ describe('Sanity', () => {
|
||||
await element(by.text('OK')).tap();
|
||||
});
|
||||
|
||||
it(`Two buttons with JustifyContent:'space-between' should be tappable`, async () => {
|
||||
it("Two buttons with JustifyContent:'space-between' should be tappable", async () => {
|
||||
await element(by.label('This looks great!')).tap();
|
||||
await expect(element(by.text('Left has been pressed!'))).toBeVisible();
|
||||
await element(by.text('OK')).tap();
|
||||
|
@ -14,7 +14,7 @@ const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const {ART, Platform, View} = ReactNative;
|
||||
|
||||
const {Surface, Path, Group, Transform, Shape} = ART;
|
||||
const {Surface, Path, Group, Shape} = ART;
|
||||
|
||||
const scale = Platform.isTV ? 4 : 1;
|
||||
|
||||
|
@ -55,11 +55,11 @@ class BasicStorageExample extends React.Component<{}, $FlowFixMeState> {
|
||||
{'Selected: '}
|
||||
<Text style={{color}}>{this.state.selectedValue}</Text>
|
||||
</Text>
|
||||
<Text> </Text>
|
||||
<Text />
|
||||
<Text onPress={this._removeStorage}>
|
||||
Press here to remove from storage.
|
||||
</Text>
|
||||
<Text> </Text>
|
||||
<Text />
|
||||
<Text>Messages:</Text>
|
||||
{this.state.messages.map(m => <Text key={m}>{m}</Text>)}
|
||||
</View>
|
||||
|
@ -13,11 +13,9 @@
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const {
|
||||
Alert,
|
||||
CameraRoll,
|
||||
Image,
|
||||
ImageEditor,
|
||||
Linking,
|
||||
Platform,
|
||||
StyleSheet,
|
||||
Text,
|
||||
|
@ -12,7 +12,6 @@
|
||||
var Image = require('Image');
|
||||
var React = require('React');
|
||||
var StyleSheet = require('StyleSheet');
|
||||
var Switch = require('Switch');
|
||||
var Text = require('Text');
|
||||
var TextInput = require('TextInput');
|
||||
var TouchableBounce = require('TouchableBounce');
|
||||
|
@ -9,11 +9,9 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const includes = require('lodash.includes');
|
||||
const minimatch = require('minimatch');
|
||||
|
||||
const {danger, fail, markdown, message, warn} = require('danger');
|
||||
const {danger, fail, warn} = require('danger');
|
||||
|
||||
// Fails if the description is too short.
|
||||
if (!danger.github.pr.body || danger.github.pr.body.length < 10) {
|
||||
|
@ -19,11 +19,7 @@ function create() {
|
||||
return prompt;
|
||||
|
||||
function prompt(ask, value, opts) {
|
||||
var insert = 0,
|
||||
savedinsert = 0,
|
||||
res,
|
||||
i,
|
||||
savedstr;
|
||||
var insert = 0;
|
||||
opts = opts || {};
|
||||
|
||||
if (Object(ask) === ask) {
|
||||
@ -52,15 +48,10 @@ function create() {
|
||||
character,
|
||||
read;
|
||||
|
||||
savedstr = '';
|
||||
|
||||
if (ask) {
|
||||
process.stdout.write(ask);
|
||||
}
|
||||
|
||||
var cycle = 0;
|
||||
var prevComplete;
|
||||
|
||||
while (true) {
|
||||
read = fs.readSync(fd, buf, 0, 3);
|
||||
if (read > 1) {
|
||||
@ -80,7 +71,7 @@ function create() {
|
||||
character = buf[read - 1];
|
||||
|
||||
// catch a ^C and return null
|
||||
if (character == 3) {
|
||||
if (character === 3) {
|
||||
process.stdout.write('^C\n');
|
||||
fs.closeSync(fd);
|
||||
process.exit(130);
|
||||
@ -89,12 +80,15 @@ function create() {
|
||||
}
|
||||
|
||||
// catch the terminating character
|
||||
if (character == term) {
|
||||
if (character === term) {
|
||||
fs.closeSync(fd);
|
||||
break;
|
||||
}
|
||||
|
||||
if (character == 127 || (process.platform == 'win32' && character == 8)) {
|
||||
if (
|
||||
character === 127 ||
|
||||
(process.platform === 'win32' && character === 8)
|
||||
) {
|
||||
//backspace
|
||||
if (!insert) {
|
||||
continue;
|
||||
@ -119,7 +113,7 @@ function create() {
|
||||
);
|
||||
} else {
|
||||
process.stdout.write('\u001b[s');
|
||||
if (insert == str.length) {
|
||||
if (insert === str.length) {
|
||||
process.stdout.write('\u001b[2K\u001b[0G' + ask + str);
|
||||
} else {
|
||||
if (ask) {
|
||||
|
@ -49,7 +49,7 @@ describe('ios::writePlist', () => {
|
||||
|
||||
it('should write a `.plist` file', () => {
|
||||
plistPath = '/Basic/Info.plist';
|
||||
const result = writePlist(project, '/', plist);
|
||||
writePlist(project, '/', plist);
|
||||
const infoPlist = readFileSync(infoPlistPath).toString();
|
||||
expect(fs.writeFileSync).toHaveBeenCalledWith(plistPath, infoPlist);
|
||||
});
|
||||
|
@ -10,7 +10,6 @@
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const xcode = require('xcode');
|
||||
const log = require('npmlog');
|
||||
const groupFilesByType = require('../groupFilesByType');
|
||||
const createGroupWithMessage = require('./createGroupWithMessage');
|
||||
const getPlist = require('./getPlist');
|
||||
|
@ -14,7 +14,6 @@ const difference = require('lodash').difference;
|
||||
const isEmpty = require('lodash').isEmpty;
|
||||
|
||||
const getGroup = require('./getGroup');
|
||||
const getProducts = require('./getProducts');
|
||||
const getTargets = require('./getTargets');
|
||||
const getHeadersInFolder = require('./getHeadersInFolder');
|
||||
const getHeaderSearchPath = require('./getHeaderSearchPath');
|
||||
|
@ -8,5 +8,5 @@ import App from '../App';
|
||||
import renderer from 'react-test-renderer';
|
||||
|
||||
it('renders correctly', () => {
|
||||
const tree = renderer.create(<App />);
|
||||
renderer.create(<App />);
|
||||
});
|
||||
|
@ -13,9 +13,7 @@ const chalk = require('chalk');
|
||||
const copyProjectTemplateAndReplace = require('../generator/copyProjectTemplateAndReplace');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const printRunInstructions = require('../generator/printRunInstructions');
|
||||
const semver = require('semver');
|
||||
const yarn = require('../util/yarn');
|
||||
|
||||
/**
|
||||
* Migrate application to a new version of React Native.
|
||||
|
@ -7,8 +7,6 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
/* globals echo:false */
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user