From 7b69b961909658893646d70015e68b1f207504d5 Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Fri, 19 Jun 2020 03:53:20 -0700 Subject: [PATCH] Fix code formatting Summary: Had some horrible dev experience caused by VSCode and Jest not agreeing what snapshots should look like, every time saving a test in VSCode, it would break the jest snapshots. After investigating eslint and prettier, turned out VSCode itself was the culprit. Caused by a global user setting, but this makes sure nobody else runs into it :) Also made sure Jest uses the correct prettier settings (it didn't before). Reviewed By: passy Differential Revision: D22114656 fbshipit-source-id: aef6c278a668bce049c96aba95c7a5101ca840ad --- .vscode/settings.json | 1 + desktop/.eslintrc.js | 13 +------------ desktop/.prettierrc.json | 8 ++++++++ 3 files changed, 10 insertions(+), 12 deletions(-) create mode 100644 desktop/.prettierrc.json diff --git a/.vscode/settings.json b/.vscode/settings.json index 8bb3f1673..14a097045 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,6 +5,7 @@ "eslint.packageManager": "yarn", "eslint.codeActionsOnSave.mode": "all", "editor.formatOnSave": true, + "files.trimTrailingWhitespace": false, // This one is broken as it cleans string literals as well, killing Jest snapshots: https://github.com/Microsoft/vscode/issues/52711 "prettier.formatAlreadyFormattedFilesOnSave": false, "files.eol": "\n", "editor.codeActionsOnSave": { diff --git a/desktop/.eslintrc.js b/desktop/.eslintrc.js index a4f9d8cdc..1505d60bf 100644 --- a/desktop/.eslintrc.js +++ b/desktop/.eslintrc.js @@ -22,18 +22,7 @@ const builtInModules = [ '@emotion/styled', ]; -const prettierConfig = { - // arrowParens=always is the default for Prettier 2.0, but other configs - // at Facebook appear to be leaking into this file, which is still on - // Prettier 1.x at the moment, so it is best to be explicit. - arrowParens: 'always', - requirePragma: true, - singleQuote: true, - trailingComma: 'all', - bracketSpacing: false, - jsxBracketSameLine: true, - parser: 'flow', -}; +const prettierConfig = require('./.prettierrc'); module.exports = { parser: 'babel-eslint', diff --git a/desktop/.prettierrc.json b/desktop/.prettierrc.json new file mode 100644 index 000000000..ce64e5f17 --- /dev/null +++ b/desktop/.prettierrc.json @@ -0,0 +1,8 @@ +{ + "arrowParens": "always", + "requirePragma": true, + "singleQuote": true, + "trailingComma": "all", + "bracketSpacing": false, + "jsxBracketSameLine": true +}