Skip to content

Commit fbac97d

Browse files
committedMar 9, 2024
refactor: remove usage of _.isEmpty
1 parent 1e7e8e5 commit fbac97d

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed
 

‎src/dependency.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export class Dependency {
9696
lines.push(`Author: ${this.author.text()}`);
9797
}
9898

99-
if (!_.isEmpty(this.contributors)) {
99+
if (this.contributors.length > 0) {
100100
lines.push(`Contributors:`);
101101

102102
const allContributors = _.chain(this.contributors)

‎src/license-plugin-option.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ function doValidation(options) {
134134
*/
135135
function validateOptions(options) {
136136
const errors = doValidation(options);
137-
if (_.isEmpty(errors)) {
137+
if (errors.length === 0) {
138138
return;
139139
}
140140

@@ -148,7 +148,7 @@ function validateOptions(options) {
148148
}
149149
});
150150

151-
if (!_.isEmpty(messages)) {
151+
if (messages.length > 0) {
152152
throw new Error(
153153
`[${PLUGIN_NAME}] -- Error during validation of option object: ${messages.join(' ; ')}`,
154154
);

‎src/license-plugin.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ class LicensePlugin {
565565
// Allow custom formatting of output using given template option.
566566
const template = _.isString(output.template) ? (dependencies) => _.template(output.template)({dependencies, _, moment}) : output.template;
567567
const defaultTemplate = (dependencies) => (
568-
_.isEmpty(dependencies) ? 'No third parties dependencies' : _.map(dependencies, (d) => d.text()).join(`${EOL}${EOL}---${EOL}${EOL}`)
568+
dependencies.length === 0 ? 'No third parties dependencies' : _.map(dependencies, (d) => d.text()).join(`${EOL}${EOL}---${EOL}${EOL}`)
569569
);
570570

571571
const text = _.isFunction(template) ? template(outputDependencies) : defaultTemplate(outputDependencies);

‎src/schema-validator.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function doItemValidation(value, schema, path) {
3939
const matchedValidators = _.filter(validators, (validator) => validator.test(value));
4040

4141
// No one matched, we can stop here and return an error with a proper message.
42-
if (_.isEmpty(matchedValidators)) {
42+
if (matchedValidators.length === 0) {
4343
return [
4444
{
4545
path,

0 commit comments

Comments
 (0)
Please sign in to comment.