Skip to content
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

Show a warning when the config is empty #1490

Closed
fvictorio opened this issue May 27, 2021 · 5 comments
Closed

Show a warning when the config is empty #1490

fvictorio opened this issue May 27, 2021 · 5 comments
Assignees
Labels
good-first-issue Good for newcomers. Guidance available if needed

Comments

@fvictorio
Copy link
Member

An user could make something like this in the config:

let config: HardhatUserConfig = {
  ...
}

and forget to do export default config. We should show a warning when that happens.

@fvictorio fvictorio added good-first-issue Good for newcomers. Guidance available if needed package:hardhat-core labels May 27, 2021
@alcuadrado
Copy link
Member

I don't think this is feasible, as a file that doesn't export anything in node is equivalent to one exporting an empty object, and that's a valid config.

@fvictorio
Copy link
Member Author

Oh, I know, but I think it's a good trade-off. We can just check Object.keys(config).length and I think it's way more likely that this helps someone than this annoys a user that explicitly wants an empty config (I don't see why anyone would do that).

@Endlessline
Copy link

I took a stab at this, is it something you all think would be useful? It sounds like it still may be up for debate.

@alcuadrado
Copy link
Member

Now I get it, @Endlessline, thanks!

I guess I'm ok with that trade-off, as we already print a warning if the user doesn't provide a solidity config.

@kanej kanej self-assigned this Dec 6, 2021
kanej added a commit that referenced this issue Dec 8, 2021
If a user fails to export from the HardhatConfig.{js,ts} file or exports an empty object, we now throw an error.

This means updating some of our tests cases which have been using the `{}` object as the base case.

Relates to #1490
@kanej kanej linked a pull request Dec 8, 2021 that will close this issue
kanej added a commit that referenced this issue Dec 8, 2021
If a user fails to export from the HardhatConfig.{js,ts} file or exports an empty object, we now throw an error.

This means updating some of our tests cases which have been using the `{}` object as the base case.

Relates to #1490
kanej added a commit that referenced this issue Dec 8, 2021
If a user fails to export from the HardhatConfig.{js,ts} file or exports an empty object, we now throw an error.

This means updating some of our tests cases which have been using the `{}` object as the base case. The docs (including plugin docs) have been updated to reflect that `module.exports = {}` will not work when copied and pasted.

Relates to #1490
kanej added a commit that referenced this issue Dec 10, 2021
This is usually indicative of a mistake in HardhatConfig, hence we should warn users.

Relates to #1490.
kanej added a commit that referenced this issue Dec 10, 2021
This is usually indicative of a mistake in HardhatConfig, hence we should warn users.

Relates to #1490.
kanej added a commit that referenced this issue Dec 10, 2021
This is usually indicative of a mistake in HardhatConfig, hence we should warn users.

Relates to #1490.
@fvictorio
Copy link
Member Author

Fixed in hardhat@2.8.1.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good-first-issue Good for newcomers. Guidance available if needed
Projects
None yet
Development

No branches or pull requests

4 participants