Skip to content

Commit 5f821ce

Browse files
committed
[Refactor] no-extraneous-dependencies: remove the last bit of lodash
Using `.length` is clearer than a polymorphic `isEmpty`.
1 parent 9347a0f commit 5f821ce

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@
8787
"eslint-import-resolver-node": "^0.3.2",
8888
"eslint-module-utils": "^2.4.0",
8989
"has": "^1.0.3",
90-
"lodash": "^4.17.11",
9190
"minimatch": "^3.0.4",
9291
"read-pkg-up": "^2.0.0",
9392
"resolve": "^1.11.0"

src/rules/no-extraneous-dependencies.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import path from 'path'
22
import fs from 'fs'
3-
import { isEmpty } from 'lodash'
43
import readPkgUp from 'read-pkg-up'
54
import minimatch from 'minimatch'
65
import resolve from 'eslint-module-utils/resolve'
@@ -31,15 +30,15 @@ function getDependencies(context, packageDir) {
3130
peerDependencies: {},
3231
}
3332

34-
if (!isEmpty(packageDir)) {
33+
if (!packageDir || packageDir.length === 0) {
3534
if (!Array.isArray(packageDir)) {
3635
paths = [path.resolve(packageDir)]
3736
} else {
3837
paths = packageDir.map(dir => path.resolve(dir))
3938
}
4039
}
4140

42-
if (!isEmpty(paths)) {
41+
if (paths.length > 0) {
4342
// use rule config to find package.json
4443
paths.forEach(dir => {
4544
const _packageContent = extractDepFields(
@@ -70,7 +69,7 @@ function getDependencies(context, packageDir) {
7069

7170
return packageContent
7271
} catch (e) {
73-
if (!isEmpty(paths) && e.code === 'ENOENT') {
72+
if (paths.length > 0 && e.code === 'ENOENT') {
7473
context.report({
7574
message: 'The package.json file could not be found.',
7675
loc: { line: 0, column: 0 },

0 commit comments

Comments
 (0)