-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
correct no-extraneous-dependencies rule: get the real name from the r…
…esolved package.json. If not aliased imports (alias/react for example) will not be correctly interpreted
- Loading branch information
JEROMEH
committed
Mar 24, 2020
1 parent
075af94
commit d33d69d
Showing
4 changed files
with
36 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
import {dirname} from 'path' | ||
import findUp from 'find-up' | ||
import readPkgUp from 'read-pkg-up' | ||
|
||
|
||
export function getContextPackagePath(context) { | ||
return getFilePackagePath(context.getFilename()) | ||
} | ||
|
||
export function getFilePackagePath(filePath) { | ||
const fp = findUp.sync('package.json', {cwd: filePath, normalize: false}) | ||
const fp = findUp.sync('package.json', {cwd: filePath}) | ||
return dirname(fp) | ||
} | ||
|
||
export function getFilePackageName(filePath) { | ||
const pkg = readPkgUp.sync({cwd: filePath, normalize: false}).pkg | ||
return pkg && pkg.name | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters