Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix linting issues #22062

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion Libraries/Animated/src/bezier.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
1 change: 0 additions & 1 deletion Libraries/Animated/src/nodes/AnimatedValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/Keyboard/KeyboardAvoidingView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/Touchable/TouchableOpacity.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
1 change: 0 additions & 1 deletion Libraries/Components/WebView/WebView.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
5 changes: 2 additions & 3 deletions Libraries/Experimental/Incremental.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion Libraries/Experimental/SwipeableRow/SwipeableFlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Image/Image.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion Libraries/Image/Image.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion Libraries/Modal/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 3 additions & 1 deletion Libraries/ReactNative/UIManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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__) {
Expand Down
2 changes: 0 additions & 2 deletions Libraries/Utilities/setAndForwardRef.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

'use strict';

const invariant = require('fbjs/lib/invariant');

import type React from 'React';

type Args = $ReadOnly<{|
Expand Down
2 changes: 2 additions & 0 deletions Libraries/polyfills/babelHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {});
Expand Down
2 changes: 1 addition & 1 deletion Libraries/polyfills/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion RNTester/RNTesterUnitTests/RNTesterUnitTestsBundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
Expand Down
4 changes: 2 additions & 2 deletions RNTester/e2e/sanity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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 () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linter would be happy with double quotes here and then you don't need to escape the inner ones.

Suggested change
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();
Expand Down
2 changes: 1 addition & 1 deletion RNTester/js/ARTExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions RNTester/js/AsyncStorageExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 0 additions & 2 deletions RNTester/js/XHRExampleFormData.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
const React = require('react');
const ReactNative = require('react-native');
const {
Alert,
CameraRoll,
Image,
ImageEditor,
Linking,
Platform,
StyleSheet,
Text,
Expand Down
1 change: 0 additions & 1 deletion ReactAndroid/src/androidTest/js/TestIdTestModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 1 addition & 3 deletions bots/dangerfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
22 changes: 8 additions & 14 deletions local-cli/generator/promptSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion local-cli/link/__tests__/ios/writePlist.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
1 change: 0 additions & 1 deletion local-cli/link/ios/copyAssets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
1 change: 0 additions & 1 deletion local-cli/link/ios/unregisterNativeModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion local-cli/templates/HelloWorld/__tests__/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 />);
});
2 changes: 0 additions & 2 deletions local-cli/upgrade/upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions scripts/try-n-times.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* @format
*/

/* globals echo:false */

'use strict';

/**
Expand Down