-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: add default prettier config #25
Conversation
Does adding this config to eslint specifically mean that we don't have a prettier config file in the project anymore? If not correct, there is duplication. If correct, what about other files that eslint doesn't support, but prettier does?
For formatting those, we do want prettier as a separate config file – including editor integration. Also, if you read https://prettier.io/docs/en/integrating-with-linters.html, they discourage enabling prettier rules in eslint, and instead just run prettier to fix things. Although I'm not completely sold on that (it would require running both prettier and eslint separately, since eslint fixes more things than prettier... not sure how that nicely integrates with editors as well). Would a better option maybe be to publish a prettier config package, and include that in skeletons as an "extends"? |
{ | ||
files: "*.json", | ||
options: { | ||
printWidth: 999999, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this value means json
files will be written in a single line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this means that they can be written in a single line, which now thinking about it does not make a lot of sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might have been a leftover from an older version of prettier where long values where wrapped to the next line.
so:
{
"key": "value .............. very long ..............."
}
would become
{
"key":
"value .............. very long ..............."
}
Just tested in the REPL, it doesn't do that anymore. So I think we can remove it.
OR, it was copied over from one of the projects where we generated mock files that were API responses (without formatting), and we didn't want prettier to constantly handle those. Either way, we can remove it.
Yes. This would be the default prettier configuration used by eslint, and it could still be overwritten by a
I did overlook this, running prettier standalone would not take the configuration from this eslint config.
We have a mix of this in our skeletons: eslint does prettier formatting through Perhaps it would be indeed better to ship a separate prettier configuration and simply disable eslint formatting rules, so eslint would be responsible for linting and prettier for formatting. I think that modern editors should be able to handle this, at least vscode and neovim both support running multiple "on save" or "on type" actions. |
Personally (using Webstorm IDE) I only run "eslint" on safe (which formats those files that are supported by eslint).
Either way, I still think a |
I don't think that would impact things too much, on the same page https://prettier.io/docs/en/integrating-with-linters.html, the maintainers mention:
I ran some benchmarks on one of our larger projects which is using the react config and these are the results I got: config with So it seems that, running eslint without prettier configured and then running prettier separately is faster, than running prettier under eslint. Note that both eslint runs were ran without any sort of cache and both were configured to run only on .ts and .tsx files.
I agree with this, but given the performance implications I would seriously consider dropping running prettier under eslint and running it standalone. Especially, as you mentioned previously, we would likely still want prettier to format files which are not supported by eslint. |
Looking at timings from other rules, there is some difference between the two tests (so nothing conclusive). But I agree the difference is neglectable for this discussion – running them separately results in similar enough speeds. And I think I agree that we should configure and run them separately. So that would mean;
|
closed in favor of #26 |
No description provided.