protofire / solhint

Solhint is an open-source project to provide a linting utility for Solidity code.
https://protofire.github.io/solhint/
MIT License
1.04k stars 160 forks source link

Gitignore syntax not fully supported #346

Open ddnexus opened 2 years ago

ddnexus commented 2 years ago

To ignore files that do not require validation you can use a .solhintignore file. It supports rules in the .gitignore format.

The pattern to ignore a dir excluding specific files in .gitignore does not seem to work:

*
!not-this-file.sol
dbale-altoros commented 1 year ago

@ddnexus Solhint works like this. Given this file structure: (Brackets name represent folders just for better understanding)

[contracts] contracts\ONE.sol contracts\TWO.sol [contracts\adapters] contracts\adapters\THREE.sol contracts\adapters\FOUR.sol [contracts\adapters\uniswap] contracts\adapters\uniswap\UNI.sol

If you want to run solhint on all files: solhint contracts/*.* contracts/**/*.* contracts/**/**/*.*

If you want to run solhint on adapters folders and all of subfolders solhint contracts/**/*.* contracts/**/**/*.*

If you want to exclude FOUR.sol and run in all other files: Fill .solhintignore with this line contracts/adapters/FOUR.sol Then run solhint contracts/*.* contracts/**/*.* contracts/**/**/*.* FOUR.sol will be excluded

From your post I think you want to put a folder in the .solhintignore and with that notation you want to ignore the whole folder but not the file with the exclamation point, meaning: If I put in .solhintignore this: contracts/adapters/ !contracts/adapters/FOUR.sol

You want solhint to process only FOUR.sol from adapters folder... Is that correct ?

ddnexus commented 1 year ago

Yes, that's how gitignore works!

Without it you would have to check the structure of contracts/adapters/ and update the many solhint arguments every time it changes.

dbale-altoros commented 1 year ago

thanks for the clarification it is a good addition we'll try to add that

ddnexus commented 1 year ago

BTW, the "file" could also be a pattern itself.