babel-plugin-comments
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -6,5 +6,5 @@ "use strict"; | ||
function filterComments(list, path, type) { | ||
function filterComments(list, path, remove) { | ||
return list.filter(function (o) { | ||
return o.type.toLowerCase() !== type.toLowerCase(); | ||
return o.type.toLowerCase() !== remove.toLowerCase(); | ||
}); | ||
@@ -20,5 +20,6 @@ } | ||
var _ref2 = _temp === void 0 ? {} : _temp, | ||
_ref2$opts$type = _ref2.opts.type, | ||
type = _ref2$opts$type === void 0 ? 'all' : _ref2$opts$type; | ||
_ref2$opts$remove = _ref2.opts.remove, | ||
remove = _ref2$opts$remove === void 0 ? 'all' : _ref2$opts$remove; | ||
if (remove === 'none') return; | ||
path.traverse({ | ||
@@ -30,11 +31,7 @@ enter: function enter(path) { | ||
if (leadingCommentsList.length > 0 || trailingCommentsList.length > 0) { | ||
if (type === 'none') return; | ||
if (type === 'all') { | ||
if (remove === 'all') { | ||
t.removeComments(path.node); | ||
} else { | ||
// t.removeComments是清空全部注释,并不能区分去掉哪种注释 | ||
// t.removeComments(path.node); | ||
path.node.leadingComments = filterComments(leadingCommentsList, path, type); | ||
path.node.trailingComments = filterComments(trailingCommentsList, path, type); | ||
path.node.leadingComments = filterComments(leadingCommentsList, path, remove); | ||
path.node.trailingComments = filterComments(trailingCommentsList, path, remove); | ||
} | ||
@@ -41,0 +38,0 @@ } |
{ | ||
"name": "babel-plugin-comments", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "It's a babel plugin for remove comments.", | ||
@@ -30,2 +30,3 @@ "main": "./lib/index.js", | ||
"babel-jest": "^23.6.0", | ||
"babel-plugin-comments": "^1.0.1", | ||
"eslint": "^5.11.1", | ||
@@ -32,0 +33,0 @@ "eslint-plugin-import": "^2.14.0", |
@@ -26,3 +26,3 @@ babel-plugin-comments | ||
**all** : all comments will be removed; | ||
**all** (default): all comments will be removed; | ||
@@ -29,0 +29,0 @@ **CommentLine** : commentline will be removed(such as: ```//example```) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3153
11
35