mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-06 07:06:11 +00:00
Add eslint
This commit is contained in:
1
.eslintignore
Normal file
1
.eslintignore
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
222
.eslintrc
Normal file
222
.eslintrc
Normal file
@@ -0,0 +1,222 @@
|
||||
{
|
||||
"parser": "babel-eslint",
|
||||
"env": {
|
||||
"es6": true,
|
||||
"node": true
|
||||
},
|
||||
|
||||
"ecmaFeatures": {
|
||||
"modules": true,
|
||||
"jsx": true,
|
||||
"flow": true
|
||||
},
|
||||
|
||||
"plugins": [
|
||||
"react"
|
||||
],
|
||||
|
||||
// Map from global var to bool specifying if it can be redefined
|
||||
"globals": {
|
||||
"__DEV__": true,
|
||||
"__dirname": false,
|
||||
"__fbBatchedBridgeConfig": false,
|
||||
"cancelAnimationFrame": false,
|
||||
"clearImmediate": true,
|
||||
"clearInterval": false,
|
||||
"clearTimeout": false,
|
||||
"console": false,
|
||||
"document": false,
|
||||
"escape": false,
|
||||
"exports": false,
|
||||
"fetch": false,
|
||||
"global": false,
|
||||
"jest": false,
|
||||
"Map": true,
|
||||
"module": false,
|
||||
"navigator": false,
|
||||
"process": false,
|
||||
"Promise": true,
|
||||
"requestAnimationFrame": true,
|
||||
"require": false,
|
||||
"Set": true,
|
||||
"setImmediate": true,
|
||||
"setInterval": false,
|
||||
"setTimeout": false,
|
||||
"window": false,
|
||||
"XMLHttpRequest": false,
|
||||
"alert": true,
|
||||
"pit": false
|
||||
},
|
||||
|
||||
"rules": {
|
||||
"comma-dangle": 0, // disallow trailing commas in object literals
|
||||
"no-cond-assign": 1, // disallow assignment in conditional expressions
|
||||
"no-console": 0, // disallow use of console (off by default in the node environment)
|
||||
"no-constant-condition": 0, // disallow use of constant expressions in conditions
|
||||
"no-control-regex": 1, // disallow control characters in regular expressions
|
||||
"no-debugger": 1, // disallow use of debugger
|
||||
"no-dupe-keys": 1, // disallow duplicate keys when creating object literals
|
||||
"no-empty": 0, // disallow empty statements
|
||||
"no-ex-assign": 1, // disallow assigning to the exception in a catch block
|
||||
"no-extra-boolean-cast": 1, // disallow double-negation boolean casts in a boolean context
|
||||
"no-extra-parens": 0, // disallow unnecessary parentheses (off by default)
|
||||
"no-extra-semi": 1, // disallow unnecessary semicolons
|
||||
"no-func-assign": 1, // disallow overwriting functions written as function declarations
|
||||
"no-inner-declarations": 0, // disallow function or variable declarations in nested blocks
|
||||
"no-invalid-regexp": 1, // disallow invalid regular expression strings in the RegExp constructor
|
||||
"no-negated-in-lhs": 1, // disallow negation of the left operand of an in expression
|
||||
"no-obj-calls": 1, // disallow the use of object properties of the global object (Math and JSON) as functions
|
||||
"no-regex-spaces": 1, // disallow multiple spaces in a regular expression literal
|
||||
"no-reserved-keys": 0, // disallow reserved words being used as object literal keys (off by default)
|
||||
"no-sparse-arrays": 1, // disallow sparse arrays
|
||||
"no-unreachable": 1, // disallow unreachable statements after a return, throw, continue, or break statement
|
||||
"use-isnan": 1, // disallow comparisons with the value NaN
|
||||
"valid-jsdoc": 0, // Ensure JSDoc comments are valid (off by default)
|
||||
"valid-typeof": 1, // Ensure that the results of typeof are compared against a valid string
|
||||
|
||||
// Best Practices
|
||||
// These are rules designed to prevent you from making mistakes. They either prescribe a better way of doing something or help you avoid footguns.
|
||||
|
||||
"block-scoped-var": 0, // treat var statements as if they were block scoped (off by default)
|
||||
"complexity": 0, // specify the maximum cyclomatic complexity allowed in a program (off by default)
|
||||
"consistent-return": 0, // require return statements to either always or never specify values
|
||||
"curly": 1, // specify curly brace conventions for all control statements
|
||||
"default-case": 0, // require default case in switch statements (off by default)
|
||||
"dot-notation": 1, // encourages use of dot notation whenever possible
|
||||
"eqeqeq": 1, // require the use of === and !==
|
||||
"guard-for-in": 0, // make sure for-in loops have an if statement (off by default)
|
||||
"no-alert": 0, // disallow the use of alert, confirm, and prompt
|
||||
"no-caller": 1, // disallow use of arguments.caller or arguments.callee
|
||||
"no-div-regex": 1, // disallow division operators explicitly at beginning of regular expression (off by default)
|
||||
"no-else-return": 0, // disallow else after a return in an if (off by default)
|
||||
"no-empty-label": 1, // disallow use of labels for anything other then loops and switches
|
||||
"no-eq-null": 0, // disallow comparisons to null without a type-checking operator (off by default)
|
||||
"no-eval": 1, // disallow use of eval()
|
||||
"no-extend-native": 1, // disallow adding to native types
|
||||
"no-extra-bind": 1, // disallow unnecessary function binding
|
||||
"no-fallthrough": 1, // disallow fallthrough of case statements
|
||||
"no-floating-decimal": 1, // disallow the use of leading or trailing decimal points in numeric literals (off by default)
|
||||
"no-implied-eval": 1, // disallow use of eval()-like methods
|
||||
"no-labels": 1, // disallow use of labeled statements
|
||||
"no-iterator": 1, // disallow usage of __iterator__ property
|
||||
"no-lone-blocks": 1, // disallow unnecessary nested blocks
|
||||
"no-loop-func": 0, // disallow creation of functions within loops
|
||||
"no-multi-str": 0, // disallow use of multiline strings
|
||||
"no-native-reassign": 0, // disallow reassignments of native objects
|
||||
"no-new": 1, // disallow use of new operator when not part of the assignment or comparison
|
||||
"no-new-func": 1, // disallow use of new operator for Function object
|
||||
"no-new-wrappers": 1, // disallows creating new instances of String,Number, and Boolean
|
||||
"no-octal": 1, // disallow use of octal literals
|
||||
"no-octal-escape": 1, // disallow use of octal escape sequences in string literals, such as var foo = "Copyright \251";
|
||||
"no-proto": 1, // disallow usage of __proto__ property
|
||||
"no-redeclare": 0, // disallow declaring the same variable more then once
|
||||
"no-return-assign": 1, // disallow use of assignment in return statement
|
||||
"no-script-url": 1, // disallow use of javascript: urls.
|
||||
"no-self-compare": 1, // disallow comparisons where both sides are exactly the same (off by default)
|
||||
"no-sequences": 1, // disallow use of comma operator
|
||||
"no-unused-expressions": 0, // disallow usage of expressions in statement position
|
||||
"no-void": 1, // disallow use of void operator (off by default)
|
||||
"no-warning-comments": 0, // disallow usage of configurable warning terms in comments": 1, // e.g. TODO or FIXME (off by default)
|
||||
"no-with": 1, // disallow use of the with statement
|
||||
"radix": 1, // require use of the second argument for parseInt() (off by default)
|
||||
"semi-spacing": 1, // require a space after a semi-colon
|
||||
"vars-on-top": 0, // requires to declare all vars on top of their containing scope (off by default)
|
||||
"wrap-iife": 0, // require immediate function invocation to be wrapped in parentheses (off by default)
|
||||
"yoda": 1, // require or disallow Yoda conditions
|
||||
|
||||
// Strict Mode
|
||||
// These rules relate to using strict mode.
|
||||
|
||||
//"no-extra-strict": 1, // disallow unnecessary use of "use strict"; when already in strict mode
|
||||
"strict": 0, // require that all functions are run in strict mode
|
||||
|
||||
// Variables
|
||||
// These rules have to do with variable declarations.
|
||||
|
||||
"no-catch-shadow": 1, // disallow the catch clause parameter name being the same as a variable in the outer scope (off by default in the node environment)
|
||||
"no-delete-var": 1, // disallow deletion of variables
|
||||
"no-label-var": 1, // disallow labels that share a name with a variable
|
||||
"no-shadow": 1, // disallow declaration of variables already declared in the outer scope
|
||||
"no-shadow-restricted-names": 1, // disallow shadowing of names such as arguments
|
||||
"no-undef": 2, // disallow use of undeclared variables unless mentioned in a /*global */ block
|
||||
"no-undefined": 0, // disallow use of undefined variable (off by default)
|
||||
"no-undef-init": 1, // disallow use of undefined when initializing variables
|
||||
"no-unused-vars": [1, {"vars": "all", "args": "none"}], // disallow declaration of variables that are not used in the code
|
||||
"no-use-before-define": 0, // disallow use of variables before they are defined
|
||||
|
||||
// Node.js
|
||||
// These rules are specific to JavaScript running on Node.js.
|
||||
|
||||
"handle-callback-err": 1, // enforces error handling in callbacks (off by default) (on by default in the node environment)
|
||||
"no-mixed-requires": 1, // disallow mixing regular variable and require declarations (off by default) (on by default in the node environment)
|
||||
"no-new-require": 1, // disallow use of new operator with the require function (off by default) (on by default in the node environment)
|
||||
"no-path-concat": 1, // disallow string concatenation with __dirname and __filename (off by default) (on by default in the node environment)
|
||||
"no-process-exit": 0, // disallow process.exit() (on by default in the node environment)
|
||||
"no-restricted-modules": 1, // restrict usage of specified node modules (off by default)
|
||||
"no-sync": 0, // disallow use of synchronous methods (off by default)
|
||||
|
||||
// Stylistic Issues
|
||||
// These rules are purely matters of style and are quite subjective.
|
||||
|
||||
"key-spacing": 0,
|
||||
"comma-spacing": 0,
|
||||
"no-multi-spaces": 0,
|
||||
"brace-style": 0, // enforce one true brace style (off by default)
|
||||
"camelcase": 0, // require camel case names
|
||||
"consistent-this": [1, "self"], // enforces consistent naming when capturing the current execution context (off by default)
|
||||
"eol-last": 1, // enforce newline at the end of file, with no multiple empty lines
|
||||
"func-names": 0, // require function expressions to have a name (off by default)
|
||||
"func-style": 0, // enforces use of function declarations or expressions (off by default)
|
||||
"new-cap": 0, // require a capital letter for constructors
|
||||
"new-parens": 1, // disallow the omission of parentheses when invoking a constructor with no arguments
|
||||
"no-nested-ternary": 0, // disallow nested ternary expressions (off by default)
|
||||
"no-array-constructor": 1, // disallow use of the Array constructor
|
||||
"no-lonely-if": 0, // disallow if as the only statement in an else block (off by default)
|
||||
"no-new-object": 1, // disallow use of the Object constructor
|
||||
"no-spaced-func": 1, // disallow space between function identifier and application
|
||||
//"no-space-before-semi": 1, // disallow space before semicolon
|
||||
"no-ternary": 0, // disallow the use of ternary operators (off by default)
|
||||
"no-trailing-spaces": 0, // disallow trailing whitespace at the end of lines
|
||||
"no-underscore-dangle": 0, // disallow dangling underscores in identifiers
|
||||
//"no-wrap-func": 1, // disallow wrapping of non-IIFE statements in parens
|
||||
"no-mixed-spaces-and-tabs": 1, // disallow mixed spaces and tabs for indentation
|
||||
"quotes": [1, "single", "avoid-escape"], // specify whether double or single quotes should be used
|
||||
"quote-props": 0, // require quotes around object literal property names (off by default)
|
||||
"semi": 1, // require or disallow use of semicolons instead of ASI
|
||||
"sort-vars": 0, // sort variables within the same declaration block (off by default)
|
||||
"space-after-keywords": 1, // require a space after certain keywords (off by default)
|
||||
"space-in-brackets": 0, // require or disallow spaces inside brackets (off by default)
|
||||
"space-in-parens": 0, // require or disallow spaces inside parentheses (off by default)
|
||||
"space-infix-ops": 1, // require spaces around operators
|
||||
"space-return-throw-case": 1, // require a space after return, throw, and case
|
||||
"space-unary-ops": [1, { "words": true, "nonwords": false }], // require or disallow spaces before/after unary operators (words on by default, nonwords off by default)
|
||||
"max-nested-callbacks": 0, // specify the maximum depth callbacks can be nested (off by default)
|
||||
"one-var": 0, // allow just one var statement per function (off by default)
|
||||
"wrap-regex": 0, // require regex literals to be wrapped in parentheses (off by default)
|
||||
|
||||
// Legacy
|
||||
// The following rules are included for compatibility with JSHint and JSLint. While the names of the rules may not match up with the JSHint/JSLint counterpart, the functionality is the same.
|
||||
|
||||
"max-depth": 0, // specify the maximum depth that blocks can be nested (off by default)
|
||||
"max-len": 0, // specify the maximum length of a line in your program (off by default)
|
||||
"max-params": 0, // limits the number of parameters that can be used in the function declaration. (off by default)
|
||||
"max-statements": 0, // specify the maximum number of statement allowed in a function (off by default)
|
||||
"no-bitwise": 1, // disallow use of bitwise operators (off by default)
|
||||
"no-plusplus": 0, // disallow use of unary operators, ++ and -- (off by default)
|
||||
|
||||
"react/display-name": 0,
|
||||
"react/jsx-boolean-value": 0,
|
||||
"react/jsx-no-undef": 1,
|
||||
"react/jsx-sort-props": 0,
|
||||
"react/jsx-uses-react": 0,
|
||||
"react/jsx-uses-vars": 1,
|
||||
"react/no-did-mount-set-state": [1, "allow-in-func"],
|
||||
"react/no-did-update-set-state": [1, "allow-in-func"],
|
||||
"react/no-multi-comp": 0,
|
||||
"react/no-unknown-property": 0,
|
||||
"react/prop-types": 0,
|
||||
"react/react-in-jsx-scope": 0,
|
||||
"react/self-closing-comp": 1,
|
||||
"react/wrap-multilines": 0
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
import React, {
|
||||
Component,
|
||||
PropTypes
|
||||
} from 'react-native';
|
||||
import Shape, {CIRCLE} from './Shape';
|
||||
import {circleProps, pathProps, fillProps, strokeProps} from '../lib/props';
|
||||
import _ from 'lodash';
|
||||
|
||||
class Circle extends Shape{
|
||||
static displayName = 'Circle';
|
||||
@@ -23,7 +21,7 @@ class Circle extends Shape{
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.type = CIRCLE;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default Circle;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import React, {
|
||||
Component,
|
||||
PropTypes,
|
||||
Children
|
||||
PropTypes
|
||||
} from 'react-native';
|
||||
import {NativeGroup} from './G';
|
||||
import {set, remove} from '../lib/extract/extractClipping';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React, {
|
||||
Component,
|
||||
PropTypes
|
||||
} from 'react-native';
|
||||
import Shape, {ELLIPSE} from './Shape';
|
||||
@@ -22,7 +21,7 @@ class Ellipse extends Shape{
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.type = ELLIPSE;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default Ellipse;
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
import React, {
|
||||
Component,
|
||||
Children,
|
||||
cloneElement,
|
||||
PropTypes,
|
||||
requireNativeComponent
|
||||
PropTypes
|
||||
} from 'react-native';
|
||||
import createReactNativeComponentClass from 'react-native/Libraries/ReactNative/createReactNativeComponentClass';
|
||||
import Defs from './Defs';
|
||||
import _ from 'lodash';
|
||||
import {GroupAttributes} from '../lib/attributes';
|
||||
import {numberProp, contextProps, textProps} from '../lib/props';
|
||||
import {numberProp, contextProps} from '../lib/props';
|
||||
|
||||
import extractProps from '../lib/extract/extractProps';
|
||||
|
||||
@@ -63,4 +60,4 @@ var NativeGroup = createReactNativeComponentClass({
|
||||
export default G;
|
||||
export {
|
||||
NativeGroup
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import React, {
|
||||
Component,
|
||||
PropTypes,
|
||||
Children
|
||||
} from 'react-native';
|
||||
import {NativeGroup} from './G';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React, {
|
||||
Component,
|
||||
PropTypes
|
||||
} from 'react-native';
|
||||
import Shape, {LINE} from './Shape';
|
||||
@@ -22,7 +21,7 @@ class Line extends Shape{
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.type = LINE;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default Line;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import React, {
|
||||
Component,
|
||||
PropTypes,
|
||||
Children
|
||||
PropTypes
|
||||
} from 'react-native';
|
||||
|
||||
import stopsOpacity from '../lib/stopsOpacity';
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import React, {
|
||||
Component,
|
||||
PropTypes,
|
||||
requireNativeComponent
|
||||
PropTypes
|
||||
} from 'react-native';
|
||||
|
||||
import _ from 'lodash';
|
||||
import Defs from './Defs';
|
||||
import createReactNativeComponentClass from 'react-native/Libraries/ReactNative/createReactNativeComponentClass';
|
||||
import extractProps from '../lib/extract/extractProps';
|
||||
@@ -11,7 +10,6 @@ import SerializablePath from '../lib/SerializablePath';
|
||||
import {PathAttributes} from '../lib/attributes';
|
||||
import {pathProps} from '../lib/props';
|
||||
|
||||
let propType = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
|
||||
class Path extends Component{
|
||||
static displayName = 'Path';
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import React, {
|
||||
|
||||
let propType = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
|
||||
|
||||
class Image extends Component{
|
||||
class Pattern extends Component{
|
||||
static displayName = 'Pattern';
|
||||
static propTypes = {
|
||||
x1: propType,
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import React, {
|
||||
Component,
|
||||
PropTypes,
|
||||
Children
|
||||
PropTypes
|
||||
} from 'react-native';
|
||||
import stopsOpacity from '../lib/stopsOpacity';
|
||||
import {numberProp} from '../lib/props';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React, {
|
||||
Component,
|
||||
PropTypes
|
||||
} from 'react-native';
|
||||
import Shape, {RECT} from './Shape';
|
||||
@@ -22,9 +21,7 @@ class Rect extends Shape{
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.type = RECT;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export default Rect;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import React, {
|
||||
Component,
|
||||
PropTypes
|
||||
Component
|
||||
} from 'react-native';
|
||||
import Path from './Path';
|
||||
import _ from 'lodash';
|
||||
import extractProps from '../lib/extract/extractProps';
|
||||
import {ShapeAttributes} from '../lib/attributes';
|
||||
@@ -69,7 +67,7 @@ class Shape extends Component{
|
||||
type: this.type
|
||||
}}
|
||||
/>;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
let NativeShape = createReactNativeComponentClass({
|
||||
|
||||
@@ -8,6 +8,7 @@ class Stop extends Component{
|
||||
stopColor: PropTypes.string,
|
||||
stopOpacity: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
||||
};
|
||||
|
||||
render() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import React, {
|
||||
requireNativeComponent
|
||||
} from 'react-native';
|
||||
import ViewBox from './ViewBox';
|
||||
import _ from 'lodash';
|
||||
|
||||
|
||||
// Svg - Root node of all Svg elements
|
||||
let id = 0;
|
||||
|
||||
@@ -23,7 +23,7 @@ class SymbolElement extends Component{
|
||||
>
|
||||
{props.children}
|
||||
</ViewBox>
|
||||
</Defs.Item>
|
||||
</Defs.Item>;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import React, {
|
||||
PropTypes
|
||||
} from 'react-native';
|
||||
import Defs from './Defs';
|
||||
import _ from 'lodash';
|
||||
import createReactNativeComponentClass from 'react-native/Libraries/ReactNative/createReactNativeComponentClass';
|
||||
import extractProps from '../lib/extract/extractProps';
|
||||
import extractText from '../lib/extract/extractText';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import React, {
|
||||
Component,
|
||||
PropTypes
|
||||
Component
|
||||
} from 'react-native';
|
||||
|
||||
import G from './G';
|
||||
@@ -31,7 +30,7 @@ class ViewBox extends Component{
|
||||
viewbox={null}
|
||||
>
|
||||
{(!scaleX || !scaleY) ? null : this.props.children}
|
||||
</G>
|
||||
</G>;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,10 @@ export default class SerializablePath {
|
||||
let p = Array.prototype.join.call(arguments, ' ')
|
||||
.replace(/(\.[\d]+)(\-?\.)/ig, '$1,$2') //-.3-.575 => -.3,-.575
|
||||
.match(/[a-df-z]|[\-+]?(?:[\d\.]e[\-+]?|[^\s\-+,a-z])+/ig);
|
||||
if (!p) return this;
|
||||
|
||||
if (!p) {
|
||||
return this;
|
||||
}
|
||||
|
||||
let last,
|
||||
cmd = p[0],
|
||||
@@ -35,7 +38,7 @@ export default class SerializablePath {
|
||||
case 's': this.curve(p[i++], p[i++], null, null, p[i++], p[i++]); break;
|
||||
case 'q': this.curve(p[i++], p[i++], p[i++], p[i++]); break;
|
||||
case 't': this.curve(p[i++], p[i++]); break;
|
||||
case 'a': this.arc(p[i+5], p[i+6], p[i], p[i+1], p[i+3], !+p[i+4], p[i+2]); i += 7; break;
|
||||
case 'a': this.arc(p[i + 5], p[i + 6], p[i], p[i + 1], p[i + 3], !+p[i + 4], p[i + 2]); i += 7; break;
|
||||
case 'h': this.line(p[i++], 0); break;
|
||||
case 'v': this.line(0, p[i++]); break;
|
||||
|
||||
@@ -45,17 +48,21 @@ export default class SerializablePath {
|
||||
case 'S': this.curveTo(p[i++], p[i++], null, null, p[i++], p[i++]); break;
|
||||
case 'Q': this.curveTo(p[i++], p[i++], p[i++], p[i++]); break;
|
||||
case 'T': this.curveTo(p[i++], p[i++]); break;
|
||||
case 'A': this.arcTo(p[i+5], p[i+6], p[i], p[i+1], p[i+3], !+p[i+4], p[i+2]); i += 7; break;
|
||||
case 'A': this.arcTo(p[i + 5], p[i + 6], p[i], p[i + 1], p[i + 3], !+p[i + 4], p[i + 2]); i += 7; break;
|
||||
case 'H': this.lineTo(p[i++], this.penY); break;
|
||||
case 'V': this.lineTo(this.penX, p[i++]); break;
|
||||
|
||||
case 'Z': case 'z': this.close(); break;
|
||||
default: cmd = last; i--; continue;
|
||||
default: i--; continue;
|
||||
}
|
||||
|
||||
last = cmd;
|
||||
if (last == 'm') last = 'l';
|
||||
else if (last == 'M') last = 'L';
|
||||
if (last === 'm') {
|
||||
last = 'l';
|
||||
}
|
||||
else if (last === 'M') {
|
||||
last = 'L';
|
||||
}
|
||||
cmd = p[i++];
|
||||
}
|
||||
return this;
|
||||
@@ -138,7 +145,9 @@ export default class SerializablePath {
|
||||
ry = Math.abs(+ry || +rx || (+y - this.penY));
|
||||
rx = Math.abs(+rx || (+x - this.penX));
|
||||
|
||||
if (!rx || !ry || (x == this.penX && y == this.penY)) return this.lineTo(x, y);
|
||||
if (!rx || !ry || (x == this.penX && y == this.penY)) {
|
||||
return this.lineTo(x, y);
|
||||
}
|
||||
|
||||
let tX = this.penX, tY = this.penY, clockwise = !+counterClockwise, large = !!+outer;
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ export default class {
|
||||
if (props[name] != null) {
|
||||
this.shape[name] = percentageTransform(props[name]);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export default class {
|
||||
constructor(xx, yx, xy, yy, x, y){
|
||||
if (xx && typeof xx == 'object'){
|
||||
if (xx && typeof xx === 'object'){
|
||||
yx = xx.yx; yy = xx.yy; y = xx.y;
|
||||
xy = xx.xy; x = xx.x; xx = xx.xx;
|
||||
}
|
||||
@@ -21,20 +21,25 @@ export default class {
|
||||
y = 0;
|
||||
|
||||
transform = (xx, yx, xy, yy, x, y) => {
|
||||
var m = this;
|
||||
if (xx && typeof xx == 'object'){
|
||||
if (xx && typeof xx === 'object'){
|
||||
yx = xx.yx; yy = xx.yy; y = xx.y;
|
||||
xy = xx.xy; x = xx.x; xx = xx.xx;
|
||||
}
|
||||
if (!x) x = 0;
|
||||
if (!y) y = 0;
|
||||
|
||||
if (!x) {
|
||||
x = 0;
|
||||
}
|
||||
|
||||
if (!y) {
|
||||
y = 0;
|
||||
}
|
||||
return this.transformTo(
|
||||
m.xx * xx + m.xy * yx,
|
||||
m.yx * xx + m.yy * yx,
|
||||
m.xx * xy + m.xy * yy,
|
||||
m.yx * xy + m.yy * yy,
|
||||
m.xx * x + m.xy * y + m.x,
|
||||
m.yx * x + m.yy * y + m.y
|
||||
this.xx * xx + this.xy * yx,
|
||||
this.yx * xx + this.yy * yx,
|
||||
this.xx * xy + this.xy * yy,
|
||||
this.yx * xy + this.yy * yy,
|
||||
this.xx * x + this.xy * y + this.x,
|
||||
this.yx * x + this.yy * y + this.y
|
||||
);
|
||||
};
|
||||
|
||||
@@ -63,46 +68,47 @@ export default class {
|
||||
var rad = deg * Math.PI / 180, sin = Math.sin(rad), cos = Math.cos(rad);
|
||||
|
||||
this.transform(1, 0, 0, 1, x, y);
|
||||
var m = this;
|
||||
|
||||
return this.transformTo(
|
||||
cos * m.xx - sin * m.yx,
|
||||
sin * m.xx + cos * m.yx,
|
||||
cos * m.xy - sin * m.yy,
|
||||
sin * m.xy + cos * m.yy,
|
||||
m.x,
|
||||
m.y
|
||||
cos * this.xx - sin * this.yx,
|
||||
sin * this.xx + cos * this.yx,
|
||||
cos * this.xy - sin * this.yy,
|
||||
sin * this.xy + cos * this.yy,
|
||||
this.x,
|
||||
this.y
|
||||
).transform(1, 0, 0, 1, -x, -y);
|
||||
};
|
||||
|
||||
moveTo = (x, y) => {
|
||||
var m = this;
|
||||
return this.transformTo(m.xx, m.yx, m.xy, m.yy, x, y);
|
||||
return this.transformTo(this.xx, this.yx, this.xy, this.yy, x, y);
|
||||
};
|
||||
|
||||
rotateTo = (deg, x, y) => {
|
||||
var m = this;
|
||||
var flip = m.yx / m.xx > m.yy / m.xy ? -1 : 1;
|
||||
if (m.xx < 0 ? m.xy >= 0 : m.xy < 0) flip = -flip;
|
||||
return this.rotate(deg - Math.atan2(flip * m.yx, flip * m.xx) * 180 / Math.PI, x, y);
|
||||
let flip = this.yx / this.xx > this.yy / this.xy ? -1 : 1;
|
||||
if (this.xx < 0 ? this.xy >= 0 : this.xy < 0) {
|
||||
flip = -flip;
|
||||
}
|
||||
return this.rotate(deg - Math.atan2(flip * this.yx, flip * this.xx) * 180 / Math.PI, x, y);
|
||||
};
|
||||
|
||||
scaleTo = (x, y) => {
|
||||
// Normalize
|
||||
var m = this;
|
||||
var h = Math.sqrt(this.xx * this.xx + this.yx * this.yx);
|
||||
this.xx /= h;
|
||||
this.yx /= h;
|
||||
|
||||
var h = Math.sqrt(m.xx * m.xx + m.yx * m.yx);
|
||||
m.xx /= h; m.yx /= h;
|
||||
|
||||
h = Math.sqrt(m.yy * m.yy + m.xy * m.xy);
|
||||
m.yy /= h; m.xy /= h;
|
||||
h = Math.sqrt(this.yy * this.yy + this.xy * this.xy);
|
||||
this.yy /= h;
|
||||
this.xy /= h;
|
||||
|
||||
return this.scale(x, y);
|
||||
};
|
||||
|
||||
resizeTo = (width, height) => {
|
||||
var w = this.width, h = this.height;
|
||||
if (!w || !h) return this;
|
||||
if (!w || !h) {
|
||||
return this;
|
||||
}
|
||||
return this.scaleTo(width / w, height / h);
|
||||
};
|
||||
|
||||
@@ -111,7 +117,9 @@ export default class {
|
||||
c = this.xy, d = this.yy,
|
||||
e = this.x, f = this.y;
|
||||
var det = b * c - a * d;
|
||||
if (det == 0) return null;
|
||||
if (det == 0) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
x: (d * (e - x) + c * (y - f)) / det,
|
||||
y: (a * (f - y) + b * (x - e)) / det
|
||||
@@ -119,10 +127,9 @@ export default class {
|
||||
};
|
||||
|
||||
point = (x, y) => {
|
||||
var m = this;
|
||||
return {
|
||||
x: m.xx * x + m.xy * y + m.x,
|
||||
y: m.yx * x + m.yy * y + m.y
|
||||
x: this.xx * x + this.xy * y + this.x,
|
||||
y: this.yx * x + this.yy * y + this.y
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ const RenderableAttributes = {
|
||||
...NodeAttributes
|
||||
};
|
||||
|
||||
const PathAttributes ={
|
||||
const PathAttributes = {
|
||||
d: {
|
||||
diff: arrayDiffer
|
||||
},
|
||||
@@ -120,5 +120,5 @@ export {
|
||||
PathAttributes,
|
||||
TextAttributes,
|
||||
ShapeAttributes
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -20,4 +20,4 @@ export {
|
||||
LINEAR_GRADIENT,
|
||||
RADIAL_GRADIENT,
|
||||
PATTERN
|
||||
}
|
||||
};
|
||||
|
||||
@@ -44,4 +44,4 @@ export default function (props) {
|
||||
export {
|
||||
set,
|
||||
remove
|
||||
}
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ export default function(props, options = {stroke: true, join: true, transform: t
|
||||
if (props.visible === false) {
|
||||
return {
|
||||
opacity: 0
|
||||
}
|
||||
};
|
||||
}
|
||||
let extractedProps = {
|
||||
opacity: +props.opacity || 1
|
||||
|
||||
@@ -89,5 +89,5 @@ export default function(props) {
|
||||
childrenAsString(props.children)
|
||||
),
|
||||
path: props.path ? new SerializablePath(props.path).toJSON() : undefined
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ export default function({viewbox, width, height, preserveAspectRatio, x: dx, y:
|
||||
y: 0,
|
||||
scaleX: 0,
|
||||
scaleY: 0
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let vx = +parts[0] || 0;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import rgba from '../rgba';
|
||||
let patterns = {};
|
||||
import patternReg from './patternReg'
|
||||
import patternReg from './patternReg';
|
||||
|
||||
import {LinearGradientGenerator} from '../../elements/LinearGradient';
|
||||
import {RadialGradientGenerator} from '../../elements/RadialGradient';
|
||||
@@ -21,7 +21,7 @@ function remove(id) {
|
||||
export {
|
||||
set,
|
||||
remove
|
||||
}
|
||||
};
|
||||
|
||||
export default function(patternSting, opacity, svgId) {
|
||||
if (isGradient(patternSting)) {
|
||||
|
||||
@@ -107,4 +107,4 @@ export {
|
||||
rectProps,
|
||||
contextProps,
|
||||
pathProps
|
||||
}
|
||||
};
|
||||
|
||||
@@ -21,6 +21,11 @@
|
||||
"color": "^0.11.1",
|
||||
"lodash": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-eslint": "^6.0.0",
|
||||
"eslint": "^2.5.3",
|
||||
"eslint-plugin-react": "^4.2.1"
|
||||
},
|
||||
"nativePackage": true,
|
||||
"rnpm": {
|
||||
"ios": {
|
||||
|
||||
Reference in New Issue
Block a user