Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check peerDependencies in imports-as-dependencies #1113

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/rules/importsAsDependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,29 @@ let deps;
const setDeps = function () {
try {
const pkg = JSON.parse(
// @ts-expect-error It's ok
// @ts-expect-error It's ok
readFileSync(join(process.cwd(), './package.json')),
);
deps = new Set([
...(pkg.dependencies ?
Object.keys(pkg.dependencies) :
// istanbul ignore next
// istanbul ignore next
[]),
...(pkg.devDependencies ?
Object.keys(pkg.devDependencies) :
// istanbul ignore next
// istanbul ignore next
[]),
...(pkg.peerDependencies ?
Object.keys(pkg.peerDependencies) :
// istanbul ignore next
[]),
]);
} catch (error) {
// istanbul ignore next -- our package.json exists
} catch (error) { // istanbul ignore next -- our package.json exists
deps = null;
/* eslint-disable no-console -- Inform user */
// istanbul ignore next -- our package.json exists
console.log(error);
/* eslint-enable no-console -- Inform user */
/* eslint-enable no-console -- Inform user */
}
};

Expand Down