Skip to content

Commit

Permalink
[Refactor] no-extraneous-dependencies: remove the last bit of lodash
Browse files Browse the repository at this point in the history
Using `.length` is clearer than a polymorphic `isEmpty`.
  • Loading branch information
ljharb committed Jul 17, 2019
1 parent dec3b86 commit 915f571
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
"eslint-import-resolver-node": "^0.3.2",
"eslint-module-utils": "^2.4.0",
"has": "^1.0.3",
"lodash": "^4.17.11",
"minimatch": "^3.0.4",
"read-pkg-up": "^2.0.0",
"resolve": "^1.11.0"
Expand Down
7 changes: 3 additions & 4 deletions src/rules/no-extraneous-dependencies.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import path from 'path'
import fs from 'fs'
import { isEmpty } from 'lodash'
import readPkgUp from 'read-pkg-up'
import minimatch from 'minimatch'
import resolve from 'eslint-module-utils/resolve'
Expand Down Expand Up @@ -31,15 +30,15 @@ function getDependencies(context, packageDir) {
peerDependencies: {},
}

if (!isEmpty(packageDir)) {
if (packageDir && packageDir.length > 0) {
if (!Array.isArray(packageDir)) {
paths = [path.resolve(packageDir)]
} else {
paths = packageDir.map(dir => path.resolve(dir))
}
}

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

return packageContent
} catch (e) {
if (!isEmpty(paths) && e.code === 'ENOENT') {
if (paths.length > 0 && e.code === 'ENOENT') {
context.report({
message: 'The package.json file could not be found.',
loc: { line: 0, column: 0 },
Expand Down

0 comments on commit 915f571

Please sign in to comment.