Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-comments

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-comments - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

22

lib/index.js

@@ -6,8 +6,15 @@ "use strict";

function filterComments(list, path, remove) {
function filterComments(list, path, _remove) {
return list.filter(function (o) {
return o.type.toLowerCase() !== remove.toLowerCase();
return o.type.toLowerCase() !== _remove;
});
}
function getRemoveType(remove) {
if (remove === 'all') return 'all';
if (remove === 'block' || remove.toLowerCase() === 'commentblock') return 'commentblock';
if (remove === 'line' || remove.toLowerCase() === 'commentline') return 'commentline';
throw new Error("The 'remove' option must be undefiend, 'none', 'all', 'block', or 'line'.");
}
function _default(_ref) {

@@ -21,5 +28,8 @@ var t = _ref.types;

_ref2$opts$remove = _ref2.opts.remove,
remove = _ref2$opts$remove === void 0 ? 'all' : _ref2$opts$remove;
remove = _ref2$opts$remove === void 0 ? 'none' : _ref2$opts$remove;
if (remove === 'none') return;
var _remove = getRemoveType(remove);
path.traverse({

@@ -31,7 +41,7 @@ enter: function enter(path) {

if (leadingCommentsList.length > 0 || trailingCommentsList.length > 0) {
if (remove === 'all') {
if (_remove === 'all') {
t.removeComments(path.node);
} else {
path.node.leadingComments = filterComments(leadingCommentsList, path, remove);
path.node.trailingComments = filterComments(trailingCommentsList, path, remove);
path.node.leadingComments = filterComments(leadingCommentsList, path, _remove);
path.node.trailingComments = filterComments(trailingCommentsList, path, _remove);
}

@@ -38,0 +48,0 @@ }

{
"name": "babel-plugin-comments",
"version": "1.0.2",
"version": "1.0.3",
"description": "It's a babel plugin for remove comments.",

@@ -30,3 +30,3 @@ "main": "./lib/index.js",

"babel-jest": "^23.6.0",
"babel-plugin-comments": "^1.0.1",
"babel-plugin-comments": "^1.0.2",
"eslint": "^5.11.1",

@@ -33,0 +33,0 @@ "eslint-plugin-import": "^2.14.0",

@@ -0,1 +1,3 @@

babel-plugin-comments

@@ -22,15 +24,19 @@ =========================

**remove** (string) type specifies the type of comments you want to remove.
Possible value:
**all** (default): all comments will be removed;
**CommentLine** : commentline will be removed(such as: ```//example```)
**CommentBlock** : commentblock will be removed(such as: ```/* example*/```)
**none** : nothing will be removed
- **remove** (string) type specifies the type of comments you want to remove.
Possible value:
```
none (default): nothing will be removed;
all : all comments will be removed;
line : commentline will be removed(such as: ```//example```);
CommentLine : same as 'line';
block : commentblock will be removed(such as: ```/* example*/```);
CommentBlock : same as 'block';
```
## Example

@@ -51,3 +57,3 @@

{
remove: 'all',
remove: 'line',
}

@@ -54,0 +60,0 @@ ],

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc