This repository has been archived by the owner on Feb 11, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(eslint): move to optional peer dependencies
Resolves #16
- Loading branch information
Showing
5 changed files
with
45 additions
and
6 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// @ts-check | ||
const pkgJson = require('../../package.json'); | ||
|
||
/** | ||
* @returns {string} The name of the package manager. | ||
*/ | ||
function readPackageManager() { | ||
const match = process.env.npm_config_user_agent?.match(/^(?<pm>\w+)\//); | ||
return match?.groups ? match.groups?.pm : 'npm'; | ||
} | ||
|
||
/** | ||
* @param {string} configName | ||
* @param {string} packageName | ||
*/ | ||
module.exports = (configName, packageName) => { | ||
try { | ||
require.resolve(packageName); | ||
} catch (e) { | ||
const packageManager = readPackageManager(); | ||
const command = packageManager === 'yarn' ? 'add' : 'install'; | ||
|
||
/* eslint-disable no-console */ | ||
console.error( | ||
`The \`${configName}\` config requires an optional peer dependency, which has not been installed.`, | ||
); | ||
console.error(); | ||
console.error('To install it, run:'); | ||
console.error( | ||
`- ${packageManager} ${command} ${packageName}@${pkgJson.peerDependencies[packageName]}`, | ||
); | ||
/* eslint-enable no-console */ | ||
|
||
process.exit(1); | ||
} | ||
}; |
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 means that we need to install next and it's peer dependencies on the root of a monorepo.
Is there a more lightweight option that doesn't require next?