mirror of
https://github.com/svg/svgo.git
synced 2025-07-29 20:21:14 +03:00
more JSHint
This commit is contained in:
@ -7,6 +7,7 @@
|
||||
},
|
||||
"node": true,
|
||||
"strict": false,
|
||||
"expr": true,
|
||||
"curly": false,
|
||||
"camelcase": true,
|
||||
"eqeqeq": true,
|
||||
|
@ -33,7 +33,8 @@
|
||||
},
|
||||
"scripts": {
|
||||
"test": "./node_modules/.bin/mocha --reporter spec --require should --recursive",
|
||||
"cover": "./node_modules/.bin/istanbul instrument --output lib-cov --no-compact --variable global.__coverage__ lib && ./node_modules/.bin/mocha --reporter mocha-istanbul --require should test/config test/svg2js"
|
||||
"cover": "./node_modules/.bin/istanbul instrument --output lib-cov --no-compact --variable global.__coverage__ lib && ./node_modules/.bin/mocha --reporter mocha-istanbul --require should test/config test/svg2js",
|
||||
"jshint": "jshint --show-non-errors ."
|
||||
},
|
||||
"dependencies": {
|
||||
"sax": "~0.4",
|
||||
|
@ -12,12 +12,11 @@ var regEnableBackground = /^new\s0\s0\s(\d+)\s(\d+)$/,
|
||||
* <svg width="100" height="50">
|
||||
*
|
||||
* @param {Object} item current iteration item
|
||||
* @param {Object} params plugin params
|
||||
* @return {Boolean} if false, item will be filtered out
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*/
|
||||
exports.cleanupEnableBackground = function(item, params) {
|
||||
exports.cleanupEnableBackground = function(item) {
|
||||
|
||||
if (
|
||||
item.isElem(elems) &&
|
||||
|
@ -19,12 +19,11 @@ var flattenOneLevel = require('../lib/svgo/tools').flattenOneLevel;
|
||||
* <path attr1="val1" d="..."/>
|
||||
*
|
||||
* @param {Object} item current iteration item
|
||||
* @param {Object} params plugin params
|
||||
* @return {Boolean} if false, item will be filtered out
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*/
|
||||
exports.collapseGroups = function(item, params) {
|
||||
exports.collapseGroups = function(item) {
|
||||
|
||||
// non-empty elements
|
||||
if (item.elem && !item.isEmpty()) {
|
||||
|
@ -568,7 +568,9 @@ function isCurveStraightLine(xs, ys) {
|
||||
j = i;
|
||||
}
|
||||
|
||||
return !+area.toFixed(2);
|
||||
if (+area.toFixed(2)) return false;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
@ -16,12 +16,11 @@ var extend = require('../lib/svgo/tools').extend,
|
||||
* <g fill="#000" color="#fff" slyle="-webkit-blah: blah">
|
||||
*
|
||||
* @param {Object} item current iteration item
|
||||
* @param {Object} params plugin params
|
||||
* @return {Boolean} if false, item will be filtered out
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*/
|
||||
exports.convertStyleToAttrs = function(item, params) {
|
||||
exports.convertStyleToAttrs = function(item) {
|
||||
|
||||
if (item.elem && item.hasAttr('style')) {
|
||||
// ['opacity: 1', 'color: #000']
|
||||
|
@ -20,12 +20,11 @@ var inheritableAttrs = require('./_collections').inheritableAttrs;
|
||||
* </g>
|
||||
*
|
||||
* @param {Object} item current iteration item
|
||||
* @param {Object} params plugin params
|
||||
* @return {Boolean} if false, item will be filtered out
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*/
|
||||
exports.moveElemsAttrsToGroup = function(item, params) {
|
||||
exports.moveElemsAttrsToGroup = function(item) {
|
||||
|
||||
if (item.isElem('g') && !item.isEmpty() && item.content.length > 1) {
|
||||
|
||||
|
@ -6,12 +6,11 @@
|
||||
* Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
*
|
||||
* @param {Object} item current iteration item
|
||||
* @param {Object} params plugin params
|
||||
* @return {Boolean} if false, item will be filtered out
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*/
|
||||
exports.removeComments = function(item, params) {
|
||||
exports.removeComments = function(item) {
|
||||
|
||||
if (item.comment && item.comment.charAt(0) !== '!') {
|
||||
return false;
|
||||
|
@ -8,12 +8,11 @@ var regValPx = /^(-?(?:[0-9]+|[0-9]*\.[0-9]+))px$/;
|
||||
* http://www.w3.org/TR/SVG/coords.html#Units
|
||||
*
|
||||
* @param {Object} item current iteration item
|
||||
* @param {Object} params plugin params
|
||||
* @return {Boolean} if false, item will be filtered out
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*/
|
||||
exports.removeDefaultPx = function(item, params) {
|
||||
exports.removeDefaultPx = function(item) {
|
||||
|
||||
if (item.elem) {
|
||||
|
||||
|
@ -13,12 +13,11 @@
|
||||
* q"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
*
|
||||
* @param {Object} item current iteration item
|
||||
* @param {Object} params plugin params
|
||||
* @return {Boolean} if false, item will be filtered out
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*/
|
||||
exports.removeDoctype = function(item, params) {
|
||||
exports.removeDoctype = function(item) {
|
||||
|
||||
return !item.doctype;
|
||||
|
||||
|
@ -10,12 +10,11 @@ var editorNamespaces = require('./_collections').editorNamespaces,
|
||||
* <path sodipodi:nodetypes="cccc"/>
|
||||
*
|
||||
* @param {Object} item current iteration item
|
||||
* @param {Object} params plugin params
|
||||
* @return {Boolean} if false, item will be filtered out
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*/
|
||||
exports.removeEditorsNSData = function(item, params) {
|
||||
exports.removeEditorsNSData = function(item) {
|
||||
|
||||
if (item.elem) {
|
||||
|
||||
|
@ -2,12 +2,11 @@
|
||||
* Remove attributes with empty values.
|
||||
*
|
||||
* @param {Object} item current iteration item
|
||||
* @param {Object} params plugin params
|
||||
* @return {Boolean} if false, item will be filtered out
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*/
|
||||
exports.removeEmptyAttrs = function(item, params) {
|
||||
exports.removeEmptyAttrs = function(item) {
|
||||
|
||||
if (item.elem) {
|
||||
|
||||
|
@ -12,12 +12,11 @@ var container = require('./_collections').elemsGroups.container;
|
||||
* <g><marker><a/></marker></g>
|
||||
*
|
||||
* @param {Object} item current iteration item
|
||||
* @param {Object} params plugin params
|
||||
* @return {Boolean} if false, item will be filtered out
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*/
|
||||
exports.removeEmptyContainers = function(item, params) {
|
||||
exports.removeEmptyContainers = function(item) {
|
||||
|
||||
return !(item.isElem(container) && !item.isElem('svg') && item.isEmpty());
|
||||
|
||||
|
@ -4,12 +4,11 @@
|
||||
* http://www.w3.org/TR/SVG/metadata.html
|
||||
*
|
||||
* @param {Object} item current iteration item
|
||||
* @param {Object} params plugin params
|
||||
* @return {Boolean} if false, item will be filtered out
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*/
|
||||
exports.removeMetadata = function(item, params) {
|
||||
exports.removeMetadata = function(item) {
|
||||
|
||||
return !item.isElem('metadata');
|
||||
|
||||
|
@ -2,12 +2,11 @@
|
||||
* Remove unused namespaces declaration.
|
||||
*
|
||||
* @param {Object} item current iteration item
|
||||
* @param {Object} params plugin params
|
||||
* @return {Boolean} if false, item will be filtered out
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*/
|
||||
exports.removeUnusedNS = function(data, params) {
|
||||
exports.removeUnusedNS = function(data) {
|
||||
|
||||
var svgElem,
|
||||
xmlnsCollection = [];
|
||||
|
@ -12,12 +12,11 @@ var regViewBox = /^0\s0\s(\d+)\s(\d+)$/,
|
||||
* <svg width="100" height="50">
|
||||
*
|
||||
* @param {Object} item current iteration item
|
||||
* @param {Object} params plugin params
|
||||
* @return {Boolean} if false, item will be filtered out
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*/
|
||||
exports.removeViewBox = function(item, params) {
|
||||
exports.removeViewBox = function(item) {
|
||||
|
||||
if (
|
||||
item.isElem(viewBoxElems) &&
|
||||
|
@ -5,12 +5,11 @@
|
||||
* <?xml version="1.0" encoding="utf-8"?>
|
||||
*
|
||||
* @param {Object} item current iteration item
|
||||
* @param {Object} params plugin params
|
||||
* @return {Boolean} if false, item will be filtered out
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*/
|
||||
exports.removeXMLProcInst = function(item, params) {
|
||||
exports.removeXMLProcInst = function(item) {
|
||||
|
||||
return !(item.processinginstruction && item.processinginstruction.name === 'xml');
|
||||
|
||||
|
Reference in New Issue
Block a user