Closed progsmile closed 2 years ago
As far as I remember, this is not supported:
"prettier/prettier": [
"error",
{
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"singleQuote": false,
"bracketSpacing": false,
"explicitTypes": "always"
}
]
You have to specify your prettier options in your .prettierrc
, not in your solhint config.
I've come to solution to import rules in prettier.config.js
.
const solhint = require('./.solhint.json')
module.exports = {
"overrides": [
{
"files": "*.sol",
"options": solhint.rules['prettier/prettier'][1]
}
]
}
That works but notice that you are making a really unnecessary indirection. The second value in the prettier/prettier
rule in your solhint.json
is ignored by solhint. I think it would be better if you just specified those options directly in the prettier.config.js
file.
Besides, if this plugin in the future adds some options, then your current config will be invalid.
It was attempt to use lint and style rules within 1 file. I've tested .solhint.json
without prettier/prettier
section and linting does not work from prettier.config.js
. I run it with solhint -f table contracts/**/*.sol
.
Any other commands to apply?
It was attempt to use lint and style rules within 1 file
I don't think that's possible. I think technically this rule could allow that, but it would add a lot of complexity (e.g., who has precedence?).
I've tested
.solhint.json
withoutprettier/prettier
section and linting does not work fromprettier.config.js
Maybe you have a wrong idea of what this plugin does. The only thing that this prettier/prettier
rule does is to "run" prettier and let you know which parts of your code are not properly formatted. This is especially useful for IDEs to indicate those spots. But other than that, you could remove this rule and use npx prettier --check
instead. Does that make sense?
@fvictorio thanks for your assistance! Make sense.
Hello! Thanks for package! I want to specify prettier rules within
.solhint.json
and not within.prettierrc
. When I do lintingsolhint -f table contracts/**/*.sol
, prettier rules are considered.But next commands does not work correctly when trying to format:
solhint --fix -f table contracts/**/*.sol
<- shows linter errors to fix, not formatingprettier --write contracts/**/*.sol
<- does not respect.solhint.json
rules, uses prettier internal config.solhint.json
Packages:
Please help to pick correct formatting command and params. Thanks!