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.4.1 to 1.4.2

test/module1/Type.js

25

index.js

@@ -67,3 +67,26 @@ const parseComment = require('comment-parser');

if (lookup in imports) {
replacement = imports[lookup];
let useImport = true;
if (!path.extname(lookup)) {
const dependency = require.resolve(path.resolve(path.dirname(resourcePath), lookup));
const content = babel.transform(fs.readFileSync(dependency, 'utf-8'));
const candidates = content.ast.program.body;
outer:
for (let i = 0, ii = candidates.length; i < ii; ++i) {
const node = candidates[i];
if (node.type == 'ExportDefaultDeclaration') {
const comments = node.leadingComments;
if (comments) {
for (let i = 0, ii = comments.length; i < ii; ++i) {
if (comments[i].value.indexOf('@enum') !== -1) {
useImport = false;
break outer;
}
}
}
}
}
}
if (useImport) {
replacement = imports[lookup];
}
}

@@ -70,0 +93,0 @@ newComment = comment.value.replace(new RegExp(`${type}([^~])`, 'g'), `${replacement}$1`);

2

package.json
{
"name": "babel-plugin-jsdoc-closure",
"version": "1.4.1",
"version": "1.4.2",
"description": "Transpiles JSDoc types from namepaths to types for Closure Compiler",

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

@@ -103,2 +103,17 @@ const babel = require('babel-core');

it('transforms an enum imported as default export', function() {
test(
'/** @module module2/types */\n' +
'import Bar from \'../module1/Bar\';\n' +
'/** @type {module:module1/Type} */\n' +
'let foo;',
'/** @module module2/types */\n' +
'import Bar from \'../module1/Bar\';\n' +
'/** @type {../module1/Type} */\n' +
'let foo;',
'./test/module2/types.js'
);
});
it('transforms a type with a JSDoc module path', function() {

@@ -105,0 +120,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