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,8 +2,8 @@
* based on
* https://github.com/CreateJS/EaselJS/blob/631cdffb85eff9413dab43b4676f059b4232d291/src/easeljs/geom/Matrix2D.js
*/
const DEG_TO_RAD = Math.PI/180;
import _ from 'lodash';
const DEG_TO_RAD = Math.PI / 180;
/**
* Represents an affine transformation matrix, and provides tools for constructing and concatenating matrices.
@@ -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;
@@ -147,12 +147,12 @@ class Matrix2D {
var c1 = this.c;
var tx1 = this.tx;
this.a = a*a1+c*this.b;
this.b = b*a1+d*this.b;
this.c = a*c1+c*this.d;
this.d = b*c1+d*this.d;
this.tx = a*tx1+c*this.ty+tx;
this.ty = b*tx1+d*this.ty+ty;
this.a = a * a1 + c * this.b;
this.b = b * a1 + d * this.b;
this.c = a * c1 + c * this.d;
this.d = b * c1 + d * this.d;
this.tx = a * tx1 + c * this.ty + tx;
this.ty = b * tx1 + d * this.ty + ty;
return this;
};
@@ -173,14 +173,14 @@ class Matrix2D {
var b1 = this.b;
var c1 = this.c;
var d1 = this.d;
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;
this.d = b1*c+d1*d;
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;
this.d = b1 * c + d1 * d;
}
this.tx = a1*tx+c1*ty+this.tx;
this.ty = b1*tx+d1*ty+this.ty;
this.tx = a1 * tx + c1 * ty + this.tx;
this.ty = b1 * tx + d1 * ty + this.ty;
return this;
};
@@ -203,8 +203,8 @@ class Matrix2D {
* @return {Matrix2D} This matrix. Useful for chaining method calls.
**/
appendTransform = function(x, y, scaleX, scaleY, rotation, skewX, skewY, regX, regY) {
if (rotation%360) {
var r = rotation*DEG_TO_RAD;
if (rotation % 360) {
var r = rotation * DEG_TO_RAD;
var cos = Math.cos(r);
var sin = Math.sin(r);
} else {
@@ -217,15 +217,15 @@ class Matrix2D {
skewX *= DEG_TO_RAD;
skewY *= DEG_TO_RAD;
this.append(Math.cos(skewY), Math.sin(skewY), -Math.sin(skewX), Math.cos(skewX), x, y);
this.append(cos*scaleX, sin*scaleX, -sin*scaleY, cos*scaleY, 0, 0);
this.append(cos * scaleX, sin * scaleX, -sin * scaleY, cos * scaleY, 0, 0);
} else {
this.append(cos*scaleX, sin*scaleX, -sin*scaleY, cos*scaleY, x, y);
this.append(cos * scaleX, sin * scaleX, -sin * scaleY, cos * scaleY, x, y);
}
if (regX || regY) {
// append the registration offset:
this.tx -= regX*this.a+regY*this.c;
this.ty -= regX*this.b+regY*this.d;
this.tx -= regX * this.a + regY * this.c;
this.ty -= regX * this.b + regY * this.d;
}
return this;
};
@@ -256,8 +256,8 @@ class Matrix2D {
* @return {Matrix2D} This matrix. Useful for chaining method calls.
**/
prependTransform = function(x, y, scaleX, scaleY, rotation, skewX, skewY, regX, regY) {
if (rotation%360) {
var r = rotation*DEG_TO_RAD;
if (rotation % 360) {
var r = rotation * DEG_TO_RAD;
var cos = Math.cos(r);
var sin = Math.sin(r);
} else {
@@ -273,10 +273,10 @@ class Matrix2D {
// TODO: can this be combined into a single prepend operation?
skewX *= DEG_TO_RAD;
skewY *= DEG_TO_RAD;
this.prepend(cos*scaleX, sin*scaleX, -sin*scaleY, cos*scaleY, 0, 0);
this.prepend(cos * scaleX, sin * scaleX, -sin * scaleY, cos * scaleY, 0, 0);
this.prepend(Math.cos(skewY), Math.sin(skewY), -Math.sin(skewX), Math.cos(skewX), x, y);
} else {
this.prepend(cos*scaleX, sin*scaleX, -sin*scaleY, cos*scaleY, x, y);
this.prepend(cos * scaleX, sin * scaleX, -sin * scaleY, cos * scaleY, x, y);
}
return this;
};

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

@@ -17,7 +17,7 @@ export default function (colorOrBrush) {
let c = new Color(colorOrBrush).rgbaArray();
return [0, c[0] / 255, c[1] / 255, c[2] / 255, c[3]];
}
} catch(err) {
} catch (err) {
console.warn(`"${colorOrBrush}" is not a valid color or brush`);
return null;
}

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"