Skip to content

Commit

Permalink
Lodash: Remove completely from docgen package (#43100)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla authored Aug 10, 2022
1 parent 9881502 commit 23d1d84
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 24 deletions.
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions packages/docgen/lib/get-export-entries.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
const { get } = require( 'lodash' );

/**
* Returns the export entry records of the given export statement.
* Unlike [the standard](http://www.ecma-international.org/ecma-262/9.0/#exportentry-record),
Expand Down Expand Up @@ -31,7 +26,7 @@ module.exports = ( token ) => {
name = t.declaration.left.name;
break;
default:
name = get( t.declaration, [ 'id', 'name' ], '*default*' );
name = t.declaration.id?.name ?? '*default*';
}
return name;
};
Expand Down Expand Up @@ -64,7 +59,7 @@ module.exports = ( token ) => {
name.push( {
localName: specifier.local.name,
exportName: specifier.exported.name,
module: get( token.source, [ 'value' ], null ),
module: token.source?.value ?? null,
lineStart: specifier.loc.start.line,
lineEnd: specifier.loc.end.line,
} )
Expand Down
9 changes: 2 additions & 7 deletions packages/docgen/lib/get-intermediate-representation.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
const { get } = require( 'lodash' );

/**
* Internal dependencies
*/
Expand Down Expand Up @@ -154,8 +149,8 @@ module.exports = (
ir.push( {
path,
name: entry.exportName,
description: get( doc, [ 'description' ], UNDOCUMENTED ),
tags: get( doc, [ 'tags' ], [] ),
description: doc?.description ?? UNDOCUMENTED,
tags: doc?.tags ?? [],
lineStart: entry.lineStart,
lineEnd: entry.lineEnd,
} );
Expand Down
10 changes: 4 additions & 6 deletions packages/docgen/lib/get-leading-comments.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
const { last } = require( 'lodash' );

/**
* Function that returns the leading comment
* of a Espree node.
Expand All @@ -14,7 +9,10 @@ const { last } = require( 'lodash' );
module.exports = ( declaration ) => {
let comments;
if ( declaration.leadingComments ) {
const lastComment = last( declaration.leadingComments );
const lastComment =
declaration.leadingComments[
declaration.leadingComments.length - 1
];
if ( lastComment ) {
comments = lastComment.value;
}
Expand Down
6 changes: 4 additions & 2 deletions packages/docgen/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
const fs = require( 'fs' );
const path = require( 'path' );
const { last } = require( 'lodash' );

/**
* Internal dependencies
Expand Down Expand Up @@ -60,7 +59,10 @@ const processFile = ( rootDir, inputFile ) => {
const result = engine(
relativePath,
data,
getIRFromRelativePath( rootDir, last( currentFileStack ) )
getIRFromRelativePath(
rootDir,
currentFileStack[ currentFileStack.length - 1 ]
)
);
currentFileStack.pop();
return result;
Expand Down
1 change: 0 additions & 1 deletion packages/docgen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"dependencies": {
"@babel/core": "^7.16.0",
"comment-parser": "^1.1.1",
"lodash": "^4.17.21",
"mdast-util-inject": "1.1.0",
"optionator": "0.8.2",
"remark": "10.0.1",
Expand Down

0 comments on commit 23d1d84

Please sign in to comment.