react-native: Fix lint failures (#15496)

...mostly by disabling them.
This commit is contained in:
Andy
2017-03-29 15:53:09 -07:00
committed by GitHub
parent efecc1d637
commit bd29808df7
9 changed files with 45 additions and 47 deletions

View File

@@ -1,6 +1,5 @@
import * as RNFS from 'react-native-fs';
// get a list of files and directories in the main bundle
RNFS.readDir(RNFS.MainBundlePath) // On Android, use "RNFS.DocumentDirectoryPath" (MainBundlePath is not defined)
.then((result) => {
@@ -26,7 +25,7 @@ RNFS.readDir(RNFS.MainBundlePath) // On Android, use "RNFS.DocumentDirectoryPath
});
// create a path you want to write to
var path = RNFS.DocumentDirectoryPath + '/test.txt';
const path = RNFS.DocumentDirectoryPath + '/test.txt';
// write the file
RNFS.writeFile(path, 'Lorem ipsum dolor sit amet', 'utf8')
@@ -46,9 +45,9 @@ RNFS.unlink('path')
console.log(err.message);
});
var uploadUrl = 'http://requestb.in/XXXXXXX'; // For testing purposes, go to http://requestb.in/ and create your own link
const uploadUrl = 'http://requestb.in/XXXXXXX'; // For testing purposes, go to http://requestb.in/ and create your own link
// create an array of objects of the files you want to upload
var files = [
const files = [
{
name: 'test1',
filename: 'test1.w4a',
@@ -62,13 +61,13 @@ var files = [
}
];
var uploadBegin: RNFS.UploadCallbackBegin = (response) => {
var jobId = response.jobId;
const uploadBegin: RNFS.UploadCallbackBegin = (response) => {
const jobId = response.jobId;
console.log('UPLOAD HAS BEGUN! JobId: ' + jobId);
};
var uploadProgress: RNFS.UploadCallbackProgress = (response) => {
var percentage = Math.floor((response.totalBytesSent / response.totalBytesExpectedToSend) * 100);
const uploadProgress: RNFS.UploadCallbackProgress = (response) => {
const percentage = Math.floor((response.totalBytesSent / response.totalBytesExpectedToSend) * 100);
console.log('UPLOAD IS ' + percentage + '% DONE!');
};
@@ -99,13 +98,13 @@ RNFS.uploadFiles({
console.log(err);
});
var downloadProgress: RNFS.DownloadCallbackProgress = (result) => {
const downloadProgress: RNFS.DownloadCallbackProgress = (result) => {
result.bytesWritten === 0;
result.contentLength > 10;
result.jobId;
};
var downloadBegin: RNFS.DownloadCallbackBegin = (result) => {
const downloadBegin: RNFS.DownloadCallbackBegin = (result) => {
result.headers === {};
};

View File

@@ -23,8 +23,7 @@ export interface onChangeTabProperties {
}
export interface renderTabBarProperties {
goToPage: (pageNumber: number) => void;
goToPage(pageNumber: number): void;
tabs: JSX.Element;
@@ -36,7 +35,6 @@ export interface renderTabBarProperties {
}
interface ScrollableTabViewProperties extends React.Props<ScrollableTabView> {
/**
* tabBarPosition (String) Defaults to "top".
* "bottom" to position the tab bar below content.
@@ -61,13 +59,13 @@ interface ScrollableTabViewProperties extends React.Props<ScrollableTabView> {
* an Object containing two keys: i: the index of the tab that is selected, ref: the ref of the
* tab that is selected
*/
onChangeTab?: (value: onChangeTabProperties) => void;
onChangeTab?(value: onChangeTabProperties): void;
/**
* onScroll (Function) - function to call when the pages are sliding,
* should accept 1 argument which is an Float number representing the page position in the slide frame.
*/
onScroll?: (value: number) => void;
onScroll?(value: number): void;
/**
* renderTabBar (Function:ReactComponent) - accept 1 argument props and should return a component
@@ -75,7 +73,7 @@ interface ScrollableTabViewProperties extends React.Props<ScrollableTabView> {
* and should implement setAnimationValue to be able to animate itself along with the tab content.
* You can manually pass the props to the TabBar component.
*/
renderTabBar?: (value: JSX.Element) => JSX.Element;
renderTabBar?(value: JSX.Element): JSX.Element;
/**
* style (View.propTypes.style)

View File

@@ -22,7 +22,6 @@ class MyText extends React.Component<MyTextProperties, {}> {
}
class ScrollableTabViewDemo extends React.Component<{}, {}> {
constructor(props: ScrollableTabViewDemo) {
super(props);
}
@@ -42,4 +41,4 @@ class ScrollableTabViewDemo extends React.Component<{}, {}> {
protected componentWillUnmount?(): void {
}
}
}

View File

@@ -10,7 +10,6 @@ import {
} from 'react-native';
interface SwiperProperties extends React.Props<Swiper> {
horizontal?: boolean;
style?: ViewStyle;
@@ -49,7 +48,7 @@ interface SwiperProperties extends React.Props<Swiper> {
index?: number;
renderPagination?: (index: number, total: number, thisObject: Swiper) => JSX.Element;
renderPagination?(index: number, total: number, thisObject: Swiper): JSX.Element;
dotStyle?: ViewStyle;
@@ -62,4 +61,3 @@ interface SwiperProperties extends React.Props<Swiper> {
export default class Swiper extends React.Component<SwiperProperties, {}> {
}

View File

@@ -7,7 +7,6 @@ import {
} from 'react-native';
import Swiper from 'react-native-swiper';
class SwiperTest extends React.Component<{}, {}> {
constructor(props: {}) {
super(props);
@@ -60,4 +59,4 @@ const styles = StyleSheet.create({
fontSize: 30,
fontWeight: 'bold'
} as ViewStyle
});
});

View File

@@ -337,7 +337,8 @@ export interface NativeMethodsMixinStatic {
}
// see react-jsx.d.ts
export function createElement<P>(type: React.ReactType,
export function createElement<P>(
type: React.ReactType,
props?: P,
...children: React.ReactNode[]): React.ReactElement<P>;
@@ -1230,7 +1231,7 @@ interface TextInputState {
* Unfocuses the specified text field
* noop if it wasn't focused
*/
blurTextInput(textFieldID?: number) : void
blurTextInput(textFieldID?: number): void
}
/**
@@ -4165,7 +4166,7 @@ export interface LeftToRightGesture {
direction: string;
}
export interface JumpGesture extends LeftToRightGesture{
export interface JumpGesture extends LeftToRightGesture {
overswipe: {
frictionConstant: number
frictionByDistance: number
@@ -5774,7 +5775,7 @@ export interface SnapshotViewIOSProperties extends ViewProperties, React.Props<S
onSnapshotReady(): any,
// A name to identify the individual instance to the SnapshotView
testIdentifier : string,
testIdentifier: string,
ref?: React.Ref<ViewStatic & SnapshotViewIOSStatic>
}
@@ -7288,7 +7289,7 @@ export interface EasingStatic {
inOut(easing: EasingFunction): EasingFunction;
}
export module Animated {
export namespace Animated {
// Most (all?) functions where AnimatedValue is used any subclass of Animated can be used as well.
type AnimatedValue = Animated;
type AnimatedValueXY = ValueXY;
@@ -7549,7 +7550,7 @@ export module Animated {
* Spring animation based on Rebound and Origami. Tracks velocity state to
* create fluid motions as the `toValue` updates, and can be chained together.
*/
export function spring (
export function spring(
value: AnimatedValue | AnimatedValueXY,
config: SpringAnimationConfig
): CompositeAnimation;
@@ -7563,7 +7564,7 @@ export module Animated {
* of the animations is stopped, they will all be stopped. You can override
* this with the `stopTogether` flag.
*/
export function parallel (
export function parallel(
animations: Array<CompositeAnimation>,
config?: ParallelConfig
): CompositeAnimation;
@@ -7589,7 +7590,7 @@ export module Animated {
* ]),
*```
*/
export function event (
export function event(
argMapping: Mapping[],
config?: EventConfig
): (...args: any[]) => void;
@@ -7597,7 +7598,7 @@ export module Animated {
/**
* Make any React component Animatable. Used to create `Animated.View`, etc.
*/
export function createAnimatedComponent (component: any) : any;
export function createAnimatedComponent(component: any): any;
/**
* Animated variants of the basic native views. Accepts Animated.Value for

View File

@@ -90,4 +90,4 @@ function TestAnimatedAPI() {
</Animated.Image>
</View>
);
}
}

View File

@@ -28,19 +28,12 @@ import {
} from 'react-native';
function testDimensions() {
var {
const {
width,
height,
scale,
fontScale,
} = Dimensions.get("window");
var {
width,
height,
scale,
fontScale,
} = Dimensions.get("screen");
} = Dimensions.get(1 === 1 ? "window" : "screen");
}
BackAndroid.addEventListener("hardwareBackPress", () => {
@@ -52,7 +45,7 @@ interface LocalStyles {
instructions: TextStyle;
}
var styles = StyleSheet.create<LocalStyles>(
const styles = StyleSheet.create<LocalStyles>(
{
container: {
flex: 1,
@@ -97,7 +90,6 @@ const stylesAlt = StyleSheet.create(
class Welcome extends React.Component<any, any> {
refs: {
[key: string]: any
rootView: View
@@ -113,7 +105,6 @@ class Welcome extends React.Component<any, any> {
}
render() {
return (
<View ref="rootView" style={styles.container}>
<Text style={styles.welcome}>
@@ -135,7 +126,7 @@ export default Welcome;
// App State
function appStateListener(state : string) {
function appStateListener(state: string) {
console.log('New state: ' + state);
}

View File

@@ -2,6 +2,19 @@
"extends": "../tslint.json",
"rules": {
// Lowercase `object` is available in TypeScript 2.2 only.
"ban-types": false
"ban-types": false,
// Below are all TODO
"array-type": false,
"comment-format": false,
"interface-over-type-literal": false,
"no-misused-new": false,
"no-consecutive-blank-lines": false,
"no-empty-interface": false,
"no-padding": false,
"no-redundant-modifiers": false,
"no-var": false,
"prefer-declare-function": false,
"prefer-method-signature": false,
"semicolon": false
}
}