Skip to content

bug in auto remappings #454

@cruzdanilo

Description

@cruzdanilo

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: base/webauthn-sol#14

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions