mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-02 23:02:16 +00:00
Fix linting, warnings, add noinspection suppression comments.
This commit is contained in:
@@ -2,8 +2,7 @@ import Color from 'color';
|
||||
import patternReg from './patternReg';
|
||||
|
||||
export default function (colorOrBrush) {
|
||||
/*eslint eqeqeq:0*/
|
||||
if (colorOrBrush === 'none' || colorOrBrush == null) {
|
||||
if (colorOrBrush === 'none' || !colorOrBrush) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,7 @@ export default function(props, styleProperties) {
|
||||
|
||||
return {
|
||||
// default fill is black
|
||||
/*eslint eqeqeq:0*/
|
||||
fill: extractBrush(props.fill == null ? '#000' : props.fill),
|
||||
fill: extractBrush(props.fill || '#000'),
|
||||
fillOpacity: extractOpacity(props.fillOpacity),
|
||||
fillRule: fillRules[props.fillRule] === 0 ? 0 : 1
|
||||
};
|
||||
|
||||
@@ -21,6 +21,7 @@ export default function(props) {
|
||||
let offset = percentToFloat(child.props.offset);
|
||||
|
||||
// add stop
|
||||
//noinspection JSUnresolvedFunction
|
||||
stops[offset] = Color(child.props.stopColor).alpha(extractOpacity(child.props.stopOpacity));
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -30,7 +30,7 @@ export default function(props, ref) {
|
||||
let transform = props.transform;
|
||||
if (transform) {
|
||||
if (typeof transform === 'string') {
|
||||
var transformParsed = tp.parse(transform);
|
||||
const transformParsed = tp.parse(transform);
|
||||
if (transformParsed.matrix) {
|
||||
// TODO: Extract scaling values for coordinate system
|
||||
// Especially scaleY for calculating scaling of fontSize
|
||||
|
||||
@@ -44,7 +44,7 @@ export default function(props, styleProperties) {
|
||||
strokeLinecap: caps[props.strokeLinecap] || 0,
|
||||
strokeLinejoin: joins[props.strokeLinejoin] || 0,
|
||||
strokeDasharray: strokeDasharray || null,
|
||||
strokeWidth: strokeWidth || "1",
|
||||
strokeWidth: strokeWidth || '1',
|
||||
strokeDashoffset: strokeDasharray ? (+props.strokeDashoffset || 0) : null,
|
||||
strokeMiterlimit: props.strokeMiterlimit || 4
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import _ from 'lodash';
|
||||
//noinspection JSUnresolvedVariable
|
||||
import React, {Children} from 'react';
|
||||
import TSpan from '../../elements/TSpan';
|
||||
|
||||
@@ -28,7 +29,7 @@ function parseFontString(font) {
|
||||
return null;
|
||||
}
|
||||
const fontFamily = extractSingleFontFamily(match[3]);
|
||||
const fontSize = match[2] || "12";
|
||||
const fontSize = match[2] || '12';
|
||||
const isBold = /bold/.exec(match[1]);
|
||||
const isItalic = /italic/.exec(match[1]);
|
||||
const fontWeight = isBold ? 'bold' : 'normal';
|
||||
|
||||
@@ -15,11 +15,11 @@ function transformToMatrix(props, transform) {
|
||||
|
||||
class TransformParser {
|
||||
constructor() {
|
||||
var floating = '(\\-?[\\d\\.e]+)';
|
||||
var commaSpace = '\\,?\\s*';
|
||||
const floating = '(\\-?[\\d\\.e]+)';
|
||||
const commaSpace = '\\,?\\s*';
|
||||
|
||||
this.regex = {
|
||||
split: /[\s*(\s*|\s*)\s*|\s*,\s*]/,
|
||||
split: /[\s*()|,]/,
|
||||
matrix: new RegExp(
|
||||
'^matrix\\(' +
|
||||
floating + commaSpace +
|
||||
@@ -33,7 +33,7 @@ class TransformParser {
|
||||
|
||||
parse(transform) {
|
||||
if (transform) {
|
||||
var retval = {};
|
||||
const retval = {};
|
||||
let transLst = _.filter(
|
||||
transform.split(this.regex.split),
|
||||
(ele) => {
|
||||
@@ -50,11 +50,11 @@ class TransformParser {
|
||||
break;
|
||||
case 'translate':
|
||||
retval.translateX = transLst[i + 1];
|
||||
retval.translateY = (3 === transLst.length) ? transLst[i + 2] : 0;
|
||||
retval.translateY = (transLst.length === 3) ? transLst[i + 2] : 0;
|
||||
break;
|
||||
case 'scale':
|
||||
retval.scaleX = transLst[i + 1];
|
||||
retval.scaleY = (3 === transLst.length) ? transLst[i + 2] : retval.scaleX;
|
||||
retval.scaleY = (transLst.length === 3) ? transLst[i + 2] : retval.scaleX;
|
||||
break;
|
||||
case 'rotate':
|
||||
retval.rotation = transLst[i + 1];
|
||||
@@ -72,17 +72,6 @@ class TransformParser {
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
||||
parseMatrix(transform) {
|
||||
var matrix = this.regex.matrix.exec(transform);
|
||||
if (matrix) {
|
||||
matrix.shift();
|
||||
for (var i = matrix.length - 1; i >= 0; i--) {
|
||||
matrix[i] = parseFloat(matrix[i]);
|
||||
}
|
||||
}
|
||||
return matrix;
|
||||
}
|
||||
}
|
||||
|
||||
export const tp = new TransformParser();
|
||||
@@ -91,7 +80,7 @@ export const tp = new TransformParser();
|
||||
function appendTransform(transform) {
|
||||
if (transform) {
|
||||
if (typeof transform === 'string') {
|
||||
var transformParsed = tp.parse(transform);
|
||||
const transformParsed = tp.parse(transform);
|
||||
if (transformParsed.matrix) {
|
||||
pooledMatrix.append(...transformParsed.matrix);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user