babel-plugin-transform-move-comments-to-top
Advanced tools
Comparing version
@@ -18,4 +18,15 @@ 'use strict'; | ||
if (path.node.leadingComments) { | ||
comments = comments.concat(path.node.leadingComments); | ||
path.node.leadingComments.forEach(function (comment) { | ||
if (!deepIncludes(comments, comment)) { | ||
comments = comments.concat(comment); | ||
} | ||
}); | ||
} | ||
if (path.node.trailingComments) { | ||
path.node.trailingComments.forEach(function (comment) { | ||
if (!deepIncludes(comments, comment)) { | ||
comments = comments.concat(comment); | ||
} | ||
}); | ||
} | ||
t.removeComments(path.node); | ||
@@ -37,2 +48,14 @@ } | ||
}; | ||
}; | ||
}; | ||
var _deepEqual = require('deep-equal'); | ||
var _deepEqual2 = _interopRequireDefault(_deepEqual); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function deepIncludes(arr, value) { | ||
return arr.some(function (item) { | ||
return (0, _deepEqual2.default)(item, value); | ||
}); | ||
} |
{ | ||
"name": "babel-plugin-transform-move-comments-to-top", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Move comments to top of the file", | ||
@@ -22,2 +22,3 @@ "repository": "https://github.com/chentsulin/babel-plugin-transform-move-comments-to-top", | ||
"mocha": "^2.5.3", | ||
"nyc": "^6.6.1", | ||
"rimraf": "^2.5.2" | ||
@@ -30,4 +31,14 @@ }, | ||
"test": "mocha --compilers js:babel-register", | ||
"test:cov": "nyc npm test", | ||
"preversion": "npm test" | ||
}, | ||
"nyc": { | ||
"reporter": [ | ||
"lcov", | ||
"text" | ||
] | ||
}, | ||
"dependencies": { | ||
"deep-equal": "^1.0.1" | ||
} | ||
} |
3683
33.3%51
59.38%1
Infinity%7
16.67%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added