Closed fvictorio closed 1 year ago
@fvictorio I understand the rule... One thing I'm missing As I see in the code... The rules are configured like this:
{
"rules": {
"max-line-length": ["error",120]
}
}
So when you say it should accept an object { default: "explicit" | "implicit" } I did not follow that... maybe something like this
{
"rules": {
"explicit-types": ["error","true"]
}
}
so explicit-types is enforced when true and explicit-types is not enforce when false
Or you meant another thing ?
{
"rules": {
"explicit-types": ["error", { default: "implicit" }]
}
}
In the meantime, I have been maintaining a direct fork with that feature backported, if anyone is interested https://www.npmjs.com/package/prettier-plugin-solidity-explicit-types
Added in this PR https://github.com/protofire/solhint/pull/467
Summary
Add a new
explicit-types
rule to forbid or enforce explicit types (likeuint256
) that have an alias (likeuint
). This rule should implement the auto-fix mechanism.Motivation
Prettier Solidity used to have an option to do this, but it was removed in v1.0.0 because we felt that that kind of thing belongs to a linter rather than a formatter.
Details
The rule should accept an options object
{ default: "explicit" | "implicit" }
, where "explicit" means thatuint256
,int256
, etc. should be used and "implicit" means thatuint
,int
, etc. should be used. The default should be "explicit".The types that should be affected are:
uint256
anduint
int256
andint
ufixed128x18
andufixed
fixed128x18
andfixed
I'm intentionally not including
bytes1
andbyte
. The reason is that, since we don't have version information, we can't know if an instance ofbytes1
(with the implicit default selected) is an error or not. If there's demand for this, we might consider adding a new option to the rule.