Skip to content

Commit

Permalink
fix(linter): create-package-json should omit non-npm and ignored pack…
Browse files Browse the repository at this point in the history
…ages
  • Loading branch information
meeroslav committed Jun 30, 2023
1 parent 3008be1 commit 05740d1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/dependency-checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default createESLintRule<Options, MessageIds>({
type: 'object',
properties: {
buildTargets: [{ type: 'string' }],
ignoreDependencies: [{ type: 'string' }],
ignoredDependencies: [{ type: 'string' }],
checkMissingDependencies: { type: 'boolean' },
checkObsoleteDependencies: { type: 'boolean' },
checkVersionMismatches: { type: 'boolean' },
Expand Down
12 changes: 12 additions & 0 deletions packages/nx/src/plugins/js/package-json/create-package-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export function findProjectsNpmDependencies(
target: string,
options: {
helperDependencies?: string[];
ignoredDependencies?: string[];
},
fileMap?: ProjectFileMap
): NpmDeps {
Expand Down Expand Up @@ -213,6 +214,7 @@ export function findProjectsNpmDependencies(
graph,
npmDeps,
seen,
options.ignoredDependencies || [],
dependencyInputs,
selfInputs
);
Expand All @@ -226,6 +228,7 @@ function findAllNpmDeps(
graph: ProjectGraph,
npmDeps: NpmDeps,
seen: Set<string>,
ignoredDependencies: string[],
dependencyPatterns: string[],
rootPatterns?: string[]
): void {
Expand Down Expand Up @@ -260,6 +263,14 @@ function findAllNpmDeps(
} else {
if (node) {
seen.add(dep);
// do not add ignored dependencies to the list or non-npm dependencies
if (
ignoredDependencies.includes(node.data.packageName) ||
node.type !== 'npm'
) {
continue;
}

npmDeps.dependencies[node.data.packageName] = node.data.version;
recursivelyCollectPeerDependencies(node.name, graph, npmDeps, seen);
} else if (graph.nodes[dep]) {
Expand All @@ -269,6 +280,7 @@ function findAllNpmDeps(
graph,
npmDeps,
seen,
ignoredDependencies,
dependencyPatterns
);
}
Expand Down

0 comments on commit 05740d1

Please sign in to comment.