Skip to content

Commit 908ff52

Browse files
authored
refactor: use native Object.entries instead of lodash/toPairs (#973)
1 parent 3d0c79f commit 908ff52

File tree

5 files changed

+6
-11
lines changed

5 files changed

+6
-11
lines changed

@commitlint/lint/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
"@commitlint/is-ignored": "^8.3.5",
4242
"@commitlint/parse": "^8.3.4",
4343
"@commitlint/rules": "^8.3.4",
44-
"@commitlint/types": "^8.3.4",
45-
"lodash": "^4.17.15"
44+
"@commitlint/types": "^8.3.4"
4645
}
4746
}

@commitlint/lint/src/lint.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import util from 'util';
22
import isIgnored from '@commitlint/is-ignored';
33
import parse from '@commitlint/parse';
44
import defaultRules from '@commitlint/rules';
5-
import toPairs from 'lodash/toPairs';
65
import {buildCommitMesage} from './commit-message';
76
import {
87
LintRuleConfig,
@@ -64,7 +63,7 @@ export default async function lint(
6463
);
6564
}
6665

67-
const invalid = toPairs(rulesConfig)
66+
const invalid = Object.entries(rulesConfig)
6867
.map(([name, config]) => {
6968
if (!Array.isArray(config)) {
7069
return new Error(
@@ -131,7 +130,7 @@ export default async function lint(
131130
}
132131

133132
// Validate against all rules
134-
const results = toPairs(rulesConfig)
133+
const results = Object.entries(rulesConfig)
135134
.filter(([, [level]]) => level > 0)
136135
.map(entry => {
137136
const [name, config] = entry;

@commitlint/load/src/load.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Path from 'path';
22

3-
import toPairs from 'lodash/toPairs';
43
import merge from 'lodash/merge';
54
import mergeWith from 'lodash/mergeWith';
65
import pick from 'lodash/pick';
@@ -94,7 +93,7 @@ export default async function load(
9493

9594
const rules = preset.rules ? preset.rules : {};
9695
const qualifiedRules = (await Promise.all(
97-
toPairs(rules || {}).map(entry => executeRule<any>(entry))
96+
Object.entries(rules || {}).map(entry => executeRule<any>(entry))
9897
)).reduce<QualifiedRules>((registry, item) => {
9998
const [key, value] = item as any;
10099
(registry as any)[key] = value;

@commitlint/prompt/src/library/format.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import chalk from 'chalk';
2-
import toPairs from 'lodash/toPairs';
32

43
export default format;
54

@@ -11,7 +10,7 @@ export default format;
1110
*/
1211
function format(input, debug = false) {
1312
const results = debug
14-
? toPairs(input).reduce((registry, item) => {
13+
? Object.entries(input || {}).reduce((registry, item) => {
1514
const [name, value] = item;
1615
registry[name] =
1716
value === null ? chalk.grey(`<${name}>`) : chalk.bold(value);

@commitlint/prompt/src/library/meta.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import chalk from 'chalk';
2-
import toPairs from 'lodash/toPairs';
32

43
/**
54
* Get formatted meta hints for configuration
@@ -8,7 +7,7 @@ import toPairs from 'lodash/toPairs';
87
*/
98
export default function meta(settings) {
109
return chalk.grey(
11-
toPairs(settings)
10+
Object.entries(settings || {})
1211
.filter(item => item[1])
1312
.map(item => {
1413
const [name, value] = item;

0 commit comments

Comments
 (0)