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
897 stars 192 forks source link

Problems With Solhint Plugins #169

Open Jaime-Iglesias opened 4 years ago

Jaime-Iglesias commented 4 years ago

I'm trying to use the rules on a custom solhint plugin by changing the .solhint.json configuration file. The rules themselves work as I can lint the file manually using the terminal and I get the expected errors, but I cannot manage to make the Solidity plugin itself detect these custom rules.

I have changed the settings to explicitly use solhint as per the documentation i.e

"solidity.linter": "solhint",
"solidity.solhintRules": {
  "avoid-sha3": "warn"
}

And I have changed the .solhint.json as per the Solhint docs too.

Any idea of what I am doing wrong?

juanfranblanco commented 4 years ago

@Jaime-Iglesias is the .solhint.json file at root?

Jaime-Iglesias commented 4 years ago

@juanfranblanco yep

structure

juanfranblanco commented 4 years ago

@Jaime-Iglesias First test without .solhint.json: image image

Jaime-Iglesias commented 4 years ago

@juanfranblanco without the .solhint.json and with it, the rules in the settings work just fine

test

test

juanfranblanco commented 4 years ago

Ok I have tested it again with a file:

image

image

image

juanfranblanco commented 4 years ago

And to make sure it just works with the file:

image

image image

What it may have happened is that you need to restart vscode due to a problem before. Try again by adding the file. A syntax error might have caused a crash.

Jaime-Iglesias commented 4 years ago

hmmm, the problem does not seem to be with the file but with the extension not being able to detect the solhint plugin since it's clear that the rules in the .solhint.json that do not belong to the custom plugin are being enforced

test

test

test

juanfranblanco commented 4 years ago

Ahh I got you, yes the extension does not recognize plugins, where do you host your plugins?

Jaime-Iglesias commented 4 years ago

Ahh I got you, yes the extension does not recognize plugins, where do you host your plugins?

What do you mean where I host ? I install them locally after publishing them (as per the solhint docs), hope that answers the question haha

juanfranblanco commented 4 years ago

Yes if you install them locally the extension might not be able to find them. I do need to do some research on this, or raise it with the solium guys.

Jaime-Iglesias commented 4 years ago

Yes if you install them locally the extension might not be able to find them. I do need to do some research on this, or raise it with the solium guys.

So if they are globally installed they do work ? (haven't tried that option yet) also thank you

juanfranblanco commented 4 years ago

At the moment the extension does not load the plugins section, i can add that and check it globally.

Jaime-Iglesias commented 4 years ago

At the moment the extension does not load the plugins section, i can add that and check it globally.

That would be great!

Ofc, ideally, loading them locally would be huge but progress is progress, thx again.

juanfranblanco commented 4 years ago

@Jaime-Iglesias quick test, it does not work i have added the no-foos rules install your package globally and nothing, it will have to be find and loaded dynamically by the extension into solhint, similar to prettier.

Jaime-Iglesias commented 4 years ago

@Jaime-Iglesias quick test, it does not work i have added the no-foos rules install your package globally and nothing, it will have to be find and loaded dynamically by the extension into solhint, similar to prettier.

@juanfranblanco I just tried it myself too but no luck either, it's weird since solhint supports plugins out of the box, I guess it's causde by how the Extension itself manages all these packages

juanfranblanco commented 4 years ago

@Jaime-Iglesias looking at the source would have been faster https://github.com/protofire/solhint/blob/32ec781509c9b76db325d0c2db91c8c478441d6a/lib/rules/index.js#L53

there is a require there, which won't be triggered as the extensions cannot access those. Prettier provides a path setting that allows for the discovery of plugins, something they could implement.

Jaime-Iglesias commented 4 years ago

@Jaime-Iglesias looking at the source would have been faster https://github.com/protofire/solhint/blob/32ec781509c9b76db325d0c2db91c8c478441d6a/lib/rules/index.js#L53

there is a require there, which won't be triggered as the extensions cannot access those. Prettier provides a path setting that allows for the discovery of plugins, something they could implement.

I see, so it's a solhint problem after all - I wonder if they will manage to fix it, I don't know how active the project is.

juanfranblanco commented 4 years ago

@Jaime-Iglesias I have added an issue for this https://github.com/protofire/solhint/issues/206

Jaime-Iglesias commented 4 years ago

@Jaime-Iglesias I have added an issue for this protofire/solhint#206

@juanfranblanco much appreciated, hopefully they will be able to support this, as I think it defenitely can bring a lot of value for both projects.

Jaime-Iglesias commented 4 years ago

Hey @juanfranblanco I hope you are doing well,

Is there any update regarding this issue and https://github.com/juanfranblanco/vscode-solidity/issues/170 ?

stay safe !

Jaime-Iglesias commented 4 years ago

friendly ping @juanfranblanco

juanfranblanco commented 4 years ago

@Jaime-Iglesias thanks for the ping!! I do need this as sometimes notifications get lost (you can find me in the Nethereum gitter if you need anything). The issue is still open with the solhint guys / gals, the best way is to chase that issue there, once is fixed on their side it could be integrated here.

Jaime-Iglesias commented 4 years ago

@Jaime-Iglesias thanks for the ping!! I do need this as sometimes notifications get lost (you can find me in the Nethereum gitter if you need anything). The issue is still open with the solhint guys / gals, the best way is to chase that issue there, once is fixed on their side it could be integrated here.

Ah I see, I thought it was depending on you - sorry about that hahaha! Thanks and stay safe !