juanfranblanco / vscode-solidity

Visual Studio Code language support extension for Solidity smart contracts in Ethereum https://marketplace.visualstudio.com/items?itemName=JuanBlanco.solidity
MIT License
871 stars 187 forks source link

bug in auto remappings #454

Open cruzdanilo opened 2 months ago

cruzdanilo commented 2 months ago

auto remappings are not working for some projects. i wonder if forge auto-remappings are being used, but they should be for foundry-based projects.

with the current trend of avoiding custom remappings, this has become very important. here is a quote from the recently published coinbase solidity style guide:

1. Avoid custom remappings.

Remappings help Forge find dependencies based on import statements. Forge will automatically deduce some remappings, for example

forge-std/=lib/forge-std/src/
solmate/=lib/solmate/src/

We should avoid adding to these or defining any remappings explicitly, as it makes our project harder for others to use as a dependency. For example, if our project depends on Solmate and so does theirs, we want to avoid our project having some irregular import naming, resolved with a custom remapping, which will conflict with their import naming.

here is an example of a case where the extension fails to resolve imports that could be resolved using forge auto-remappings: https://github.com/cruzdanilo/repro-webauthn

Screenshot 2024-04-09 at 12 48 40

forge remappings output for the project:

@openzeppelin/contracts/=lib/webauthn-sol/lib/openzeppelin-contracts/contracts/
FreshCryptoLib/=lib/webauthn-sol/lib/FreshCryptoLib/solidity/src/
ds-test/=lib/webauthn-sol/lib/forge-std/lib/ds-test/src/
erc4626-tests/=lib/webauthn-sol/lib/openzeppelin-contracts/lib/erc4626-tests/
forge-std/=lib/webauthn-sol/lib/forge-std/src/
openzeppelin-contracts/=lib/webauthn-sol/lib/openzeppelin-contracts/
solady/=lib/webauthn-sol/lib/solady/src/
webauthn-sol/=lib/webauthn-sol/src/

in this issue discussion, it was mentioned that other solidity extensions for vscode do work out of the box in this case: https://github.com/base-org/webauthn-sol/pull/14

MateoEmilio1 commented 2 months ago

same issue here, i was following the https://docs.pyth.network/price-feeds/create-your-first-pyth-app/evm/part-1 and this error stoped me :/ i have installed the last version of Juan Blanco