From 30f8a193535fbc9a30ea0a691efe354e4b6b4735 Mon Sep 17 00:00:00 2001 From: imnasnainaec Date: Thu, 12 Nov 2020 12:24:32 -0500 Subject: [PATCH 1/3] Add explicit default formatters by language --- .vscode/extensions.json | 2 +- .vscode/settings.json | 20 ++++++++++++++++++++ package.json | 1 + scripts/printVersion.js | 2 +- 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 8b3e3c0ca3..26c61fddb9 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -3,7 +3,7 @@ // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp // List of extensions which should be recommended for users of this workspace. - "recommendations": ["esbenp.prettier-vscode"], + "recommendations": ["esbenp.prettier-vscode", "ms-dotnettools.csharp"], // List of extensions recommended by VS Code that should not be recommended for users of this workspace. "unwantedRecommendations": [] diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..68ce925641 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,20 @@ +{ + "[csharp]": { + "editor.defaultFormatter": "ms-dotnettools.csharp" + }, + "[javascript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[javascriptreact]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[json]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[typescript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[typescriptreact]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + } +} diff --git a/package.json b/package.json index 3e347355c4..e66652387c 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "fmt-backend-check": "dotnet-format --check", "fmt-frontend": "prettier --write \"./src/**/*.{js,jsx,ts,tsx,json}\"", "fmt-frontend-check": "prettier --check \"./src/**/*.{js,jsx,ts,tsx,json}\"", + "fmt-project": "prettier --write \"./{.vscode,public,scripts}/**/*.{js,jsx,ts,tsx,json}\"", "frontend": "react-scripts start", "gen-backend-coverage-report": "tsc scripts/genBackendCoverageReport.ts && node scripts/genBackendCoverageReport.js", "import-sem-doms": "tsc scripts/importSemanticDomains.ts && node scripts/importSemanticDomains.js", diff --git a/scripts/printVersion.js b/scripts/printVersion.js index 8729268eea..eeb45766b7 100755 --- a/scripts/printVersion.js +++ b/scripts/printVersion.js @@ -1 +1 @@ -console.log(require('../package.json').version); +console.log(require("../package.json").version); From fd6c81a630e259cc500c35e7b70af5f63d432c65 Mon Sep 17 00:00:00 2001 From: imnasnainaec Date: Fri, 13 Nov 2020 09:53:06 -0500 Subject: [PATCH 2/3] Expand fmt-frontend with a few other js-carrying folders --- package.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index e66652387c..d27128257e 100644 --- a/package.json +++ b/package.json @@ -11,9 +11,8 @@ "eject": "react-scripts eject", "fmt-backend": "dotnet-format", "fmt-backend-check": "dotnet-format --check", - "fmt-frontend": "prettier --write \"./src/**/*.{js,jsx,ts,tsx,json}\"", - "fmt-frontend-check": "prettier --check \"./src/**/*.{js,jsx,ts,tsx,json}\"", - "fmt-project": "prettier --write \"./{.vscode,public,scripts}/**/*.{js,jsx,ts,tsx,json}\"", + "fmt-frontend": "prettier --write \"./{.vscode,public,scripts,src}/**/*.{js,jsx,ts,tsx,json}\"", + "fmt-frontend-check": "prettier --check \"./{.vscode,public,scripts,src}/**/*.{js,jsx,ts,tsx,json}\"", "frontend": "react-scripts start", "gen-backend-coverage-report": "tsc scripts/genBackendCoverageReport.ts && node scripts/genBackendCoverageReport.js", "import-sem-doms": "tsc scripts/importSemanticDomains.ts && node scripts/importSemanticDomains.js", From 60f584c374c801bbec279646e183e1641f701ccf Mon Sep 17 00:00:00 2001 From: imnasnainaec Date: Fri, 13 Nov 2020 10:36:05 -0500 Subject: [PATCH 3/3] Add to .vscode/settings.json: format-on-save; jsonc and markdown formatter --- .vscode/settings.json | 8 ++++++++ README.md | 12 +++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 68ce925641..ea225fb56f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,6 @@ { + "editor.formatOnSave": true, + "editor.formatOnSaveMode": "file", "[csharp]": { "editor.defaultFormatter": "ms-dotnettools.csharp" }, @@ -11,6 +13,12 @@ "[json]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, + "[jsonc]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[markdown]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, "[typescript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, diff --git a/README.md b/README.md index d5ca65f1dc..41f9486bda 100644 --- a/README.md +++ b/README.md @@ -64,8 +64,9 @@ A rapid word collection tool. - [MongoDB](https://docs.mongodb.com/manual/administration/install-community/) and add /bin to PATH Environment Variable - On Windows, if using [Chocolatey][chocolatey]: `choco install mongodb` - - [VS Code](https://code.visualstudio.com/download) and Prettier code - formatting extension + - [VS Code](https://code.visualstudio.com/download) and the following extensions: + - C# (`ms-dotnettools.csharp`) + - Prettier - Code formatter (`esbenp.prettier-vscode`) - [dotnet-format](https://github.com/dotnet/format): `dotnet tool update --global dotnet-format --version 4.1.131201` - [dotnet-reportgenerator](https://github.com/danielpalme/ReportGenerator) @@ -85,13 +86,10 @@ A rapid word collection tool. - `COMBINE_SMTP_ADDRESS` - `COMBINE_SMTP_FROM` -6. (VS Code Users Only) Enable automatic formatting on save. - - **File** | **Preferences** | **Settings** | Search for **formatOnSave** and - check the box. -7. Run `npm start` from the project directory to install dependencies and start +6. Run `npm start` from the project directory to install dependencies and start the project. -8. Consult our [C#](docs/c_sharp_style_guide.md) +7. Consult our [C#](docs/c_sharp_style_guide.md) and [JavaScript/TypeScript](docs/ts_style_guide.md) style guides for best coding practices in this project.