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.2.0 to 1.3.0

9

index.js

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

const name = pathParts.pop();
const namedParts = name.split('.');
const namedParts = name.split(/[\.~]/);
let up = '';

@@ -22,3 +22,3 @@ for (let i = 1; i < levelsUp; ++i) {

if (namedParts.length > 1) {
if (namedParts.length > 1 && namedParts[1] != namedParts[0]) {
return `const ${formatType(type)} = require('${typePath}${namedParts[0]}').${namedParts[1]};`;

@@ -28,2 +28,3 @@ } else {

}
}

@@ -35,3 +36,3 @@

const name = pathParts.pop();
const namedParts = name.split('.');
const namedParts = name.split(/[\.~]/);
if (namedParts.length > 1) {

@@ -57,3 +58,3 @@ return `${pathParts.join('_')}_${namedParts.join('_')}`;

let replacement;
const moduleMatch = type.match(/module:([^\.]*)\.(.*)$/);
const moduleMatch = type.match(/module:([^\.]*)[\.~](.*)$/);
if (moduleMatch && moduleMatch[1] == modulePath) {

@@ -60,0 +61,0 @@ replacement = moduleMatch[2];

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

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

@@ -29,3 +29,3 @@ const babel = require('babel-core');

it('transforms a type with an import', function() {
it('transforms a type with an imported module', function() {
test(

@@ -43,5 +43,18 @@ '/** @module module2/types */\n' +

it('transforms a type with a named import', function() {
it('transforms a type with an imported default export', function() {
test(
'/** @module module2/types */\n' +
'/** @type {module:module1/Bar~Bar} */\n' +
'let foo;\n',
'/** @module module2/types */\n' +
'/** @type {module1_Bar_Bar} */\n' +
'let foo;\n' +
'const module1_Bar_Bar = require(\'../module1/Bar\');',
'./test/module2/types.js'
);
});
it('transforms a type with an imported named export', function() {
test(
'/** @module module2/types */\n' +
'/** @type {module:types.foo} */\n' +

@@ -57,2 +70,15 @@ 'let foo;\n',

it('transforms a type with a JSDoc module path', function() {
test(
'/** @module module2/types */\n' +
'/** @type {module:types~foo} */\n' +
'let foo;\n',
'/** @module module2/types */\n' +
'/** @type {_types_foo} */\n' +
'let foo;' + '\n' +
'const _types_foo = require(\'../types\').foo;',
'./test/module2/types.js'
);
});
it('resolves path correctly for index.js files', function() {

@@ -59,0 +85,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