fix lint warnings

This commit is contained in:
Horcrux
2016-07-27 12:10:12 +08:00
parent f2ee72bb76
commit 7d09dcde29
19 changed files with 54 additions and 61 deletions

View File

@@ -1,4 +1,4 @@
import React, {PropTypes} from 'react';
import React from 'react';
import createReactNativeComponentClass from 'react/lib/createReactNativeComponentClass';
import Shape from './Shape';
import {CircleAttributes} from '../lib/attributes';
@@ -27,7 +27,7 @@ class Circle extends Shape {
render() {
let props = this.props;
return <RNSVGCircle
ref={ele => this.root = ele}
ref={ele => {this.root = ele;}}
{...this.extractProps(props)}
cx={props.cx.toString()}
cy={props.cy.toString()}

View File

@@ -1,6 +1,6 @@
import React, {
Component,
} from 'react'
} from 'react';
import createReactNativeComponentClass from 'react/lib/createReactNativeComponentClass';
class Defs extends Component {

View File

@@ -1,4 +1,4 @@
import React, {PropTypes} from 'react';
import React from 'react';
import createReactNativeComponentClass from 'react/lib/createReactNativeComponentClass';
import Shape from './Shape';
import {pathProps, numberProp} from '../lib/props';
@@ -30,7 +30,7 @@ class Ellipse extends Shape{
let props = this.props;
return <RNSVGEllipse
ref={ele => this.root = ele}
ref={ele => {this.root = ele;}}
{...this.extractProps(props)}
cx={props.cx.toString()}
cy={props.cy.toString()}

View File

@@ -1,5 +1,4 @@
import React, {Component, PropTypes} from 'react';
import _ from 'lodash';
import React, {Component} from 'react';
import createReactNativeComponentClass from 'react/lib/createReactNativeComponentClass';
import {transformProps} from '../lib/props';
import {GroupAttributes} from '../lib/attributes';
@@ -25,9 +24,7 @@ class G extends Component{
return <RNSVGGroup
{...extractedProps}
ref={ele => {
this.root = ele;
}}
ref={ele => {this.root = ele;}}
>
{this.props.children}
</RNSVGGroup>;

View File

@@ -1,4 +1,4 @@
import React, {Children, Component} from 'react';
import {Children, Component} from 'react';
import percentToFloat from '../lib/percentToFloat';
import Stop from './Stop';
import Color from 'color';
@@ -20,7 +20,7 @@ class Gradient extends Component{
stops[offset] = Color(child.props.stopColor).alpha(extractOpacity(child.props.stopOpacity));
}
} else {
console.warn(`'Gradient' can only receive 'Stop' elements as children`);
console.warn('\'Gradient\' can only receive \'Stop\' elements as children');
}
});

View File

@@ -33,7 +33,7 @@ class Image extends Shape {
render() {
let {props} = this;
return <RNSVGImage
ref={ele => this.root = ele}
ref={ele => {this.root = ele;}}
{...this.extractProps(props, {responder: true})}
x={props.x.toString()}
y={props.y.toString()}

View File

@@ -1,4 +1,4 @@
import React, {PropTypes} from 'react';
import React from 'react';
import createReactNativeComponentClass from 'react/lib/createReactNativeComponentClass';
import {LineAttributes} from '../lib/attributes';
import Shape from './Shape';
@@ -29,7 +29,7 @@ class Line extends Shape {
render() {
let props = this.props;
return <RNSVGLine
ref={ele => this.root = ele}
ref={ele => {this.root = ele;}}
{...this.extractProps(props)}
x1={props.x1.toString()}
y1={props.y1.toString()}

View File

@@ -3,7 +3,7 @@ import SerializablePath from '../lib/SerializablePath';
import createReactNativeComponentClass from 'react/lib/createReactNativeComponentClass';
import {PathAttributes} from '../lib/attributes';
import Shape from './Shape';
import {pathProps, numberProp} from '../lib/props';
import {pathProps} from '../lib/props';
class Path extends Shape {
static displayName = 'Path';
@@ -23,7 +23,7 @@ class Path extends Shape {
let d = new SerializablePath(props.d).toJSON();
return (
<RNSVGPath
ref={ele => this.root = ele}
ref={ele => {this.root = ele;}}
{...this.extractProps(props)}
d={d}
/>

View File

@@ -25,7 +25,7 @@ class Polygon extends Component{
}
return <Path
ref={ele => this.root = ele}
ref={ele => {this.root = ele;}}
{...this.props}
d={`M${points.trim().replace(/\s+/g, 'L')}z`}
/>;

View File

@@ -25,7 +25,7 @@ class Polyline extends Component{
}
return <Path
ref={ele => this.root = ele}
ref={ele => {this.root = ele;}}
{...this.props}
d={`M${points.trim().replace(/\s+/g, 'L')}`}
/>;

View File

@@ -1,4 +1,4 @@
import React, {PropTypes} from 'react';
import React from 'react';
import './Path'; // must import Path first, don`t know why. without this will throw an `Super expression must either be null or a function, not undefined`
import createReactNativeComponentClass from 'react/lib/createReactNativeComponentClass';
import {pathProps, numberProp} from '../lib/props';
@@ -35,7 +35,7 @@ class Rect extends Shape {
let props = this.props;
return <RNSVGRect
ref={ele => this.root = ele}
ref={ele => {this.root = ele;}}
{...this.extractProps({
...props,
x: null,

View File

@@ -1,4 +1,4 @@
import React, {Children, Component, cloneElement, PropTypes} from 'react';
import React, {Component, PropTypes} from 'react';
import {View, requireNativeComponent, StyleSheet} from 'react-native';
import ViewBox from './ViewBox';
@@ -57,7 +57,7 @@ class Svg extends Component{
width,
height,
flex: 0
}
};
}
if (props.viewbox) {
@@ -78,7 +78,7 @@ class Svg extends Component{
height={null}
viewBox={null}
preserveAspectRatio={null}
ref={ele => this.root = ele}
ref={ele => {this.root = ele;}}
style={[
styles.svg,
props.style,

View File

@@ -1,6 +1,5 @@
import React, {PropTypes} from 'react';
import createReactNativeComponentClass from 'react/lib/createReactNativeComponentClass';
import Defs from './Defs';
import extractProps from '../lib/extract/extractProps';
import extractText from '../lib/extract/extractText';
import {numberProp, pathProps} from '../lib/props';
@@ -47,7 +46,7 @@ class Text extends Shape {
return (
<RNSVGText
ref={ele => this.root = ele}
ref={ele => {this.root = ele;}}
{...extractProps({...props, x, y})}
{...extractText(props)}
/>

View File

@@ -4,7 +4,6 @@ import {UseAttributes} from '../lib/attributes';
import Shape from './Shape';
import React from 'react';
import createReactNativeComponentClass from 'react/lib/createReactNativeComponentClass';
import _ from 'lodash';
const idExpReg = /^#(.+)$/;
class Use extends Shape {
@@ -43,7 +42,7 @@ class Use extends Shape {
});
return <RNSVGUse
ref={ele => this.root = ele}
ref={ele => {this.root = ele;}}
{...extractedProps}
href={href}
width={props.width}

View File

@@ -44,7 +44,7 @@ class ViewBox extends Component{
console.warn('`viewBox` expected a string like `minX minY width height`, but got:' + viewBox);
return <G>
{this.props.children}
</G>
</G>;
}
let modes = preserveAspectRatio.trim().split(spacesRegExp);
@@ -62,7 +62,7 @@ class ViewBox extends Component{
meetOrSlice={meetOrSlice}
>
{this.props.children}
</RNSVGViewBox>
</RNSVGViewBox>;
}
}

View File

@@ -2,7 +2,7 @@
* based on
* https://github.com/CreateJS/EaselJS/blob/631cdffb85eff9413dab43b4676f059b4232d291/src/easeljs/geom/Matrix2D.js
*/
import _ from 'lodash';
const DEG_TO_RAD = Math.PI / 180;
/**
@@ -81,10 +81,10 @@ class Matrix2D {
*/
setTransform = function(a, b, c, d, tx, ty) {
// don't forget to update docs in the constructor if these change:
this.a = (a == null) ? 1 : a;
this.a = _.isNil(a) ? 1 : a;
this.b = b || 0;
this.c = c || 0;
this.d = (d == null) ? 1 : d;
this.d = _.isNil(d) ? 1 : d;
this.tx = tx || 0;
this.ty = ty || 0;
return this;
@@ -173,7 +173,7 @@ class Matrix2D {
var b1 = this.b;
var c1 = this.c;
var d1 = this.d;
if (a != 1 || b != 0 || c != 0 || d != 1) {
if (a !== 1 || b !== 0 || c !== 0 || d !== 1) {
this.a = a1 * a + c1 * b;
this.b = b1 * a + d1 * b;
this.c = a1 * c + c1 * d;

View File

@@ -3,8 +3,6 @@ const MOVE_TO = 0;
const CLOSE = 1;
const LINE_TO = 2;
const CURVE_TO = 3;
const ARC = 4;
export default class SerializablePath {
constructor(path) {

View File

@@ -1,7 +1,7 @@
{
"version": "4.0.0",
"name": "react-native-svg",
"description": "react native svg library",
"description": "SVG library for react-native",
"repository": {
"type": "git",
"url": "https://github.com/magicismight/react-native-svg"