Repository navigation
Closed as not planned
Description
What I'm trying to do
I've forked solhint and been trying it
out against exactly's codebase
The problem
however, when updating the dependency & running yarn lint:sol at the tip of the aforementioned
PR's tip, I get the following error:
[I] capu ~/s/exactly-protocol (basedhint)> yarn lint:sol
yarn run v1.22.19
warning package.json: License should be a valid SPDX license expression
$ solhint '{contracts,test}/**/*.sol'
/home/capu/src/exactly-protocol/node_modules/solhint-community/lib/index.js:40
throw e
^
Error: The specified node does not exist
at ImportDirectiveContext.getChild (/home/capu/src/exactly-protocol/node_modules/solhint-community/node_modules/@solidity-parser/parser/dist/index.cjs.js:9354:15)
at ImportDirectiveContext.getRuleContext (/home/capu/src/exactly-protocol/node_modules/solhint-community/node_modules/@solidity-parser/parser/dist/index.cjs.js:9417:19)
at ImportDirectiveContext.importPath (/home/capu/src/exactly-protocol/node_modules/solhint-community/node_modules/@solidity-parser/parser/dist/index.cjs.js:32102:17)
at ASTBuilder.visitImportDirective (/home/capu/src/exactly-protocol/node_modules/solhint-community/node_modules/@solidity-parser/parser/dist/index.cjs.js:36578:41)
at ImportDirectiveContext.accept (/home/capu/src/exactly-protocol/node_modules/solhint-community/node_modules/@solidity-parser/parser/dist/index.cjs.js:32136:22)
at ASTBuilder.visit (/home/capu/src/exactly-protocol/node_modules/solhint-community/node_modules/@solidity-parser/parser/dist/index.cjs.js:17669:19)
at /home/capu/src/exactly-protocol/node_modules/solhint-community/node_modules/@solidity-parser/parser/dist/index.cjs.js:35544:59
at Array.map (<anonymous>)
at ASTBuilder.visitSourceUnit (/home/capu/src/exactly-protocol/node_modules/solhint-community/node_modules/@solidity-parser/parser/dist/index.cjs.js:35544:39)
at SourceUnitContext.accept (/home/capu/src/exactly-protocol/node_modules/solhint-community/node_modules/@solidity-parser/parser/dist/index.cjs.js:31881:22)
Node.js v18.16.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
solhint-community clearly states it needs a parser of semver-range version 0.16.0
[N] capu ~/s/exactly-protocol (basedhint) [5]> jq ".dependencies.\"@solidity-parser/parser\"" < "node_modules/solhint-community/package.json"
"^0.16.0"
...and it has it under its own node_modules, and the stack trace shows that it's the one being
used:
[I] capu ~/s/exactly-protocol (basedhint)> jq ".version" < "node_modules/solhint-community/node_modules/@solidity-parser/parser/package.json"
"0.16.0"
what I've tried so far
If the fixes for the no-unused-import rule are rolled back (checking out the previous commit), then
the linter reports them successfully.
[I] capu ~/s/exactly-protocol ((82e3ed0e))> yarn lint:sol
yarn run v1.22.19
warning package.json: License should be a valid SPDX license expression
$ solhint '{contracts,test}/**/*.sol'
contracts/InterestRateModel.sol
4:10 error imported name Math is not used no-unused-import
contracts/mocks/MockPriceFeed.sol
4:10 error imported name MockERC20 is not used no-unused-import
...
but that's not of much help.
Also, disabling the no-unused-import rule doesn't prevent the crash either.
Metadata
Metadata
Assignees
Labels
No labels
Activity
juanpcapurro commentedon May 31, 2023
update: I narrowed it down to the
npx solhint test/solidity/Leverager.t.solfile causing the crashfvictorio commentedon Jun 1, 2023
I cannot reproduce this 😶
exactlyrepoyarn add solhint-communitynpx solhint test/solidity/Leverager.t.solAm I missing something here?
juanpcapurro commentedon Jun 2, 2023
sorry, I wasn't clear:
I created a PR on Exactly where this issue can be reproduced: exactly/protocol#628 , so you should
basedhint,yarnto install dependencies,npx solhint test/solidity/Leverager.t.solto cause the exception
it can only be replicated when using solhint-community (first commit of my pr) and with the unused imports removed (second commit)
fvictorio commentedon Jun 2, 2023
That file has a syntax error. There is a trailing comma in this import:
As far as I can tell, solidity doesn't support that.
juanpcapurro commentedon Jun 3, 2023
lol that's embarrasing 😅 thanks for taking the time