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

babel-plugin-jsdoc-closure

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-jsdoc-closure - npm Package Compare versions

Comparing version 1.3.3 to 1.3.4

19

index.js

@@ -123,8 +123,2 @@ const parseComment = require('comment-parser');

comment = babel.transform(`/*${newComment}*/`).ast.comments[0];
if (path.parent && path.parent.type == 'ReturnStatement') {
const parenthesized = babel.types.parenthesizedExpression(node);
parenthesized.comments = path.parent.argument.comments;
delete path.parent.argument.comments;
path.parent.argument = parenthesized;
}
comments[i] = comment;

@@ -161,6 +155,17 @@ } else {

babel = b;
const t = babel.types;
return {
visitor: {
Program: function(path, state) {
ReturnStatement(path) {
const argument = path.node.argument;
if (argument && argument.comments && argument.extra && argument.extra.parenthesized) {
const parenthesized = t.parenthesizedExpression(path.node.argument);
const comments = path.node.argument.comments;
delete path.node.argument.comments;
parenthesized.comments = comments;
path.node.argument = parenthesized;
}
},
Program(path, state) {
recast = state.file.opts.parserOpts && state.file.opts.parserOpts.parser == 'recast';

@@ -167,0 +172,0 @@ commentsProperty = recast ? 'comments' : 'leadingComments';

{
"name": "babel-plugin-jsdoc-closure",
"version": "1.3.3",
"version": "1.3.4",
"description": "Transpiles JSDoc types from namepaths to types for Closure Compiler",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -60,2 +60,20 @@ const babel = require('babel-core');

it('transforms an object property type cast with an imported module in a return statement', function() {
// requires recast, and causes line break changes unfortunately
const source =
'/** @module module2/types */\n' +
'function getFoo() {\n' +
' return /** @type {Object} */ ({\n foo: /** @type {module:module1/Foo} */ (\'bar\')\n });\n' +
'}';
const expected =
'/** @module module2/types */\n' +
'function getFoo() {\n' +
' return (\n /** @type {Object} */ ({\n foo: /** @type {module1$Foo} */ (\'bar\')\n })\n );\n' +
'}\n' +
'const module1$Foo = require(\'../module1/Foo\');';
const filename = './test/module2/types.js';
const got = babel.transform(source, Object.assign({filename}, recastOptions));
assert.equal(got.code, expected);
});
it('transforms a type with an imported default export', function() {

@@ -62,0 +80,0 @@ test(

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