From bb6323c7f82cf67849dbf7e9ad30d367dc9df415 Mon Sep 17 00:00:00 2001 From: deepsweet Date: Tue, 27 Nov 2012 16:53:05 +0200 Subject: [PATCH] more JSHint --- .jshintrc | 1 + package.json | 3 ++- plugins/cleanupEnableBackground.js | 3 +-- plugins/collapseGroups.js | 3 +-- plugins/convertPathData.js | 4 +++- plugins/convertStyleToAttrs.js | 3 +-- plugins/moveElemsAttrsToGroup.js | 3 +-- plugins/removeComments.js | 3 +-- plugins/removeDefaultPx.js | 3 +-- plugins/removeDoctype.js | 3 +-- plugins/removeEditorsNSData.js | 3 +-- plugins/removeEmptyAttrs.js | 3 +-- plugins/removeEmptyContainers.js | 3 +-- plugins/removeMetadata.js | 3 +-- plugins/removeUnusedNS.js | 3 +-- plugins/removeViewBox.js | 3 +-- plugins/removeXMLProcInst.js | 3 +-- 17 files changed, 20 insertions(+), 30 deletions(-) diff --git a/.jshintrc b/.jshintrc index 30b4460f..b199491a 100644 --- a/.jshintrc +++ b/.jshintrc @@ -7,6 +7,7 @@ }, "node": true, "strict": false, + "expr": true, "curly": false, "camelcase": true, "eqeqeq": true, diff --git a/package.json b/package.json index df8f6bdd..365073d9 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/plugins/cleanupEnableBackground.js b/plugins/cleanupEnableBackground.js index 63d32986..b206ffa1 100644 --- a/plugins/cleanupEnableBackground.js +++ b/plugins/cleanupEnableBackground.js @@ -12,12 +12,11 @@ var regEnableBackground = /^new\s0\s0\s(\d+)\s(\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.cleanupEnableBackground = function(item, params) { +exports.cleanupEnableBackground = function(item) { if ( item.isElem(elems) && diff --git a/plugins/collapseGroups.js b/plugins/collapseGroups.js index 407cb78c..429c93de 100644 --- a/plugins/collapseGroups.js +++ b/plugins/collapseGroups.js @@ -19,12 +19,11 @@ var flattenOneLevel = require('../lib/svgo/tools').flattenOneLevel; * * * @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()) { diff --git a/plugins/convertPathData.js b/plugins/convertPathData.js index 589e7b89..861115c1 100644 --- a/plugins/convertPathData.js +++ b/plugins/convertPathData.js @@ -568,7 +568,9 @@ function isCurveStraightLine(xs, ys) { j = i; } - return !+area.toFixed(2); + if (+area.toFixed(2)) return false; + + return true; } diff --git a/plugins/convertStyleToAttrs.js b/plugins/convertStyleToAttrs.js index d7186588..4cb8fcef 100644 --- a/plugins/convertStyleToAttrs.js +++ b/plugins/convertStyleToAttrs.js @@ -16,12 +16,11 @@ var extend = require('../lib/svgo/tools').extend, * * * @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'] diff --git a/plugins/moveElemsAttrsToGroup.js b/plugins/moveElemsAttrsToGroup.js index a03364fe..e521f43b 100644 --- a/plugins/moveElemsAttrsToGroup.js +++ b/plugins/moveElemsAttrsToGroup.js @@ -20,12 +20,11 @@ var inheritableAttrs = require('./_collections').inheritableAttrs; * * * @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) { diff --git a/plugins/removeComments.js b/plugins/removeComments.js index 55c38589..86912ab5 100644 --- a/plugins/removeComments.js +++ b/plugins/removeComments.js @@ -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; diff --git a/plugins/removeDefaultPx.js b/plugins/removeDefaultPx.js index a9c944f2..76484b08 100644 --- a/plugins/removeDefaultPx.js +++ b/plugins/removeDefaultPx.js @@ -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) { diff --git a/plugins/removeDoctype.js b/plugins/removeDoctype.js index f2bc8195..c26e4feb 100644 --- a/plugins/removeDoctype.js +++ b/plugins/removeDoctype.js @@ -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; diff --git a/plugins/removeEditorsNSData.js b/plugins/removeEditorsNSData.js index c65d23f3..3c0e3db7 100644 --- a/plugins/removeEditorsNSData.js +++ b/plugins/removeEditorsNSData.js @@ -10,12 +10,11 @@ var editorNamespaces = require('./_collections').editorNamespaces, * * * @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) { diff --git a/plugins/removeEmptyAttrs.js b/plugins/removeEmptyAttrs.js index 28fb8541..56d18c57 100644 --- a/plugins/removeEmptyAttrs.js +++ b/plugins/removeEmptyAttrs.js @@ -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) { diff --git a/plugins/removeEmptyContainers.js b/plugins/removeEmptyContainers.js index 71375ad2..af86b644 100644 --- a/plugins/removeEmptyContainers.js +++ b/plugins/removeEmptyContainers.js @@ -12,12 +12,11 @@ var container = require('./_collections').elemsGroups.container; * * * @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()); diff --git a/plugins/removeMetadata.js b/plugins/removeMetadata.js index 0eea9bc2..18365e9b 100644 --- a/plugins/removeMetadata.js +++ b/plugins/removeMetadata.js @@ -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'); diff --git a/plugins/removeUnusedNS.js b/plugins/removeUnusedNS.js index f0b5d5db..075a2d74 100644 --- a/plugins/removeUnusedNS.js +++ b/plugins/removeUnusedNS.js @@ -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 = []; diff --git a/plugins/removeViewBox.js b/plugins/removeViewBox.js index dc5dd6cc..d6cae64c 100644 --- a/plugins/removeViewBox.js +++ b/plugins/removeViewBox.js @@ -12,12 +12,11 @@ var regViewBox = /^0\s0\s(\d+)\s(\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.removeViewBox = function(item, params) { +exports.removeViewBox = function(item) { if ( item.isElem(viewBoxElems) && diff --git a/plugins/removeXMLProcInst.js b/plugins/removeXMLProcInst.js index 495b27ef..ad0d8a8f 100644 --- a/plugins/removeXMLProcInst.js +++ b/plugins/removeXMLProcInst.js @@ -5,12 +5,11 @@ * * * @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');