From f4d5e8c23357dc006c7d237e8d6a6f85e3a704a1 Mon Sep 17 00:00:00 2001 From: JP Driver Date: Mon, 15 Jul 2019 02:05:35 -0700 Subject: [PATCH] Fresh RN projects fails ESLint / Prettier by default (#25478) Summary: Fixes https://github.com/facebook/react-native/issues/25477 This PR adds a `.prettierrc.js` config file to the HelloWorld template. `eslint-config-react-native-community` includes custom settings for some rules which conflict with Prettier's default settings. Consequently, if you run `eslint` immediately after scaffolding a new app you get errors (see linked issue). This PR configures Prettier to be compatible with both the existing ESLint config and the existing project template (with no code changes to the latter). ## Changelog [General] [Changed] - Added a default Prettier config for new projects Pull Request resolved: https://github.com/facebook/react-native/pull/25478 Test Plan: - The following screenshots show the output of `yarn lint` before and after these changes - These were run immediate after running `npx react-native-cli init RN060` ### Without these changes - Linting errors on new projects - Unfixable automatically due to conflicting rules Screenshot 2019-07-03 at 17 44 55 Screenshot 2019-07-03 at 17 45 07 ### With these changes - Brand new projects will not produce lint errors out of the box Screenshot 2019-07-03 at 17 48 25 Differential Revision: D16223094 Pulled By: cpojer fbshipit-source-id: bd2c00b1fcf27b1afcad8c18b357b95a3900bdf7 --- template/_prettierrc.js | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 template/_prettierrc.js diff --git a/template/_prettierrc.js b/template/_prettierrc.js new file mode 100644 index 00000000000000..5c4de1a4f6592d --- /dev/null +++ b/template/_prettierrc.js @@ -0,0 +1,6 @@ +module.exports = { + bracketSpacing: false, + jsxBracketSameLine: true, + singleQuote: true, + trailingComma: 'all', +};