Skip to content

Commit

Permalink
build: resolve lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Planeshifter committed Oct 11, 2023
1 parent 143818d commit ec0bc28
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions lib/node_modules/@stdlib/_tools/scripts/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,8 @@ function transformer( fileInfo, api ) {

root
.find( j.VariableDeclarator )
.filter( function onPath( path ) {
var node = path.node;
return node.init &&
node.init.type === 'CallExpression' &&
node.init.callee.name === 'require' &&
node.init.arguments[0].value === '@stdlib/string-format';
})
.forEach( function onPath() {
formatVar = path.node.id.name;
});
.filter( onStringFormat )
.forEach( assignFormatVar );

requires = root.find( j.CallExpression, {
'callee': {
Expand Down Expand Up @@ -129,6 +121,32 @@ function transformer( fileInfo, api ) {

return replace( out, RE_INDENT, '\n' );

/**
* Tests whether a variable declaration is for the `@stdlib/string-format` require.
*
* @private
* @param {Object} path - AST node path
* @returns {boolean} boolean indicating whether a variable declaration is for the `@stdlib/string-format` require
*/
function onStringFormat( path ) {
var node = path.node;
return node.init &&
node.init.type === 'CallExpression' &&
node.init.callee.name === 'require' &&
node.init.arguments[0].value === '@stdlib/string-format';
}

/**
* Assigns the variable name for the `@stdlib/string-format` require.
*
* @private
* @param {Object} path - AST node path
* @returns {void}
*/
function assignFormatVar( path ) {
formatVar = path.node.id.name;
}

/**
* Returns false if the node index is equal to zero and true otherwise.
*
Expand Down

0 comments on commit ec0bc28

Please sign in to comment.