Skip to content

Commit 66dc5f9

Browse files
isaacswraithgar
authored andcommitted
fix: update eresolve explanations for new arborist data provided
Fix: #3138 PR-URL: #3588 Credit: @isaacs Close: #3588 Reviewed-by: @wraithgar
1 parent 97cb5ec commit 66dc5f9

File tree

3 files changed

+380
-39
lines changed

3 files changed

+380
-39
lines changed

lib/utils/explain-eresolve.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,33 @@ const { explainEdge, explainNode, printNode } = require('./explain-dep.js')
99
// The full report (ie, depth=Infinity) is always written to the cache folder
1010
// at ${cache}/eresolve-report.txt along with full json.
1111
const explain = (expl, color, depth) => {
12-
const { edge, current, peerConflict, currentEdge } = expl
12+
const { edge, dep, current, peerConflict, currentEdge } = expl
1313

1414
const out = []
15-
if (edge.from && edge.from.whileInstalling)
16-
out.push('While resolving: ' + printNode(edge.from.whileInstalling, color))
15+
const whileInstalling = dep && dep.whileInstalling ||
16+
current && current.whileInstalling ||
17+
edge && edge.from && edge.from.whileInstalling
18+
if (whileInstalling)
19+
out.push('While resolving: ' + printNode(whileInstalling, color))
1720

1821
// it "should" be impossible for an ERESOLVE explanation to lack both
1922
// current and currentEdge, but better to have a less helpful error
2023
// than a crashing failure.
2124
if (current)
2225
out.push('Found: ' + explainNode(current, depth, color))
26+
else if (peerConflict && peerConflict.current)
27+
out.push('Found: ' + explainNode(peerConflict.current, depth, color))
2328
else if (currentEdge)
2429
out.push('Found: ' + explainEdge(currentEdge, depth, color))
30+
else /* istanbul ignore else - should always have one */ if (edge)
31+
out.push('Found: ' + explainEdge(edge, depth, color))
2532

2633
out.push('\nCould not resolve dependency:\n' +
2734
explainEdge(edge, depth, color))
2835

2936
if (peerConflict) {
3037
const heading = '\nConflicting peer dependency:'
31-
const pc = explainNode(peerConflict, depth, color)
38+
const pc = explainNode(peerConflict.peer, depth, color)
3239
out.push(heading + ' ' + pc)
3340
}
3441

tap-snapshots/test/lib/utils/explain-eresolve.js.test.cjs

+151
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,142 @@ to accept an incorrect (and potentially broken) dependency resolution.
215215
See \${REPORT} for a full report.
216216
`
217217

218+
exports[`test/lib/utils/explain-eresolve.js TAP eslint-plugin case > explain with color, depth of 2 1`] = `
219+
While resolving: eslint-plugin-react@7.24.0
220+
Found: eslint@6.8.0
221+
node_modules/eslint
222+
dev eslint@"^3 || ^4 || ^5 || ^6 || ^7" from the root project
223+
3 more (@typescript-eslint/parser, ...)
224+
225+
Could not resolve dependency:
226+
dev eslint-plugin-eslint-plugin@"^3.1.0" from the root project
227+
228+
Conflicting peer dependency: eslint@7.31.0
229+
node_modules/eslint
230+
peer eslint@"^7.0.0" from eslint-plugin-eslint-plugin@3.5.1
231+
node_modules/eslint-plugin-eslint-plugin
232+
dev eslint-plugin-eslint-plugin@"^3.1.0" from the root project
233+
`
234+
235+
exports[`test/lib/utils/explain-eresolve.js TAP eslint-plugin case > explain with no color, depth of 6 1`] = `
236+
While resolving: [email protected]
237+
238+
node_modules/eslint
239+
dev eslint@"^3 || ^4 || ^5 || ^6 || ^7" from the root project
240+
peer eslint@"^5.0.0 || ^6.0.0" from @typescript-eslint/[email protected]
241+
node_modules/@typescript-eslint/parser
242+
dev @typescript-eslint/parser@"^2.34.0" from the root project
243+
peer eslint@"^5.16.0 || ^6.8.0 || ^7.2.0" from [email protected]
244+
node_modules/eslint-config-airbnb-base
245+
dev eslint-config-airbnb-base@"^14.2.1" from the root project
246+
1 more (eslint-plugin-import)
247+
248+
Could not resolve dependency:
249+
dev eslint-plugin-eslint-plugin@"^3.1.0" from the root project
250+
251+
Conflicting peer dependency: [email protected]
252+
node_modules/eslint
253+
peer eslint@"^7.0.0" from [email protected]
254+
node_modules/eslint-plugin-eslint-plugin
255+
dev eslint-plugin-eslint-plugin@"^3.1.0" from the root project
256+
`
257+
258+
exports[`test/lib/utils/explain-eresolve.js TAP eslint-plugin case > report 1`] = `
259+
# npm resolution error report
260+
261+
\${TIME}
262+
263+
While resolving: [email protected]
264+
265+
node_modules/eslint
266+
dev eslint@"^3 || ^4 || ^5 || ^6 || ^7" from the root project
267+
peer eslint@"^5.0.0 || ^6.0.0" from @typescript-eslint/[email protected]
268+
node_modules/@typescript-eslint/parser
269+
dev @typescript-eslint/parser@"^2.34.0" from the root project
270+
peer eslint@"^5.16.0 || ^6.8.0 || ^7.2.0" from [email protected]
271+
node_modules/eslint-config-airbnb-base
272+
dev eslint-config-airbnb-base@"^14.2.1" from the root project
273+
peer eslint@"^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0" from [email protected]
274+
node_modules/eslint-plugin-import
275+
dev eslint-plugin-import@"^2.23.4" from the root project
276+
peer eslint-plugin-import@"^2.22.1" from [email protected]
277+
node_modules/eslint-config-airbnb-base
278+
dev eslint-config-airbnb-base@"^14.2.1" from the root project
279+
280+
Could not resolve dependency:
281+
dev eslint-plugin-eslint-plugin@"^3.1.0" from the root project
282+
283+
Conflicting peer dependency: [email protected]
284+
node_modules/eslint
285+
peer eslint@"^7.0.0" from [email protected]
286+
node_modules/eslint-plugin-eslint-plugin
287+
dev eslint-plugin-eslint-plugin@"^3.1.0" from the root project
288+
289+
Fix the upstream dependency conflict, or retry
290+
this command with --force, or --legacy-peer-deps
291+
to accept an incorrect (and potentially broken) dependency resolution.
292+
293+
Raw JSON explanation object:
294+
295+
{
296+
"name": "eslint-plugin case",
297+
"json": true
298+
}
299+
300+
`
301+
302+
exports[`test/lib/utils/explain-eresolve.js TAP eslint-plugin case > report with color 1`] = `
303+
While resolving: eslint-plugin-react@7.24.0
304+
Found: eslint@6.8.0
305+
node_modules/eslint
306+
dev eslint@"^3 || ^4 || ^5 || ^6 || ^7" from the root project
307+
peer eslint@"^5.0.0 || ^6.0.0" from @typescript-eslint/parser@2.34.0
308+
node_modules/@typescript-eslint/parser
309+
dev @typescript-eslint/parser@"^2.34.0" from the root project
310+
2 more (eslint-config-airbnb-base, eslint-plugin-import)
311+
312+
Could not resolve dependency:
313+
dev eslint-plugin-eslint-plugin@"^3.1.0" from the root project
314+
315+
Conflicting peer dependency: eslint@7.31.0
316+
node_modules/eslint
317+
peer eslint@"^7.0.0" from eslint-plugin-eslint-plugin@3.5.1
318+
node_modules/eslint-plugin-eslint-plugin
319+
dev eslint-plugin-eslint-plugin@"^3.1.0" from the root project
320+
321+
Fix the upstream dependency conflict, or retry
322+
this command with --force, or --legacy-peer-deps
323+
to accept an incorrect (and potentially broken) dependency resolution.
324+
325+
See \${REPORT} for a full report.
326+
`
327+
328+
exports[`test/lib/utils/explain-eresolve.js TAP eslint-plugin case > report with no color 1`] = `
329+
While resolving: [email protected]
330+
331+
node_modules/eslint
332+
dev eslint@"^3 || ^4 || ^5 || ^6 || ^7" from the root project
333+
peer eslint@"^5.0.0 || ^6.0.0" from @typescript-eslint/[email protected]
334+
node_modules/@typescript-eslint/parser
335+
dev @typescript-eslint/parser@"^2.34.0" from the root project
336+
2 more (eslint-config-airbnb-base, eslint-plugin-import)
337+
338+
Could not resolve dependency:
339+
dev eslint-plugin-eslint-plugin@"^3.1.0" from the root project
340+
341+
Conflicting peer dependency: [email protected]
342+
node_modules/eslint
343+
peer eslint@"^7.0.0" from [email protected]
344+
node_modules/eslint-plugin-eslint-plugin
345+
dev eslint-plugin-eslint-plugin@"^3.1.0" from the root project
346+
347+
Fix the upstream dependency conflict, or retry
348+
this command with --force, or --legacy-peer-deps
349+
to accept an incorrect (and potentially broken) dependency resolution.
350+
351+
See \${REPORT} for a full report.
352+
`
353+
218354
exports[`test/lib/utils/explain-eresolve.js TAP gatsby > explain with color, depth of 2 1`] = `
219355
While resolving: gatsby-recipes@0.2.31
220356
Found: ink@3.0.0-7
@@ -433,6 +569,9 @@ See \${REPORT} for a full report.
433569

434570
exports[`test/lib/utils/explain-eresolve.js TAP no current node, no current edge, idk > explain with color, depth of 2 1`] = `
435571
While resolving: eslint@7.22.0
572+
Found: peer eslint@"^6.0.0" from eslint-plugin-jsdoc@22.2.0
573+
node_modules/eslint-plugin-jsdoc
574+
dev eslint-plugin-jsdoc@"^22.1.0" from the root project
436575
437576
Could not resolve dependency:
438577
peer eslint@"^6.0.0" from eslint-plugin-jsdoc@22.2.0
@@ -442,6 +581,9 @@ Could not resolve dependency:
442581

443582
exports[`test/lib/utils/explain-eresolve.js TAP no current node, no current edge, idk > explain with no color, depth of 6 1`] = `
444583
While resolving: [email protected]
584+
Found: peer eslint@"^6.0.0" from [email protected]
585+
node_modules/eslint-plugin-jsdoc
586+
dev eslint-plugin-jsdoc@"^22.1.0" from the root project
445587
446588
Could not resolve dependency:
447589
peer eslint@"^6.0.0" from [email protected]
@@ -455,6 +597,9 @@ exports[`test/lib/utils/explain-eresolve.js TAP no current node, no current edge
455597
\${TIME}
456598
457599
While resolving: [email protected]
600+
Found: peer eslint@"^6.0.0" from [email protected]
601+
node_modules/eslint-plugin-jsdoc
602+
dev eslint-plugin-jsdoc@"^22.1.0" from the root project
458603
459604
Could not resolve dependency:
460605
peer eslint@"^6.0.0" from [email protected]
@@ -476,6 +621,9 @@ Raw JSON explanation object:
476621

477622
exports[`test/lib/utils/explain-eresolve.js TAP no current node, no current edge, idk > report with color 1`] = `
478623
While resolving: eslint@7.22.0
624+
Found: peer eslint@"^6.0.0" from eslint-plugin-jsdoc@22.2.0
625+
node_modules/eslint-plugin-jsdoc
626+
dev eslint-plugin-jsdoc@"^22.1.0" from the root project
479627
480628
Could not resolve dependency:
481629
peer eslint@"^6.0.0" from eslint-plugin-jsdoc@22.2.0
@@ -491,6 +639,9 @@ See \${REPORT} for a full report.
491639

492640
exports[`test/lib/utils/explain-eresolve.js TAP no current node, no current edge, idk > report with no color 1`] = `
493641
While resolving: [email protected]
642+
Found: peer eslint@"^6.0.0" from [email protected]
643+
node_modules/eslint-plugin-jsdoc
644+
dev eslint-plugin-jsdoc@"^22.1.0" from the root project
494645
495646
Could not resolve dependency:
496647
peer eslint@"^6.0.0" from [email protected]

0 commit comments

Comments
 (0)