-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Suggest installing hardhat-foundry when appropriate #7919
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fc296db
Suggest installing hardhat-foundry when appropriate
alcuadrado 2bf06d3
Create olive-shirts-obey.md
alcuadrado c2a1ca9
Improve messaging
alcuadrado eeb3898
Rename fromHasFoundryToml fields
alcuadrado 421ab91
Add tests to the error-messages module and fix the issues encountered
alcuadrado File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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,5 @@ | ||
| --- | ||
| "hardhat": patch | ||
| --- | ||
|
|
||
| Suggest installing hardhat-foundry when appropriate |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -57,7 +57,14 @@ Note that the npm module is being remapped by ${formatRemappingReference(error.u | |
| } | ||
|
|
||
| case RootResolutionErrorType.NPM_ROOT_FILE_OF_UNINSTALLED_PACKAGE: { | ||
| return `The package "${error.installationName}" is not installed.`; | ||
| const baseMessage = `The package "${error.installationName}" is not installed.`; | ||
| if (error.projectHasFoundryToml === true) { | ||
| return `${baseMessage} | ||
|
|
||
| Your project has a foundry.toml, and you may need to install the "@nomicfoundation/hardhat-foundry" plugin. | ||
| Learn more about Hardhat's Foundry compatibility here: https://hardhat.org/foundry-compatibility`; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this URL is currently a 404! UPDATE: just saw that it is sent as a next PR |
||
| } | ||
| return baseMessage; | ||
| } | ||
|
|
||
| case RootResolutionErrorType.NPM_ROOT_FILE_RESOLUTION_WITH_REMAPPING_ERRORS: { | ||
|
|
@@ -107,21 +114,28 @@ export function formatImportResolutionError( | |
| } | ||
|
|
||
| case ImportResolutionErrorType.ILLEGAL_RELATIVE_IMPORT: { | ||
| return "The import has too many '../', and trying to leave its package."; | ||
| return "The import has too many '../' and is trying to leave its package."; | ||
| } | ||
|
|
||
| case ImportResolutionErrorType.RELATIVE_IMPORT_INTO_NODE_MODULES: { | ||
| return `You are trying to import a file from your node_modules directory with its file system path. | ||
|
|
||
| You should write your the path of your imports into npm modules just as you would do in JavaScript files.`; | ||
| You should write your imports into npm modules just as you would do in JavaScript files.`; | ||
| } | ||
|
|
||
| case ImportResolutionErrorType.IMPORT_WITH_INVALID_NPM_SYNTAX: { | ||
| return "You are trying to import an npm file but its syntax is invalid."; | ||
| } | ||
|
|
||
| case ImportResolutionErrorType.IMPORT_OF_UNINSTALLED_PACKAGE: { | ||
| return `The package "${error.installationName}" is not installed.`; | ||
| const baseMessage = `The package "${error.installationName}" is not installed.`; | ||
| if (error.importerPackageHasFoundryToml === true) { | ||
| return `${baseMessage} | ||
|
|
||
| The file importing this package is inside a Foundry project (foundry.toml detected), and you may need to install the "@nomicfoundation/hardhat-foundry" plugin. | ||
| Learn more about Hardhat's Foundry compatibility here: https://hardhat.org/foundry-compatibility`; | ||
|
marianfe marked this conversation as resolved.
|
||
| } | ||
| return baseMessage; | ||
| } | ||
|
|
||
| case ImportResolutionErrorType.IMPORT_WITH_REMAPPING_ERRORS: { | ||
|
|
@@ -148,7 +162,7 @@ If you still want to be able to do it, try adding this remapping "${error.sugges | |
| ? "the package" | ||
| : "the project"; | ||
|
|
||
| const message = `The file ${error.packageExportsResolvedSubpath ?? error.subpath} doesn't exist within ${packageOrProject}.`; | ||
| const message = `The file "${error.packageExportsResolvedSubpath ?? error.subpath}" doesn't exist within ${packageOrProject}.`; | ||
|
|
||
| return formatResolutionErrorRemappingsOrPackageExportsNotes({ | ||
| message, | ||
|
|
||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these errors message updates dont have a corresponding unit test to verify the behavior works with hasFoundryToml and without it. same for the one further below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has 100% coverage after d80c347, thanks!