Skip to content

Commit

Permalink
refactor: remove usage of _.forEach
Browse files Browse the repository at this point in the history
  • Loading branch information
mjeanroy committed Mar 9, 2024
1 parent 4b5ee3c commit 36882d2
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/format-path.js
Expand Up @@ -33,7 +33,7 @@ import _ from 'lodash';
export function formatPath(paths) {
let str = '';

_.forEach(paths, (p) => {
paths.forEach((p) => {
if (_.isNumber(p)) {
str += `[${p}]`;
} else if (!str) {
Expand Down
2 changes: 1 addition & 1 deletion src/license-plugin-option.js
Expand Up @@ -140,7 +140,7 @@ function validateOptions(options) {

const messages = [];

_.forEach(errors, (e) => {
errors.forEach((e) => {
if (e.type === 'object.allowUnknown') {
warn(`Unknown property: "${formatPath(e.path)}", allowed options are: ${_.keys(SCHEMA).join(', ')}.`);
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/license-plugin.js
Expand Up @@ -220,7 +220,7 @@ class LicensePlugin {
}

// Update the cache
_.forEach(scannedDirs, (scannedDir) => {
scannedDirs.forEach((scannedDir) => {
this._cache[scannedDir] = pkg;
});
}
Expand All @@ -234,7 +234,7 @@ class LicensePlugin {
scanDependencies(dependencies) {
this.debug(`Scanning: ${dependencies}`);

_.forEach(dependencies, (dependency) => {
dependencies.forEach((dependency) => {
this.scanDependency(dependency);
});
}
Expand Down Expand Up @@ -455,7 +455,7 @@ class LicensePlugin {
* @return {void}
*/
_scanLicenseViolations(outputDependencies, allow) {
_.forEach(outputDependencies, (dependency) => {
outputDependencies.forEach((dependency) => {
this._scanLicenseViolation(dependency, allow);
});
}
Expand Down Expand Up @@ -541,7 +541,7 @@ class LicensePlugin {
* @return {void}
*/
_exportThirdParties(outputDependencies, outputs) {
_.forEach(_.castArray(outputs), (output) => {
_.castArray(outputs).forEach((output) => {
this._exportThirdPartiesToOutput(outputDependencies, output);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/person.js
Expand Up @@ -57,7 +57,7 @@ export class Person {
}
}

_.forEach(['name', 'email', 'url'], (prop) => {
['name', 'email', 'url'].forEach((prop) => {
if (_.has(o, prop)) {
o[prop] = _.trim(o[prop]);
}
Expand Down
3 changes: 2 additions & 1 deletion src/schema-validator.js
Expand Up @@ -68,7 +68,8 @@ function doItemValidation(value, schema, path) {
function validateObject(obj, schema, current) {
const errors = [];

_.forEach(obj, (value, k) => {
Object.keys(obj).forEach((k) => {
const value = obj[k];
if (_.isNil(value)) {
return;
}
Expand Down

0 comments on commit 36882d2

Please sign in to comment.