Skip to content

Commit 154b3a7

Browse files
author
Steven Hargrove
committed
cached package locator now exports a factory fn
1 parent 14fdf06 commit 154b3a7

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import path from 'path'
22
import os from 'os'
33
import fs from 'fs'
44

5-
export default class CachedPackageLocator {
5+
class CachedPackageLocator {
66
constructor() {
77
this.store = {}
88
}
@@ -59,3 +59,5 @@ export default class CachedPackageLocator {
5959
})
6060
}
6161
}
62+
63+
export default () => new CachedPackageLocator()

src/rules/no-extraneous-dependencies.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import minimatch from 'minimatch'
33
import resolve from 'eslint-module-utils/resolve'
44
import importType from '../core/importType'
55
import isStaticRequire from '../core/staticRequire'
6-
import CachedPackageLocator from '../core/CachedPackageLocator'
6+
import createPackageLocator from '../core/createPackageLocator'
77
import docsUrl from '../docsUrl'
88

9-
const packageLocator = new CachedPackageLocator()
9+
const packageLocator = createPackageLocator()
1010

1111
function notEmpty(obj) {
1212
return Object.keys(obj).length

tests/src/core/CachedPackageLocator.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import fs from 'fs'
22
import sinon from 'sinon'
33
import { expect } from 'chai'
4-
5-
import CachedPackageLocator from '../../../src/core/CachedPackageLocator'
4+
import createPackageLocator from '../../../src/core/createPackageLocator'
65

76
function notEmpty(obj) {
87
return Object.keys(obj).length
@@ -55,7 +54,7 @@ describe('CachedPackageLocator.readUpSync()', function () {
5554

5655
beforeEach(function () {
5756
fs.readFileSync.throws({ code: 'ENOENT' })
58-
packageLocator = new CachedPackageLocator()
57+
packageLocator = createPackageLocator()
5958
})
6059

6160
afterEach(function () {

0 commit comments

Comments
 (0)