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

@nomiclabs/hardhat-solhint does not work #3724

Closed
sherpya opened this issue Feb 27, 2023 · 6 comments · Fixed by #3726
Closed

@nomiclabs/hardhat-solhint does not work #3724

sherpya opened this issue Feb 27, 2023 · 6 comments · Fixed by #3726

Comments

@sherpya
Copy link

sherpya commented Feb 27, 2023

Version of Hardhat

2.12.7

What happened?

NomicLabsHardhatPluginError: An error occurred loading the solhint formatter stylish
    at getFormatter (.../node_modules/@nomiclabs/hardhat-solhint/src/index.ts:21:11

Caused by: Error: Cannot find module 'eslint/lib/formatters/stylish'

calling:

https://github.com/NomicFoundation/hardhat/blob/main/packages/hardhat-solhint/src/index.ts#L12

Minimal reproduction steps

  • create hardhat project using typescript and default settings
  • add hardhat-solhint and enable in config
  • run npx hardhat check

Search terms

solhint hardhat-solhint

@yhuard
Copy link
Contributor

yhuard commented Feb 28, 2023

I have the same issue. I'll try to push a fix later today

@Oni-giri
Copy link

@yhuard Please consider addressing this issue along: #1665

@yhuard
Copy link
Contributor

yhuard commented Feb 28, 2023

@Oni-giri I'll have a look on my free time 👌

@mhm13dev
Copy link

mhm13dev commented Apr 6, 2023

@yhuard Just to update you:
You fixed this issue in #3726 but when I installed hardhat-solhint I still get this error.
When I checked in node_modules, your fix is not included
image

@yhuard
Copy link
Contributor

yhuard commented Apr 6, 2023

Hi @mhm13dev!
Indeed, the changes have not been published yet. The last update of the @nomiclabs/hardhat-solhint package was on December 29, 2022, while my PR was merged on March 4, 2023.
Until a new version of the package is published, I use patch-package in my projects in order to patch it.
Here's what the patch looks like:

diff --git a/node_modules/@nomiclabs/hardhat-solhint/dist/src/index.js b/node_modules/@nomiclabs/hardhat-solhint/dist/src/index.js
index acf1244..cbaff27 100644
--- a/node_modules/@nomiclabs/hardhat-solhint/dist/src/index.js
+++ b/node_modules/@nomiclabs/hardhat-solhint/dist/src/index.js
@@ -30,8 +30,7 @@ function getDefaultConfig() {
 }
 function getFormatter(formatterName = "stylish") {
     try {
-        const solhintPath = require.resolve("solhint");
-        const formatterPath = require.resolve(`eslint/lib/formatters/${formatterName}`, { paths: [solhintPath] });
+        const formatterPath = require.resolve(`solhint/lib/formatters/${formatterName}`);
         return require(formatterPath);
     }
     catch (ex) {

@mhm13dev
Copy link

mhm13dev commented Apr 6, 2023

Okay I will use the patch-package for now.
Appreciated 👍

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants