From 2a6b8c4a00703171931f0acdbae619ebc48fde52 Mon Sep 17 00:00:00 2001 From: Resi Respati Date: Wed, 1 Aug 2018 12:08:55 +0700 Subject: [PATCH] limit formatOnSave option to JS/TS files, add docs re: prettier --- .vscode/extensions.json | 3 --- .vscode/settings.json | 12 ++++++++++-- docs/in-depth/prettier.md | 19 +++++++++++++++++++ docs/in-depth/typescript.md | 8 ++++---- 4 files changed, 33 insertions(+), 9 deletions(-) delete mode 100644 .vscode/extensions.json create mode 100644 docs/in-depth/prettier.md diff --git a/.vscode/extensions.json b/.vscode/extensions.json deleted file mode 100644 index b98e704..0000000 --- a/.vscode/extensions.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "recommendations": ["eg2.tslint", "EditorConfig.EditorConfig", "esbenp.prettier-vscode"] -} diff --git a/.vscode/settings.json b/.vscode/settings.json index 6d3582f..0b1a7d9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,5 @@ { "editor.renderWhitespace": "boundary", - "editor.formatOnSave": true, "files.encoding": "utf8", "files.trimTrailingWhitespace": true, "files.insertFinalNewline": true, @@ -11,5 +10,14 @@ "node_modules/**": true, "typings/**": true }, - "typescript.tsdk": "./node_modules/typescript/lib" + "typescript.tsdk": "./node_modules/typescript/lib", + "[json]": { + "editor.formatOnSave": true + }, + "[javascript]": { + "editor.formatOnSave": true + }, + "[typescript]": { + "editor.formatOnSave": true + } } diff --git a/docs/in-depth/prettier.md b/docs/in-depth/prettier.md new file mode 100644 index 0000000..b4ab6dc --- /dev/null +++ b/docs/in-depth/prettier.md @@ -0,0 +1,19 @@ +# Prettier + +[Prettier](https://prettier.io/) is an automatic code formatter which supports various languages, including TypeScript. It also has extensions for various text editors like [VSCode](https://github.com/prettier/prettier-vscode), [Atom](https://github.com/prettier/prettier-atom), and even [Vim](https://github.com/prettier/vim-prettier). If you have installed these extensions, it will use Prettier's service to automatically format your code after saving. + +If you would rather not use Prettier instead, you can easily disable it too. In VSCode, open `.vscode/settings.json`, then change the `"editor.formatOnSave"` option to `false`: + +```json +{ + "[json]": { + "editor.formatOnSave": false + }, + "[javascript]": { + "editor.formatOnSave": false + }, + "[typescript]": { + "editor.formatOnSave": false + } +} +``` diff --git a/docs/in-depth/typescript.md b/docs/in-depth/typescript.md index 3d7d984..eaf9fd1 100644 --- a/docs/in-depth/typescript.md +++ b/docs/in-depth/typescript.md @@ -33,10 +33,10 @@ This project provides TSLint rules through a `tslint.json` file, which extends t We've made some changes to these rules, which we considered necessary and/or relevant to a proper Screeps project: - - set the [forin](http://palantir.github.io/tslint/rules/forin/) rule to `false`, it was forcing `for ( ... in ...)` loops to check if object members were not coming from the class prototype. - - set the [interface-name](http://palantir.github.io/tslint/rules/interface-name/) rule to `false`, in order to allow interfaces that are not prefixed with `I`. - - set the [no-console](http://palantir.github.io/tslint/rules/no-console/) rule to `false`, in order to allow using `console`. - - in the [variable-name](http://palantir.github.io/tslint/rules/variable-name/) rule, added `allow-leading-underscore`. +* set the [forin](http://palantir.github.io/tslint/rules/forin/) rule to `false`, it was forcing `for ( ... in ...)` loops to check if object members were not coming from the class prototype. +* set the [interface-name](http://palantir.github.io/tslint/rules/interface-name/) rule to `false`, in order to allow interfaces that are not prefixed with `I`. +* set the [no-console](http://palantir.github.io/tslint/rules/no-console/) rule to `false`, in order to allow using `console`. +* in the [variable-name](http://palantir.github.io/tslint/rules/variable-name/) rule, added `allow-leading-underscore`. ### Customising TSLint