Videos
» npm install eslint-plugin-prettier
I've heard ESLint can format but I haven't found a clear answer why it seems prettier is used instead of the ESLint formatter. Whenever I try to look it up most comments neglect to mention that ESLint can also format so it's not obvious why prettier would be needed at all.
» npm install eslint-config-prettier
To solve conflict
install eslint configuration for prettier
npm install eslint-config-prettier
And include it in the extends option in the file .eslintrc.js
extends: [
...,
"prettier",
],
This is potentially because of conflicting rules between ESLint and Prettier plugins. Now you have two options
- Either let ESLint know that you want to use Prettier as a formatter.
https://dev.to/s2engineers/how-to-make-eslint-work-with-prettier-avoiding-conflicts-and-problems-57pi
2.You can configure ESlint and Prettier together and resolve the conflicting rules without any conflicts. https://blog.theodo.com/2019/08/empower-your-dev-environment-with-eslint-prettier-and-editorconfig-with-no-conflicts/
Instead of disabling linting for the file, you can instead disable prettier within the eslintrc.js config file:
module.exports = {
root: true,
extends: '@react-native-community',
rules: {
'prettier/prettier': 0,
},
};
To get rid of conflicting rules when using both - prettier and eslint there is a eslint-config-prettier package.
Run npm install --save-dev eslint-config-prettier to install and then in eslintrc.js (or wherever you have the eslint rules defined) add:
{
"extends": [
...,
"@react-native-community",
"prettier"
]
}
Now eslint should respect prettier rules. Here is a link to GH repo.