Skip to content

Commit

Permalink
Replace fs.read + JSON.parse with require
Browse files Browse the repository at this point in the history
  • Loading branch information
golopot committed Feb 15, 2020
1 parent dfdd7d4 commit 87d9b97
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/rules/default-import-match-filename.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import docsUrl from '../docsUrl'
import isStaticRequire from '../core/staticRequire'
import Path from 'path'
import fs from 'fs'

/**
* @param {string} filename
Expand Down Expand Up @@ -64,9 +63,7 @@ function isAncestorRelativePath(path) {
*/
function getPackageJsonName(packageJsonPath) {
try {
const packageJsonContent = String(fs.readFileSync(packageJsonPath))
const packageJson = JSON.parse(packageJsonContent)
return packageJson.name || undefined
return require(packageJsonPath).name || undefined
} catch (_) {
return undefined
}
Expand Down

0 comments on commit 87d9b97

Please sign in to comment.