Skip to content

refactor: use native Object.entries instead of lodash/toPairs #973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions @commitlint/lint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"@commitlint/is-ignored": "^8.3.5",
"@commitlint/parse": "^8.3.4",
"@commitlint/rules": "^8.3.4",
"@commitlint/types": "^8.3.4",
"lodash": "^4.17.15"
"@commitlint/types": "^8.3.4"
}
}
5 changes: 2 additions & 3 deletions @commitlint/lint/src/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import util from 'util';
import isIgnored from '@commitlint/is-ignored';
import parse from '@commitlint/parse';
import defaultRules from '@commitlint/rules';
import toPairs from 'lodash/toPairs';
import {buildCommitMesage} from './commit-message';
import {
LintRuleConfig,
Expand Down Expand Up @@ -64,7 +63,7 @@ export default async function lint(
);
}

const invalid = toPairs(rulesConfig)
const invalid = Object.entries(rulesConfig)
.map(([name, config]) => {
if (!Array.isArray(config)) {
return new Error(
Expand Down Expand Up @@ -131,7 +130,7 @@ export default async function lint(
}

// Validate against all rules
const results = toPairs(rulesConfig)
const results = Object.entries(rulesConfig)
.filter(([, [level]]) => level > 0)
.map(entry => {
const [name, config] = entry;
Expand Down
3 changes: 1 addition & 2 deletions @commitlint/load/src/load.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Path from 'path';

import toPairs from 'lodash/toPairs';
import merge from 'lodash/merge';
import mergeWith from 'lodash/mergeWith';
import pick from 'lodash/pick';
Expand Down Expand Up @@ -94,7 +93,7 @@ export default async function load(

const rules = preset.rules ? preset.rules : {};
const qualifiedRules = (await Promise.all(
toPairs(rules || {}).map(entry => executeRule<any>(entry))
Object.entries(rules || {}).map(entry => executeRule<any>(entry))
)).reduce<QualifiedRules>((registry, item) => {
const [key, value] = item as any;
(registry as any)[key] = value;
Expand Down
3 changes: 1 addition & 2 deletions @commitlint/prompt/src/library/format.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import chalk from 'chalk';
import toPairs from 'lodash/toPairs';

export default format;

Expand All @@ -11,7 +10,7 @@ export default format;
*/
function format(input, debug = false) {
const results = debug
? toPairs(input).reduce((registry, item) => {
? Object.entries(input || {}).reduce((registry, item) => {
const [name, value] = item;
registry[name] =
value === null ? chalk.grey(`<${name}>`) : chalk.bold(value);
Expand Down
3 changes: 1 addition & 2 deletions @commitlint/prompt/src/library/meta.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import chalk from 'chalk';
import toPairs from 'lodash/toPairs';

/**
* Get formatted meta hints for configuration
Expand All @@ -8,7 +7,7 @@ import toPairs from 'lodash/toPairs';
*/
export default function meta(settings) {
return chalk.grey(
toPairs(settings)
Object.entries(settings || {})
.filter(item => item[1])
.map(item => {
const [name, value] = item;
Expand Down