diff --git a/package-lock.json b/package-lock.json index 8e5f202c7601ab..3ab747322efb4c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16935,7 +16935,6 @@ "requires": { "@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", diff --git a/packages/docgen/lib/get-export-entries.js b/packages/docgen/lib/get-export-entries.js index fb697264d3162a..dc4046b72fcc77 100644 --- a/packages/docgen/lib/get-export-entries.js +++ b/packages/docgen/lib/get-export-entries.js @@ -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), @@ -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; }; @@ -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, } ) diff --git a/packages/docgen/lib/get-intermediate-representation.js b/packages/docgen/lib/get-intermediate-representation.js index 253283d74a27fe..2f8e155c575650 100644 --- a/packages/docgen/lib/get-intermediate-representation.js +++ b/packages/docgen/lib/get-intermediate-representation.js @@ -1,8 +1,3 @@ -/** - * External dependencies - */ -const { get } = require( 'lodash' ); - /** * Internal dependencies */ @@ -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, } ); diff --git a/packages/docgen/lib/get-leading-comments.js b/packages/docgen/lib/get-leading-comments.js index 09911a995c064c..ddc0261f368e68 100644 --- a/packages/docgen/lib/get-leading-comments.js +++ b/packages/docgen/lib/get-leading-comments.js @@ -1,8 +1,3 @@ -/** - * External dependencies - */ -const { last } = require( 'lodash' ); - /** * Function that returns the leading comment * of a Espree node. @@ -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; } diff --git a/packages/docgen/lib/index.js b/packages/docgen/lib/index.js index f21864d2f7411e..42416d9b452388 100644 --- a/packages/docgen/lib/index.js +++ b/packages/docgen/lib/index.js @@ -3,7 +3,6 @@ */ const fs = require( 'fs' ); const path = require( 'path' ); -const { last } = require( 'lodash' ); /** * Internal dependencies @@ -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; diff --git a/packages/docgen/package.json b/packages/docgen/package.json index 2d3caaa27eab8b..73844baa723c14 100644 --- a/packages/docgen/package.json +++ b/packages/docgen/package.json @@ -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",