Hi.
I use prettier as a plugin in my code editor (Sublime Text), and use eslint-config-prettier to disable formatting rules from Eslint. But eslint keep popping up a lot of formatting rules. After some time searching i found that the origin of these rules was the prettier plugin in the eslint-config-react-native-community package.
I don't know why these rules are in this package, but i think they don't need to be there.
Steps to reproduce:
Follow the configuration tutorial in the readme page:
https://github.com/facebook/react-native/blob/master/packages/eslint-config-react-native-community/README.md
Run the bellow command to check the enabled rules:
yarn eslint --print-config *.tsx (replace *.tsx with your project file format)
Output:
"plugins": [
"jest",
"react-native",
"prettier",
"eslint-comments",
"react-hooks",
"react",
"@typescript-eslint"
]
These are the enabled plugins with the extension.
Now i disabled it and run the print-config again:
"plugins": [
"react-hooks",
"react",
"@typescript-eslint"
]
As you can see, these plugins are added by the @react-native-community extension:
Why does React-Native force developers to use prettier by default? Why add dependencies unnecessarily? IMO, we should remove prettier eslint configuration by default and let developers add it if required. It shouldn't be the other way where react-native adds it by default and users have to disable it if not required. Already react-native takes lot of effort to start a simple project and run for new developers, why then add more configurations. Let's keep it simple and clean.
I agree with @ravirajn22. Why is prettier enabled by default? Seems to conflict with rules within the eslint config.
Absolutely hate the fact that the cli is shipping with preset eslint/prettier rules. I had both of them conflicting about whether to use double or single quotes.
I really love prettier & use it on every projects since the first day I tried that. But this "prettier" rules are really annoying, especially if prettier is setup in your IDE and/or as precommit hook. The goal of prettier is to help you "NOT CARE ABOUT STYLING".
The prettier and all styles rules enabled by @react-native-community/eslint-config
are so annoying during development if your IDE shows you eslint errors/warnings as this defeat the entire purpose of prettier (again: not think about styling). It gives you false positives about "errors" as it show you something that a simple save (if you setup your editor to format on save) or a precommit hook will handle.
Please please remove all styles rules OR remove prettier & prettier rules, but be consistant. Encouraging prettier + adding unecessary/annoyings styles rules is a very awkward situation...
Until a decision is made for those wanting to get "most of this config except prettier stuff", you can
Install eslint-config-prettier
And use this config
module.exports = {
root: true,
extends: [
'@react-native-community/eslint-config',
'eslint-config-prettier',
],
rules: {
'prettier/prettier': 0,
},
};
As a follow-up to @MoOx - Prettier was still issuing linting errors with my editor.
I solved it with an additional step. I created a .prettierignore
in the project root directory and added the following paths:
./*
*/*
/*.*
Cheers.
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.
I'm still seeing these issues. The standard prettier config blended with react-native-community's eslint contradict eachother. If I format a document it breaks prettier's rules
Prettier eslint rules should be removed. Prettier is to forget about formatting, not to paint your code with red underlines everywhere.
Most helpful comment
Until a decision is made for those wanting to get "most of this config except prettier stuff", you can
Install eslint-config-prettier
And use this config