-
Notifications
You must be signed in to change notification settings - Fork 128
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
Prettier should not be included by default in eslint-config #556
Comments
Could you elaborate on this more? The config is set up to use prettier as a peerDependency, so that the user controls the version. It also sets style options in a I think prettier provides a lot of value in the config. Almost every JavaScript project I've used pulls it in for formatting, and it can be very useful to check formatting during linting. I'm not sure how many projects see real issues caused by linting performance, and anecdotally, sets of rules like It is also still possible to use ESLint for a react-native project without extending |
My point is exactly that, there are rules to replicate prettier behaviour without any of the performance compromises. Prettier is a parser/executable and needs to start up each time it's going to run, it cannot be run as a daemon, so for each tab in VSCode that is going to run a lint job it needs to bootup again, I had my VSCode's "Quick Fixes" quickly start to hang on "Running Save Participants..." because of that, it took me some debugging and time to find the culprit; This problem also extends to pre/post commit hooks, CI/CD, etc. That said there are some solutions for running prettier as a daemon (e.g. prettierd) but don't support all prettier features and requires a global install or brew setup in the machine alongside cat_d, which not only isn't compatible with eslint but also greatly increase the work necessary to run projects as compared to a C.I.E. (clone, install and execute) project. Ultimately it's a overkill just to run lint on files.
I've also been using/seen prettier in basically all react/react-native project, I don't think that implies it's necessarily an argument that it should keep being used, I'm pretty sure most maintainers and developers are also not aware of the huge impact that prettier has on the time to complete a lint call. Being widely used does not mean there aren't better alternatives out there or that the current state of things shouldn't be improved. Like I mentioned before and as far as I've researched most of prettier's rules can be replicated with alternative eslint rules except for Prose Wrap. So RN can be still opinionated, it just doesn't need to slow down the lint executions. Furthermore I use @typescript-eslint in my projects and haven't seen any rule take more than 10ms to execute, which is meaningless compared with prettier/prettier taking ~55x to run.
Being as big as RN is the recommended configuration will be the default for most projects, so all unnecessary performance compromises should be avoided as those will potentially be extended to a whole community, specially if they can be completely avoided with equivalent alternatives. With all that said you're also free to test this in bigger projects, running it with TIMING=1 before the lint command prints all the timing data. If there's any specific realistic scenario you have in mind let me know and I'll run benchmark tests on it. |
When migrating to newer version of this package I faced a error in the eslint because my project does not use prettier. |
Introduction
Prettier is know to cause many ESLint issues & conflicts as well as being slow to run since it has to "boot up" prettier executable each time it parses a file, hence it should not be included by default on
@react-native-community/eslint-config
, I believe it's better to leave it to developers to decide wether to include it or not.Details
ESLint on a relatively small file with prettier:
ESLint on a relatively small file without prettier:
As it can be seen prettier itself is ~55x slower than the heaviest of our rules, that delay scales up the more files we get and slows ESLint job in general.
Discussion points
The text was updated successfully, but these errors were encountered: