Skip to content

Commit

Permalink
fix: peer dependencies
Browse files Browse the repository at this point in the history
- Fixes #182
- Fixes #183
  • Loading branch information
mightyiam committed Nov 28, 2019
1 parent e86bfca commit 969e66b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@
"eslint-config-standard": "^14.1.0"
},
"peerDependencies": {
"eslint": ">=6.0.1",
"eslint": ">=6.2.2",
"eslint-plugin-import": ">=2.18.0",
"eslint-plugin-node": ">=9.1.0",
"eslint-plugin-promise": ">=4.2.1",
"eslint-plugin-standard": ">=4.0.0",
"@typescript-eslint/eslint-plugin": ">=2.0.0"
"@typescript-eslint/eslint-plugin": ">=2.3.3"
},
"devDependencies": {
"@commitlint/cli": "^8.2.0",
Expand All @@ -81,6 +81,7 @@
"eslint-plugin-standard": "^4.0.1",
"husky": "^3.1.0",
"npm-run-all": "^4.1.3",
"read-pkg-up": "^7.0.0",
"standard-version": "^7.0.1",
"tsconfigs": "^4.0.1",
"typescript": "3.6.4"
Expand Down
42 changes: 42 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
import test from 'ava'
import exported from '.'
import standardPkg from 'eslint-config-standard/package.json'
import readPkgUp, { NormalizedPackageJson } from 'read-pkg-up'

interface OurDeps {
ourPeerDeps: NonNullable<NormalizedPackageJson['peerDependencies']>
ourDevDeps: NonNullable<NormalizedPackageJson['devDependencies']>
}

const getOurDeps = async (): Promise<OurDeps> => {
const readResult = await readPkgUp()
if (readResult === undefined) { throw new Error() }
const ourPkg = readResult.packageJson
if (ourPkg.peerDependencies === undefined) { throw new Error() }
const ourPeerDeps = ourPkg.peerDependencies
if (ourPkg.devDependencies === undefined) { throw new Error() }
const ourDevDeps = ourPkg.devDependencies
return { ourPeerDeps, ourDevDeps }
}

test('export', (t): void => {
const expected = {
Expand Down Expand Up @@ -92,3 +110,27 @@ test('export', (t): void => {

t.deepEqual(exported, expected)
})

test('Own peerDependencies include those of eslint-config-standard', async (t) => {
const { ourPeerDeps } = await getOurDeps()
Object
.entries(standardPkg.peerDependencies)
.forEach(([_name, standardRange]) => {
// https://github.com/microsoft/TypeScript/pull/12253
const name = _name as keyof typeof standardPkg.peerDependencies
const ourRange = ourPeerDeps[name]
t.is(ourRange, standardRange)
})
})

test('Dependency @typescript-eslint/eslint-plugin', async (t) => {
const { ourPeerDeps, ourDevDeps } = await getOurDeps()
const peerDepPluginRange = ourPeerDeps['@typescript-eslint/eslint-plugin']
const devDepPluginRange = ourDevDeps['@typescript-eslint/eslint-plugin']
t.true(peerDepPluginRange.startsWith('>='))
t.true(devDepPluginRange.startsWith('^'))
t.is(
peerDepPluginRange.split('>=')[1],
devDepPluginRange.split('^')[1]
)
})

0 comments on commit 969e66b

Please sign in to comment.